revert PointerAnalysis hack that makes containsAny() and contains() methods in OrdinalSet unusable
This commit is contained in:
parent
428a3975ed
commit
ef4513d377
|
@ -384,7 +384,8 @@ public abstract class JavaIRTests extends IRTests {
|
|||
// can't do an IRAssertion() -- we need the pointer analysis
|
||||
|
||||
CallGraph cg = (CallGraph) x.fst;
|
||||
PointerAnalysis pa = (PointerAnalysis) x.snd;
|
||||
@SuppressWarnings("unchecked")
|
||||
PointerAnalysis<? extends InstanceKey> pa = (PointerAnalysis<? extends InstanceKey>) x.snd;
|
||||
|
||||
Iterator<CGNode> iter = cg.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
|
@ -442,7 +443,8 @@ public abstract class JavaIRTests extends IRTests {
|
|||
// can't do an IRAssertion() -- we need the pointer analysis
|
||||
|
||||
CallGraph cg = (CallGraph) x.fst;
|
||||
PointerAnalysis pa = (PointerAnalysis) x.snd;
|
||||
@SuppressWarnings("unchecked")
|
||||
PointerAnalysis<? extends InstanceKey> pa = (PointerAnalysis<? extends InstanceKey>) x.snd;
|
||||
|
||||
Iterator<CGNode> iter = cg.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
|
|
|
@ -98,7 +98,7 @@ public abstract class FieldBasedCallGraphBuilder {
|
|||
/**
|
||||
* Main entry point: builds a flow graph, then extracts a call graph and returns it.
|
||||
*/
|
||||
public Pair<JSCallGraph,PointerAnalysis> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
|
||||
public Pair<JSCallGraph,PointerAnalysis<FuncVertex>> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
|
||||
long fgBegin, fgEnd, cgBegin, cgEnd;
|
||||
|
||||
if(LOG_TIMINGS) fgBegin = System.currentTimeMillis();
|
||||
|
|
|
@ -141,11 +141,11 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
return graph.iterator();
|
||||
}
|
||||
|
||||
public PointerAnalysis getPointerAnalysis(final IProgressMonitor monitor) {
|
||||
return new PointerAnalysis() {
|
||||
public PointerAnalysis<FuncVertex> getPointerAnalysis(final IProgressMonitor monitor) {
|
||||
return new PointerAnalysis<FuncVertex>() {
|
||||
|
||||
@Override
|
||||
public OrdinalSet<? extends InstanceKey> getPointsToSet(PointerKey key) {
|
||||
public OrdinalSet<FuncVertex> getPointsToSet(PointerKey key) {
|
||||
if (key instanceof LocalPointerKey) {
|
||||
CGNode node = ((LocalPointerKey)key).getNode();
|
||||
FuncVertex fn = factory.makeFuncVertex(node.getMethod().getDeclaringClass());
|
||||
|
|
|
@ -56,7 +56,7 @@ public class LoadFileTargetSelector implements MethodTargetSelector {
|
|||
Set<String> names = new HashSet<String>();
|
||||
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()];
|
||||
LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));
|
||||
OrdinalSet<? extends InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
|
||||
OrdinalSet<InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
|
||||
for(InstanceKey k : ptrs) {
|
||||
if (k instanceof ConstantKey) {
|
||||
Object v = ((ConstantKey)k).getValue();
|
||||
|
|
|
@ -121,7 +121,7 @@ public class LexicalModRef {
|
|||
Collection<Pair<CGNode, String>> result = HashSetFactory.make();
|
||||
// use scope-mapping instance keys in pointer analysis. may need a different
|
||||
// scheme for CG construction not based on pointer analysis
|
||||
OrdinalSet<? extends InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
|
||||
OrdinalSet<InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
|
||||
for (InstanceKey ik : functionValues) {
|
||||
if (ik instanceof ScopeMappingInstanceKey) {
|
||||
ScopeMappingInstanceKey smik = (ScopeMappingInstanceKey) ik;
|
||||
|
|
|
@ -257,7 +257,7 @@ public class CallGraphTest extends WalaTestCase {
|
|||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
CGNode mainMethod = AbstractPtrTest.findMainMethod(cg);
|
||||
PointerKey keyToQuery = AbstractPtrTest.getParam(mainMethod, "testThisVar", pa.getHeapModel());
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery);
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery);
|
||||
Assert.assertEquals(1, pointsToSet.size());
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class MultiDimArrayTest extends WalaTestCase {
|
|||
|
||||
CGNode node = findDoNothingNode(cg);
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
OrdinalSet<? extends InstanceKey> ptsTo = pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> ptsTo = pa.getPointsToSet(pk);
|
||||
Assert.assertEquals(1, ptsTo.size());
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ public class TypeBasedArrayAliasTest extends WalaTestCase {
|
|||
}
|
||||
|
||||
private static boolean mayAliased(PointerKey pk1, PointerKey pk2, PointerAnalysis pa) {
|
||||
OrdinalSet<? extends InstanceKey> ptsTo1 = pa.getPointsToSet(pk1);
|
||||
OrdinalSet<? extends InstanceKey> ptsTo2 = pa.getPointsToSet(pk2);
|
||||
OrdinalSet<InstanceKey> ptsTo1 = pa.getPointsToSet(pk1);
|
||||
OrdinalSet<InstanceKey> ptsTo2 = pa.getPointsToSet(pk2);
|
||||
boolean foundIntersection = false;
|
||||
outer: for (InstanceKey i : ptsTo1) {
|
||||
for (InstanceKey j : ptsTo2) {
|
||||
|
|
|
@ -60,10 +60,10 @@ public class ZeroLengthArrayTest {
|
|||
cha.resolveMethod(MethodReference.findOrCreate(
|
||||
TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.ZERO_LENGTH_ARRAY_MAIN),
|
||||
Selector.make("main([Ljava/lang/String;)V"))), Everywhere.EVERYWHERE);
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4));
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4));
|
||||
Assert.assertEquals(1, pointsToSet.size());
|
||||
InstanceKey arrayKey = pointsToSet.iterator().next();
|
||||
OrdinalSet<? extends InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey));
|
||||
OrdinalSet<InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey));
|
||||
System.err.println(arrayContents);
|
||||
Assert.assertEquals(0, arrayContents.size());
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ public class CompareToZeroOneCFADriver {
|
|||
LocalPointerKey pk = (LocalPointerKey) heapModel.getPointerKeyForLocal(node, i);
|
||||
LocalPointerKey oldPk = (LocalPointerKey) CallGraphMapUtil.mapPointerKey(pk, cg, oldCG, heapModel);
|
||||
Collection<InstanceKey> p2set = dmp.getPointsTo(pk);
|
||||
OrdinalSet<? extends InstanceKey> otherP2Set = pa.getPointsToSet(oldPk);
|
||||
OrdinalSet<InstanceKey> otherP2Set = pa.getPointsToSet(oldPk);
|
||||
System.err.println(("OLD POINTS-TO " + otherP2Set));
|
||||
for (InstanceKey key : otherP2Set) {
|
||||
if (knownBug(key)) {
|
||||
|
|
|
@ -256,8 +256,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
//
|
||||
for (Iterator<PointerKey> rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
|
||||
PointerKey root = rts.next();
|
||||
OrdinalSet<? extends InstanceKey> objects = pa.getPointsToSet(root);
|
||||
for (Iterator<? extends InstanceKey> objs = objects.iterator(); objs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> objects = pa.getPointsToSet(root);
|
||||
for (Iterator<InstanceKey> objs = objects.iterator(); objs.hasNext();) {
|
||||
InstanceKey obj = (InstanceKey) objs.next();
|
||||
escapingInstanceKeys.add(obj);
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
if (type.isArrayClass()) {
|
||||
if (((ArrayClass) type).getElementClass() != null) {
|
||||
PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
|
||||
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
InstanceKey fobj = (InstanceKey) fobjs.next();
|
||||
if (!escapingInstanceKeys.contains(fobj)) {
|
||||
newKeys.add(fobj);
|
||||
|
@ -290,8 +290,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
IField f = (IField) fs.next();
|
||||
if (f.getFieldTypeReference().isReferenceType()) {
|
||||
PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
|
||||
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
InstanceKey fobj = (InstanceKey) fobjs.next();
|
||||
if (!escapingInstanceKeys.contains(fobj)) {
|
||||
newKeys.add(fobj);
|
||||
|
|
|
@ -256,10 +256,10 @@ public class BasicHeapGraph extends HeapGraph {
|
|||
private int[] computeSuccNodeNumbers(Object N, NumberedNodeManager<Object> nodeManager) {
|
||||
if (N instanceof PointerKey) {
|
||||
PointerKey P = (PointerKey) N;
|
||||
OrdinalSet<? extends InstanceKey> S = getPointerAnalysis().getPointsToSet(P);
|
||||
OrdinalSet<InstanceKey> S = getPointerAnalysis().getPointsToSet(P);
|
||||
int[] result = new int[S.size()];
|
||||
int i = 0;
|
||||
for (Iterator<? extends InstanceKey> it = S.iterator(); it.hasNext();) {
|
||||
for (Iterator<InstanceKey> it = S.iterator(); it.hasNext();) {
|
||||
result[i] = nodeManager.getNumber(it.next());
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -2460,7 +2460,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
|
|||
|
||||
private boolean predHoldsForPk(PointerKey curPk, Predicate<InstanceKey> pred, PointerAnalysis pa) {
|
||||
PointerKey curPkForPAHeapModel = convertToHeapModel(curPk, pa.getHeapModel());
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(curPkForPAHeapModel);
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(curPkForPAHeapModel);
|
||||
for (InstanceKey ik : pointsToSet) {
|
||||
if (!pred.test(ik)) {
|
||||
return false;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
|
|||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private final PointerAnalysis pa;
|
||||
private final PointerAnalysis<? extends InstanceKey> pa;
|
||||
|
||||
private final HeapModel heapModel;
|
||||
|
||||
|
@ -51,15 +51,15 @@ public class PABasedMemoryAccessMap implements MemoryAccessMap {
|
|||
|
||||
private final Map<PointerKey, Set<Statement>> invRef;
|
||||
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis pa) {
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis<? extends InstanceKey> pa) {
|
||||
this(cg, pa, new SDG(cg, pa, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
|
||||
}
|
||||
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis pa, SDG sdg) {
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis<? extends InstanceKey> pa, SDG sdg) {
|
||||
this(cg, pa, CISlicer.scanForMod(sdg, pa, true, ModRef.make()), CISlicer.scanForRef(sdg, pa));
|
||||
}
|
||||
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis pa, Map<Statement, Set<PointerKey>> mod,
|
||||
public PABasedMemoryAccessMap(CallGraph cg, PointerAnalysis<? extends InstanceKey> pa, Map<Statement, Set<PointerKey>> mod,
|
||||
Map<Statement, Set<PointerKey>> ref) {
|
||||
if (pa == null) {
|
||||
throw new IllegalArgumentException("null pa");
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.ibm.wala.ipa.callgraph;
|
||||
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
|
||||
|
@ -30,7 +31,7 @@ public interface CallGraphBuilder {
|
|||
/**
|
||||
* @return the Pointer Analysis information computed as a side-effect of call graph construction.
|
||||
*/
|
||||
public PointerAnalysis getPointerAnalysis();
|
||||
public PointerAnalysis<InstanceKey> getPointerAnalysis();
|
||||
|
||||
/**
|
||||
* @return A cache of various analysis artifacts used during call graph construction.
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.ibm.wala.util.intset.OrdinalSetMapping;
|
|||
/**
|
||||
* Abstract superclass for {@link PointerAnalysis} implementations.
|
||||
*/
|
||||
public abstract class AbstractPointerAnalysis implements PointerAnalysis {
|
||||
public abstract class AbstractPointerAnalysis implements PointerAnalysis<InstanceKey> {
|
||||
|
||||
/**
|
||||
* graph representation of pointer-analysis results
|
||||
|
|
|
@ -20,14 +20,14 @@ import com.ibm.wala.util.intset.OrdinalSetMapping;
|
|||
/**
|
||||
* Abstract definition of pointer analysis
|
||||
*/
|
||||
public interface PointerAnalysis {
|
||||
public interface PointerAnalysis<T extends InstanceKey> {
|
||||
|
||||
/**
|
||||
* @param key representative of an equivalence class of pointers
|
||||
* @return Set of InstanceKey, representing the instance abstractions that define
|
||||
* the points-to set computed for the pointer key
|
||||
*/
|
||||
OrdinalSet<? extends InstanceKey> getPointsToSet(PointerKey key);
|
||||
OrdinalSet<T> getPointsToSet(PointerKey key);
|
||||
|
||||
/**
|
||||
* @return an Object that determines how to model abstract locations in the heap.
|
||||
|
|
|
@ -683,7 +683,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder {
|
|||
* @see com.ibm.detox.ipa.callgraph.CallGraphBuilder#getPointerAnalysis()
|
||||
*/
|
||||
@Override
|
||||
public PointerAnalysis getPointerAnalysis() {
|
||||
public PointerAnalysis<InstanceKey> getPointerAnalysis() {
|
||||
return system.extractPointerAnalysis(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,11 +175,11 @@ public class ModRef {
|
|||
|
||||
private final Collection<PointerKey> result;
|
||||
|
||||
private final PointerAnalysis pa;
|
||||
private final PointerAnalysis<? extends InstanceKey> pa;
|
||||
|
||||
private final ExtendedHeapModel h;
|
||||
|
||||
protected RefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected RefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<? extends InstanceKey> pa, ExtendedHeapModel h) {
|
||||
this.n = n;
|
||||
this.result = result;
|
||||
this.pa = pa;
|
||||
|
@ -225,12 +225,12 @@ public class ModRef {
|
|||
|
||||
private final ExtendedHeapModel h;
|
||||
|
||||
private final PointerAnalysis pa;
|
||||
private final PointerAnalysis<? extends InstanceKey> pa;
|
||||
|
||||
private final boolean ignoreAllocHeapDefs;
|
||||
|
||||
protected ModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis pa,
|
||||
boolean ignoreAllocHeapDefs) {
|
||||
protected ModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h,
|
||||
PointerAnalysis<? extends InstanceKey> pa, boolean ignoreAllocHeapDefs) {
|
||||
this.n = n;
|
||||
this.result = result;
|
||||
this.h = h;
|
||||
|
|
|
@ -54,7 +54,7 @@ import com.ibm.wala.util.intset.OrdinalSetMapping;
|
|||
*/
|
||||
public class PaPanel extends JSplitPane {
|
||||
|
||||
protected final PointerAnalysis pa;
|
||||
protected final PointerAnalysis<? extends InstanceKey> pa;
|
||||
protected final CallGraph cg;
|
||||
|
||||
private JTextField fullName;
|
||||
|
@ -66,7 +66,7 @@ public class PaPanel extends JSplitPane {
|
|||
private MutableMapping<List<InstanceFieldPointerKey>> instanceKeyIdToInstanceFieldPointers = MutableMapping.<List<InstanceFieldPointerKey>> make();
|
||||
|
||||
|
||||
public PaPanel(CallGraph cg, PointerAnalysis pa) {
|
||||
public PaPanel(CallGraph cg, PointerAnalysis<? extends InstanceKey> pa) {
|
||||
super(JSplitPane.HORIZONTAL_SPLIT);
|
||||
|
||||
this.pa = pa;
|
||||
|
|
|
@ -86,7 +86,7 @@ public class LocalSinkPoint implements ISinkPoint {
|
|||
final CGNode node = block.getNode();
|
||||
PointerKey pk = ctx.pa.getHeapModel().getPointerKeyForLocal(node,
|
||||
ssaVal);
|
||||
OrdinalSet<? extends InstanceKey> iks = ctx.pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> iks = ctx.pa.getPointsToSet(pk);
|
||||
if (null == iks) {
|
||||
logger.warn("no instance keys found for SinkPoint {}", this);
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ implements IFlowFunctionMap<BasicBlockInContext<E>> {
|
|||
// now add the field keys to the defs list so that they
|
||||
// are also tainted:
|
||||
if (pk!=null) {
|
||||
OrdinalSet<? extends InstanceKey> m = pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> m = pa.getPointsToSet(pk);
|
||||
if (m != null) {
|
||||
for (InstanceKey instanceKey : m) {
|
||||
elements.add(new FieldElement(instanceKey, pi.getDeclaredField()));
|
||||
|
@ -346,7 +346,7 @@ implements IFlowFunctionMap<BasicBlockInContext<E>> {
|
|||
|
||||
if (pk!=null) {
|
||||
Set<CodeElement> elements = Sets.newHashSet();
|
||||
OrdinalSet<? extends InstanceKey> m = pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> m = pa.getPointsToSet(pk);
|
||||
if(m != null) {
|
||||
for (InstanceKey instanceKey : m) {
|
||||
elements.add(new FieldElement(instanceKey, declaredField));
|
||||
|
|
|
@ -483,7 +483,7 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
|
|||
PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node,
|
||||
inst.getRef());
|
||||
|
||||
final OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
if (pointsToSet.isEmpty()) {
|
||||
logger.debug(
|
||||
"pointsToSet empty for ref of {}, creating InstanceKey manually",
|
||||
|
@ -519,7 +519,7 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
|
|||
Set<CodeElement> elts = Sets.newHashSet();
|
||||
final PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node,
|
||||
inst.getArrayRef());
|
||||
final OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
if (pointsToSet.isEmpty()) {
|
||||
logger.debug(
|
||||
"pointsToSet empty for ref of {}, creating InstanceKey manually",
|
||||
|
|
|
@ -128,7 +128,7 @@ public class StringBuilderUseAnalysis {
|
|||
}
|
||||
} else if (!(pk instanceof ReturnValueKey)) {
|
||||
// if this pointer key points to our instance key then we have to give up -- we can only analyze local pointer keys
|
||||
final OrdinalSet<? extends InstanceKey> pts = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pts = pa.getPointsToSet(pk);
|
||||
if (pts.contains(ik)) {
|
||||
logger.warn("Found non LocalPointerKey refering to our ik: " + pk);
|
||||
return null;
|
||||
|
|
|
@ -223,22 +223,22 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
|
|||
final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
|
||||
final SSAInvokeInstruction invoke =
|
||||
(SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction();
|
||||
final OrdinalSet<? extends InstanceKey> ptsUri =
|
||||
final OrdinalSet<InstanceKey> ptsUri =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0)));
|
||||
|
||||
if (!ptsUri.isEmpty()) {
|
||||
final InstanceKey uriKey = ptsUri.iterator().next();
|
||||
final OrdinalSet<? extends InstanceKey> points =
|
||||
final OrdinalSet<InstanceKey> points =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(1)));
|
||||
|
||||
if (!points.isEmpty()) {
|
||||
final InstanceKey stringKey = points.iterator().next();
|
||||
|
||||
final OrdinalSet<? extends InstanceKey> returnSet =
|
||||
final OrdinalSet<InstanceKey> returnSet =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getReturnValue(0)));
|
||||
logger.debug("Sizeof returnset: " + returnSet.size() + "--" + lpk);
|
||||
|
||||
for (final Iterator<? extends InstanceKey> rIK = returnSet.iterator(); rIK.hasNext(); ) {
|
||||
for (final Iterator<InstanceKey> rIK = returnSet.iterator(); rIK.hasNext(); ) {
|
||||
final InstanceKey returnIK = rIK.next();
|
||||
final UriAppendString node = new UriAppendString(mapping.getMappedIndex(returnIK),
|
||||
mapping.getMappedIndex(uriKey), mapping.getMappedIndex(stringKey));
|
||||
|
@ -276,12 +276,12 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
|
|||
final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
|
||||
final SSAInvokeInstruction invoke =
|
||||
(SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction();
|
||||
final OrdinalSet<? extends InstanceKey> ptsUri =
|
||||
final OrdinalSet<InstanceKey> ptsUri =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0)));
|
||||
|
||||
if (!ptsUri.isEmpty()) {
|
||||
final InstanceKey uriKey = ptsUri.iterator().next();
|
||||
final OrdinalSet<? extends InstanceKey> points =
|
||||
final OrdinalSet<InstanceKey> points =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(1)));
|
||||
|
||||
if (!points.isEmpty()) {
|
||||
|
@ -316,7 +316,7 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
|
|||
(SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction();
|
||||
logger.debug("invoke inst: " + invoke + " getuse: " + invoke.getUse(0));
|
||||
logger.debug("in node: " + caller);
|
||||
final OrdinalSet<? extends InstanceKey> points =
|
||||
final OrdinalSet<InstanceKey> points =
|
||||
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0)));
|
||||
|
||||
if (!points.isEmpty()) {
|
||||
|
|
|
@ -95,7 +95,7 @@ public class EntryArgSourceSpec extends SourceSpec {
|
|||
final Set<CodeElement> valueElements = CodeElement.valueElements(pa, node, ssaVal);
|
||||
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, ssaVal);
|
||||
final OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
|
||||
if (pointsToSet.isEmpty()) {
|
||||
TypeReference typeRef = node.getMethod().getParameterType(i);
|
||||
|
|
|
@ -114,7 +114,7 @@ public class StaticFieldSourceSpec extends SourceSpec {
|
|||
// else, handle reference types:
|
||||
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForStaticField(field);
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
|
||||
if (pointsToSet.isEmpty()) {
|
||||
IClassHierarchy cha = im.getClassHierarchy();
|
||||
|
|
|
@ -320,7 +320,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
// don't do anything for primitive contents
|
||||
continue;
|
||||
}
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet =
|
||||
OrdinalSet<InstanceKey> pointsToSet =
|
||||
pa.getPointsToSet(pa.getHeapModel().getPointerKeyForArrayContents(ik));
|
||||
if (pointsToSet.isEmpty()) {
|
||||
logger.debug("pointsToSet empty for array contents, creating InstanceKey manually");
|
||||
|
@ -362,7 +362,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
continue;
|
||||
} else if (fieldTypeRef.isArrayType()) {
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForInstanceField(ik, field);
|
||||
final OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
if (pointsToSet.isEmpty()) {
|
||||
logger.debug("pointsToSet empty for array field, creating InstanceKey manually");
|
||||
InstanceKey fieldIK = new ConcreteTypeKey(pa.getClassHierarchy().lookupClass(fieldTypeRef));
|
||||
|
@ -382,7 +382,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
|
|||
}
|
||||
} else if (fieldTypeRef.isReferenceType()) {
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForInstanceField(ik, field);
|
||||
final OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
|
||||
if (pointsToSet.isEmpty() && !analysisContext.getClassHierarchy().isInterface(fieldTypeRef)) {
|
||||
logger.debug("pointsToSet empty for reference field, creating InstanceKey manually");
|
||||
InstanceKey fieldIK = new ConcreteTypeKey(fieldClass);
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.ibm.wala.cast.js.callgraph.fieldbased.PessimisticCallGraphBuilder;
|
|||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.FilteredFlowGraphBuilder;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.FlowGraph;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.FlowGraphBuilder;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.FuncVertex;
|
||||
import com.ibm.wala.cast.js.client.impl.ZeroCFABuilderFactory;
|
||||
import com.ibm.wala.cast.js.html.IncludedPosition;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSAnalysisOptions;
|
||||
|
@ -116,11 +117,11 @@ public class EclipseJavaScriptAnalysisEngine extends EclipseProjectSourceAnalysi
|
|||
return new ZeroCFABuilderFactory().make((JSAnalysisOptions)options, cache, cha, scope, false);
|
||||
}
|
||||
|
||||
public Pair<JSCallGraph, PointerAnalysis> getFieldBasedCallGraph() throws CancelException {
|
||||
public Pair<JSCallGraph, PointerAnalysis<FuncVertex>> getFieldBasedCallGraph() throws CancelException {
|
||||
return getFieldBasedCallGraph(JSCallGraphUtil.makeScriptRoots(getClassHierarchy()));
|
||||
}
|
||||
|
||||
public Pair<JSCallGraph, PointerAnalysis> getFieldBasedCallGraph(String scriptName) throws CancelException {
|
||||
public Pair<JSCallGraph, PointerAnalysis<FuncVertex>> getFieldBasedCallGraph(String scriptName) throws CancelException {
|
||||
Set<Entrypoint> eps= HashSetFactory.make();
|
||||
eps.add(JSCallGraphUtil.makeScriptRoots(getClassHierarchy()).make(scriptName));
|
||||
eps.add(JSCallGraphUtil.makeScriptRoots(getClassHierarchy()).make("Lprologue.js"));
|
||||
|
@ -139,7 +140,7 @@ public class EclipseJavaScriptAnalysisEngine extends EclipseProjectSourceAnalysi
|
|||
return fileName.substring(fileName.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
protected Pair<JSCallGraph, PointerAnalysis> getFieldBasedCallGraph(Iterable<Entrypoint> roots) throws CancelException {
|
||||
protected Pair<JSCallGraph, PointerAnalysis<FuncVertex>> getFieldBasedCallGraph(Iterable<Entrypoint> roots) throws CancelException {
|
||||
final Set<String> scripts = HashSetFactory.make();
|
||||
for(Entrypoint e : roots) {
|
||||
String scriptName = getScriptName(((AstMethod)e.getMethod()));
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.wst.jsdt.core.IJavaScriptProject;
|
|||
import com.ibm.wala.cast.ipa.callgraph.CAstAnalysisScope;
|
||||
import com.ibm.wala.cast.js.JavaScriptPlugin;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.FlowGraph;
|
||||
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.FuncVertex;
|
||||
import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraph;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil;
|
||||
|
@ -56,7 +57,7 @@ public class EclipseWebAnalysisEngine extends EclipseJavaScriptAnalysisEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Pair<JSCallGraph, PointerAnalysis> getFieldBasedCallGraph(String scriptName) throws CancelException {
|
||||
public Pair<JSCallGraph, PointerAnalysis<FuncVertex>> getFieldBasedCallGraph(String scriptName) throws CancelException {
|
||||
Set<Entrypoint> eps= HashSetFactory.make();
|
||||
eps.add(JSCallGraphUtil.makeScriptRoots(getClassHierarchy()).make(scriptName));
|
||||
eps.add(JSCallGraphUtil.makeScriptRoots(getClassHierarchy()).make("Lprologue.js"));
|
||||
|
|
|
@ -172,7 +172,7 @@ public class OrdinalSet<T> implements Iterable<T> {
|
|||
/**
|
||||
* @return true iff this set contains object
|
||||
*/
|
||||
public boolean contains(Object object) {
|
||||
public boolean contains(T object) {
|
||||
if (this == EMPTY || S == null || object == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue