optimization of getAllExposedUses for lexical scoping
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3046 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
9200772866
commit
42ffd051dc
|
@ -73,6 +73,7 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
import com.ibm.wala.util.debug.Trace;
|
||||
import com.ibm.wala.util.functions.Function;
|
||||
import com.ibm.wala.util.graph.traverse.NumberedDFSDiscoverTimeIterator;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.intset.IntSetAction;
|
||||
import com.ibm.wala.util.intset.IntSetUtil;
|
||||
import com.ibm.wala.util.intset.MutableIntSet;
|
||||
|
@ -242,11 +243,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
|
||||
public boolean hasNoInterestingUses(CGNode node, int vn, DefUse du) {
|
||||
if (node.getMethod() instanceof AstMethod) {
|
||||
int uses[] = ((AstMethod) node.getMethod()).lexicalInfo.getAllExposedUses();
|
||||
for (int i = 0; i < uses.length; i++) {
|
||||
if (uses[i] == vn) {
|
||||
return false;
|
||||
}
|
||||
IntSet uses = ((AstMethod) node.getMethod()).lexicalInfo.getAllExposedUses();
|
||||
if (uses.contains(vn)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,6 +843,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
|
||||
// now redo analysis
|
||||
// TODO: only values[i] uses need to be re-done.
|
||||
AstM.lexicalInfo.handleAlteration();
|
||||
getAnalysisCache().getSSACache().invalidateDU(M, n.getContext());
|
||||
// addConstraintsFromChangedNode(n);
|
||||
getBuilder().markChanged(n);
|
||||
|
|
|
@ -43,6 +43,9 @@ import com.ibm.wala.util.debug.Trace;
|
|||
import com.ibm.wala.util.functions.Function;
|
||||
import com.ibm.wala.util.graph.INodeWithNumber;
|
||||
import com.ibm.wala.util.graph.impl.SparseNumberedGraph;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.intset.IntSetUtil;
|
||||
import com.ibm.wala.util.intset.MutableIntSet;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
/**
|
||||
|
@ -1910,7 +1913,9 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle
|
|||
private final int[] exitLexicalUses;
|
||||
|
||||
private final String[] scopingParents;
|
||||
|
||||
|
||||
private MutableIntSet allExposedUses = null;
|
||||
|
||||
private int[] buildLexicalUseArray(Pair[] exposedNames) {
|
||||
if (exposedNames != null) {
|
||||
int[] lexicalUses = new int[exposedNames.length];
|
||||
|
@ -1994,30 +1999,28 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle
|
|||
return instructionLexicalUses[instructionOffset];
|
||||
}
|
||||
|
||||
public int[] getAllExposedUses() {
|
||||
List<Integer> uses = new ArrayList<Integer>();
|
||||
if (exitLexicalUses != null) {
|
||||
for (int i = 0; i < exitLexicalUses.length; i++) {
|
||||
uses.add(new Integer(exitLexicalUses[i]));
|
||||
public IntSet getAllExposedUses() {
|
||||
if (allExposedUses == null) {
|
||||
allExposedUses = IntSetUtil.make();
|
||||
if (exitLexicalUses != null) {
|
||||
for (int i = 0; i < exitLexicalUses.length; i++) {
|
||||
allExposedUses.add(exitLexicalUses[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (instructionLexicalUses != null) {
|
||||
for (int i = 0; i < instructionLexicalUses.length; i++) {
|
||||
if (instructionLexicalUses[i] != null) {
|
||||
for (int j = 0; j < instructionLexicalUses[i].length; j++) {
|
||||
uses.add(new Integer(instructionLexicalUses[i][j]));
|
||||
if (instructionLexicalUses != null) {
|
||||
for (int i = 0; i < instructionLexicalUses.length; i++) {
|
||||
if (instructionLexicalUses[i] != null) {
|
||||
for (int j = 0; j < instructionLexicalUses[i].length; j++) {
|
||||
if (instructionLexicalUses[i][j] > 0) {
|
||||
allExposedUses.add(instructionLexicalUses[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int[] result = new int[uses.size()];
|
||||
for (Iterator x = uses.iterator(); x.hasNext();) {
|
||||
result[i++] = ((Integer) x.next()).intValue();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
return allExposedUses;
|
||||
}
|
||||
|
||||
public Pair[] getExposedNames() {
|
||||
|
@ -2027,6 +2030,10 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle
|
|||
public String[] getScopingParents() {
|
||||
return scopingParents;
|
||||
}
|
||||
|
||||
public void handleAlteration() {
|
||||
allExposedUses = null;
|
||||
}
|
||||
};
|
||||
|
||||
private final Map<CAstNode, Integer> results = new LinkedHashMap<CAstNode, Integer>();
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.types.Selector;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
public abstract class AstMethod implements IMethod {
|
||||
|
@ -45,11 +46,13 @@ public abstract class AstMethod implements IMethod {
|
|||
|
||||
public int[] getExposedUses(int instructionOffset);
|
||||
|
||||
public int[] getAllExposedUses();
|
||||
public IntSet getAllExposedUses();
|
||||
|
||||
public Pair[] getExposedNames();
|
||||
|
||||
public String[] getScopingParents();
|
||||
|
||||
public void handleAlteration();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue