From c8cdaf86163b9b0d3f717ac8f5376f293900a548 Mon Sep 17 00:00:00 2001 From: Julian Dolby Date: Mon, 5 Feb 2018 15:18:37 -0800 Subject: [PATCH] further refactoring to enable more reuse eliminate all non-jva 8 compilation --- .travis.yml | 4 + .../java/ipa/callgraph/AstJavaCFABuilder.java | 3 +- ...AstJavaSSAPropagationCallGraphBuilder.java | 6 +- .../translator/JavaCAst2IRTranslator.java | 4 +- .../wala/cast/js/examples/hybrid/Driver.java | 5 +- .../JavaJavaScriptHybridCallGraphBuilder.java | 14 +- .../js/translator/RhinoToAstTranslator.java | 10 +- .../FieldBasedCallGraphBuilder.java | 3 +- .../cast/js/ipa/callgraph/JSCFABuilder.java | 3 +- .../cast/js/ipa/callgraph/JSCallGraph.java | 24 +- .../JSSSAPropagationCallGraphBuilder.java | 9 +- .../ipa/callgraph/JavaScriptEntryPoints.java | 4 +- ...ScriptFunctionApplyContextInterpreter.java | 7 +- ...vaScriptFunctionDotCallTargetSelector.java | 5 +- .../JavaScriptConstructorFunctions.java | 8 +- .../wala/cast/js/loader/JavaScriptLoader.java | 9 + .../cast/js/translator/JSAstTranslator.java | 6 +- .../wala/cast/ipa/callgraph/AstCallGraph.java | 26 +- .../AstSSAPropagationCallGraphBuilder.java | 9 +- .../ipa/callgraph/CrossLanguageCallGraph.java | 17 +- ...anguageSSAPropagationCallGraphBuilder.java | 10 +- .../ir/translator/AbstractCodeEntity.java | 3 +- .../cast/ir/translator/AstTranslator.java | 4 +- .../ir/translator/ExposedNamesCollector.java | 2 +- .../cast/ir/translator/TranslatorToCAst.java | 10 + .../cast/loader/CAstAbstractModuleLoader.java | 1 + .../cast/loader/DynamicCallSiteReference.java | 19 +- .../ibm/wala/cast/tree/visit/CAstVisitor.java | 30 +- com.ibm.wala.core.testdata/build.xml | 15 +- .../wala/core/tests/callGraph/CPATest.java | 3 +- .../core/tests/callGraph/CallGraphTest.java | 3 +- .../tests/callGraph/CallGraphTestUtil.java | 7 +- .../core/tests/demandpa/AbstractPtrTest.java | 5 +- .../ExceptionAnalysis2EdgeFilterTest.java | 3 +- .../ExceptionAnalysisTest.java | 3 +- .../core/tests/ptrs/MultiDimArrayTest.java | 3 +- .../core/tests/ptrs/ZeroLengthArrayTest.java | 3 +- .../wala/core/tests/slicer/SlicerTest.java | 58 ++-- .../driver/CompareToZeroOneCFADriver.java | 5 +- .../driver/TestAgainstSimpleDriver.java | 3 +- .../analysis/SimpleThreadEscapeAnalysis.java | 3 +- .../analysis/dataflow/DataflowTest.java | 5 +- .../analysis/dataflow/InitializerTest.java | 3 +- .../examples/drivers/JavaViewerDriver.java | 3 +- .../wala/examples/drivers/PDFCallGraph.java | 3 +- .../com/ibm/wala/examples/drivers/PDFSDG.java | 3 +- .../ibm/wala/examples/drivers/PDFSlice.java | 3 +- .../ibm/wala/cfg/exc/inter/AnalysisUtil.java | 6 +- .../inter/InterprocNullPointerAnalysis.java | 6 +- .../ibm/wala/classLoader/JavaLanguage.java | 11 + .../com/ibm/wala/classLoader/Language.java | 5 + .../ibm/wala/classLoader/SyntheticMethod.java | 2 +- .../wala/ipa/callgraph/cha/CHACallGraph.java | 6 +- .../callgraph/impl/AbstractRootMethod.java | 10 +- .../ipa/callgraph/impl/ExplicitCallGraph.java | 11 +- .../ipa/callgraph/impl/FakeRootClass.java | 19 +- .../ipa/callgraph/impl/FakeRootMethod.java | 19 +- .../callgraph/impl/FakeWorldClinitMethod.java | 9 +- .../com/ibm/wala/ipa/callgraph/impl/Util.java | 29 +- .../PropagationCallGraphBuilder.java | 12 +- .../SSAPropagationCallGraphBuilder.java | 7 +- .../propagation/cfa/ZeroXCFABuilder.java | 11 +- .../cfa/ZeroXContainerCFABuilder.java | 3 +- .../propagation/cfa/nCFABuilder.java | 6 +- .../propagation/rta/AbstractRTABuilder.java | 9 +- .../rta/DelegatingExplicitCallGraph.java | 5 +- com.ibm.wala.dalvik.test/build.xml | 10 +- .../callGraph/DalvikCallGraphTestBase.java | 5 +- .../callGraph/JVMLDalvikComparisonTest.java | 3 +- com.ibm.wala.dalvik/pom.xml | 4 +- .../callgraph/impl/DexExplicitCallGraph.java | 73 ----- .../ipa/callgraph/impl/DexFakeRootMethod.java | 280 ------------------ .../DexSSAPropagationCallGraphBuilder.java | 84 ------ .../launchers/JDTJavaIRTests.launch | 87 +++--- .../demandpa/driver/DemandCastChecker.java | 5 +- .../examples/drivers/IFDSExplorerExample.java | 3 +- .../wala/examples/drivers/SWTCallGraph.java | 3 +- .../wala/examples/drivers/SWTPointsTo.java | 3 +- .../util/AndroidAnalysisContext.java | 5 +- pom.xml | 170 ++++++----- 80 files changed, 495 insertions(+), 815 deletions(-) rename com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JSCallSiteReference.java => com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/DynamicCallSiteReference.java (74%) delete mode 100644 com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexExplicitCallGraph.java delete mode 100644 com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexFakeRootMethod.java delete mode 100644 com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/propagation/cfa/DexSSAPropagationCallGraphBuilder.java diff --git a/.travis.yml b/.travis.yml index 8ac2ab5a2..bb2df4e32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ language: android +android: + components: + - build-tools-26.0.2 jdk: oraclejdk8 addons: apt: @@ -6,6 +9,7 @@ addons: - realpath - xvfb before_install: +- echo $ANDROID_HOME - git clone --depth=1 https://github.com/secure-software-engineering/DroidBench.git /tmp/DroidBench - export M2_HOME=$HOME/apache-maven-3.5.0 - if [ ! -d $M2_HOME/bin ]; then curl https://archive.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz | tar zxf - -C $HOME; fi diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaCFABuilder.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaCFABuilder.java index 09019546c..342e1cc2e 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaCFABuilder.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaCFABuilder.java @@ -10,6 +10,7 @@ *****************************************************************************/ package com.ibm.wala.cast.java.ipa.callgraph; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.propagation.cfa.DefaultPointerKeyFactory; @@ -21,7 +22,7 @@ import com.ibm.wala.ipa.cha.IClassHierarchy; public class AstJavaCFABuilder extends AstJavaSSAPropagationCallGraphBuilder { public AstJavaCFABuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache, new DefaultPointerKeyFactory()); + super(Language.JAVA.getFakeRootMethod(cha, options, cache), options, cache, new DefaultPointerKeyFactory()); } } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java index 221f1e257..f868e3a12 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ipa/callgraph/AstJavaSSAPropagationCallGraphBuilder.java @@ -20,6 +20,7 @@ import com.ibm.wala.cast.java.ssa.AstJavaInvokeInstruction; import com.ibm.wala.cast.java.ssa.AstJavaNewEnclosingInstruction; import com.ibm.wala.cast.java.ssa.EnclosingObjectReference; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.fixpoint.IntSetVariable; import com.ibm.wala.fixpoint.UnaryOperator; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -31,7 +32,6 @@ import com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey; import com.ibm.wala.ipa.callgraph.propagation.PointerKey; import com.ibm.wala.ipa.callgraph.propagation.PointerKeyFactory; import com.ibm.wala.ipa.callgraph.propagation.PointsToSetVariable; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.IR; import com.ibm.wala.ssa.SSANewInstruction; import com.ibm.wala.ssa.SymbolTable; @@ -41,9 +41,9 @@ import com.ibm.wala.util.strings.Atom; public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraphBuilder { - protected AstJavaSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, + protected AstJavaSSAPropagationCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(fakeRootClass, options, cache, pointerKeyFactory); } // /////////////////////////////////////////////////////////////////////////// diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java index e114e3080..1ab4c33ab 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java @@ -231,7 +231,9 @@ public class JavaCAst2IRTranslator extends AstTranslator { assert owner != null : makeType(owningType).getName().toString() + " not found in " + loader; - ((JavaSourceLoaderImpl) loader).defineAbstractFunction(N, owner); + if (N.getQualifiers().contains(CAstQualifier.ABSTRACT)) { + ((JavaSourceLoaderImpl) loader).defineAbstractFunction(N, owner); + } } @Override diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/Driver.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/Driver.java index ea9865c47..30f3ce3db 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/Driver.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/Driver.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.net.URL; import java.util.Map; +import com.ibm.wala.cast.ipa.callgraph.CrossLanguageCallGraph; import com.ibm.wala.cast.ipa.callgraph.CrossLanguageMethodTargetSelector; import com.ibm.wala.cast.ipa.callgraph.StandardFunctionTargetSelector; import com.ibm.wala.cast.ipa.cha.CrossLanguageClassHierarchy; @@ -22,6 +23,8 @@ import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.MethodTargetSelector; import com.ibm.wala.ipa.callgraph.impl.ComposedEntrypoints; +import com.ibm.wala.ipa.callgraph.impl.FakeRootClass; +import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.ClassHierarchyException; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.IRFactory; @@ -82,7 +85,7 @@ public class Driver { addDefaultDispatchLogic(options, cha); - JavaJavaScriptHybridCallGraphBuilder b = new JavaJavaScriptHybridCallGraphBuilder(cha, options, cache); + JavaJavaScriptHybridCallGraphBuilder b = new JavaJavaScriptHybridCallGraphBuilder(new FakeRootMethod(new FakeRootClass(CrossLanguageCallGraph.crossCoreLoader, cha), options, cache), options, cache); System.err.println(b.makeCallGraph(options)); } diff --git a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/JavaJavaScriptHybridCallGraphBuilder.java b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/JavaJavaScriptHybridCallGraphBuilder.java index 300270a40..e1bd3f012 100644 --- a/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/JavaJavaScriptHybridCallGraphBuilder.java +++ b/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/examples/hybrid/JavaJavaScriptHybridCallGraphBuilder.java @@ -9,7 +9,6 @@ import com.ibm.wala.cast.ipa.callgraph.CrossLanguageContextSelector; import com.ibm.wala.cast.ipa.callgraph.CrossLanguageInstanceKeys; import com.ibm.wala.cast.ipa.callgraph.CrossLanguageSSAPropagationCallGraphBuilder; import com.ibm.wala.cast.ipa.callgraph.GlobalObjectKey; -import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraph.JSFakeRoot; import com.ibm.wala.cast.js.ipa.callgraph.JSSSAPropagationCallGraphBuilder; import com.ibm.wala.cast.js.ipa.callgraph.JSSSAPropagationCallGraphBuilder.JSConstraintVisitor; import com.ibm.wala.cast.js.ipa.callgraph.JSSSAPropagationCallGraphBuilder.JSInterestingVisitor; @@ -21,6 +20,7 @@ import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptScopeMappingInstanceKeys; import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.types.JavaScriptTypes; import com.ibm.wala.cast.util.TargetLanguageSelector; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; @@ -28,7 +28,6 @@ import com.ibm.wala.ipa.callgraph.ContextSelector; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.DefaultContextSelector; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.callgraph.propagation.AbstractFieldPointerKey; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory; @@ -36,15 +35,14 @@ import com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey; import com.ibm.wala.ipa.callgraph.propagation.PointerKey; import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.util.collections.HashMapFactory; import com.ibm.wala.util.strings.Atom; public class JavaJavaScriptHybridCallGraphBuilder extends CrossLanguageSSAPropagationCallGraphBuilder { - public JavaJavaScriptHybridCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache, new AstCFAPointerKeys()); + public JavaJavaScriptHybridCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache) { + super(fakeRootClass, options, cache, new AstCFAPointerKeys()); globalObject = new GlobalObjectKey(cha.lookupClass(JavaScriptTypes.Root)); SSAContextInterpreter contextInterpreter = makeDefaultContextInterpreters(null, options, cha); @@ -113,11 +111,7 @@ public class JavaJavaScriptHybridCallGraphBuilder extends CrossLanguageSSAPropag @Override protected TargetLanguageSelector makeRootNodeSelector() { return (language, construct) -> { - if (JavaScriptTypes.jsName.equals(language)) { - return new JSFakeRoot(getClassHierarchy(), getOptions(), getAnalysisCache()); - } else { - return new FakeRootMethod(getClassHierarchy(), getOptions(), getAnalysisCache()); - } + return getOptions().getAnalysisScope().getLanguage(language).getFakeRootMethod(getClassHierarchy(), getOptions(), getAnalysisCache()); }; } diff --git a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java index 638788619..2e2451377 100644 --- a/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java +++ b/com.ibm.wala.cast.js.rhino/source/com/ibm/wala/cast/js/translator/RhinoToAstTranslator.java @@ -568,15 +568,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst { return pos; } - private void pushSourcePosition(WalkContext context, CAstNode n, Position p) { - if (context.pos().getPosition(n) == null && !(n.getKind()==CAstNode.FUNCTION_EXPR || n.getKind()==CAstNode.FUNCTION_STMT)) { - context.pos().setPosition(n, p); - for(int i = 0; i < n.getChildCount(); i++) { - pushSourcePosition(context, n.getChild(i), p); - } - } - } - private CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) { + protected CAstNode noteSourcePosition(WalkContext context, CAstNode n, AstNode p) { if (p.getLineno() != -1 && context.pos().getPosition(n) == null) { pushSourcePosition(context, n, makePosition(p)); } diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/callgraph/fieldbased/FieldBasedCallGraphBuilder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/callgraph/fieldbased/FieldBasedCallGraphBuilder.java index 330e179ab..7ffb12a73 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/callgraph/fieldbased/FieldBasedCallGraphBuilder.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/callgraph/fieldbased/FieldBasedCallGraphBuilder.java @@ -29,6 +29,7 @@ import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptFunctionApplyTargetSelector; import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptFunctionDotCallTargetSelector; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptConstructorFunctions; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptConstructorFunctions.JavaScriptConstructor; +import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.types.JavaScriptMethods; import com.ibm.wala.cast.types.AstMethodReference; import com.ibm.wala.classLoader.CallSiteReference; @@ -146,7 +147,7 @@ public abstract class FieldBasedCallGraphBuilder { @SuppressWarnings("deprecation") public JSCallGraph extract(SSAContextInterpreter interpreter, FlowGraph flowgraph, Iterable eps, IProgressMonitor monitor) throws CancelException { // set up call graph - final JSCallGraph cg = new JSCallGraph(cha, options, cache); + final JSCallGraph cg = new JSCallGraph(JavaScriptLoader.JS.getFakeRootMethod(cha, options, cache), options, cache); cg.init(); // setup context interpreters diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCFABuilder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCFABuilder.java index 705b586ed..8203c2e82 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCFABuilder.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCFABuilder.java @@ -14,6 +14,7 @@ import java.util.Iterator; import com.ibm.wala.cast.ipa.callgraph.AstCFAPointerKeys; import com.ibm.wala.cast.ipa.callgraph.ReflectedFieldPointerKey; +import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.types.JavaScriptTypes; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IField; @@ -34,7 +35,7 @@ import com.ibm.wala.util.strings.Atom; public abstract class JSCFABuilder extends JSSSAPropagationCallGraphBuilder { public JSCFABuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache, new AstCFAPointerKeys() { + super(JavaScriptLoader.JS.getFakeRootMethod(cha, options, cache), options, cache, new AstCFAPointerKeys() { private boolean isBogusKey(InstanceKey K) { TypeReference t = K.getConcreteType().getReference(); diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCallGraph.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCallGraph.java index 10b88502f..4eff69052 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCallGraph.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSCallGraph.java @@ -14,14 +14,13 @@ import java.util.Set; import com.ibm.wala.cast.ipa.callgraph.AstCallGraph; import com.ibm.wala.cast.js.cfg.JSInducedCFG; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.ssa.JavaScriptInvoke; import com.ibm.wala.cast.js.types.JavaScriptMethods; import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IMethod; -import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; @@ -30,15 +29,13 @@ import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAInstruction; -import com.ibm.wala.ssa.SSANewInstruction; import com.ibm.wala.types.MethodReference; -import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.collections.HashSetFactory; public class JSCallGraph extends AstCallGraph { - public JSCallGraph(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache); + public JSCallGraph(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache) { + super(fakeRootClass, options, cache); } public final static MethodReference fakeRoot = MethodReference.findOrCreate(JavaScriptTypes.FakeRoot, FakeRootMethod.name, @@ -55,22 +52,9 @@ public class JSCallGraph extends AstCallGraph { return new JSInducedCFG(instructions, this, Everywhere.EVERYWHERE); } - @Override - public SSANewInstruction addAllocation(TypeReference T) { - if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(JavaScriptTypes.Root))) { - int instance = nextLocal++; - NewSiteReference ref = NewSiteReference.make(statements.size(), T); - SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref); - statements.add(result); - return result; - } else { - return super.addAllocation(T); - } - } - @Override public SSAAbstractInvokeInstruction addDirectCall(int function, int[] params, CallSiteReference site) { - CallSiteReference newSite = new JSCallSiteReference(statements.size()); + CallSiteReference newSite = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, statements.size()); JavaScriptInvoke s = new JavaScriptInvoke(statements.size(), function, nextLocal++, params, nextLocal++, newSite); statements.add(s); diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java index bb3c3894e..365cf5e3b 100755 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JSSSAPropagationCallGraphBuilder.java @@ -48,6 +48,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; +import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; import com.ibm.wala.ipa.callgraph.propagation.AbstractFieldPointerKey; import com.ibm.wala.ipa.callgraph.propagation.ConcreteTypeKey; @@ -151,9 +152,9 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph this.scriptBaseURL = url; } - protected JSSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, + protected JSSSAPropagationCallGraphBuilder(AbstractRootMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(abstractRootMethod, options, cache, pointerKeyFactory); globalObject = new GlobalObjectKey(cha.lookupClass(JavaScriptTypes.Root)); } @@ -218,8 +219,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph return getPointerKeyForInstanceField(getGlobalObject(JavaScriptTypes.jsName), f); } @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new JSCallGraph(cha, options, getAnalysisCache()); + protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) { + return new JSCallGraph(fakeRootClass, options, getAnalysisCache()); } protected TypeInference makeTypeInference(IR ir, IClassHierarchy cha) { diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptEntryPoints.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptEntryPoints.java index 5dc7d697c..764bef6cb 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptEntryPoints.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptEntryPoints.java @@ -11,8 +11,8 @@ package com.ibm.wala.cast.js.ipa.callgraph; import com.ibm.wala.cast.ipa.callgraph.ScriptEntryPoints; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClassLoader; import com.ibm.wala.classLoader.IMethod; @@ -22,7 +22,7 @@ public class JavaScriptEntryPoints extends ScriptEntryPoints { @Override protected CallSiteReference makeScriptSite(IMethod m, int pc) { - return new JSCallSiteReference(pc); + return new DynamicCallSiteReference(JavaScriptTypes.CodeBody, pc); } public JavaScriptEntryPoints(IClassHierarchy cha, IClassLoader loader) { diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionApplyContextInterpreter.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionApplyContextInterpreter.java index 09bc3ca50..35525b1f6 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionApplyContextInterpreter.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionApplyContextInterpreter.java @@ -13,8 +13,9 @@ package com.ibm.wala.cast.js.ipa.callgraph; import com.ibm.wala.cast.ipa.callgraph.AstContextInsensitiveSSAContextInterpreter; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummarizedFunction; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummary; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.ssa.JSInstructionFactory; +import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -103,7 +104,7 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi // int curValNum = passArbitraryPropertyValAsParams(insts, nargs, S, paramsToPassToInvoked); int curValNum = passActualPropertyValsAsParams(insts, nargs, S, paramsToPassToInvoked); - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); // function being invoked is in v2 int resultVal = curValNum++; @@ -175,7 +176,7 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi // generate invocation instruction for the real method being invoked int resultVal = nargs + 2; - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); int[] params = new int[1]; params[0] = 3; // function being invoked is in v2 diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionDotCallTargetSelector.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionDotCallTargetSelector.java index 70ad606ad..c9187f431 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionDotCallTargetSelector.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/callgraph/JavaScriptFunctionDotCallTargetSelector.java @@ -15,11 +15,12 @@ import java.util.Map; import com.ibm.wala.cast.ipa.callgraph.CAstCallGraphUtil; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummarizedFunction; import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummary; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.ssa.JSInstructionFactory; import com.ibm.wala.cast.js.types.JavaScriptMethods; +import com.ibm.wala.cast.js.types.JavaScriptTypes; import com.ibm.wala.cast.loader.AstMethod; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position; import com.ibm.wala.cast.types.AstMethodReference; import com.ibm.wala.classLoader.CallSiteReference; @@ -153,7 +154,7 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele // generate invocation instruction for the real method being invoked int resultVal = nargs + 2; - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); int[] params = new int[nargs - 2]; for (int i = 0; i < params.length; i++) { // add 3 to skip v1 (which points to Function.call() itself) and v2 (the diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/summaries/JavaScriptConstructorFunctions.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/summaries/JavaScriptConstructorFunctions.java index 2acdc29ca..038e45ce4 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/summaries/JavaScriptConstructorFunctions.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/ipa/summaries/JavaScriptConstructorFunctions.java @@ -22,11 +22,11 @@ import java.util.Map; import java.util.Set; import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.ssa.JSInstructionFactory; import com.ibm.wala.cast.js.types.JavaScriptMethods; import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.cast.types.AstMethodReference; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; @@ -316,7 +316,7 @@ public class JavaScriptConstructorFunctions { S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toString")); S.getNextProgramCounter(); - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false)); @@ -356,7 +356,7 @@ public class JavaScriptConstructorFunctions { S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toNumber")); S.getNextProgramCounter(); - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false)); @@ -569,7 +569,7 @@ public class JavaScriptConstructorFunctions { S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), nargs + 5, nargs + 4)); S.getNextProgramCounter(); - CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); + CallSiteReference cs = new DynamicCallSiteReference(JavaScriptTypes.CodeBody, S.getNextProgramCounter()); int[] args = new int[nargs + 1]; args[0] = nargs + 5; for (int i = 0; i < nargs; i++) diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoader.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoader.java index cb83dc6f6..8d267cbc1 100755 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoader.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JavaScriptLoader.java @@ -33,6 +33,7 @@ import com.ibm.wala.cast.ir.translator.AstTranslator.WalkContext; import com.ibm.wala.cast.ir.translator.TranslatorToCAst; import com.ibm.wala.cast.ir.translator.TranslatorToIR; import com.ibm.wala.cast.js.analysis.typeInference.JSPrimitiveType; +import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraph.JSFakeRoot; import com.ibm.wala.cast.js.ssa.JSInstructionFactory; import com.ibm.wala.cast.js.ssa.JavaScriptCheckReference; import com.ibm.wala.cast.js.ssa.JavaScriptInstanceOf; @@ -63,6 +64,9 @@ import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.LanguageImpl; import com.ibm.wala.classLoader.ModuleEntry; import com.ibm.wala.classLoader.NewSiteReference; +import com.ibm.wala.ipa.callgraph.AnalysisOptions; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; +import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.IBinaryOpInstruction.IOperator; import com.ibm.wala.shrikeBT.IComparisonInstruction.Operator; @@ -658,6 +662,11 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader { return false; } + @Override + public AbstractRootMethod getFakeRootMethod(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { + return new JSFakeRoot(cha, options, cache); + } + }; private final JavaScriptTranslatorFactory translatorFactory; diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java index 1cb01c51b..76a8fdb04 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java +++ b/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/translator/JSAstTranslator.java @@ -16,13 +16,13 @@ import java.util.Map; import java.util.Set; import com.ibm.wala.cast.ir.translator.AstTranslator; -import com.ibm.wala.cast.js.loader.JSCallSiteReference; import com.ibm.wala.cast.js.loader.JavaScriptLoader; import com.ibm.wala.cast.js.ssa.JSInstructionFactory; import com.ibm.wala.cast.js.ssa.JavaScriptInstanceOf; import com.ibm.wala.cast.js.ssa.PrototypeLookup; import com.ibm.wala.cast.js.types.JavaScriptMethods; import com.ibm.wala.cast.js.types.JavaScriptTypes; +import com.ibm.wala.cast.loader.DynamicCallSiteReference; import com.ibm.wala.cast.loader.AstMethod.DebuggingInformation; import com.ibm.wala.cast.tree.CAstEntity; import com.ibm.wala.cast.tree.CAstNode; @@ -196,7 +196,7 @@ public class JSAstTranslator extends AstTranslator { context.cfg().addInstruction( ((JSInstructionFactory) insts).Invoke(context.cfg().getCurrentInstruction(), receiver, result, arguments, exception, - new JSCallSiteReference(ref, context.cfg().getCurrentInstruction()))); + new DynamicCallSiteReference(ref, context.cfg().getCurrentInstruction()))); context.cfg().addPreNode(call, context.getUnwindState()); @@ -226,7 +226,7 @@ public class JSAstTranslator extends AstTranslator { int tmp = super.doGlobalRead(n, context, "Function", JavaScriptTypes.Function); context.cfg().addInstruction( ((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), tmp, result, new int[]{ nm }, exception, - new JSCallSiteReference(JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction()))); + new DynamicCallSiteReference(JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction()))); } @Override diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java index ed71fd04b..6e5b74ad9 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java @@ -20,6 +20,7 @@ import com.ibm.wala.cfg.InducedCFG; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.Context; @@ -27,19 +28,18 @@ import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.callgraph.impl.Everywhere; import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAInstruction; +import com.ibm.wala.ssa.SSANewInstruction; import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.TypeReference; -import com.ibm.wala.util.CancelException; import com.ibm.wala.util.collections.HashSetFactory; import com.ibm.wala.util.collections.Iterator2Iterable; public class AstCallGraph extends ExplicitCallGraph { - public AstCallGraph(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache); + public AstCallGraph(IMethod fakeRootClass2, AnalysisOptions options, IAnalysisCacheView cache) { + super(fakeRootClass2, options, cache); } public static class AstFakeRoot extends AbstractRootMethod { @@ -76,6 +76,19 @@ public class AstCallGraph extends ExplicitCallGraph { public abstract SSAAbstractInvokeInstruction addDirectCall(int functionVn, int[] argVns, CallSiteReference callSite); + @Override + public SSANewInstruction addAllocation(TypeReference T) { + if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(declaringClass.getClassLoader().getLanguage().getRootType()))) { + int instance = nextLocal++; + NewSiteReference ref = NewSiteReference.make(statements.size(), T); + SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref); + statements.add(result); + return result; + } else { + return super.addAllocation(T); + } + } + } public class AstCGNode extends ExplicitNode { @@ -161,9 +174,4 @@ public class AstCallGraph extends ExplicitCallGraph { return new AstCGNode(method, context); } - @Override - protected CGNode makeFakeRootNode() throws CancelException { - return findOrCreateNode(new AstFakeRoot(FakeRootMethod.rootMethod, cha, options, getAnalysisCache()), Everywhere.EVERYWHERE); - } - } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java index 00b716beb..8436cd297 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstSSAPropagationCallGraphBuilder.java @@ -34,6 +34,7 @@ import com.ibm.wala.cast.ir.translator.AstTranslator; import com.ibm.wala.cast.loader.AstMethod; import com.ibm.wala.cast.loader.AstMethod.LexicalInformation; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.fixpoint.AbstractOperator; import com.ibm.wala.fixpoint.IntSetVariable; import com.ibm.wala.fixpoint.UnaryOperator; @@ -115,9 +116,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa public abstract GlobalObjectKey getGlobalObject(Atom language); - protected AstSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, + protected AstSSAPropagationCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(fakeRootClass, options, cache, pointerKeyFactory); } public SSAContextInterpreter makeDefaultContextInterpreters(SSAContextInterpreter appContextInterpreter, AnalysisOptions options, @@ -249,8 +250,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa // ///////////////////////////////////////////////////////////////////////// @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new AstCallGraph(cha, options, getAnalysisCache()); + protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) { + return new AstCallGraph(fakeRootClass, options, getAnalysisCache()); } public static class AstInterestingVisitor extends InterestingVisitor implements AstInstructionVisitor { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java index 6316d9fab..baa23bb17 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageCallGraph.java @@ -30,7 +30,10 @@ import com.ibm.wala.shrikeBT.IInvokeInstruction; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAInvokeInstruction; import com.ibm.wala.ssa.SSANewInstruction; +import com.ibm.wala.types.ClassLoaderReference; import com.ibm.wala.types.FieldReference; +import com.ibm.wala.types.MethodReference; +import com.ibm.wala.types.TypeName; import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.CancelException; import com.ibm.wala.util.collections.HashMapFactory; @@ -49,9 +52,9 @@ import com.ibm.wala.util.strings.Atom; */ public class CrossLanguageCallGraph extends AstCallGraph { - public CrossLanguageCallGraph(TargetLanguageSelector roots, IClassHierarchy cha, + public CrossLanguageCallGraph(TargetLanguageSelector roots, IMethod fakeRootClass2, AnalysisOptions options, IAnalysisCacheView cache) { - super(cha, options, cache); + super(fakeRootClass2, options, cache); this.roots = roots; } @@ -91,14 +94,20 @@ public class CrossLanguageCallGraph extends AstCallGraph { return (AbstractRootMethod) languageRoots.get(language); } + public static ClassLoaderReference crossCoreLoader = ClassLoaderReference.Primordial; + + public static TypeReference fakeRootClass = TypeReference.findOrCreate(crossCoreLoader, TypeName.findOrCreate("CrossFakeRoot")); + + public static MethodReference rootMethod = MethodReference.findOrCreate(fakeRootClass, FakeRootMethod.name, FakeRootMethod.descr); + public class CrossLanguageFakeRoot extends ScriptFakeRoot { public CrossLanguageFakeRoot(IClass declaringClass, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(FakeRootMethod.rootMethod, declaringClass, cha, options, cache); + super(rootMethod, declaringClass, cha, options, cache); } public CrossLanguageFakeRoot(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(FakeRootMethod.rootMethod, cha, options, cache); + super(rootMethod, cha, options, cache); } public int addPhi(TypeReference type, int[] values) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java index 6ed1fb800..bb96a3214 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/CrossLanguageSSAPropagationCallGraphBuilder.java @@ -12,6 +12,7 @@ package com.ibm.wala.cast.ipa.callgraph; import com.ibm.wala.cast.ipa.callgraph.AstSSAPropagationCallGraphBuilder.AstPointerAnalysisImpl.AstImplicitPointsToSetVisitor; import com.ibm.wala.cast.util.TargetLanguageSelector; +import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; import com.ibm.wala.ipa.callgraph.CallGraph; @@ -26,7 +27,6 @@ import com.ibm.wala.ipa.callgraph.propagation.PointerKeyFactory; import com.ibm.wala.ipa.callgraph.propagation.PointsToMap; import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder; import com.ibm.wala.ipa.callgraph.propagation.PropagationSystem; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.util.intset.MutableMapping; import com.ibm.wala.util.strings.Atom; @@ -45,16 +45,16 @@ public abstract class CrossLanguageSSAPropagationCallGraphBuilder extends AstSSA protected abstract TargetLanguageSelector makeRootNodeSelector(); - protected CrossLanguageSSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, + protected CrossLanguageSSAPropagationCallGraphBuilder(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache, PointerKeyFactory pointerKeyFactory) { - super(cha, options, cache, pointerKeyFactory); + super(fakeRootClass, options, cache, pointerKeyFactory); visitors = makeMainVisitorSelector(); interesting = makeInterestingVisitorSelector(); } @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new CrossLanguageCallGraph(makeRootNodeSelector(), cha, options, getAnalysisCache()); + protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) { + return new CrossLanguageCallGraph(makeRootNodeSelector(), fakeRootClass, options, getAnalysisCache()); } protected static Atom getLanguage(CGNode node) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AbstractCodeEntity.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AbstractCodeEntity.java index 1a771e04b..930d82c6b 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AbstractCodeEntity.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AbstractCodeEntity.java @@ -16,7 +16,6 @@ package com.ibm.wala.cast.ir.translator; import com.ibm.wala.cast.tree.CAstControlFlowMap; import com.ibm.wala.cast.tree.CAstNode; -import com.ibm.wala.cast.tree.CAstSourcePositionMap; import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position; import com.ibm.wala.cast.tree.CAstType; import com.ibm.wala.cast.tree.impl.CAstControlFlowRecorder; @@ -54,7 +53,7 @@ public abstract class AbstractCodeEntity extends AbstractEntity { } @Override - public CAstSourcePositionMap getSourceMap() { + public CAstSourcePositionRecorder getSourceMap() { return src; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java index 317089ce1..be5cfe20f 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java @@ -3230,8 +3230,10 @@ public abstract class AstTranslator extends CAstVisitor visitor) { if (n.getAST() == null) // presumably abstract declareFunction(n, context); - else + else { + declareFunction(n, context); initFunctionEntity(codeContext); + } return false; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/ExposedNamesCollector.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/ExposedNamesCollector.java index 3bab3da93..680adea84 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/ExposedNamesCollector.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/ExposedNamesCollector.java @@ -115,7 +115,7 @@ public class ExposedNamesCollector extends CAstVisitor, Y> void pushSourcePosition(WalkContext context, CAstNode n, Position p) { + if (context.pos().getPosition(n) == null && !(n.getKind()==CAstNode.FUNCTION_EXPR || n.getKind()==CAstNode.FUNCTION_STMT)) { + context.pos().setPosition(n, p); + for(int i = 0; i < n.getChildCount(); i++) { + pushSourcePosition(context, n.getChild(i), p); + } + } + } + } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java index 1c81e2275..1c2d2c8f3 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/CAstAbstractModuleLoader.java @@ -368,4 +368,5 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader { } } + } diff --git a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JSCallSiteReference.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/DynamicCallSiteReference.java similarity index 74% rename from com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JSCallSiteReference.java rename to com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/DynamicCallSiteReference.java index ff978cd13..f7e363f09 100644 --- a/com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/loader/JSCallSiteReference.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/loader/DynamicCallSiteReference.java @@ -8,15 +8,15 @@ * Contributors: * IBM Corporation - initial API and implementation *****************************************************************************/ -package com.ibm.wala.cast.js.loader; +package com.ibm.wala.cast.loader; -import com.ibm.wala.cast.js.types.JavaScriptTypes; import com.ibm.wala.cast.types.AstMethodReference; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.shrikeBT.IInvokeInstruction; import com.ibm.wala.types.MethodReference; +import com.ibm.wala.types.TypeReference; -public class JSCallSiteReference extends CallSiteReference { +public class DynamicCallSiteReference extends CallSiteReference { // this must be distinct from java invoke codes. // see com.ibm.shrikeBT.BytecodeConstants @@ -29,12 +29,12 @@ public class JSCallSiteReference extends CallSiteReference { } } - public JSCallSiteReference(MethodReference ref, int pc) { + public DynamicCallSiteReference(MethodReference ref, int pc) { super(pc, ref); } - public JSCallSiteReference(int pc) { - this(AstMethodReference.fnReference(JavaScriptTypes.CodeBody), pc); + public DynamicCallSiteReference(TypeReference ref, int pc) { + this(AstMethodReference.fnReference(ref), pc); } @Override @@ -42,13 +42,18 @@ public class JSCallSiteReference extends CallSiteReference { return Dispatch.JS_CALL; } + @Override + protected String getInvocationString(IInvokeInstruction.IDispatch invocationCode) { + return "Function"; + } + @Override public String toString() { return "JSCall@" + getProgramCounter(); } public CallSiteReference cloneReference(int pc) { - return new JSCallSiteReference(pc); + return new DynamicCallSiteReference(getDeclaredTarget(), pc); } @Override diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/tree/visit/CAstVisitor.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/tree/visit/CAstVisitor.java index 8abeeef8e..db8299797 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/tree/visit/CAstVisitor.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/tree/visit/CAstVisitor.java @@ -386,7 +386,8 @@ public abstract class CAstVisitor { * * @return true if node was handled */ - protected boolean doVisitAssignNodes() { + @SuppressWarnings("unused") + protected boolean doVisitAssignNodes(CAstNode n, C context, CAstNode v, CAstNode a, CAstVisitor visitor) { return false; } @@ -967,8 +968,16 @@ public abstract class CAstVisitor { break; } + case CAstNode.ARRAY_LITERAL: { + assert assign; + if (visitor.visitArrayLiteralAssign(n, v, a, context, visitor)) + return true; + visitor.leaveArrayLiteralAssign(n, v, a, context, visitor); + break; + } + default: { - if (!visitor.doVisitAssignNodes()) { + if (!visitor.doVisitAssignNodes(n, context, a, v, visitor)) { if (DEBUG) { System.err.println(("cannot handle assign to kind " + n.getKind())); } @@ -1559,6 +1568,23 @@ public abstract class CAstVisitor { * @param c a visitor-specific context */ protected void leaveVarAssign(CAstNode n, CAstNode v, CAstNode a, C c, @SuppressWarnings("unused") CAstVisitor visitor) { /* empty */ } + /** + * Visit an array literal Assignment node after visiting the RHS. + * @param n the LHS node to process + * @param v the RHS node to process + * @param a the assignment node to process + * @param c a visitor-specific context + * @return true if no further processing is needed + */ + protected boolean visitArrayLiteralAssign(CAstNode n, CAstNode v, CAstNode a, C c, @SuppressWarnings("unused") CAstVisitor visitor) { /* empty */ return false; } + /** + * Visit an array literal Assignment node after visiting the LHS. + * @param n the LHS node to process + * @param v the RHS node to process + * @param a the assignment node to process + * @param c a visitor-specific context + */ + protected void leaveArrayLiteralAssign(CAstNode n, CAstNode v, CAstNode a, C c, @SuppressWarnings("unused") CAstVisitor visitor) { /* empty */ } /** * Visit a Var Op/Assignment node after visiting the RHS. * @param n the LHS node to process diff --git a/com.ibm.wala.core.testdata/build.xml b/com.ibm.wala.core.testdata/build.xml index a5b67497e..7342fea11 100644 --- a/com.ibm.wala.core.testdata/build.xml +++ b/com.ibm.wala.core.testdata/build.xml @@ -35,7 +35,7 @@ - + @@ -120,12 +120,7 @@ - - - - - - + @@ -163,12 +158,6 @@ - - - - - - diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CPATest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CPATest.java index 8d62f1b78..2a465793b 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CPATest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CPATest.java @@ -16,6 +16,7 @@ import java.util.Set; import org.junit.Assert; import org.junit.Test; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.core.tests.util.WalaTestCase; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -57,7 +58,7 @@ public class CPATest extends WalaTestCase { Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, testClass); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); builder.setContextSelector(new CPAContextSelector(builder.getContextSelector())); CallGraph cg = builder.makeCallGraph(options, null); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java index 7e7208dc5..601a1f8bd 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.demandpa.AbstractPtrTest; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.core.tests.util.WalaTestCase; @@ -183,7 +184,7 @@ public class CallGraphTest extends WalaTestCase { Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "LstaticInit/TestSystemProperties"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options); for (CGNode n : cg) { if (n.toString().equals("Node: < Application, LstaticInit/TestSystemProperties, main([Ljava/lang/String;)V > Context: Everywhere")) { diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java index bb635749a..df188f89f 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTestUtil.java @@ -12,6 +12,7 @@ package com.ibm.wala.core.tests.callGraph; import java.io.IOException; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.CallGraph; @@ -81,7 +82,7 @@ public class CallGraphTestUtil { S.start(); } - SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(options, cache, cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (testPAtoString) { builder.getPointerAnalysis().toString(); @@ -102,7 +103,7 @@ public class CallGraphTestUtil { S.start(); } - CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope); + CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (CHECK_FOOTPRINT) { @@ -120,7 +121,7 @@ public class CallGraphTestUtil { S.start(); } - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cache, cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (testPAtoString) { builder.getPointerAnalysis().toString(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/demandpa/AbstractPtrTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/demandpa/AbstractPtrTest.java index c8df32362..0f72c81ab 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/demandpa/AbstractPtrTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/demandpa/AbstractPtrTest.java @@ -43,6 +43,7 @@ import org.junit.AfterClass; import org.junit.Assert; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo; @@ -230,14 +231,14 @@ public abstract class AbstractPtrTest { AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); final IAnalysisCacheView analysisCache = new AnalysisCacheImpl(); - CallGraphBuilder cgBuilder = Util.makeZeroCFABuilder(options, analysisCache, cha, scope); + CallGraphBuilder cgBuilder = Util.makeZeroCFABuilder(Language.JAVA, options, analysisCache, cha, scope); final CallGraph cg = cgBuilder.makeCallGraph(options, null); // System.err.println(cg.toString()); // MemoryAccessMap mam = new SimpleMemoryAccessMap(cg, // cgBuilder.getPointerAnalysis().getHeapModel(), false); MemoryAccessMap mam = new PABasedMemoryAccessMap(cg, cgBuilder.getPointerAnalysis()); - SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, analysisCache, cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, analysisCache, cha, scope); DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, mam, cha, options, getStateMachineFactory()); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysis2EdgeFilterTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysis2EdgeFilterTest.java index 886837e50..6d1f45e4b 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysis2EdgeFilterTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysis2EdgeFilterTest.java @@ -15,6 +15,7 @@ import org.junit.rules.ErrorCollector; import com.ibm.wala.analysis.exceptionanalysis.ExceptionAnalysis; import com.ibm.wala.analysis.exceptionanalysis.ExceptionAnalysis2EdgeFilter; import com.ibm.wala.cfg.ControlFlowGraph; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -83,7 +84,7 @@ public class ExceptionAnalysis2EdgeFilterTest { ReferenceCleanser.registerClassHierarchy(cha); IAnalysisCacheView cache = new AnalysisCacheImpl(); ReferenceCleanser.registerCache(cache); - CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cache, cha, scope); + CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); cg = builder.makeCallGraph(options, null); pointerAnalysis = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysisTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysisTest.java index 4f9685152..69dd726a7 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysisTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/exceptionpruning/ExceptionAnalysisTest.java @@ -17,6 +17,7 @@ import org.junit.rules.ErrorCollector; import com.ibm.wala.analysis.exceptionanalysis.ExceptionAnalysis; import com.ibm.wala.analysis.exceptionanalysis.IntraproceduralExceptionAnalysis; import com.ibm.wala.classLoader.CallSiteReference; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -77,7 +78,7 @@ public class ExceptionAnalysisTest { ReferenceCleanser.registerClassHierarchy(cha); IAnalysisCacheView cache = new AnalysisCacheImpl(); ReferenceCleanser.registerCache(cache); - CallGraphBuilder builder = Util.makeZeroCFABuilder(options, cache, cha, scope); + CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); cg = builder.makeCallGraph(options, null); pointerAnalysis = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java index 2c2bbeffc..e572e3349 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/MultiDimArrayTest.java @@ -14,6 +14,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.core.tests.util.WalaTestCase; @@ -62,7 +63,7 @@ public class MultiDimArrayTest extends WalaTestCase { .makeMainEntrypoints(scope, cha, TestConstants.MULTI_DIM_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(),cha, scope); + CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis pa = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/ZeroLengthArrayTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/ZeroLengthArrayTest.java index bee43884e..343720535 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/ZeroLengthArrayTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/ptrs/ZeroLengthArrayTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -50,7 +51,7 @@ public class ZeroLengthArrayTest { TestConstants.ZERO_LENGTH_ARRAY_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis pa = builder.getPointerAnalysis(); // System.err.println(pa); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java index 614164747..eea8ce81e 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/slicer/SlicerTest.java @@ -18,10 +18,12 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; import java.util.Collections; + import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.examples.drivers.PDFSlice; @@ -33,6 +35,7 @@ import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ipa.callgraph.CallGraphBuilder; import com.ibm.wala.ipa.callgraph.ContextSelector; import com.ibm.wala.ipa.callgraph.Entrypoint; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.PartialCallGraph; import com.ibm.wala.ipa.callgraph.impl.Util; import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; @@ -127,7 +130,7 @@ public class SlicerTest { TestConstants.SLICE1_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -158,7 +161,7 @@ public class SlicerTest { TestConstants.SLICE2_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMethod(cg, "baz"); @@ -183,7 +186,7 @@ public class SlicerTest { TestConstants.SLICE3_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMethod(cg, "main"); @@ -207,7 +210,7 @@ public class SlicerTest { TestConstants.SLICE4_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -231,7 +234,7 @@ public class SlicerTest { TestConstants.SLICE5_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode n = findMethod(cg, "baz"); @@ -291,7 +294,7 @@ public class SlicerTest { TestConstants.SLICE8_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode process = findMethod(cg, Descriptor.findOrCreateUTF8("()V"), Atom.findOrCreateUnicodeAtom("process")); @@ -318,7 +321,7 @@ public class SlicerTest { TestConstants.SLICE9_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -341,7 +344,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD1); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -365,7 +368,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD2); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -389,7 +392,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD3); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -413,7 +416,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD4); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -444,7 +447,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD5); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -470,7 +473,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD5); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -496,7 +499,7 @@ public class SlicerTest { TestConstants.SLICE_TESTCD6); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -521,7 +524,7 @@ public class SlicerTest { TestConstants.SLICE_TESTID); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -545,7 +548,7 @@ public class SlicerTest { TestConstants.SLICE_TESTARRAYS); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -570,7 +573,7 @@ public class SlicerTest { TestConstants.SLICE_TESTFIELDS); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -595,7 +598,7 @@ public class SlicerTest { TestConstants.SLICE_TESTTHIN1); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -630,7 +633,7 @@ public class SlicerTest { TestConstants.SLICE_TESTGLOBAL); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -656,7 +659,7 @@ public class SlicerTest { TestConstants.SLICE_TESTMULTITARGET); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -680,7 +683,7 @@ public class SlicerTest { TestConstants.SLICE_TESTRECURSION); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -706,7 +709,7 @@ public class SlicerTest { TestConstants.SLICE_TEST_PRIM_GETTER_SETTER); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode test = findMethod(cg, "test"); @@ -742,7 +745,8 @@ public class SlicerTest { Util.addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); ContextSelector appSelector = null; SSAContextInterpreter appInterpreter = null; - SSAPropagationCallGraphBuilder builder = new nCFABuilder(1, cha, options, new AnalysisCacheImpl(), appSelector, appInterpreter); + IAnalysisCacheView cache = new AnalysisCacheImpl(); + SSAPropagationCallGraphBuilder builder = new nCFABuilder(1, Language.JAVA.getFakeRootMethod(cha, options, cache), options, cache, appSelector, appInterpreter); // nCFABuilder uses type-based heap abstraction by default, but we want allocation sites // NOTE: we disable ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS for this test, since IntWrapper // is a primitive holder @@ -775,7 +779,7 @@ public class SlicerTest { TestConstants.SLICE_TESTTHROWCATCH); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -801,7 +805,7 @@ public class SlicerTest { TestConstants.SLICE_TESTMESSAGEFORMAT); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); @@ -827,7 +831,7 @@ public class SlicerTest { TestConstants.SLICE_TESTINETADDR); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); SDG sdg = new SDG<>(cg, builder.getPointerAnalysis(), DataDependenceOptions.NO_BASE_NO_HEAP, ControlDependenceOptions.FULL); GraphIntegrity.check(sdg); @@ -842,7 +846,7 @@ public class SlicerTest { TestConstants.SLICE_JUSTTHROW); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/CompareToZeroOneCFADriver.java b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/CompareToZeroOneCFADriver.java index 21181e189..e7a63f8ef 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/CompareToZeroOneCFADriver.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/CompareToZeroOneCFADriver.java @@ -46,6 +46,7 @@ import java.util.Collection; import com.ibm.wala.analysis.reflection.InstanceKeyWithNode; import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.analysis.typeInference.TypeInference; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.demandpa.TestInfo; import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo; @@ -149,7 +150,7 @@ public class CompareToZeroOneCFADriver { } private static void doTests(AnalysisScope scope, final ClassHierarchy cha, AnalysisOptions options) throws IllegalArgumentException, CancelException { - final SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + final SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); final CallGraph oldCG = builder.makeCallGraph(options,null); final PointerAnalysis pa = builder.getPointerAnalysis(); @@ -225,7 +226,7 @@ public class CompareToZeroOneCFADriver { private static IDemandPointerAnalysis makeDemandPointerAnalysis(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, CallGraph cg, MemoryAccessMap fam) { - SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); // return new TestNewGraphPointsTo(cg, builder, fam, cha, warnings); DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, fam, cha, options, new DummyStateMachine.Factory()); // fullDemandPointsTo.setOnTheFly(true); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/TestAgainstSimpleDriver.java b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/TestAgainstSimpleDriver.java index 073be7f47..45eddc194 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/TestAgainstSimpleDriver.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/demandpa/driver/TestAgainstSimpleDriver.java @@ -44,6 +44,7 @@ import java.io.IOException; import java.util.Collection; import com.ibm.wala.analysis.typeInference.TypeAbstraction; import com.ibm.wala.analysis.typeInference.TypeInference; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.demandpa.TestInfo; import com.ibm.wala.demandpa.alg.DemandRefinementPointsTo; @@ -162,7 +163,7 @@ public class TestAgainstSimpleDriver { private static IDemandPointerAnalysis makeDemandPointerAnalysis(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, CallGraph cg, MemoryAccessMap fam) { - SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); // return new TestNewGraphPointsTo(cg, builder, fam, cha, warnings); DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, fam, cha, options, new DummyStateMachine.Factory()); // fullDemandPointsTo.setCGRefinePolicy(new AlwaysRefineCGPolicy()); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java index 7ec3206ae..9999c3e1d 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/SimpleThreadEscapeAnalysis.java @@ -22,6 +22,7 @@ import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IField; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.JarFileModule; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.client.AbstractAnalysisEngine; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.CGNode; @@ -89,7 +90,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - return Util.makeZeroCFABuilder(options, cache, cha, scope); + return Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); } /** diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java index 64504e53b..63b6244ad 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/DataflowTest.java @@ -20,6 +20,7 @@ import org.junit.BeforeClass; import org.junit.Test; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.core.tests.util.WalaTestCase; @@ -151,7 +152,7 @@ public class DataflowTest extends WalaTestCase { "Ldataflow/StaticDataflow"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); ExplodedInterproceduralCFG icfg = ExplodedInterproceduralCFG.make(cg); ContextInsensitiveReachingDefs reachingDefs = new ContextInsensitiveReachingDefs(icfg, cha); @@ -183,7 +184,7 @@ public class DataflowTest extends WalaTestCase { "Ldataflow/StaticDataflow"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg); TabulationResult, CGNode, Pair> result = reachingDefs.analyze(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/InitializerTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/InitializerTest.java index 2eaf90d5b..54f788ede 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/InitializerTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/analysis/dataflow/InitializerTest.java @@ -16,6 +16,7 @@ import java.io.IOException; import org.junit.Assert; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.dataflow.IFDS.ISupergraph; @@ -69,7 +70,7 @@ public class InitializerTest { Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "LstaticInit/TestStaticInit"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = null; try { cg = builder.makeCallGraph(options, null); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java index 0b7c0cc48..ecc71e96c 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/JavaViewerDriver.java @@ -14,6 +14,7 @@ import java.io.File; import java.io.IOException; import java.util.Properties; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -64,7 +65,7 @@ public class JavaViewerDriver { // // // build the call graph // // - com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis pa = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java index d72aaa0dd..350609027 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFCallGraph.java @@ -17,6 +17,7 @@ import java.util.Iterator; import java.util.Properties; import java.util.function.Predicate; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.examples.properties.WalaExamplesProperties; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -156,7 +157,7 @@ public class PDFCallGraph { // // // build the call graph // // - com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); System.err.println(CallGraphStats.getStats(cg)); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java index afba98ea1..12411af7c 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSDG.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.Properties; import java.util.function.Predicate; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.examples.properties.WalaExamplesProperties; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -128,7 +129,7 @@ public class PDFSDG { Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options,null); final PointerAnalysis pointerAnalysis = builder.getPointerAnalysis(); SDG sdg = new SDG<>(cg, pointerAnalysis, dOptions, cOptions); diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java index ada6d82b8..f7da96482 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/examples/drivers/PDFSlice.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.Collection; import java.util.Properties; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.slicer.SlicerTest; import com.ibm.wala.examples.properties.WalaExamplesProperties; @@ -154,7 +155,7 @@ public class PDFSlice { ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); // CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new // AnalysisCache(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/AnalysisUtil.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/AnalysisUtil.java index dbf9896c7..091da3010 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/AnalysisUtil.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/AnalysisUtil.java @@ -16,7 +16,7 @@ import java.util.Set; import com.ibm.wala.cfg.ControlFlowGraph; import com.ibm.wala.ipa.callgraph.CGNode; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; +import com.ibm.wala.ipa.callgraph.CallGraph; import com.ibm.wala.ssa.SSAAbstractInvokeInstruction; import com.ibm.wala.ssa.SSAInstruction; import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; @@ -43,8 +43,8 @@ public final class AnalysisUtil { * the node to check * @return true if node is FakeRoot */ - public static boolean isFakeRoot(CGNode node) { - return (node.getMethod().getName().equals(FakeRootMethod.rootMethod.getName())); + public static boolean isFakeRoot(CallGraph CG, CGNode node) { + return (node.equals(CG.getFakeRootNode())); } /** diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/InterprocNullPointerAnalysis.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/InterprocNullPointerAnalysis.java index 0a54a5a87..45247f434 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/InterprocNullPointerAnalysis.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/exc/inter/InterprocNullPointerAnalysis.java @@ -65,7 +65,8 @@ public final class InterprocNullPointerAnalysis { private final MethodState defaultMethodState; private final Map states; private final boolean optHasExceptions; - + private CallGraph cg; + public static InterprocNullPointerAnalysis compute(final TypeReference[] ignoredExceptions, final CallGraph cg, final MethodState defaultMethodState, final IProgressMonitor progress, boolean optHasExceptions) throws WalaException, UnsoundGraphException, CancelException { @@ -88,6 +89,7 @@ public final class InterprocNullPointerAnalysis { } // we filter out everything we do not need now + this.cg = cg; this.cgFiltered = computeFilteredCallgraph(cg); // we start with the first node @@ -142,7 +144,7 @@ public final class InterprocNullPointerAnalysis { private void analysisSecondPass(final CGNode startNode, final ParameterState paramState, final IProgressMonitor progress) throws UnsoundGraphException, CancelException { final IR ir = startNode.getIR(); - if (!AnalysisUtil.isFakeRoot(startNode) && !(ir == null || ir.isEmptyIR())) { + if (!AnalysisUtil.isFakeRoot(cg, startNode) && !(ir == null || ir.isEmptyIR())) { final MethodState ims = new InterprocMethodState(startNode, cgFiltered, states); final MethodState mState = (defaultMethodState != null ? new DelegatingMethodState(defaultMethodState, ims) : ims); diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/JavaLanguage.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/JavaLanguage.java index 3148cc964..7baeaf98b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/JavaLanguage.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/JavaLanguage.java @@ -20,6 +20,11 @@ import java.util.Collections; import com.ibm.wala.analysis.typeInference.JavaPrimitiveType; import com.ibm.wala.analysis.typeInference.PrimitiveType; +import com.ibm.wala.ipa.callgraph.AnalysisOptions; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; +import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; +import com.ibm.wala.ipa.callgraph.impl.FakeRootClass; +import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.ConstantInstruction; import com.ibm.wala.shrikeBT.ConstantInstruction.ClassToken; @@ -764,4 +769,10 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons public boolean methodsHaveDeclaredParameterTypes() { return true; } + + @Override + public AbstractRootMethod getFakeRootMethod(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { + return new FakeRootMethod(new FakeRootClass(ClassLoaderReference.Primordial, cha), options, cache); + } + } diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/Language.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/Language.java index 4d7ec12e6..59afe82f9 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/Language.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/Language.java @@ -15,6 +15,9 @@ import java.util.Set; import com.ibm.wala.analysis.typeInference.PrimitiveType; import com.ibm.wala.analysis.typeInference.TypeInference; +import com.ibm.wala.ipa.callgraph.AnalysisOptions; +import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; +import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeCT.InvalidClassFileException; import com.ibm.wala.ssa.SSAInstructionFactory; @@ -145,4 +148,6 @@ public interface Language { */ boolean methodsHaveDeclaredParameterTypes(); + AbstractRootMethod getFakeRootMethod(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache); + } diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java index 01ff9af24..700e4d884 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java @@ -41,7 +41,7 @@ public class SyntheticMethod implements IMethod { protected final IMethod resolvedMethod; - protected final IClass declaringClass; + public final IClass declaringClass; private final boolean isStatic; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/cha/CHACallGraph.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/cha/CHACallGraph.java index 430cef2c2..3b3b63b33 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/cha/CHACallGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/cha/CHACallGraph.java @@ -20,6 +20,7 @@ import java.util.function.Predicate; import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; import com.ibm.wala.ipa.callgraph.AnalysisOptions; @@ -29,7 +30,6 @@ import com.ibm.wala.ipa.callgraph.Entrypoint; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; import com.ibm.wala.ipa.callgraph.impl.BasicCallGraph; import com.ibm.wala.ipa.callgraph.impl.Everywhere; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; import com.ibm.wala.ipa.callgraph.impl.FakeWorldClinitMethod; import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.shrikeBT.IInvokeInstruction; @@ -207,12 +207,12 @@ public class CHACallGraph extends BasicCallGraph { @Override protected CGNode makeFakeRootNode() throws CancelException { - return new CHARootNode(new FakeRootMethod(cha, options, cache), Everywhere.EVERYWHERE); + return new CHARootNode(Language.JAVA.getFakeRootMethod(cha, options, cache), Everywhere.EVERYWHERE); } @Override protected CGNode makeFakeWorldClinitNode() throws CancelException { - return new CHARootNode(new FakeWorldClinitMethod(cha, options, cache), Everywhere.EVERYWHERE); + return new CHARootNode(new FakeWorldClinitMethod(Language.JAVA.getFakeRootMethod(cha, options, cache).getDeclaringClass(), options, cache), Everywhere.EVERYWHERE); } private int clinitPC = 0; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java index 08a367e17..0655121d4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java @@ -54,7 +54,7 @@ import com.ibm.wala.util.warnings.Warnings; */ public abstract class AbstractRootMethod extends SyntheticMethod { - final protected ArrayList statements = new ArrayList<>(); + public final ArrayList statements = new ArrayList<>(); private Map constant2ValueNumber = HashMapFactory.make(); @@ -62,9 +62,9 @@ public abstract class AbstractRootMethod extends SyntheticMethod { * The number of the next local value number available for the fake root method. Note that we reserve value number 1 to represent * the value "any exception caught by the root method" */ - protected int nextLocal = 2; + public int nextLocal = 2; - protected final IClassHierarchy cha; + public final IClassHierarchy cha; private final AnalysisOptions options; @@ -90,7 +90,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod { } public AbstractRootMethod(MethodReference method, final IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - this(method, new FakeRootClass(cha), cha, options, cache); + this(method, new FakeRootClass(method.getDeclaringClass().getClassLoader(), cha), cha, options, cache); } /* @@ -407,7 +407,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod { @Override public boolean understands(CGNode node) { - return node.getMethod().getDeclaringClass().getReference().equals(FakeRootClass.FAKE_ROOT_CLASS); + return node.getMethod().getDeclaringClass().equals(AbstractRootMethod.this.getDeclaringClass()); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ExplicitCallGraph.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ExplicitCallGraph.java index fe7d2295f..3b68290a4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ExplicitCallGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ExplicitCallGraph.java @@ -61,12 +61,13 @@ public class ExplicitCallGraph extends BasicCallGraph imp private final long maxNumberOfNodes; + private final IMethod fakeRootMethod; /** * special object to track call graph edges */ private final ExplicitEdgeManager edgeManager = makeEdgeManger(); - public ExplicitCallGraph(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { + public ExplicitCallGraph(IMethod fakeRootMethod, AnalysisOptions options, IAnalysisCacheView cache) { super(); if (options == null) { throw new IllegalArgumentException("null options"); @@ -74,11 +75,11 @@ public class ExplicitCallGraph extends BasicCallGraph imp if (cache == null) { throw new IllegalArgumentException("null cache"); } - this.cha = cha; + this.cha = fakeRootMethod.getClassHierarchy(); this.options = options; this.cache = cache; this.maxNumberOfNodes = options.getMaxNumberOfNodes(); - + this.fakeRootMethod = fakeRootMethod; } /** @@ -95,7 +96,7 @@ public class ExplicitCallGraph extends BasicCallGraph imp */ @Override protected CGNode makeFakeRootNode() throws CancelException { - return findOrCreateNode(new FakeRootMethod(cha, options, cache), Everywhere.EVERYWHERE); + return findOrCreateNode(fakeRootMethod, Everywhere.EVERYWHERE); } /** @@ -105,7 +106,7 @@ public class ExplicitCallGraph extends BasicCallGraph imp */ @Override protected CGNode makeFakeWorldClinitNode() throws CancelException { - return findOrCreateNode(new FakeWorldClinitMethod(cha, options, cache), Everywhere.EVERYWHERE); + return findOrCreateNode(new FakeWorldClinitMethod(fakeRootMethod.getDeclaringClass(), options, cache), Everywhere.EVERYWHERE); } /** diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootClass.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootClass.java index 9d0f7cec8..be44de92d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootClass.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootClass.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Set; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.IClassLoader; import com.ibm.wala.classLoader.IField; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.classLoader.SyntheticClass; @@ -37,21 +38,27 @@ import com.ibm.wala.util.strings.Atom; * A synthetic class for the fake root method. */ public class FakeRootClass extends SyntheticClass { - public static final TypeReference FAKE_ROOT_CLASS = TypeReference.findOrCreate(ClassLoaderReference.Primordial, TypeName - .string2TypeName("Lcom/ibm/wala/FakeRootClass")); - + public static final TypeReference fakeRootClass(ClassLoaderReference clr) { + return TypeReference.findOrCreate(clr, TypeName.string2TypeName("Lcom/ibm/wala/FakeRootClass")); + } + private Map fakeRootStaticFields = null; private Set methods = HashSetFactory.make(); - public FakeRootClass(IClassHierarchy cha) { - this(FAKE_ROOT_CLASS, cha); + public FakeRootClass(ClassLoaderReference clr, IClassHierarchy cha) { + this(fakeRootClass(clr), cha); } public FakeRootClass(TypeReference typeRef, IClassHierarchy cha) { super(typeRef, cha); } + @Override + public IClassLoader getClassLoader() { + return getClassHierarchy().getLoader(getReference().getClassLoader()); + } + public void addMethod(IMethod m) { methods.add(m); } @@ -94,7 +101,7 @@ public class FakeRootClass extends SyntheticClass { @Override public FieldReference getReference() { - return FieldReference.findOrCreate(FAKE_ROOT_CLASS, name, fieldType); + return FieldReference.findOrCreate(FakeRootClass.this.getReference(), name, fieldType); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootMethod.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootMethod.java index d84b60b1c..77343c9b2 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeRootMethod.java @@ -11,10 +11,10 @@ package com.ibm.wala.ipa.callgraph.impl; import com.ibm.wala.cfg.IBasicBlock; +import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.types.Descriptor; import com.ibm.wala.types.MemberReference; import com.ibm.wala.types.MethodReference; @@ -31,21 +31,19 @@ public class FakeRootMethod extends AbstractRootMethod { public static final Descriptor descr = Descriptor.findOrCreate(new TypeName[0], TypeReference.VoidName); - public static final MethodReference rootMethod = MethodReference.findOrCreate(FakeRootClass.FAKE_ROOT_CLASS, name, descr); - - public FakeRootMethod(final IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(rootMethod, cha, options, cache); + public FakeRootMethod(final IClass fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache) { + super(MethodReference.findOrCreate(fakeRootClass.getReference(), name, descr), fakeRootClass.getClassHierarchy(), options, cache); } /** * @return true iff m is the fake root method. * @throws IllegalArgumentException if m is null */ - public static boolean isFakeRootMethod(MemberReference m) { + public boolean isFakeRootMethod(MemberReference m) { if (m == null) { throw new IllegalArgumentException("m is null"); } - return m.equals(rootMethod); + return m.equals(getReference()); } /** @@ -57,11 +55,6 @@ public class FakeRootMethod extends AbstractRootMethod { throw new IllegalArgumentException("block is null"); } IMethod m = block.getMethod(); - return FakeRootMethod.isFakeRootMethod(m.getReference()); + return m instanceof FakeRootMethod && ((FakeRootMethod)m).isFakeRootMethod(m.getReference()); } - - public static MethodReference getRootMethod() { - return rootMethod; - } - } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeWorldClinitMethod.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeWorldClinitMethod.java index feedf395d..94f50a94f 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeWorldClinitMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/FakeWorldClinitMethod.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.ibm.wala.ipa.callgraph.impl; +import com.ibm.wala.classLoader.IClass; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; -import com.ibm.wala.ipa.cha.IClassHierarchy; import com.ibm.wala.types.Descriptor; import com.ibm.wala.types.MethodReference; import com.ibm.wala.types.TypeName; @@ -26,10 +26,9 @@ public class FakeWorldClinitMethod extends AbstractRootMethod { private static final Atom name = Atom.findOrCreateAsciiAtom("fakeWorldClinit"); - private static final MethodReference worldClinitMethod = MethodReference.findOrCreate(FakeRootClass.FAKE_ROOT_CLASS, name, Descriptor - .findOrCreate(new TypeName[0], TypeReference.VoidName)); + private static final Descriptor descr = Descriptor.findOrCreate(new TypeName[0], TypeReference.VoidName); - public FakeWorldClinitMethod(final IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(worldClinitMethod, cha, options, cache); + public FakeWorldClinitMethod(final IClass fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache) { + super(MethodReference.findOrCreate(fakeRootClass.getReference(), name, descr), fakeRootClass.getClassHierarchy(), options, cache); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java index 772f294d4..66360cfad 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java @@ -21,6 +21,7 @@ import java.util.Set; import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IMethod; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisScope; import com.ibm.wala.ipa.callgraph.CallGraphBuilder; @@ -325,9 +326,9 @@ public class Util { * @param scope representation of the analysis scope * @return a 0-CFA Call Graph Builder. */ - public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(AnalysisOptions options, IAnalysisCacheView cache, + public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) { - return makeZeroCFABuilder(options, cache, cha, scope, null, null); + return makeZeroCFABuilder(l, options, cache, cha, scope, null, null); } /** @@ -339,7 +340,7 @@ public class Util { * @return a 0-CFA Call Graph Builder. * @throws IllegalArgumentException if options is null */ - public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(AnalysisOptions options, IAnalysisCacheView cache, + public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope, ContextSelector customSelector, SSAContextInterpreter customInterpreter) { if (options == null) { @@ -348,7 +349,7 @@ public class Util { addDefaultSelectors(options, cha); addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); - return ZeroXCFABuilder.make(cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.NONE); + return ZeroXCFABuilder.make(l, cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.NONE); } /** @@ -358,9 +359,9 @@ public class Util { * @param cha governing class hierarchy * @param scope representation of the analysis scope */ - public static SSAPropagationCallGraphBuilder makeZeroOneCFABuilder(AnalysisOptions options, IAnalysisCacheView cache, + public static SSAPropagationCallGraphBuilder makeZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) { - return makeZeroOneCFABuilder(options, cache, cha, scope, null, null); + return makeZeroOneCFABuilder(l, options, cache, cha, scope, null, null); } /** @@ -372,7 +373,7 @@ public class Util { * @return a 0-1-CFA Call Graph Builder. * @throws IllegalArgumentException if options is null */ - public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options, IAnalysisCacheView analysisCache, + public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView analysisCache, IClassHierarchy cha, AnalysisScope scope, ContextSelector customSelector, SSAContextInterpreter customInterpreter) { if (options == null) { @@ -381,7 +382,7 @@ public class Util { addDefaultSelectors(options, cha); addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); - return ZeroXCFABuilder.make(cha, options, analysisCache, customSelector, customInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC); + return ZeroXCFABuilder.make(l, cha, options, analysisCache, customSelector, customInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC); } /** @@ -391,9 +392,9 @@ public class Util { * @param cha governing class hierarchy * @param scope representation of the analysis scope */ - public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options, IAnalysisCacheView analysisCache, + public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView analysisCache, IClassHierarchy cha, AnalysisScope scope) { - return makeVanillaZeroOneCFABuilder(options, analysisCache, cha, scope, null, null); + return makeVanillaZeroOneCFABuilder(l, options, analysisCache, cha, scope, null, null); } /** @@ -405,7 +406,7 @@ public class Util { * @return a 0-1-CFA Call Graph Builder. * @throws IllegalArgumentException if options is null */ - public static SSAPropagationCallGraphBuilder makeZeroOneCFABuilder(AnalysisOptions options, IAnalysisCacheView cache, + public static SSAPropagationCallGraphBuilder makeZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope, ContextSelector customSelector, SSAContextInterpreter customInterpreter) { if (options == null) { @@ -414,7 +415,7 @@ public class Util { addDefaultSelectors(options, cha); addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); - return ZeroXCFABuilder.make(cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS + return ZeroXCFABuilder.make(l, cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_THROWABLES); } @@ -478,7 +479,7 @@ public class Util { addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); ContextSelector appSelector = null; SSAContextInterpreter appInterpreter = null; - SSAPropagationCallGraphBuilder result = new nCFABuilder(n, cha, options, cache, appSelector, appInterpreter); + SSAPropagationCallGraphBuilder result = new nCFABuilder(n, Language.JAVA.getFakeRootMethod(cha, options, cache), options, cache, appSelector, appInterpreter); // nCFABuilder uses type-based heap abstraction by default, but we want allocation sites result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(), ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS @@ -501,7 +502,7 @@ public class Util { addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha); ContextSelector appSelector = null; SSAContextInterpreter appInterpreter = null; - SSAPropagationCallGraphBuilder result = new nCFABuilder(n, cha, options, cache, appSelector, appInterpreter); + SSAPropagationCallGraphBuilder result = new nCFABuilder(n, Language.JAVA.getFakeRootMethod(cha, options, cache), options, cache, appSelector, appInterpreter); // nCFABuilder uses type-based heap abstraction by default, but we want allocation sites result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(), ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC)); return result; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java index 40ef1573f..a4eaae924 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PropagationCallGraphBuilder.java @@ -175,22 +175,22 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder - + - + - - - - diff --git a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/DalvikCallGraphTestBase.java b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/DalvikCallGraphTestBase.java index 9c8a7047c..a6825f73c 100644 --- a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/DalvikCallGraphTestBase.java +++ b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/DalvikCallGraphTestBase.java @@ -24,6 +24,7 @@ import java.util.function.Function; import java.util.function.Predicate; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.classLoader.NewSiteReference; import com.ibm.wala.core.tests.shrike.DynamicCallGraphTestBase; import com.ibm.wala.dalvik.classLoader.DexIRFactory; @@ -121,7 +122,7 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase { options.setReflectionOptions(policy); // SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(options, cache, cha, scope, null, makeDefaultInterpreter(options, cache)); - SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(options, cache, cha, scope); + SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph callGraph = cgb.makeCallGraph(options, monitor); @@ -157,7 +158,7 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase { AnalysisOptions options = new AnalysisOptions(scope, entrypoints); - SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(options, cache, cha, scope); + SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph callGraph = cgb.makeCallGraph(options); diff --git a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java index 59e640ac3..098a71eff 100644 --- a/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java +++ b/com.ibm.wala.dalvik.test/source/com/ibm/wala/dalvik/test/callGraph/JVMLDalvikComparisonTest.java @@ -21,6 +21,7 @@ import java.util.Set; import org.junit.Assert; import org.junit.Test; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -54,7 +55,7 @@ public class JVMLDalvikComparisonTest extends DalvikCallGraphTestBase { ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); - SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); + SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph CG = builder.makeCallGraph(options); return Pair.make(CG, builder.getPointerAnalysis()); } diff --git a/com.ibm.wala.dalvik/pom.xml b/com.ibm.wala.dalvik/pom.xml index f7db41496..84cf2ed56 100644 --- a/com.ibm.wala.dalvik/pom.xml +++ b/com.ibm.wala.dalvik/pom.xml @@ -78,12 +78,12 @@ org.smali dexlib2 - 2.2.1 + 2.2.2 org.smali util - 2.2.1 + 2.2.2 diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexExplicitCallGraph.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexExplicitCallGraph.java deleted file mode 100644 index f1cf2f447..000000000 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexExplicitCallGraph.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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. - * - * This file is a derivative of code released under the terms listed below. - * - */ -/** - * - * Copyright (c) 2009-2012, - * - * Galois, Inc. (Aaron Tomb , Rogan Creswick ) - * Steve Suh - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The names of the contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - */ -package com.ibm.wala.dalvik.ipa.callgraph.impl; - -import com.ibm.wala.ipa.callgraph.AnalysisOptions; -import com.ibm.wala.ipa.callgraph.CGNode; -import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; -import com.ibm.wala.ipa.callgraph.impl.Everywhere; -import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; -import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.util.CancelException; - -/** - * @deprecated The Android-Model has been moved out from DrexFakeRootMethod, so DexExplicitCallGraph is not needed any longer - */ -@Deprecated -public class DexExplicitCallGraph extends ExplicitCallGraph { - - public DexExplicitCallGraph(IClassHierarchy cha, AnalysisOptions options, - IAnalysisCacheView cache) { - super(cha, options, cache); - } - - @Override - protected CGNode makeFakeRootNode() throws CancelException { - return findOrCreateNode(new DexFakeRootMethod(cha, options, getAnalysisCache()), Everywhere.EVERYWHERE); - } - -} diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexFakeRootMethod.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexFakeRootMethod.java deleted file mode 100644 index 62fdeb490..000000000 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/impl/DexFakeRootMethod.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * 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. - * - * This file is a derivative of code released under the terms listed below. - * - */ -/** - * - * Copyright (c) 2009-2012, - * - * Galois, Inc. (Aaron Tomb , Rogan Creswick ) - * Steve Suh - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The names of the contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - */ -package com.ibm.wala.dalvik.ipa.callgraph.impl; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import com.ibm.wala.cfg.IBasicBlock; -import com.ibm.wala.classLoader.CallSiteReference; -import com.ibm.wala.classLoader.IClass; -import com.ibm.wala.classLoader.IMethod; -import com.ibm.wala.classLoader.NewSiteReference; -import com.ibm.wala.ipa.callgraph.AnalysisOptions; -import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; -import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod; -import com.ibm.wala.ipa.callgraph.impl.Everywhere; -import com.ibm.wala.ipa.callgraph.impl.FakeRootClass; -import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod; -import com.ibm.wala.ipa.cha.IClassHierarchy; -import com.ibm.wala.shrikeBT.IInvokeInstruction; -import com.ibm.wala.ssa.SSAArrayStoreInstruction; -import com.ibm.wala.ssa.SSANewInstruction; -import com.ibm.wala.types.Descriptor; -import com.ibm.wala.types.MemberReference; -import com.ibm.wala.types.MethodReference; -import com.ibm.wala.types.TypeName; -import com.ibm.wala.types.TypeReference; -import com.ibm.wala.util.strings.Atom; -import com.ibm.wala.util.warnings.Warning; -import com.ibm.wala.util.warnings.Warnings; - -/** - * @deprecated building the Android-model uses a "normal" fake-root now - */ -@Deprecated -public class DexFakeRootMethod extends AbstractRootMethod { - - public static final Atom name = Atom.findOrCreateAsciiAtom("DexFakeRootMethod"); - - public static final Descriptor descr = Descriptor.findOrCreate(new TypeName[0], TypeReference.VoidName); - - public static final MethodReference rootMethod = MethodReference.findOrCreate(FakeRootClass.FAKE_ROOT_CLASS, name, descr); - - public static Map referenceTypeMap = new HashMap<>(); - -// public static Set referenceTypeSet = new HashSet(); - - public DexFakeRootMethod(final IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) { - super(rootMethod, cha, options, cache); - } - - @Override - public SSANewInstruction addAllocation(TypeReference T) { - return addAllocation(T, true); - } - - private SSANewInstruction addAllocation(TypeReference T, boolean invokeCtor) { - if (T == null) { - throw new IllegalArgumentException("T is null"); - } - int instance = nextLocal++; - SSANewInstruction result = null; - if (T.isReferenceType()) { - NewSiteReference ref = NewSiteReference.make(statements.size(), T); - if (T.isArrayType()) { - int[] sizes = new int[T.getDimensionality()]; - Arrays.fill(sizes, getValueNumberForIntConstant(1)); - result = insts.NewInstruction(statements.size(), instance, ref, sizes); - } else { - result = insts.NewInstruction(statements.size(), instance, ref); - } - statements.add(result); - - IClass klass = cha.lookupClass(T); - if (klass == null) { - Warnings.add(AllocationFailure.create(T)); - return null; - } - - if (klass.isArrayClass()) { - int arrayRef = result.getDef(); - TypeReference e = klass.getReference().getArrayElementType(); - while (e != null && !e.isPrimitiveType()) { - // allocate an instance for the array contents - NewSiteReference n = NewSiteReference.make(statements.size(), e); - int alloc = nextLocal++; - SSANewInstruction ni = null; - if (e.isArrayType()) { - int[] sizes = new int[T.getDimensionality()]; - Arrays.fill(sizes, getValueNumberForIntConstant(1)); - ni = insts.NewInstruction(statements.size(), alloc, n, sizes); - } else { - ni = insts.NewInstruction(statements.size(), alloc, n); - } - statements.add(ni); - - // emit an astore - SSAArrayStoreInstruction store = insts.ArrayStoreInstruction(statements.size(), arrayRef, getValueNumberForIntConstant(0), alloc, e); - statements.add(store); - - e = e.isArrayType() ? e.getArrayElementType() : null; - arrayRef = alloc; - } - } - if (invokeCtor) { - IMethod ctor = cha.resolveMethod(klass, MethodReference.initSelector); - if (ctor!=null) { - int[] allocSites = null; - referenceTypeMap.put(T, instance); - - if (!ctor.getDeclaringClass().getName().toString().equals(klass.getName().toString())) { - boolean found = false; - for (IMethod im: klass.getAllMethods()) { - if (im.getDeclaringClass().getName().toString().equals(klass.getName().toString()) && - im.getSelector().getName().toString().equals(MethodReference.initAtom.toString())) { - ctor = im; - allocSites = new int[ctor.getNumberOfParameters()]; - allocSites[0] = instance; - for (int j = 1; j < ctor.getNumberOfParameters(); j++) { - if (im.getParameterType(j).isPrimitiveType()) { - allocSites[j] = addLocal(); - } - else if (referenceTypeMap.containsKey(im.getParameterType(j))) { - allocSites[j] = referenceTypeMap.get(im.getParameterType(j)).intValue(); - } - else { - SSANewInstruction n = addAllocation(im.getParameterType(j), invokeCtor); - allocSites[j] = (n == null) ? -1 : n.getDef(); - referenceTypeMap.put(im.getParameterType(j), allocSites[j]); - } - } - found = true; - break; - } - } - if (!found) { - Set implementors = cha.getImplementors(T); - int[] values = new int[implementors.size()]; - int countErrors = 0; - int index = 0; - for (IClass ic: implementors){ - int value; - - if (referenceTypeMap.containsKey(ic.getReference())) { - value = referenceTypeMap.get(ic.getReference()).intValue(); - } - else { - SSANewInstruction n = addAllocation(ic.getReference(), invokeCtor); - value = (n == null) ? -1 : n.getDef(); - referenceTypeMap.put(ic.getReference(), value); - } - if (value == -1) { - countErrors++; - } else { - values[index - countErrors] = value; - } - index++; - } - - if (countErrors > 0) { - int[] oldValues = values; - values = new int[oldValues.length - countErrors]; - System.arraycopy(oldValues, 0, values, 0, values.length); - } - if (values.length > 1) { - instance = addPhi(values); - referenceTypeMap.put(T, instance); - } - } - } - if (allocSites!=null) - for (int allocSite : allocSites) { - if (allocSite == -1) { - Warnings.add(AllocationFailure.create(T)); - return null; - } - } - addInvocation(allocSites==null?new int[] {instance}:allocSites, CallSiteReference.make(statements.size(), ctor.getReference(), - IInvokeInstruction.Dispatch.SPECIAL)); - } - } - } - cache.invalidate(this, Everywhere.EVERYWHERE); - return result; - } - - - private static class AllocationFailure extends Warning { - - final TypeReference t; - - AllocationFailure(TypeReference t) { - super(Warning.SEVERE); - this.t = t; - } - - @Override - public String getMsg() { - return getClass().toString() + " : " + t; - } - - public static AllocationFailure create(TypeReference t) { - return new AllocationFailure(t); - } - } - - /** - * @return true iff m is the fake root method. - * @throws IllegalArgumentException if m is null - */ - public static boolean isFakeRootMethod(MemberReference m) { - if (m == null) { - throw new IllegalArgumentException("m is null"); - } - return m.equals(rootMethod); - } - - /** - * @return true iff block is a basic block in the fake root method - * @throws IllegalArgumentException if block is null - */ - public static boolean isFromFakeRoot(IBasicBlock block) { - if (block == null) { - throw new IllegalArgumentException("block is null"); - } - IMethod m = block.getMethod(); - return FakeRootMethod.isFakeRootMethod(m.getReference()); - } - - public static MethodReference getRootMethod() { - return rootMethod; - } - -} diff --git a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/propagation/cfa/DexSSAPropagationCallGraphBuilder.java b/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/propagation/cfa/DexSSAPropagationCallGraphBuilder.java deleted file mode 100644 index f334078b9..000000000 --- a/com.ibm.wala.dalvik/src/com/ibm/wala/dalvik/ipa/callgraph/propagation/cfa/DexSSAPropagationCallGraphBuilder.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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. - * - * This file is a derivative of code released under the terms listed below. - * - */ -/** - * - * Copyright (c) 2009-2012, - * - * Galois, Inc. (Aaron Tomb , Rogan Creswick ) - * Steve Suh - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The names of the contributors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * - */ -package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa; - -import com.ibm.wala.dalvik.ipa.callgraph.impl.DexExplicitCallGraph; -import com.ibm.wala.ipa.callgraph.AnalysisOptions; -import com.ibm.wala.ipa.callgraph.ContextSelector; -import com.ibm.wala.ipa.callgraph.IAnalysisCacheView; -import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph; -import com.ibm.wala.ipa.callgraph.propagation.InstanceKeyFactory; -import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter; -import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder; -import com.ibm.wala.ipa.callgraph.propagation.cfa.DefaultPointerKeyFactory; -import com.ibm.wala.ipa.cha.IClassHierarchy; - -/** - * @deprecated Building the AndroidLivecycle works with a "normal" CGB - */ -@Deprecated -public class DexSSAPropagationCallGraphBuilder extends - SSAPropagationCallGraphBuilder { - - - - public DexSSAPropagationCallGraphBuilder(IClassHierarchy cha, - AnalysisOptions options, IAnalysisCacheView cache, - ContextSelector appContextSelector, - SSAContextInterpreter appContextInterpreter, InstanceKeyFactory instanceKeys) { - super(cha, options, cache, new DefaultPointerKeyFactory()); - setContextSelector(appContextSelector); - setContextInterpreter(appContextInterpreter); - setInstanceKeys(instanceKeys); - } - - @Override - protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) { - return new DexExplicitCallGraph(cha, options, getAnalysisCache()); - } - -} diff --git a/com.ibm.wala.ide.jdt.test/launchers/JDTJavaIRTests.launch b/com.ibm.wala.ide.jdt.test/launchers/JDTJavaIRTests.launch index b5bba0a5b..7f594ad12 100644 --- a/com.ibm.wala.ide.jdt.test/launchers/JDTJavaIRTests.launch +++ b/com.ibm.wala.ide.jdt.test/launchers/JDTJavaIRTests.launch @@ -1,46 +1,47 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.ibm.wala.ide.jdt.test/source/com/ibm/wala/demandpa/driver/DemandCastChecker.java b/com.ibm.wala.ide.jdt.test/source/com/ibm/wala/demandpa/driver/DemandCastChecker.java index 48d75924f..a6674f010 100644 --- a/com.ibm.wala.ide.jdt.test/source/com/ibm/wala/demandpa/driver/DemandCastChecker.java +++ b/com.ibm.wala.ide.jdt.test/source/com/ibm/wala/demandpa/driver/DemandCastChecker.java @@ -47,6 +47,7 @@ import java.util.List; import java.util.Properties; import java.util.function.Predicate; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.demandpa.alg.ContextSensitiveStateMachine; @@ -187,9 +188,9 @@ public class DemandCastChecker { final IAnalysisCacheView cache = new AnalysisCacheImpl(); CallGraphBuilder builder; if (CHEAP_CG) { - builder = Util.makeZeroCFABuilder(options, cache, cha, scope); + builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); // we want vanilla 0-1 CFA, which has one abstract loc per allocation - heapModel = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope); + heapModel = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); } else { builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); heapModel = (HeapModel) builder; diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java index 5a5674dfe..9bc5e8ca8 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/IFDSExplorerExample.java @@ -13,6 +13,7 @@ package com.ibm.wala.examples.drivers; import java.io.IOException; import java.util.Properties; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.core.tests.util.TestConstants; import com.ibm.wala.dataflow.IFDS.TabulationResult; @@ -61,7 +62,7 @@ public class IFDSExplorerExample { "Ldataflow/StaticDataflow"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); IAnalysisCacheView cache = new AnalysisCacheImpl(); - CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, cache, cha, scope); + CallGraphBuilder builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); System.out.println("building CG"); CallGraph cg = builder.makeCallGraph(options, null); System.out.println("done with CG"); diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java index 04c52300a..4f6c07d7c 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTCallGraph.java @@ -16,6 +16,7 @@ import java.util.jar.JarFile; import org.eclipse.jface.window.ApplicationWindow; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.examples.properties.WalaExamplesProperties; import com.ibm.wala.ide.ui.SWTTreeViewer; @@ -118,7 +119,7 @@ public class SWTCallGraph { // // // build the call graph // // - com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope, null, + com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope, null, null); CallGraph cg = builder.makeCallGraph(options,null); diff --git a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java index ab24ce541..a5f13faf7 100644 --- a/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java +++ b/com.ibm.wala.ide.tests/src/com/ibm/wala/examples/drivers/SWTPointsTo.java @@ -16,6 +16,7 @@ import java.util.Properties; import org.eclipse.jface.window.ApplicationWindow; import com.ibm.wala.analysis.pointers.BasicHeapGraph; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil; import com.ibm.wala.ide.ui.SWTTreeViewer; import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl; @@ -92,7 +93,7 @@ public class SWTPointsTo { // // // build the call graph // // - com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(),cha, scope, null, null); + com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope, null, null); CallGraph cg = builder.makeCallGraph(options,null); PointerAnalysis pointerAnalysis = builder.getPointerAnalysis(); diff --git a/com.ibm.wala.scandroid/source/org/scandroid/util/AndroidAnalysisContext.java b/com.ibm.wala.scandroid/source/org/scandroid/util/AndroidAnalysisContext.java index 76ddb4887..1b4ef2a06 100644 --- a/com.ibm.wala.scandroid/source/org/scandroid/util/AndroidAnalysisContext.java +++ b/com.ibm.wala.scandroid/source/org/scandroid/util/AndroidAnalysisContext.java @@ -61,6 +61,7 @@ import java.util.Set; import com.google.common.collect.Lists; import com.google.common.collect.Queues; import com.ibm.wala.classLoader.IClass; +import com.ibm.wala.classLoader.Language; import com.ibm.wala.dalvik.util.AndroidAnalysisScope; import com.ibm.wala.ipa.callgraph.AnalysisOptions; import com.ibm.wala.ipa.callgraph.AnalysisScope; @@ -150,7 +151,7 @@ public class AndroidAnalysisContext { // AndroidAppLoader.class.getClassLoader(), methodSpec, cha); addBypassLogic(options, scope, summariesStream, cha, extraSummary); - return ZeroXCFABuilder.make(cha, options, cache, customSelector, + return ZeroXCFABuilder.make(Language.JAVA, cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC); } @@ -213,7 +214,7 @@ public class AndroidAnalysisContext { addBypassLogic(options, scope, stream, cha, extraSummary); } - return ZeroXCFABuilder.make(cha, options, cache, customSelector, + return ZeroXCFABuilder.make(Language.JAVA, cha, options, cache, customSelector, customInterpreter, ZeroXInstanceKeys.NONE); } diff --git a/pom.xml b/pom.xml index af08138f9..1d934f6fe 100644 --- a/pom.xml +++ b/pom.xml @@ -14,81 +14,107 @@ 0.23.1 scm:git:ssh://github.com:wala/WALA.git - - - targets - - com.ibm.wala_feature - com.ibm.wala.core - com.ibm.wala.shrike - com.ibm.wala.util - - com.ibm.wala.core.testdata - com.ibm.wala.core.tests - - com.ibm.wala.cast - com.ibm.wala.cast.test - com.ibm.wala.cast.java - com.ibm.wala.cast.java.test - com.ibm.wala.cast.java.test.data - - com.ibm.wala.cast.java.ecj - - com.ibm.wala.ide_feature - com.ibm.wala.ide - com.ibm.wala.ide.tests - - com.ibm.wala.ide.jdt - com.ibm.wala.ide.jdt.test - - com.ibm.wala.cast.js - com.ibm.wala.cast.js.html.nu_validator - com.ibm.wala.cast.js.test - com.ibm.wala.cast.js.test.data - com.ibm.wala.cast.js.rhino - com.ibm.wala.cast.js.rhino.test - - com.ibm.wala.cast.js.nodejs - com.ibm.wala.cast.js.nodejs.test - - com.ibm.wala.ide.jsdt - com.ibm.wala.ide.jsdt.tests - - com.ibm.wala.dalvik - com.ibm.wala.dalvik.test - - com.ibm.wala.scandroid - - com.ibm.wala-repository - - - - linux - - - unix - Linux - - - - - - org.eclipse.tycho - target-platform-configuration - ${tycho-version} - - - ignore - - - - - - + + noAndroid + + targets + com.ibm.wala_feature + com.ibm.wala.core + com.ibm.wala.shrike + com.ibm.wala.util + com.ibm.wala.core.testdata + com.ibm.wala.core.tests + com.ibm.wala.cast + com.ibm.wala.cast.test + com.ibm.wala.cast.java + com.ibm.wala.cast.java.test + com.ibm.wala.cast.java.test.data + com.ibm.wala.cast.java.ecj + com.ibm.wala.ide_feature + com.ibm.wala.ide + com.ibm.wala.ide.tests + com.ibm.wala.ide.jdt + com.ibm.wala.ide.jdt.test + com.ibm.wala.cast.js + com.ibm.wala.cast.js.html.nu_validator + com.ibm.wala.cast.js.test + com.ibm.wala.cast.js.test.data + com.ibm.wala.cast.js.rhino + com.ibm.wala.cast.js.rhino.test + com.ibm.wala.cast.js.nodejs + com.ibm.wala.cast.js.nodejs.test + com.ibm.wala.ide.jsdt + com.ibm.wala.ide.jsdt.tests + com.ibm.wala-repository + + + + default + + true + + + targets + com.ibm.wala_feature + com.ibm.wala.core + com.ibm.wala.shrike + com.ibm.wala.util + com.ibm.wala.core.testdata + com.ibm.wala.core.tests + com.ibm.wala.cast + com.ibm.wala.cast.test + com.ibm.wala.cast.java + com.ibm.wala.cast.java.test + com.ibm.wala.cast.java.test.data + com.ibm.wala.cast.java.ecj + com.ibm.wala.ide_feature + com.ibm.wala.ide + com.ibm.wala.ide.tests + com.ibm.wala.ide.jdt + com.ibm.wala.ide.jdt.test + com.ibm.wala.cast.js + com.ibm.wala.cast.js.html.nu_validator + com.ibm.wala.cast.js.test + com.ibm.wala.cast.js.test.data + com.ibm.wala.cast.js.rhino + com.ibm.wala.cast.js.rhino.test + com.ibm.wala.cast.js.nodejs + com.ibm.wala.cast.js.nodejs.test + com.ibm.wala.ide.jsdt + com.ibm.wala.ide.jsdt.tests + com.ibm.wala.dalvik + com.ibm.wala.dalvik.test + com.ibm.wala.scandroid + com.ibm.wala-repository + + + + linux + + + unix + Linux + + + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + + ignore + + + + + + - +