further refactoring to enable more reuse

eliminate all non-jva 8 compilation
This commit is contained in:
Julian Dolby 2018-02-05 15:18:37 -08:00
parent b7d9d037a6
commit c8cdaf8616
80 changed files with 495 additions and 815 deletions

View File

@ -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

View File

@ -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());
}
}

View File

@ -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);
}
// ///////////////////////////////////////////////////////////////////////////

View File

@ -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

View File

@ -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));
}

View File

@ -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<AbstractRootMethod, CrossLanguageCallGraph> 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());
};
}

View File

@ -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));
}

View File

@ -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<? extends Entrypoint> 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

View File

@ -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();

View File

@ -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);

View File

@ -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) {

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -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++)

View File

@ -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;

View File

@ -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

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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<AbstractRootMethod, CrossLanguageCallGraph> roots, IClassHierarchy cha,
public CrossLanguageCallGraph(TargetLanguageSelector<AbstractRootMethod, CrossLanguageCallGraph> 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) {

View File

@ -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<AbstractRootMethod, CrossLanguageCallGraph> 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) {

View File

@ -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;
}

View File

@ -3230,8 +3230,10 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
protected boolean visitFunctionEntity(CAstEntity n, WalkContext context, WalkContext codeContext, CAstVisitor<WalkContext> visitor) {
if (n.getAST() == null) // presumably abstract
declareFunction(n, context);
else
else {
declareFunction(n, context);
initFunctionEntity(codeContext);
}
return false;
}

View File

@ -115,7 +115,7 @@ public class ExposedNamesCollector extends CAstVisitor<ExposedNamesCollector.Ent
}
}
if (declaringEntity != null) {
// System.err.println("marking " + nm + " from entity " + declaringEntity + " as exposed");
// System.err.println("marking " + nm + " from entity " + declaringEntity + " as exposed");
MapUtil.findOrCreateSet(entity2ExposedNames, declaringEntity).add(nm);
}
}

View File

@ -20,6 +20,7 @@ import java.util.Set;
import com.ibm.wala.cast.tree.CAst;
import com.ibm.wala.cast.tree.CAstEntity;
import com.ibm.wala.cast.tree.CAstNode;
import com.ibm.wala.cast.tree.CAstSourcePositionMap.Position;
import com.ibm.wala.cast.tree.impl.CAstControlFlowRecorder;
import com.ibm.wala.cast.tree.impl.CAstNodeTypeMapRecorder;
import com.ibm.wala.cast.tree.impl.CAstSourcePositionRecorder;
@ -324,4 +325,13 @@ public interface TranslatorToCAst {
}
}
default <X extends WalkContext<X,Y>, Y> void pushSourcePosition(WalkContext<X, Y> 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);
}
}
}
}

View File

@ -368,4 +368,5 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader {
}
}
}

View File

@ -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

View File

@ -386,7 +386,8 @@ public abstract class CAstVisitor<C extends CAstVisitor.Context> {
*
* @return true if node was handled
*/
protected boolean doVisitAssignNodes() {
@SuppressWarnings("unused")
protected boolean doVisitAssignNodes(CAstNode n, C context, CAstNode v, CAstNode a, CAstVisitor<C> visitor) {
return false;
}
@ -967,8 +968,16 @@ public abstract class CAstVisitor<C extends CAstVisitor.Context> {
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<C extends CAstVisitor.Context> {
* @param c a visitor-specific context
*/
protected void leaveVarAssign(CAstNode n, CAstNode v, CAstNode a, C c, @SuppressWarnings("unused") CAstVisitor<C> 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<C> 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<C> visitor) { /* empty */ }
/**
* Visit a Var Op/Assignment node after visiting the RHS.
* @param n the LHS node to process

View File

@ -35,7 +35,7 @@
<delete dir="${temp.folder}"/>
<mkdir dir="${temp.folder}/JLex"/>
<get src="http://www.cs.princeton.edu/~appel/modern/java/JLex/current/Main.java" dest="${temp.folder}/JLex/Main.java"/>
<javac target="1.4" source="1.4" includeAntRuntime="no" srcdir="${temp.folder}" destdir="${temp.folder}"/>
<javac includeAntRuntime="no" srcdir="${temp.folder}" destdir="${temp.folder}"/>
<jar destfile="${plugin.destination}/JLex.jar" basedir="${temp.folder}" />
<delete dir="${temp.folder}"/>
</target>
@ -120,12 +120,7 @@
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/jdk"/>
</antcall>
<antcall target="gather.bin.parts">
<param name="destination.temp.folder" value="${temp.folder}/dalvik/"/>
</antcall>
<zip destfile="${plugin.destination}/bin/com.ibm.wala.core.testdata_1.0.0a.jar" basedir="${temp.folder}/dalvik/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false" excludes="**/CodeDeleted.class"/>
<zip destfile="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0a.jar" basedir="${temp.folder}/dalvik/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false" excludes="**/CodeDeleted.class"/>
<zip destfile="${plugin.destination}/bin/com.ibm.wala.core.testdata_1.0.0.jar" basedir="${temp.folder}/jdk/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false"/>
<zip destfile="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0a.jar" basedir="${temp.folder}/jdk/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false" excludes="**/CodeDeleted.class,**/SortingExample.class,**/A.class"/>
<zip destfile="${plugin.destination}/com.ibm.wala.core.testdata_1.0.0.jar" basedir="${temp.folder}/jdk/com.ibm.wala.core.testdata_1.0.0" filesonly="false" whenempty="skip" update="false"/>
<delete dir="${temp.folder}"/>
</target>
@ -163,12 +158,6 @@
<param name="jtv" value="${bundleJavacTarget}"/>
<param name="excludes" value="**/bak/"/>
</antcall>
<antcall target="@dot">
<param name="destdir" value="${temp.folder}/dalvik/@dot"/>
<param name="jsv" value="1.6"/>
<param name="jtv" value="1.6"/>
<param name="excludes" value="**/bak/,**/SortingExample.java,defaultMethods/*.java,special/A.java,bug144/A.java,annotations/TypeAnnotatedClass*.java, annotations/TypeAnnotationTypeUse.java"/>
</antcall>
</target>
<target name="build.sources" depends="init">

View File

@ -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<Entrypoint> 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);

View File

@ -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<Entrypoint> 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")) {

View File

@ -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<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(options, cache, cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, cache, cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
if (testPAtoString) {
builder.getPointerAnalysis().toString();

View File

@ -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<InstanceKey> cgBuilder = Util.makeZeroCFABuilder(options, analysisCache, cha, scope);
CallGraphBuilder<InstanceKey> 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());

View File

@ -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<InstanceKey> builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
cg = builder.makeCallGraph(options, null);
pointerAnalysis = builder.getPointerAnalysis();

View File

@ -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<InstanceKey> builder = Util.makeZeroCFABuilder(options, cache, cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
cg = builder.makeCallGraph(options, null);
pointerAnalysis = builder.getPointerAnalysis();

View File

@ -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<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(),cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();

View File

@ -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<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
// System.err.println(pa);

View File

@ -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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
CGNode main = findMainMethod(cg);

View File

@ -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<InstanceKey> 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<IFlowLabel>());
// fullDemandPointsTo.setOnTheFly(true);

View File

@ -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<IFlowLabel>());
// fullDemandPointsTo.setCGRefinePolicy(new AlwaysRefineCGPolicy());

View File

@ -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<InstanceK
@Override
protected CallGraphBuilder<InstanceKey> getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) {
return Util.makeZeroCFABuilder(options, cache, cha, scope);
return Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
}
/**

View File

@ -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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg);
TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = reachingDefs.analyze();

View File

@ -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<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "LstaticInit/TestStaticInit");
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = null;
try {
cg = builder.makeCallGraph(options, null);

View File

@ -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<InstanceKey> builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();

View File

@ -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<InstanceKey> builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
System.err.println(CallGraphStats.getStats(cg));

View File

@ -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<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options,null);
final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();
SDG<?> sdg = new SDG<>(cg, pointerAnalysis, dOptions, cOptions);

View File

@ -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<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraphBuilder<InstanceKey> 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);

View File

@ -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()));
}
/**

View File

@ -65,7 +65,8 @@ public final class InterprocNullPointerAnalysis {
private final MethodState defaultMethodState;
private final Map<CGNode, IntraprocAnalysisState> 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);

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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<CHAContextInterpreter> {
@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;

View File

@ -54,7 +54,7 @@ import com.ibm.wala.util.warnings.Warnings;
*/
public abstract class AbstractRootMethod extends SyntheticMethod {
final protected ArrayList<SSAInstruction> statements = new ArrayList<>();
public final ArrayList<SSAInstruction> statements = new ArrayList<>();
private Map<ConstantValue, Integer> 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

View File

@ -61,12 +61,13 @@ public class ExplicitCallGraph extends BasicCallGraph<SSAContextInterpreter> 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<SSAContextInterpreter> 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<SSAContextInterpreter> 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<SSAContextInterpreter> 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);
}
/**

View File

@ -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<Atom, IField> fakeRootStaticFields = null;
private Set<IMethod> 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

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -175,22 +175,22 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
* @param options governing call graph construction options
* @param pointerKeyFactory factory which embodies pointer abstraction policy
*/
protected PropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
protected PropagationCallGraphBuilder(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache,
PointerKeyFactory pointerKeyFactory) {
if (cha == null) {
if (abstractRootMethod == null) {
throw new IllegalArgumentException("cha is null");
}
if (options == null) {
throw new IllegalArgumentException("options is null");
}
assert cache != null;
this.cha = cha;
this.cha = abstractRootMethod.getClassHierarchy();
this.options = options;
this.analysisCache = cache;
// we need pointer keys to handle reflection
assert pointerKeyFactory != null;
this.pointerKeyFactory = pointerKeyFactory;
callGraph = createEmptyCallGraph(cha, options);
callGraph = createEmptyCallGraph(abstractRootMethod, options);
try {
callGraph.init();
} catch (CancelException e) {
@ -202,8 +202,8 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
JAVA_LANG_OBJECT = cha.lookupClass(TypeReference.JavaLangObject);
}
protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) {
return new ExplicitCallGraph(cha, options, getAnalysisCache());
protected ExplicitCallGraph createEmptyCallGraph(IMethod abstractRootMethod, AnalysisOptions options) {
return new ExplicitCallGraph(abstractRootMethod, options, getAnalysisCache());
}
/**

View File

@ -40,7 +40,6 @@ import com.ibm.wala.ipa.callgraph.IAnalysisCacheView;
import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod;
import com.ibm.wala.ipa.callgraph.impl.DefaultEntrypoint;
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.shrikeBT.ConditionalBranchInstruction;
import com.ibm.wala.shrikeBT.IInvokeInstruction;
@ -159,9 +158,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
public IProgressMonitor monitor;
protected SSAPropagationCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
protected SSAPropagationCallGraphBuilder(IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache,
PointerKeyFactory pointerKeyFactory) {
super(cha, options, cache, pointerKeyFactory);
super(abstractRootMethod, options, cache, pointerKeyFactory);
// this.usePreTransitiveSolver = options.usePreTransitiveSolver();
}
@ -1581,7 +1580,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
}
caller.addTarget(instruction.getCallSite(), target);
if (FakeRootMethod.isFakeRootMethod(caller.getMethod().getReference())) {
if (callGraph.getFakeRootNode().equals(caller)) {
if (entrypointCallSites.contains(instruction.getCallSite())) {
callGraph.registerEntrypoint(target);
}

View File

@ -11,6 +11,7 @@
package com.ibm.wala.ipa.callgraph.propagation.cfa;
import com.ibm.wala.analysis.reflection.ReflectionContextInterpreter;
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.ContextSelector;
@ -27,10 +28,10 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
*/
public class ZeroXCFABuilder extends SSAPropagationCallGraphBuilder {
public ZeroXCFABuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector,
public ZeroXCFABuilder(Language l, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector,
SSAContextInterpreter appContextInterpreter, int instancePolicy) {
super(cha, options, cache, new DefaultPointerKeyFactory());
super(l.getFakeRootMethod(cha, options, cache), options, cache, new DefaultPointerKeyFactory());
ContextSelector def = new DefaultContextSelector(options, cha);
ContextSelector contextSelector = appContextSelector == null ? def : new DelegatingContextSelector(appContextSelector, def);
@ -80,15 +81,15 @@ public class ZeroXCFABuilder extends SSAPropagationCallGraphBuilder {
Util.addBypassLogic(options, scope, cl, xmlFile, cha);
}
return new ZeroXCFABuilder(cha, options, cache, null, null, instancePolicy);
return new ZeroXCFABuilder(Language.JAVA, cha, options, cache, null, null, instancePolicy);
}
public static ZeroXCFABuilder make(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
public static ZeroXCFABuilder make(Language l, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, int instancePolicy) throws IllegalArgumentException {
if (options == null) {
throw new IllegalArgumentException("options == null");
}
return new ZeroXCFABuilder(cha, options, cache, appContextSelector, appContextInterpreter, instancePolicy);
return new ZeroXCFABuilder(l, cha, options, cache, appContextSelector, appContextInterpreter, instancePolicy);
}
}

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package com.ibm.wala.ipa.callgraph.propagation.cfa;
import com.ibm.wala.classLoader.Language;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.IAnalysisCacheView;
@ -32,7 +33,7 @@ public class ZeroXContainerCFABuilder extends ZeroXCFABuilder {
public ZeroXContainerCFABuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, int instancePolicy) {
super(cha, options, cache, appContextSelector, appContextInterpreter, instancePolicy);
super(Language.JAVA, cha, options, cache, appContextSelector, appContextInterpreter, instancePolicy);
ContextSelector CCS = makeContainerContextSelector(cha, (ZeroXInstanceKeys) getInstanceKeys());
DelegatingContextSelector DCS = new DelegatingContextSelector(CCS, contextSelector);

View File

@ -12,6 +12,7 @@
package com.ibm.wala.ipa.callgraph.propagation.cfa;
import com.ibm.wala.analysis.reflection.ReflectionContextInterpreter;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.IAnalysisCacheView;
@ -20,7 +21,6 @@ import com.ibm.wala.ipa.callgraph.impl.DelegatingContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.ClassBasedInstanceKeys;
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.ipa.cha.IClassHierarchy;
/**
* nCFA Call graph builder. Note that by default, this builder uses a
@ -28,10 +28,10 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
*/
public class nCFABuilder extends SSAPropagationCallGraphBuilder {
public nCFABuilder(int n, IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector,
public nCFABuilder(int n, IMethod abstractRootMethod, AnalysisOptions options, IAnalysisCacheView cache, ContextSelector appContextSelector,
SSAContextInterpreter appContextInterpreter) {
super(cha, options, cache, new DefaultPointerKeyFactory());
super(abstractRootMethod, options, cache, new DefaultPointerKeyFactory());
if (options == null) {
throw new IllegalArgumentException("options is null");
}

View File

@ -17,6 +17,7 @@ import com.ibm.wala.analysis.reflection.ReflectionContextInterpreter;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.Language;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.fixpoint.UnaryOperator;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
@ -99,7 +100,7 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
protected AbstractRTABuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache,
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter) {
super(cha, options, cache, new DefaultPointerKeyFactory());
super(Language.JAVA.getFakeRootMethod(cha, options, cache), options, cache, new DefaultPointerKeyFactory());
setInstanceKeys(new ClassBasedInstanceKeys(options, cha));
setContextSelector(makeContextSelector(appContextSelector));
setContextInterpreter(makeContextInterpreter(appContextInterpreter));
@ -281,7 +282,7 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
}
caller.addTarget(site, target);
if (FakeRootMethod.isFakeRootMethod(caller.getMethod().getReference())) {
if (caller.equals(callGraph.getFakeRootNode())) {
if (entrypointCallSites.contains(site)) {
callGraph.registerEntrypoint(target);
}
@ -395,8 +396,8 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
}
@Override
protected ExplicitCallGraph createEmptyCallGraph(IClassHierarchy cha, AnalysisOptions options) {
return new DelegatingExplicitCallGraph(cha, options, getAnalysisCache());
protected ExplicitCallGraph createEmptyCallGraph(IMethod fakeRootClass, AnalysisOptions options) {
return new DelegatingExplicitCallGraph(fakeRootClass, options, getAnalysisCache());
}
/*

View File

@ -19,7 +19,6 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.IAnalysisCacheView;
import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.intset.BasicNaturalRelation;
import com.ibm.wala.util.intset.BitVectorIntSet;
@ -45,8 +44,8 @@ public class DelegatingExplicitCallGraph extends ExplicitCallGraph {
* @param cha
* @param options
*/
public DelegatingExplicitCallGraph(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) {
super(cha, options, cache);
public DelegatingExplicitCallGraph(IMethod fakeRootClass, AnalysisOptions options, IAnalysisCacheView cache) {
super(fakeRootClass, options, cache);
}
/**

View File

@ -62,15 +62,13 @@
<available file="${plugin.destination}/data/android.jar" property="android.jar.present"/>
</target>
<target name="fetchDxJar" depends="dxJarPresent" unless="dx.jar.present">
<target name="fetchDxJar">
<mkdir dir="${basedir}/lib/"/>
<get src="http://central.maven.org/maven2/com/google/android/tools/dx/1.7/dx-1.7.jar" dest="${basedir}/lib/dx.jar" />
<copy
file="${env.ANDROID_HOME}/build-tools/26.0.2/lib/dx.jar"
tofile="${basedir}/lib/dx.jar" force="true"/>
</target>
<target name="dxJarPresent" depends="init">
<available file="${basedir}/lib/dx.jar" property="dx.jar.present"/>
</target>
<target name="getJars" depends="fetchSampleLex,fetchSampleCup,fetchAndroidJar,fetchDxJar" />
<target name="init" depends="properties">

View File

@ -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);

View File

@ -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<Entrypoint> 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());
}

View File

@ -78,12 +78,12 @@
<dependency>
<groupId>org.smali</groupId>
<artifactId>dexlib2</artifactId>
<version>2.2.1</version>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.smali</groupId>
<artifactId>util</artifactId>
<version>2.2.1</version>
<version>2.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>

View File

@ -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 <atomb@galois.com>, Rogan Creswick <creswick@galois.com>)
* Steve Suh <suhsteve@gmail.com>
*
* 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);
}
}

View File

@ -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 <atomb@galois.com>, Rogan Creswick <creswick@galois.com>)
* Steve Suh <suhsteve@gmail.com>
*
* 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<TypeReference, Integer> referenceTypeMap = new HashMap<>();
// public static Set<TypeReference> referenceTypeSet = new HashSet<TypeReference>();
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<IClass> 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;
}
}

View File

@ -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 <atomb@galois.com>, Rogan Creswick <creswick@galois.com>)
* Steve Suh <suhsteve@gmail.com>
*
* 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());
}
}

File diff suppressed because one or more lines are too long

View File

@ -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<InstanceKey> 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;

View File

@ -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<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, cache, cha, scope);
CallGraphBuilder<InstanceKey> 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");

View File

@ -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<InstanceKey> builder = Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope, null,
com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope, null,
null);
CallGraph cg = builder.makeCallGraph(options,null);

View File

@ -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<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCacheImpl(),cha, scope, null, null);
com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope, null, null);
CallGraph cg = builder.makeCallGraph(options,null);
PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();

View File

@ -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);
}

170
pom.xml
View File

@ -14,81 +14,107 @@
<tycho-version>0.23.1</tycho-version>
<tycho.scmUrl>scm:git:ssh://github.com:wala/WALA.git</tycho.scmUrl>
</properties>
<modules>
<module>targets</module>
<module>com.ibm.wala_feature</module>
<module>com.ibm.wala.core</module>
<module>com.ibm.wala.shrike</module>
<module>com.ibm.wala.util</module>
<module>com.ibm.wala.core.testdata</module>
<module>com.ibm.wala.core.tests</module>
<module>com.ibm.wala.cast</module>
<module>com.ibm.wala.cast.test</module>
<module>com.ibm.wala.cast.java</module>
<module>com.ibm.wala.cast.java.test</module>
<module>com.ibm.wala.cast.java.test.data</module>
<module>com.ibm.wala.cast.java.ecj</module>
<module>com.ibm.wala.ide_feature</module>
<module>com.ibm.wala.ide</module>
<module>com.ibm.wala.ide.tests</module>
<module>com.ibm.wala.ide.jdt</module>
<module>com.ibm.wala.ide.jdt.test</module>
<module>com.ibm.wala.cast.js</module>
<module>com.ibm.wala.cast.js.html.nu_validator</module>
<module>com.ibm.wala.cast.js.test</module>
<module>com.ibm.wala.cast.js.test.data</module>
<module>com.ibm.wala.cast.js.rhino</module>
<module>com.ibm.wala.cast.js.rhino.test</module>
<module>com.ibm.wala.cast.js.nodejs</module>
<module>com.ibm.wala.cast.js.nodejs.test</module>
<module>com.ibm.wala.ide.jsdt</module>
<module>com.ibm.wala.ide.jsdt.tests</module>
<module>com.ibm.wala.dalvik</module>
<module>com.ibm.wala.dalvik.test</module>
<module>com.ibm.wala.scandroid</module>
<module>com.ibm.wala-repository</module>
</modules>
<profiles>
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>noAndroid</id>
<modules>
<module>targets</module>
<module>com.ibm.wala_feature</module>
<module>com.ibm.wala.core</module>
<module>com.ibm.wala.shrike</module>
<module>com.ibm.wala.util</module>
<module>com.ibm.wala.core.testdata</module>
<module>com.ibm.wala.core.tests</module>
<module>com.ibm.wala.cast</module>
<module>com.ibm.wala.cast.test</module>
<module>com.ibm.wala.cast.java</module>
<module>com.ibm.wala.cast.java.test</module>
<module>com.ibm.wala.cast.java.test.data</module>
<module>com.ibm.wala.cast.java.ecj</module>
<module>com.ibm.wala.ide_feature</module>
<module>com.ibm.wala.ide</module>
<module>com.ibm.wala.ide.tests</module>
<module>com.ibm.wala.ide.jdt</module>
<module>com.ibm.wala.ide.jdt.test</module>
<module>com.ibm.wala.cast.js</module>
<module>com.ibm.wala.cast.js.html.nu_validator</module>
<module>com.ibm.wala.cast.js.test</module>
<module>com.ibm.wala.cast.js.test.data</module>
<module>com.ibm.wala.cast.js.rhino</module>
<module>com.ibm.wala.cast.js.rhino.test</module>
<module>com.ibm.wala.cast.js.nodejs</module>
<module>com.ibm.wala.cast.js.nodejs.test</module>
<module>com.ibm.wala.ide.jsdt</module>
<module>com.ibm.wala.ide.jsdt.tests</module>
<module>com.ibm.wala-repository</module>
</modules>
</profile>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>targets</module>
<module>com.ibm.wala_feature</module>
<module>com.ibm.wala.core</module>
<module>com.ibm.wala.shrike</module>
<module>com.ibm.wala.util</module>
<module>com.ibm.wala.core.testdata</module>
<module>com.ibm.wala.core.tests</module>
<module>com.ibm.wala.cast</module>
<module>com.ibm.wala.cast.test</module>
<module>com.ibm.wala.cast.java</module>
<module>com.ibm.wala.cast.java.test</module>
<module>com.ibm.wala.cast.java.test.data</module>
<module>com.ibm.wala.cast.java.ecj</module>
<module>com.ibm.wala.ide_feature</module>
<module>com.ibm.wala.ide</module>
<module>com.ibm.wala.ide.tests</module>
<module>com.ibm.wala.ide.jdt</module>
<module>com.ibm.wala.ide.jdt.test</module>
<module>com.ibm.wala.cast.js</module>
<module>com.ibm.wala.cast.js.html.nu_validator</module>
<module>com.ibm.wala.cast.js.test</module>
<module>com.ibm.wala.cast.js.test.data</module>
<module>com.ibm.wala.cast.js.rhino</module>
<module>com.ibm.wala.cast.js.rhino.test</module>
<module>com.ibm.wala.cast.js.nodejs</module>
<module>com.ibm.wala.cast.js.nodejs.test</module>
<module>com.ibm.wala.ide.jsdt</module>
<module>com.ibm.wala.ide.jsdt.tests</module>
<module>com.ibm.wala.dalvik</module>
<module>com.ibm.wala.dalvik.test</module>
<module>com.ibm.wala.scandroid</module>
<module>com.ibm.wala-repository</module>
</modules>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<dependency-resolution>
<optionalDependencies>ignore</optionalDependencies>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>