add some abstraction to IR, using IRView
This commit is contained in:
parent
a1f8894ba1
commit
f595eb357e
|
@ -37,7 +37,7 @@ public class TestCPA {
|
|||
builder.setContextSelector(new CPAContextSelector(builder.getContextSelector()));
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
JSCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
|||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
@ -206,9 +207,9 @@ public class JSCallGraphBuilderUtil extends com.ibm.wala.cast.js.ipa.callgraph.J
|
|||
}
|
||||
|
||||
public static CallGraph makeHTMLCG(URL url, Function<Void, JSSourceExtractor> fExtractor) throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder b = makeHTMLCGBuilder(url, fExtractor);
|
||||
SSAPropagationCallGraphBuilder b = makeHTMLCGBuilder(url, fExtractor);
|
||||
CallGraph CG = b.makeCallGraph(b.getOptions());
|
||||
dumpCG(b.getPointerAnalysis(), CG);
|
||||
dumpCG(b.getCFAContextInterpreter(), b.getPointerAnalysis(), CG);
|
||||
return CG;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public abstract class TestArgumentSensitivity extends TestJSCallGraphShape {
|
|||
CallGraph CG = builder.makeCallGraph(options);
|
||||
|
||||
// CAstCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
|
||||
verifyGraphAssertions(CG, assertionsForArgs);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
URL url = getClass().getClassLoader().getResource("pages/page3.html");
|
||||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
@Test public void testPage3WithHack() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
|
@ -46,7 +46,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
addHackedForInLoopSensitivity(builder);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
@Ignore("This test now blows up due to proper handling of the || construct, used in extend(). Should handle this eventually.")
|
||||
|
@ -55,7 +55,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
addHackedForInLoopSensitivity(builder);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -88,7 +88,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
@Test public void testBadForInWithoutHack() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForBadForin);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin.js");
|
||||
addHackedForInLoopSensitivity(B);
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForBadForin);
|
||||
verifyGraphAssertions(CG, assertionsForBadForinHackPrecision);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
@Test public void testbadforin2WithoutHack() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin2.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForbadforin2);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin2.js");
|
||||
addHackedForInLoopSensitivity(B);
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForbadforin2);
|
||||
verifyGraphAssertions(CG, assertionsForbadforin2HackPrecision);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public abstract class TestForInLoopHack extends TestJSCallGraphShape {
|
|||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "badforin3.js");
|
||||
addHackedForInLoopSensitivity(B);
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,6 @@ public class TestJQueryExamples extends TestJSCallGraphShape {
|
|||
URL url = getClass().getClassLoader().getResource("pages/jquery/ex1.html");
|
||||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "forin.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
// JSCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForForin);
|
||||
}
|
||||
|
||||
|
@ -266,11 +266,11 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
@Test
|
||||
public void testStringPrims() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "string-prims.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "string-prims.js");
|
||||
B.getOptions().setTraceStringConstants(true);
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
// JSCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForStringPrims);
|
||||
}
|
||||
|
||||
|
@ -478,10 +478,10 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
@Test
|
||||
public void testReturnThis() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "return_this.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "return_this.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
// JSCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForReturnThis);
|
||||
}
|
||||
|
||||
|
@ -573,10 +573,10 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
@Test
|
||||
public void testDispatch() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "dispatch.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "dispatch.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
// JSCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForDispatch);
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,7 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
boolean save = CAstCallGraphUtil.AVOID_DUMP;
|
||||
//CAstCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.AVOID_DUMP = save;
|
||||
}
|
||||
|
||||
|
@ -724,14 +724,14 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
monitor.beginTask("build CG", 1);
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions(), monitor);
|
||||
monitor.done();
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTutorialExample() throws IllegalArgumentException, IOException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "tutorial-example.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "tutorial-example.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
// verifyGraphAssertions(CG, assertionsForDateProperty);
|
||||
}
|
||||
|
||||
|
@ -743,11 +743,11 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
@Ignore("need to fix this. bug from Sukyoung's group")
|
||||
@Test
|
||||
public void testLoops() throws IllegalArgumentException, IOException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "loops.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "loops.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
boolean x = CAstCallGraphUtil.AVOID_DUMP;
|
||||
CAstCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.AVOID_DUMP = x;
|
||||
verifyGraphAssertions(CG, assertionsForLoops);
|
||||
}
|
||||
|
@ -762,11 +762,11 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
@Ignore("need to fix this. bug from Sukyoung's group")
|
||||
@Test
|
||||
public void testPrimitiveStrings() throws IllegalArgumentException, IOException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "primitive_strings.js");
|
||||
SSAPropagationCallGraphBuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "primitive_strings.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
boolean x = CAstCallGraphUtil.AVOID_DUMP;
|
||||
CAstCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(B.getCFAContextInterpreter(), B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.AVOID_DUMP = x;
|
||||
verifyGraphAssertions(CG, assertionsForPrimitiveStrings);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
// JSCallGraphBuilderUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
verifySourceAssertions(CG, sourceAssertionsForList);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
URL url = getClass().getClassLoader().getResource("pages/windowx.html");
|
||||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForWindowx);
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
URL url = getClass().getClassLoader().getResource("pages/windowonload.html");
|
||||
JSCFABuilder builder = JSCallGraphBuilderUtil.makeHTMLCGBuilder(url);
|
||||
CallGraph CG = builder.makeCallGraph(builder.getOptions());
|
||||
CAstCallGraphUtil.dumpCG(builder.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.dumpCG(builder.getCFAContextInterpreter(), builder.getPointerAnalysis(), CG);
|
||||
verifyGraphAssertions(CG, assertionsForWindowOnload);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ import com.ibm.wala.shrikeBT.BinaryOpInstruction;
|
|||
import com.ibm.wala.shrikeBT.IUnaryOpInstruction;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.SSAAbstractBinaryInstruction;
|
||||
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
|
||||
import com.ibm.wala.ssa.SSABinaryOpInstruction;
|
||||
|
@ -1023,10 +1024,10 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
|
|||
public static void processCallingConstraintsInternal(AstSSAPropagationCallGraphBuilder builder, CGNode caller, SSAAbstractInvokeInstruction instruction, CGNode target,
|
||||
InstanceKey[][] constParams, PointerKey uniqueCatchKey) {
|
||||
|
||||
IR sourceIR = builder.getCFAContextInterpreter().getIR(caller);
|
||||
IRView sourceIR = builder.getCFAContextInterpreter().getIRView(caller);
|
||||
SymbolTable sourceST = sourceIR.getSymbolTable();
|
||||
|
||||
IR targetIR = builder.getCFAContextInterpreter().getIR(target);
|
||||
IRView targetIR = builder.getCFAContextInterpreter().getIRView(target);
|
||||
SymbolTable targetST = targetIR.getSymbolTable();
|
||||
|
||||
JSConstraintVisitor targetVisitor = null;
|
||||
|
|
|
@ -65,6 +65,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.ipa.modref.ArrayLengthKey;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
|
@ -378,9 +379,10 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
if (lexicalKey instanceof LocalPointerKey) {
|
||||
CGNode lnode = ((LocalPointerKey) lexicalKey).getNode();
|
||||
int lvn = ((LocalPointerKey) lexicalKey).getValueNumber();
|
||||
IR lir = getBuilder().getCFAContextInterpreter().getIR(lnode);
|
||||
IRView lir = getBuilder().getCFAContextInterpreter().getIRView(lnode);
|
||||
SymbolTable lsymtab = lir.getSymbolTable();
|
||||
DefUse ldu = getAnalysisCache().getDefUse(lir);
|
||||
DefUse ldu = getBuilder().getCFAContextInterpreter().getDU(lnode);
|
||||
// DefUse ldu = getAnalysisCache().getDefUse(lir);
|
||||
if (contentsAreInvariant(lsymtab, ldu, lvn)) {
|
||||
InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn);
|
||||
system.recordImplicitPointsToSet(lexicalKey);
|
||||
|
@ -701,7 +703,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
final Set<CGNode> result = HashSetFactory.make();
|
||||
PointerKey F = getBuilder().getPointerKeyForLocal(opNode, 1);
|
||||
|
||||
IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode);
|
||||
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode);
|
||||
SymbolTable symtab = ir.getSymbolTable();
|
||||
DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode);
|
||||
if (contentsAreInvariant(symtab, du, 1)) {
|
||||
|
@ -762,7 +764,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
if (name.equals(names[i].fst) && definer.equals(names[i].snd)) {
|
||||
int vn = LI.getExitExposedUses()[i];
|
||||
if (vn > 0) {
|
||||
IR ir = getBuilder().getCFAContextInterpreter().getIR(definingNode);
|
||||
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(definingNode);
|
||||
DefUse du = getBuilder().getCFAContextInterpreter().getDU(definingNode);
|
||||
SymbolTable st = ir.getSymbolTable();
|
||||
|
||||
|
@ -852,7 +854,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
|
||||
private void newFieldOperation(CGNode opNode, final int objVn, final int fieldsVn, final boolean isLoadOperation,
|
||||
final ReflectedFieldAction action) {
|
||||
IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode);
|
||||
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode);
|
||||
SymbolTable symtab = ir.getSymbolTable();
|
||||
DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode);
|
||||
PointerKey objKey = getBuilder().getPointerKeyForLocal(opNode, objVn);
|
||||
|
@ -936,7 +938,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
|
||||
protected void newFieldOperationFieldConstant(CGNode opNode, final boolean isLoadOperation, final ReflectedFieldAction action,
|
||||
final int objVn, final InstanceKey[] fieldsKeys) {
|
||||
IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode);
|
||||
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode);
|
||||
SymbolTable symtab = ir.getSymbolTable();
|
||||
DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode);
|
||||
PointerKey objKey = getBuilder().getPointerKeyForLocal(opNode, objVn);
|
||||
|
@ -1152,7 +1154,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
}
|
||||
|
||||
public void newFieldWrite(CGNode opNode, int objVn, int fieldsVn, int rhsVn) {
|
||||
IR ir = getBuilder().getCFAContextInterpreter().getIR(opNode);
|
||||
IRView ir = getBuilder().getCFAContextInterpreter().getIRView(opNode);
|
||||
SymbolTable symtab = ir.getSymbolTable();
|
||||
DefUse du = getBuilder().getCFAContextInterpreter().getDU(opNode);
|
||||
PointerKey rhsKey = getBuilder().getPointerKeyForLocal(opNode, rhsVn);
|
||||
|
|
|
@ -34,8 +34,10 @@ import com.ibm.wala.ipa.callgraph.CallGraph;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRFactory;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class CAstCallGraphUtil {
|
||||
|
@ -120,7 +122,7 @@ public class CAstCallGraphUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void dumpCG(PointerAnalysis<InstanceKey> PA, CallGraph CG) {
|
||||
public static void dumpCG(SSAContextInterpreter interp, PointerAnalysis<InstanceKey> PA, CallGraph CG) {
|
||||
if (AVOID_DUMP)
|
||||
return;
|
||||
for (Iterator x = CG.iterator(); x.hasNext();) {
|
||||
|
@ -136,7 +138,7 @@ public class CAstCallGraphUtil {
|
|||
}
|
||||
System.err.println("]");
|
||||
System.err.println("\nIR of node " + N.getGraphNodeId() + ", context " + N.getContext());
|
||||
IR ir = N.getIR();
|
||||
IRView ir = interp.getIRView(N);
|
||||
if (ir != null) {
|
||||
System.err.println(ir);
|
||||
} else {
|
||||
|
|
|
@ -46,7 +46,11 @@ public class CallGraphTestUtil {
|
|||
private static final boolean CHECK_FOOTPRINT = false;
|
||||
|
||||
public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile, String exclusionsFile) throws IOException {
|
||||
AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, (new FileProvider()).getFile(exclusionsFile), MY_CLASSLOADER);
|
||||
return makeJ2SEAnalysisScope(scopeFile, exclusionsFile, MY_CLASSLOADER);
|
||||
}
|
||||
|
||||
public static AnalysisScope makeJ2SEAnalysisScope(String scopeFile, String exclusionsFile, ClassLoader myClassLoader) throws IOException {
|
||||
AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, (new FileProvider()).getFile(exclusionsFile), myClassLoader);
|
||||
return scope;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
|||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
|
@ -61,6 +62,7 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
|||
}
|
||||
/** BEGIN Custom change: caching */
|
||||
|
||||
|
||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
||||
final IMethod method = node.getMethod();
|
||||
final String hashKey = method.toString() + "@" + context.toString();
|
||||
|
@ -76,6 +78,11 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
assert understands(node);
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
|
@ -95,6 +96,11 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
assert understands(node);
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.ibm.wala.ipa.summaries.SyntheticIR;
|
|||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
@ -114,6 +115,11 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
assert understands(node);
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
|||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
|
@ -95,6 +96,11 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
return cache.getIR(m, node.getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
private Set<TypeReference> getTypesForContext(Context context) {
|
||||
// first try user spec
|
||||
// XMLReflectionReader spec = (XMLReflectionReader) userSpec;
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
|||
import com.ibm.wala.ipa.summaries.SyntheticIR;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
|
@ -73,6 +74,11 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
assert understands(node);
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ibm.wala.ipa.summaries.SyntheticIR;
|
|||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
|
@ -94,6 +95,11 @@ public class GetMethodContextInterpreter implements SSAContextInterpreter {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter#getNumberOfStatements(com.ibm.wala.ipa.callgraph.CGNode)
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.ibm.wala.ipa.summaries.SyntheticIR;
|
|||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
@ -122,6 +123,11 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
private IR makeIR(IMethod method, JavaTypeContext context) {
|
||||
Map<Integer, ConstantValue> constants = HashMapFactory.make();
|
||||
if (method.getReference().equals(GET_CONSTRUCTOR)) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ipa.callgraph.propagation.cfa.DelegatingSSAContextInterprete
|
|||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
|
@ -90,6 +91,11 @@ public class ReflectionContextInterpreter {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefUse getDU(CGNode node) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.ibm.wala.shrikeBT.IInvokeInstruction.Dispatch;
|
|||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSACheckCastInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
@ -86,6 +87,11 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter#getNumberOfStatements(com.ibm.wala.ipa.callgraph.CGNode)
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.ibm.wala.shrikeBT.IInvokeInstruction.Dispatch;
|
|||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAFieldAccessInstruction;
|
||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
||||
|
@ -288,6 +289,11 @@ public class MethodHandles {
|
|||
return irs.get(node).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefUse getDU(CGNode node) {
|
||||
return new DefUse(getIR(node));
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.shrikeBT.BytecodeConstants;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.rta.RTAContextInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
||||
|
@ -28,6 +29,8 @@ public interface SSAContextInterpreter extends RTAContextInterpreter {
|
|||
*/
|
||||
public IR getIR(CGNode node);
|
||||
|
||||
public IRView getIRView(CGNode node);
|
||||
|
||||
/**
|
||||
* @return DefUse for the IR that models the method context, or null if it's an unmodelled native method
|
||||
*/
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.ibm.wala.shrikeBT.ConditionalBranchInstruction;
|
|||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
|
||||
import com.ibm.wala.ssa.SSAAbstractThrowInstruction;
|
||||
|
@ -214,7 +215,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
if (DEBUG) {
|
||||
System.err.println("\n\nAdd constraints from node " + node);
|
||||
}
|
||||
IR ir = getCFAContextInterpreter().getIR(node);
|
||||
IRView ir = getCFAContextInterpreter().getIRView(node);
|
||||
if (DEBUG) {
|
||||
if (ir == null) {
|
||||
System.err.println("\n No statements\n");
|
||||
|
@ -256,11 +257,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
this.monitor = monitor;
|
||||
ConstraintVisitor v = makeVisitor(node);
|
||||
|
||||
IR ir = v.ir;
|
||||
ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = ir.getControlFlowGraph();
|
||||
for (Iterator<ISSABasicBlock> x = cfg.iterator(); x.hasNext();) {
|
||||
IRView ir = v.ir;
|
||||
for (Iterator<ISSABasicBlock> x = ir.getBlocks(); x.hasNext();) {
|
||||
BasicBlock b = (BasicBlock) x.next();
|
||||
addBlockInstructionConstraints(node, cfg, b, v, monitor);
|
||||
addBlockInstructionConstraints(node, ir, b, v, monitor);
|
||||
if (wasChanged(node)) {
|
||||
return;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
* Add constraints for a particular basic block.
|
||||
* @throws CancelException
|
||||
*/
|
||||
protected void addBlockInstructionConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg, BasicBlock b,
|
||||
protected void addBlockInstructionConstraints(CGNode node, IRView ir, BasicBlock b,
|
||||
ConstraintVisitor v, IProgressMonitor monitor) throws CancelException {
|
||||
this.monitor = monitor;
|
||||
v.setBasicBlock(b);
|
||||
|
@ -296,24 +296,24 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
}
|
||||
}
|
||||
|
||||
addPhiConstraints(node, cfg, b, v);
|
||||
addPhiConstraints(node, ir.getControlFlowGraph(), b, v);
|
||||
}
|
||||
|
||||
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg, BasicBlock b,
|
||||
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> controlFlowGraph, BasicBlock b,
|
||||
ConstraintVisitor v) {
|
||||
// visit each phi instruction in each successor block
|
||||
for (Iterator sbs = cfg.getSuccNodes(b); sbs.hasNext();) {
|
||||
for (Iterator sbs = controlFlowGraph.getSuccNodes(b); sbs.hasNext();) {
|
||||
BasicBlock sb = (BasicBlock) sbs.next();
|
||||
if (!sb.hasPhi()) {
|
||||
continue;
|
||||
}
|
||||
int n = 0;
|
||||
for (Iterator<? extends IBasicBlock> back = cfg.getPredNodes(sb); back.hasNext(); n++) {
|
||||
for (Iterator<? extends IBasicBlock> back = controlFlowGraph.getPredNodes(sb); back.hasNext(); n++) {
|
||||
if (back.next() == b) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert n < cfg.getPredNodeCount(sb);
|
||||
assert n < controlFlowGraph.getPredNodeCount(sb);
|
||||
for (Iterator<? extends SSAInstruction> phis = sb.iteratePhis(); phis.hasNext();) {
|
||||
SSAPhiInstruction phi = (SSAPhiInstruction) phis.next();
|
||||
if (phi == null) {
|
||||
|
@ -348,7 +348,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
* @param node
|
||||
* @param ir
|
||||
*/
|
||||
protected void addNodePassthruExceptionConstraints(CGNode node, IR ir, DefUse du) {
|
||||
protected void addNodePassthruExceptionConstraints(CGNode node, IRView ir, DefUse du) {
|
||||
// add constraints relating to thrown exceptions that reach the exit block.
|
||||
List<ProgramCounter> peis = getIncomingPEIs(ir, ir.getExitBlock());
|
||||
PointerKey exception = getPointerKeyForExceptionalReturnValue(node);
|
||||
|
@ -366,7 +366,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
* @param exceptionVar PointerKey representing a pointer to an exception value
|
||||
* @param catchClasses the types "caught" by the exceptionVar
|
||||
*/
|
||||
private void addExceptionDefConstraints(IR ir, DefUse du, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar,
|
||||
private void addExceptionDefConstraints(IRView ir, DefUse du, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar,
|
||||
Set<IClass> catchClasses) {
|
||||
if (DEBUG) {
|
||||
System.err.println("Add exception def constraints for node " + node);
|
||||
|
@ -434,7 +434,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
/**
|
||||
* @return true iff there's a unique catch block which catches all exceptions thrown by a certain call site.
|
||||
*/
|
||||
protected static boolean hasUniqueCatchBlock(SSAAbstractInvokeInstruction call, IR ir) {
|
||||
protected static boolean hasUniqueCatchBlock(SSAAbstractInvokeInstruction call, IRView ir) {
|
||||
ISSABasicBlock[] bb = ir.getBasicBlocksForCall(call.getCallSite());
|
||||
if (bb.length == 1) {
|
||||
Iterator<ISSABasicBlock> it = ir.getControlFlowGraph().getExceptionalSuccessors(bb[0]).iterator();
|
||||
|
@ -454,7 +454,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
* @throws IllegalArgumentException if ir == null
|
||||
* @throws IllegalArgumentException if call == null
|
||||
*/
|
||||
public PointerKey getUniqueCatchKey(SSAAbstractInvokeInstruction call, IR ir, CGNode node) throws IllegalArgumentException,
|
||||
public PointerKey getUniqueCatchKey(SSAAbstractInvokeInstruction call, IRView ir, CGNode node) throws IllegalArgumentException,
|
||||
IllegalArgumentException {
|
||||
if (call == null) {
|
||||
throw new IllegalArgumentException("call == null");
|
||||
|
@ -478,7 +478,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
* @return a List of Instructions that may transfer control to bb via an exceptional edge
|
||||
* @throws IllegalArgumentException if ir is null
|
||||
*/
|
||||
public static List<ProgramCounter> getIncomingPEIs(IR ir, ISSABasicBlock bb) {
|
||||
public static List<ProgramCounter> getIncomingPEIs(IRView ir, ISSABasicBlock bb) {
|
||||
if (ir == null) {
|
||||
throw new IllegalArgumentException("ir is null");
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A visitor that generates constraints based on statements in SSA form.
|
||||
*/
|
||||
|
@ -599,7 +599,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
/**
|
||||
* The governing IR
|
||||
*/
|
||||
protected final IR ir;
|
||||
protected final IRView ir;
|
||||
|
||||
/**
|
||||
* The governing propagation system, into which constraints are added
|
||||
|
@ -629,10 +629,11 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
|
||||
this.system = builder.getPropagationSystem();
|
||||
|
||||
this.ir = builder.getCFAContextInterpreter().getIR(node);
|
||||
SSAContextInterpreter interp = builder.getCFAContextInterpreter();
|
||||
this.ir = interp.getIRView(node);
|
||||
this.symbolTable = this.ir.getSymbolTable();
|
||||
|
||||
this.du = builder.getCFAContextInterpreter().getDU(node);
|
||||
this.du = interp.getDU(node);
|
||||
|
||||
assert symbolTable != null;
|
||||
}
|
||||
|
@ -2405,7 +2406,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
return system.iteratePointerKeys();
|
||||
}
|
||||
|
||||
public static Set<IClass> getCaughtExceptionTypes(SSAGetCaughtExceptionInstruction instruction, IR ir) {
|
||||
public static Set<IClass> getCaughtExceptionTypes(SSAGetCaughtExceptionInstruction instruction, IRView ir) {
|
||||
if (ir == null) {
|
||||
throw new IllegalArgumentException("ir is null");
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.rta.ContextInsensitiveRTAInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
||||
|
@ -45,6 +46,12 @@ public class ContextInsensitiveSSAInterpreter extends ContextInsensitiveRTAInter
|
|||
// EVERYWHERE context
|
||||
return getAnalysisCache().getIR(node.getMethod(), Everywhere.EVERYWHERE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.rta.DefaultRTAInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
||||
|
@ -57,6 +58,12 @@ public class DefaultSSAInterpreter extends DefaultRTAInterpreter implements SSAC
|
|||
return getCFAInterpreter(node).getIR(node);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
return getCFAInterpreter(node).getNumberOfStatements(node);
|
||||
|
|
|
@ -17,6 +17,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.rta.DelegatingRTAContextInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
|
||||
|
@ -55,6 +56,17 @@ public class DelegatingSSAContextInterpreter extends DelegatingRTAContextInterpr
|
|||
return B.getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
if (A != null) {
|
||||
if (A.understands(node)) {
|
||||
return A.getIRView(node);
|
||||
}
|
||||
}
|
||||
assert B.understands(node);
|
||||
return B.getIRView(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfStatements(CGNode node) {
|
||||
if (A != null) {
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
|
@ -63,7 +64,7 @@ public class FallbackContextInterpreter implements SSAContextInterpreter {
|
|||
if (node.getMethod() instanceof SyntheticMethod || node.getMethod() instanceof ShrikeCTMethod) {
|
||||
return shrikeCI.iterateNewSites(node);
|
||||
} else {
|
||||
IR ir = getIR(node);
|
||||
IRView ir = getIR(node);
|
||||
if (ir == null) {
|
||||
return EmptyIterator.instance();
|
||||
} else {
|
||||
|
@ -96,7 +97,7 @@ public class FallbackContextInterpreter implements SSAContextInterpreter {
|
|||
if (node.getMethod() instanceof SyntheticMethod || node.getMethod() instanceof ShrikeCTMethod) {
|
||||
return shrikeCI.iterateCallSites(node);
|
||||
} else {
|
||||
IR ir = getIR(node);
|
||||
IRView ir = getIR(node);
|
||||
if (ir == null) {
|
||||
return EmptyIterator.instance();
|
||||
} else {
|
||||
|
@ -129,6 +130,11 @@ public class FallbackContextInterpreter implements SSAContextInterpreter {
|
|||
return shrikeCI.getIR(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter#getDU(com.ibm.wala.ipa.callgraph.CGNode)
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.ssa;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.classLoader.ProgramCounter;
|
||||
|
||||
public interface IRView {
|
||||
|
||||
SymbolTable getSymbolTable();
|
||||
|
||||
ControlFlowGraph<SSAInstruction, ISSABasicBlock> getControlFlowGraph();
|
||||
|
||||
ISSABasicBlock[] getBasicBlocksForCall(CallSiteReference callSite);
|
||||
|
||||
SSAInstruction[] getInstructions();
|
||||
|
||||
SSAInstruction getPEI(ProgramCounter peiLoc);
|
||||
|
||||
IMethod getMethod();
|
||||
|
||||
ISSABasicBlock getExitBlock();
|
||||
|
||||
Iterator<NewSiteReference> iterateNewSites();
|
||||
|
||||
Iterator<CallSiteReference> iterateCallSites();
|
||||
|
||||
Iterator<ISSABasicBlock> getBlocks();
|
||||
|
||||
String[] getLocalNames(int i, int v);
|
||||
|
||||
}
|
|
@ -59,6 +59,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
|
@ -118,6 +119,11 @@ public class DexIContextInterpreter implements SSAContextInterpreter {
|
|||
return cache.getSSACache().findOrCreateIR(node.getMethod(), node.getContext(), options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
public DefUse getDU(CGNode node) {
|
||||
return cache.getSSACache().findOrCreateDU(getIR(node), node.getContext());
|
||||
// return new DefUse(getIR(node));
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
import com.ibm.wala.ipa.summaries.SummarizedMethod;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRView;
|
||||
import com.ibm.wala.ssa.ISSABasicBlock;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
|
@ -245,6 +246,11 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRView getIRView(CGNode node) {
|
||||
return getIR(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the function associated with the node is handled by this class.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue