This commit is contained in:
commit
774be73672
|
@ -1,15 +1,37 @@
|
|||
target/
|
||||
*.DS_Store
|
||||
*.class
|
||||
*.out
|
||||
*.swp
|
||||
*/bin/
|
||||
com.ibm.wala.cast.js.rhino/lib/
|
||||
com.ibm.wala.cast.js/lib/
|
||||
*/bin/*
|
||||
*~
|
||||
.metadata/
|
||||
com.ibm.wala.cast.java.jdt.test/
|
||||
com.ibm.wala.cast.java.polyglot/lib/
|
||||
com.ibm.wala.cast.java.test.data/src/JLex/
|
||||
.metadata/
|
||||
*~
|
||||
com.ibm.wala.cast.js.test.data/examples-src/ajaxslt/
|
||||
com.ibm.wala.core.testdata/@dot/
|
||||
com.ibm.wala.core.testdata/*.jar
|
||||
com.ibm.wala.core/dat/wala.properties
|
||||
com.ibm.wala.core.tests/dat/wala.examples.properties
|
||||
com.ibm.wala.cast.java.test/testdata/
|
||||
com.ibm.wala.cast.js.html.nu_validator/lib/
|
||||
com.ibm.wala.cast.js.rhino.test/*.dump
|
||||
com.ibm.wala.cast.js.rhino.test/*.html*
|
||||
com.ibm.wala.cast.js.rhino.test/2009_swine_flu_outbreak
|
||||
com.ibm.wala.cast.js.rhino.test/?game*
|
||||
com.ibm.wala.cast.js.rhino.test/BunnyHunt
|
||||
com.ibm.wala.cast.js.rhino.test/digg_attack
|
||||
com.ibm.wala.cast.js.rhino.test/game.php*
|
||||
com.ibm.wala.cast.js.rhino.test/xxxx
|
||||
com.ibm.wala.cast.js.rhino/lib/
|
||||
com.ibm.wala.cast.js.test.data/examples-src/ajaxslt/
|
||||
com.ibm.wala.cast.js.test/examples-src/ajaxslt/
|
||||
com.ibm.wala.cast.js/lib/
|
||||
com.ibm.wala.core.testdata/*.jar
|
||||
com.ibm.wala.core.testdata/@dot/
|
||||
com.ibm.wala.core.testdata/lib/
|
||||
com.ibm.wala.core.tests/dat/wala.examples.properties
|
||||
com.ibm.wala.core.tests/report
|
||||
com.ibm.wala.core/@dot
|
||||
com.ibm.wala.core/com.ibm.wala.core*.jar
|
||||
com.ibm.wala.core/dat/wala.properties
|
||||
com.ibm.wala.dalvik/src/logback.xml
|
||||
com.ibm.wala.ide.jdt.test/testdata/
|
||||
edu.kit.wala.smali.test/out/
|
||||
target/
|
||||
|
|
15
README.md
15
README.md
|
@ -1,2 +1,13 @@
|
|||
This is the main source repository for WALA. For more details on WALA, see <a
|
||||
href="http://wala.sourceforge.net">the WALA home page</a>.
|
||||
# About WALA
|
||||
|
||||
This is a fork of the program analysis framework WALA. The original framework can be found at <a href="http://wala.sourceforge.net">wala.sourceforge.net</a> and <a href="https://github.com/wala/WALA">github.com/wala/WALA</a>.
|
||||
|
||||
This version is tailored for the information flow control framework JOANA. See <a href="http://joana.ipd.kit.edu">joana.ipd.kit.edu</a> and <a href="https://github.com/jgf/joana">github.com/jgf/joana</a> for details.
|
||||
|
||||
This fork includes some additional features:
|
||||
- null-pointer detection that removes spurious CFG edges.
|
||||
- it includes the code for a dalivk bytecode frontend copied and integrated from <a href="https://github.com/SCanDroid/SCanDroid">github.com/SCanDroid/SCanDroid</a>.
|
||||
- configuration/property files are loaded from current directory, with an automatic fallback to load from .jar.
|
||||
- SDG implementation that has different edge types for control and data dependencies.
|
||||
- every SSAInstrution knows its index.
|
||||
- many other minor changes.
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.ibm.wala.ide.jdt.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -7,6 +7,9 @@
|
|||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
|
||||
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
|
||||
</mapAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/console.txt"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
|
|
|
@ -40,6 +40,8 @@ import com.ibm.wala.classLoader.SourceFileModule;
|
|||
import com.ibm.wala.client.AbstractAnalysisEngine;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.properties.WalaProperties;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
|
@ -344,8 +346,8 @@ public abstract class IRTests {
|
|||
|
||||
protected abstract AbstractAnalysisEngine getAnalysisEngine(String[] mainClassDescriptors, Collection<String> sources, List<String> libs);
|
||||
|
||||
public Pair runTest(Collection<String> sources, List<String> libs, String[] mainClassDescriptors, List<? extends IRAssertion> ca,
|
||||
boolean assertReachable) {
|
||||
public Pair<CallGraph, PointerAnalysis<InstanceKey>> runTest(Collection<String> sources, List<String> libs,
|
||||
String[] mainClassDescriptors, List<? extends IRAssertion> ca, boolean assertReachable) {
|
||||
AbstractAnalysisEngine engine = getAnalysisEngine(mainClassDescriptors, sources, libs);
|
||||
|
||||
CallGraph callGraph;
|
||||
|
|
|
@ -379,12 +379,13 @@ public abstract class JavaIRTests extends IRTests {
|
|||
}
|
||||
|
||||
@Test public void testInnerClassA() {
|
||||
Pair x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
|
||||
Pair<CallGraph, PointerAnalysis<InstanceKey>> x =
|
||||
runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
|
||||
|
||||
// can't do an IRAssertion() -- we need the pointer analysis
|
||||
|
||||
CallGraph cg = (CallGraph) x.fst;
|
||||
PointerAnalysis pa = (PointerAnalysis) x.snd;
|
||||
CallGraph cg = x.fst;
|
||||
PointerAnalysis<InstanceKey> pa = x.snd;
|
||||
|
||||
Iterator<CGNode> iter = cg.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
|
@ -437,12 +438,13 @@ public abstract class JavaIRTests extends IRTests {
|
|||
}
|
||||
|
||||
@Test public void testInnerClassSuper() {
|
||||
Pair x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
|
||||
Pair<CallGraph, PointerAnalysis<InstanceKey>> x =
|
||||
runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), new ArrayList<IRAssertion>(), true);
|
||||
|
||||
// can't do an IRAssertion() -- we need the pointer analysis
|
||||
|
||||
CallGraph cg = (CallGraph) x.fst;
|
||||
PointerAnalysis pa = (PointerAnalysis) x.snd;
|
||||
CallGraph cg = x.fst;
|
||||
PointerAnalysis<InstanceKey> pa = x.snd;
|
||||
|
||||
Iterator<CGNode> iter = cg.iterator();
|
||||
while ( iter.hasNext() ) {
|
||||
|
@ -594,10 +596,10 @@ public abstract class JavaIRTests extends IRTests {
|
|||
}
|
||||
|
||||
@Test public void testMiniaturSliceBug() throws IllegalArgumentException, CancelException {
|
||||
Pair<?, ?> x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true);
|
||||
Pair<CallGraph, PointerAnalysis<InstanceKey>> x = runTest(singleTestSrc(), rtJar, simpleTestEntryPoint(), emptyList, true);
|
||||
|
||||
PointerAnalysis pa = (PointerAnalysis) x.snd;
|
||||
CallGraph cg = (CallGraph) x.fst;
|
||||
PointerAnalysis<InstanceKey> pa = x.snd;
|
||||
CallGraph cg = x.fst;
|
||||
|
||||
// test partial slice
|
||||
MethodReference sliceRootRef = getSliceRootReference("MiniaturSliceBug", "validNonDispatchedCall", "(LIntWrapper;)V");
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
|
|
@ -18,6 +18,7 @@ import com.ibm.wala.cast.java.ssa.AstJavaInstructionVisitor;
|
|||
import com.ibm.wala.cast.java.ssa.AstJavaInvokeInstruction;
|
||||
import com.ibm.wala.cast.java.ssa.EnclosingObjectReference;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
|
||||
|
@ -29,7 +30,7 @@ public class AstJavaModRef extends AstModRef {
|
|||
implements AstJavaInstructionVisitor
|
||||
{
|
||||
|
||||
protected AstJavaRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected AstJavaRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
|
||||
super(n, result, pa, (AstHeapModel)h);
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ public class AstJavaModRef extends AstModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
|
||||
return new AstJavaRefVisitor(n, result, pa, h);
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class AstJavaModRef extends AstModRef {
|
|||
implements AstJavaInstructionVisitor
|
||||
{
|
||||
|
||||
protected AstJavaModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis pa) {
|
||||
protected AstJavaModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis<InstanceKey> pa) {
|
||||
super(n, result, (AstHeapModel)h, pa);
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ public class AstJavaModRef extends AstModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
return new AstJavaModVisitor(n, result, h, pa);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import com.ibm.wala.cast.java.ipa.modref.AstJavaModRef;
|
|||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.impl.PartialCallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.slicer.NormalStatement;
|
||||
import com.ibm.wala.ipa.slicer.SDG;
|
||||
|
@ -111,7 +112,7 @@ public class AstJavaSlicer extends Slicer {
|
|||
});
|
||||
}
|
||||
|
||||
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis pa,
|
||||
public static Pair<Collection<Statement>, SDG> computeAssertionSlice(CallGraph CG, PointerAnalysis<InstanceKey> pa,
|
||||
Collection<CGNode> partialRoots, boolean multiThreadedCode) throws IllegalArgumentException, CancelException {
|
||||
CallGraph pcg = PartialCallGraph.make(CG, new LinkedHashSet<CGNode>(partialRoots));
|
||||
SDG sdg = new SDG(pcg, pa, new AstJavaModRef(), DataDependenceOptions.FULL, ControlDependenceOptions.FULL);
|
||||
|
|
|
@ -87,6 +87,9 @@ import com.ibm.wala.util.strings.Atom;
|
|||
*/
|
||||
public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
||||
public Map<CAstEntity, IClass> fTypeMap = HashMapFactory.make();
|
||||
/** BEGIN Custom change: Common superclass is optional */
|
||||
private final boolean existsCommonSuperclass; // extension to deal with X10 that has no common superclass
|
||||
/** END Custom change: Common superclass is optional */
|
||||
|
||||
/**
|
||||
* WALA representation of a Java class residing in a source file
|
||||
|
@ -135,7 +138,10 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
// The following test allows the root class to reside in source; without
|
||||
// it, the assertion requires all classes represented by a JavaClass to
|
||||
// have a superclass.
|
||||
if (!getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) {
|
||||
/** BEGIN Custom change: Common superclass is optional */
|
||||
// Is no longer true in new X10 - no common object super class
|
||||
if (existsCommonSuperclass && !getName().equals(JavaSourceLoaderImpl.this.getLanguage().getRootType().getName()) && !excludedSupertype) {
|
||||
/** END Custom change: Common superclass is optional */
|
||||
Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames);
|
||||
}
|
||||
|
||||
|
@ -477,9 +483,18 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
return result;
|
||||
}
|
||||
|
||||
public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
|
||||
/** BEGIN Custom change: Common superclass is optional */
|
||||
public JavaSourceLoaderImpl(boolean existsCommonSuperClass, ClassLoaderReference loaderRef, IClassLoader parent,
|
||||
SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
|
||||
super(loaderRef, cha.getScope().getArrayClassLoader(), parent, cha.getScope().getExclusions(), cha);
|
||||
this.existsCommonSuperclass = existsCommonSuperClass;
|
||||
}
|
||||
|
||||
public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
|
||||
// standard case: we have a common super class
|
||||
this(true, loaderRef, parent, exclusions, cha);
|
||||
}
|
||||
/** END Custom change: Common superclass is optional */
|
||||
|
||||
public IClassHierarchy getClassHierarchy() {
|
||||
return cha;
|
||||
|
@ -491,11 +506,19 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
}
|
||||
|
||||
protected abstract SourceModuleTranslator getTranslator();
|
||||
/** BEGIN Custom change: Optional deletion of fTypeMap */
|
||||
public static volatile boolean deleteTypeMapAfterInit = true;
|
||||
/** END Custom change: Optional deletion of fTypeMap */
|
||||
|
||||
|
||||
@Override
|
||||
public void init(List<Module> modules) throws IOException {
|
||||
super.init(modules);
|
||||
fTypeMap = null;
|
||||
/** BEGIN Custom change: Optional deletion of fTypeMap */
|
||||
if (deleteTypeMapAfterInit) {
|
||||
fTypeMap = null;
|
||||
}
|
||||
/** END Custom change: Optional deletion of fTypeMap */
|
||||
}
|
||||
|
||||
public void defineFunction(CAstEntity n, IClass owner, AbstractCFG cfg, SymbolTable symtab, boolean hasCatchBlock,
|
||||
|
@ -541,107 +564,107 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory {
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.java.ssa.EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type) {
|
||||
return new EnclosingObjectReference(lval, type);
|
||||
public com.ibm.wala.cast.java.ssa.EnclosingObjectReference EnclosingObjectReference(int iindex, int lval, TypeReference type) {
|
||||
return new EnclosingObjectReference(iindex, lval, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing) {
|
||||
return new AstJavaNewEnclosingInstruction(result, site, enclosing);
|
||||
public AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing) {
|
||||
return new AstJavaNewEnclosingInstruction(iindex, result, site, enclosing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstJavaInvokeInstruction JavaInvokeInstruction(int result[], int[] params, int exception, CallSiteReference site) {
|
||||
return result == null ? new AstJavaInvokeInstruction(params, exception, site) : new AstJavaInvokeInstruction(result[0],
|
||||
public AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int result[], int[] params, int exception, CallSiteReference site) {
|
||||
return result == null ? new AstJavaInvokeInstruction(iindex, params, exception, site) : new AstJavaInvokeInstruction(iindex, result[0],
|
||||
params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
|
||||
return new AstAssertInstruction(value, fromSpecification);
|
||||
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
|
||||
return new AstAssertInstruction(iindex, value, fromSpecification);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
|
||||
return new AssignInstruction(result, val);
|
||||
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
|
||||
return new AssignInstruction(iindex, result, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstEchoInstruction EchoInstruction(int[] rvals) {
|
||||
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
|
||||
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
|
||||
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(Access[] accesses) {
|
||||
return new AstLexicalRead(accesses);
|
||||
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
|
||||
return new AstLexicalRead(iindex, accesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(Access access) {
|
||||
return new AstLexicalRead(access);
|
||||
public AstLexicalRead LexicalRead(int iindex, Access access) {
|
||||
return new AstLexicalRead(iindex, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type) {
|
||||
return new AstLexicalRead(lhs, definer, globalName, type);
|
||||
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
|
||||
return new AstLexicalRead(iindex, lhs, definer, globalName, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(Access[] accesses) {
|
||||
return new AstLexicalWrite(accesses);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
|
||||
return new AstLexicalWrite(iindex, accesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(Access access) {
|
||||
return new AstLexicalWrite(access);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
|
||||
return new AstLexicalWrite(iindex, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
|
||||
return new AstLexicalWrite(definer, globalName, type, rhs);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
|
||||
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
|
||||
}
|
||||
|
||||
public SSAThrowInstruction NonExceptingThrowInstruction(int exception) {
|
||||
public SSAThrowInstruction NonExceptingThrowInstruction(int iindex, int exception) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ import com.ibm.wala.types.TypeReference;
|
|||
|
||||
public interface AstJavaInstructionFactory extends AstInstructionFactory {
|
||||
|
||||
AstJavaInvokeInstruction JavaInvokeInstruction(int result[], int[] params, int exception, CallSiteReference site);
|
||||
AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int result[], int[] params, int exception, CallSiteReference site);
|
||||
|
||||
EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type);
|
||||
EnclosingObjectReference EnclosingObjectReference(int iindex, int lval, TypeReference type);
|
||||
|
||||
AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing);
|
||||
AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,25 +22,25 @@ import com.ibm.wala.types.TypeReference;
|
|||
|
||||
public class AstJavaInvokeInstruction extends FixedParametersInvokeInstruction {
|
||||
|
||||
protected AstJavaInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(results, params, exception, site);
|
||||
protected AstJavaInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(iindex, results, params, exception, site);
|
||||
}
|
||||
|
||||
public AstJavaInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(new int[] { result }, params, exception, site);
|
||||
public AstJavaInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, new int[] { result }, params, exception, site);
|
||||
SSAInvokeInstruction.assertParamsKosher(result, params, site);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor InvokeInstruction. This case for void return values
|
||||
*/
|
||||
public AstJavaInvokeInstruction(int[] params, int exception, CallSiteReference site) {
|
||||
this(null, params, exception, site);
|
||||
public AstJavaInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, null, params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SSAInstruction copyInstruction(SSAInstructionFactory insts, int results[], int[] params, int exception) {
|
||||
return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(results, params, exception, getCallSite());
|
||||
return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(iindex, results, params, exception, getCallSite());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,8 +35,8 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
|
|||
return enclosing;
|
||||
}
|
||||
|
||||
public AstJavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing) throws IllegalArgumentException {
|
||||
super(result, site);
|
||||
public AstJavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing) throws IllegalArgumentException {
|
||||
super(iindex, result, site);
|
||||
this.enclosing = enclosing;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction {
|
|||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstJavaInstructionFactory)insts).JavaNewEnclosingInstruction(defs==null? getDef(0): defs[0], getNewSite(), uses==null? enclosing: uses[0]);
|
||||
return ((AstJavaInstructionFactory)insts).JavaNewEnclosingInstruction(iindex, defs==null? getDef(0): defs[0], getNewSite(), uses==null? enclosing: uses[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,8 @@ public class EnclosingObjectReference extends SSAInstruction {
|
|||
|
||||
private final int lval;
|
||||
|
||||
public EnclosingObjectReference(int lval, TypeReference type) {
|
||||
public EnclosingObjectReference(int iindex, int lval, TypeReference type) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ public class EnclosingObjectReference extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(defs == null ? lval : defs[0], type);
|
||||
return ((AstJavaInstructionFactory) insts).EnclosingObjectReference(iindex, defs == null ? lval : defs[0], type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -98,13 +98,13 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
|
||||
@Override
|
||||
protected void doThrow(WalkContext context, int exception) {
|
||||
context.cfg().addInstruction(insts.ThrowInstruction(exception));
|
||||
context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doArrayRead(WalkContext context, int result, int arrayValue, CAstNode arrayRefNode, int[] dimValues) {
|
||||
TypeReference arrayTypeRef = (TypeReference) arrayRefNode.getChild(1).getValue();
|
||||
context.cfg().addInstruction(insts.ArrayLoadInstruction(result, arrayValue, dimValues[0], arrayTypeRef));
|
||||
context.cfg().addInstruction(insts.ArrayLoadInstruction(context.cfg().getCurrentInstruction(), result, arrayValue, dimValues[0], arrayTypeRef));
|
||||
processExceptions(arrayRefNode, context);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
TypeReference arrayTypeRef = arrayRefNode.getKind() == CAstNode.ARRAY_LITERAL ? ((TypeReference) arrayRefNode.getChild(0)
|
||||
.getChild(0).getValue()).getArrayElementType() : (TypeReference) arrayRefNode.getChild(1).getValue();
|
||||
|
||||
context.cfg().addInstruction(insts.ArrayStoreInstruction(arrayValue, dimValues[0], rval, arrayTypeRef));
|
||||
context.cfg().addInstruction(insts.ArrayStoreInstruction(context.cfg().getCurrentInstruction(), arrayValue, dimValues[0], rval, arrayTypeRef));
|
||||
|
||||
processExceptions(arrayRefNode, context);
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
|
||||
if (receiver == -1) { // a static field: AstTranslator.getValue() produces
|
||||
// -1 for null, we hope
|
||||
context.cfg().addInstruction(insts.GetInstruction(result, fieldRef));
|
||||
context.cfg().addInstruction(insts.GetInstruction(context.cfg().getCurrentInstruction(), result, fieldRef));
|
||||
} else {
|
||||
context.cfg().addInstruction(insts.GetInstruction(result, receiver, fieldRef));
|
||||
context.cfg().addInstruction(insts.GetInstruction(context.cfg().getCurrentInstruction(), result, receiver, fieldRef));
|
||||
processExceptions(parent, context);
|
||||
}
|
||||
}
|
||||
|
@ -138,9 +138,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
|
||||
if (receiver == -1) { // a static field: AstTranslator.getValue() produces
|
||||
// -1 for null, we hope
|
||||
context.cfg().addInstruction(insts.PutInstruction(rval, fieldRef));
|
||||
context.cfg().addInstruction(insts.PutInstruction(context.cfg().getCurrentInstruction(), rval, fieldRef));
|
||||
} else {
|
||||
context.cfg().addInstruction(insts.PutInstruction(receiver, rval, fieldRef));
|
||||
context.cfg().addInstruction(insts.PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, fieldRef));
|
||||
processExceptions(parent, context);
|
||||
}
|
||||
}
|
||||
|
@ -158,10 +158,10 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
NewSiteReference site = NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef);
|
||||
|
||||
if (newNode.getKind() == CAstNode.NEW_ENCLOSING) {
|
||||
context.cfg().addInstruction(new AstJavaNewEnclosingInstruction(result, site, arguments[0]));
|
||||
context.cfg().addInstruction(new AstJavaNewEnclosingInstruction(context.cfg().getCurrentInstruction(), result, site, arguments[0]));
|
||||
} else {
|
||||
context.cfg().addInstruction(
|
||||
(arguments == null) ? insts.NewInstruction(result, site) : insts.NewInstruction(result, site, arguments));
|
||||
(arguments == null) ? insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site) : insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site, arguments));
|
||||
}
|
||||
processExceptions(newNode, context);
|
||||
}
|
||||
|
@ -197,9 +197,9 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
CallSiteReference realSiteRef = CallSiteReference.make(pc, dummySiteRef.getDeclaredTarget(), dummySiteRef.getInvocationCode());
|
||||
|
||||
if (realSiteRef.getDeclaredTarget().getReturnType().equals(TypeReference.Void))
|
||||
context.cfg().addInstruction(new AstJavaInvokeInstruction(realArgs, exception, realSiteRef));
|
||||
context.cfg().addInstruction(new AstJavaInvokeInstruction(context.cfg().getCurrentInstruction(), realArgs, exception, realSiteRef));
|
||||
else
|
||||
context.cfg().addInstruction(new AstJavaInvokeInstruction(result, realArgs, exception, realSiteRef));
|
||||
context.cfg().addInstruction(new AstJavaInvokeInstruction(context.cfg().getCurrentInstruction(), result, realArgs, exception, realSiteRef));
|
||||
processExceptions(call, context);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
} else {
|
||||
int result = c.currentScope().allocateTempValue();
|
||||
c.setValue(n, result);
|
||||
c.cfg().addInstruction(new EnclosingObjectReference(result, (TypeReference) n.getChild(0).getValue()));
|
||||
c.cfg().addInstruction(new EnclosingObjectReference(c.cfg().getCurrentInstruction(), result, (TypeReference) n.getChild(0).getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,23 +351,24 @@ public class JavaCAst2IRTranslator extends AstTranslator {
|
|||
TypeReference fromRef = makeType(fromType);
|
||||
|
||||
if (toRef.isPrimitiveType()) {
|
||||
context.cfg().addInstruction(
|
||||
insts.ConversionInstruction(
|
||||
context.cfg().addInstruction(
|
||||
insts.ConversionInstruction(
|
||||
context.cfg().getCurrentInstruction(),
|
||||
result,
|
||||
context.getValue(n.getChild(1)),
|
||||
fromRef,
|
||||
toRef,
|
||||
false));
|
||||
|
||||
} else {
|
||||
context.cfg().addInstruction(
|
||||
insts.CheckCastInstruction(
|
||||
context.cfg().getCurrentInstruction(),
|
||||
result,
|
||||
context.getValue(n.getChild(1)),
|
||||
toRef,
|
||||
true));
|
||||
|
||||
processExceptions(n, context);
|
||||
processExceptions(n, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,6 +387,7 @@ processExceptions(n, context);
|
|||
TypeReference ref = makeType( type );
|
||||
context.cfg().addInstruction(
|
||||
insts.InstanceofInstruction(
|
||||
context.cfg().getCurrentInstruction(),
|
||||
result,
|
||||
context.getValue(n.getChild(1)),
|
||||
ref));
|
||||
|
@ -395,13 +397,13 @@ processExceptions(n, context);
|
|||
protected boolean doVisit(CAstNode n, WalkContext wc, CAstVisitor<WalkContext> visitor) {
|
||||
if (n.getKind() == CAstNode.MONITOR_ENTER) {
|
||||
visitor.visit(n.getChild(0), wc, visitor);
|
||||
wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), true));
|
||||
wc.cfg().addInstruction(insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), wc.getValue(n.getChild(0)), true));
|
||||
processExceptions(n, wc);
|
||||
|
||||
return true;
|
||||
} else if (n.getKind() == CAstNode.MONITOR_EXIT) {
|
||||
visitor.visit(n.getChild(0), wc, visitor);
|
||||
wc.cfg().addInstruction(insts.MonitorInstruction(wc.getValue(n.getChild(0)), false));
|
||||
wc.cfg().addInstruction(insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), wc.getValue(n.getChild(0)), false));
|
||||
processExceptions(n, wc);
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
|||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.NullProgressMonitor;
|
||||
|
@ -59,7 +60,7 @@ public class HTMLCGBuilder {
|
|||
public JSCFABuilder builder;
|
||||
|
||||
/** pointer analysis results; partial if {@link #construction_time} is {@code -1} */
|
||||
public PointerAnalysis pa;
|
||||
public PointerAnalysis<InstanceKey> pa;
|
||||
|
||||
/** call graph; partial if {@link #construction_time} is {@code -1} */
|
||||
public CallGraph cg;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.junit.Test;
|
|||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
||||
import com.ibm.wala.cast.js.util.Util;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
@ -39,7 +40,7 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
|
|||
public void test214631() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
JSCFABuilder b = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "214631.js");
|
||||
b.makeCallGraph(b.getOptions());
|
||||
PointerAnalysis PA = b.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> PA = b.getPointerAnalysis();
|
||||
// just make sure this does not crash
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
|
|||
import com.ibm.wala.classLoader.SourceFileModule;
|
||||
import com.ibm.wala.classLoader.SourceModule;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
|
@ -57,7 +58,7 @@ public class JsViewerDriver extends JSCallGraphBuilderUtil {
|
|||
builder.setBaseURL(url);
|
||||
|
||||
CallGraph cg = builder.makeCallGraph(builder.getOptions());
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
|
||||
new JsViewer(cg, pa);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.cast.js.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShape.java"/>
|
||||
|
@ -7,6 +7,9 @@
|
|||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
|
||||
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
|
||||
</mapAttribute>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
|
|
|
@ -104,7 +104,7 @@ public abstract class FieldBasedCallGraphBuilder {
|
|||
/**
|
||||
* Main entry point: builds a flow graph, then extracts a call graph and returns it.
|
||||
*/
|
||||
public Pair<JSCallGraph,PointerAnalysis> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
|
||||
public Pair<JSCallGraph,PointerAnalysis<FuncVertex>> buildCallGraph(Iterable<Entrypoint> eps, IProgressMonitor monitor) throws CancelException {
|
||||
long fgBegin, fgEnd, cgBegin, cgEnd;
|
||||
|
||||
if(LOG_TIMINGS) fgBegin = System.currentTimeMillis();
|
||||
|
|
|
@ -141,11 +141,11 @@ public class FlowGraph implements Iterable<Vertex> {
|
|||
return graph.iterator();
|
||||
}
|
||||
|
||||
public PointerAnalysis getPointerAnalysis(final IProgressMonitor monitor) {
|
||||
return new PointerAnalysis() {
|
||||
public PointerAnalysis<FuncVertex> getPointerAnalysis(final IProgressMonitor monitor) {
|
||||
return new PointerAnalysis<FuncVertex>() {
|
||||
|
||||
@Override
|
||||
public OrdinalSet<? extends InstanceKey> getPointsToSet(PointerKey key) {
|
||||
public OrdinalSet<FuncVertex> getPointsToSet(PointerKey key) {
|
||||
if (key instanceof LocalPointerKey) {
|
||||
CGNode node = ((LocalPointerKey)key).getNode();
|
||||
FuncVertex fn = factory.makeFuncVertex(node.getMethod().getDeclaringClass());
|
||||
|
|
|
@ -65,7 +65,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
|
|||
context.currentScope().getConstantValue(name);
|
||||
doIsFieldDefined(context, isDefined, windowVal, Ast.makeConstant(name));
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(
|
||||
insts.ConditionalBranchInstruction(context.cfg().getCurrentInstruction(),
|
||||
translateConditionOpcode(CAstOperator.OP_NE),
|
||||
null,
|
||||
isDefined,
|
||||
|
@ -75,16 +75,16 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
|
|||
|
||||
// field lookup of value
|
||||
context.cfg().newBlock(true);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(result, windowVal, name));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(context.cfg().getCurrentInstruction(), result, windowVal, name));
|
||||
context.cfg().newBlock(true);
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().getCurrentInstruction(), -1));
|
||||
PreBasicBlock trueB = context.cfg().getCurrentBlock();
|
||||
|
||||
// read global
|
||||
context.cfg().newBlock(false);
|
||||
PreBasicBlock falseB = context.cfg().getCurrentBlock();
|
||||
int sr = super.doGlobalRead(n, context, name, type);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(result, sr));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(context.cfg().getCurrentInstruction(), result, sr));
|
||||
|
||||
// end
|
||||
context.cfg().newBlock(true);
|
||||
|
@ -104,7 +104,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
|
|||
if (isNestedWithinScriptBody(context) && ! "$$undefined".equals(nm) && !"window".equals(nm) && !nm.startsWith("$$destructure")) {
|
||||
int windowVal = super.doLocalRead(context, "this", type);
|
||||
context.currentScope().getConstantValue(nm);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(windowVal, rval, nm));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), windowVal, rval, nm));
|
||||
}
|
||||
|
||||
super.doLocalWrite(context, nm, type, rval);
|
||||
|
@ -118,7 +118,7 @@ public class WebPageLoaderFactory extends JavaScriptLoaderFactory {
|
|||
int fnValue = context.currentScope().lookup(fn.getName()).valueNumber();
|
||||
assert fnValue > 0;
|
||||
int windowVal = super.doLocalRead(context, "this", JavaScriptTypes.Function);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(windowVal, fnValue, fn.getName()));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), windowVal, fnValue, fn.getName()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -60,7 +60,7 @@ public class JSCallGraph extends AstCallGraph {
|
|||
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(instance, ref);
|
||||
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref);
|
||||
statements.add(result);
|
||||
return result;
|
||||
} else {
|
||||
|
@ -72,7 +72,7 @@ public class JSCallGraph extends AstCallGraph {
|
|||
public SSAAbstractInvokeInstruction addDirectCall(int function, int[] params, CallSiteReference site) {
|
||||
CallSiteReference newSite = new JSCallSiteReference(statements.size());
|
||||
|
||||
JavaScriptInvoke s = new JavaScriptInvoke(function, nextLocal++, params, nextLocal++, newSite);
|
||||
JavaScriptInvoke s = new JavaScriptInvoke(statements.size(), function, nextLocal++, params, nextLocal++, newSite);
|
||||
statements.add(s);
|
||||
|
||||
return s;
|
||||
|
|
|
@ -381,7 +381,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
|
|||
protected PropagationSystem makeSystem(AnalysisOptions options) {
|
||||
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
|
||||
@Override
|
||||
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
return new JSPointerAnalysisImpl(builder, cg, pointsToMap, instanceKeys, pointerKeyFactory, instanceKeyFactory);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -110,10 +110,10 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
|
|||
// function being invoked is in v2
|
||||
int resultVal = curValNum++;
|
||||
int excVal = curValNum++;
|
||||
S.addStatement(insts.Invoke(2, resultVal, paramsToPassToInvoked, excVal, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, paramsToPassToInvoked, excVal, cs));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(resultVal, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, declaringClass);
|
||||
|
@ -125,11 +125,11 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
|
|||
// read an arbitrary property name via EachElementGet
|
||||
int curValNum = nargs + 2;
|
||||
int eachElementGetResult = curValNum++;
|
||||
S.addStatement(insts.EachElementGetInstruction(eachElementGetResult, 4));
|
||||
S.addStatement(insts.EachElementGetInstruction(S.getNumberOfStatements(), eachElementGetResult, 4));
|
||||
S.getNextProgramCounter();
|
||||
// read value from the arbitrary property name
|
||||
int propertyReadResult = curValNum++;
|
||||
S.addStatement(insts.PropertyRead(propertyReadResult, 4, eachElementGetResult));
|
||||
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), propertyReadResult, 4, eachElementGetResult));
|
||||
S.getNextProgramCounter();
|
||||
for (int i = 1; i < paramsToPassToInvoked.length; i++) {
|
||||
paramsToPassToInvoked[i] = propertyReadResult;
|
||||
|
@ -150,7 +150,7 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
|
|||
S.addConstant(constVN, new ConstantValue(i-1));
|
||||
int propertyReadResult = curValNum++;
|
||||
// 4 is position of arguments array
|
||||
S.addStatement(insts.PropertyRead(propertyReadResult, 4, constVN));
|
||||
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), propertyReadResult, 4, constVN));
|
||||
S.getNextProgramCounter();
|
||||
paramsToPassToInvoked[i] = propertyReadResult;
|
||||
}
|
||||
|
@ -173,10 +173,10 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
|
|||
int[] params = new int[1];
|
||||
params[0] = 3;
|
||||
// function being invoked is in v2
|
||||
S.addStatement(insts.Invoke(2, resultVal, params, resultVal + 1, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, params, resultVal + 1, cs));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(resultVal, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, declaringClass);
|
||||
|
|
|
@ -162,10 +162,10 @@ public class JavaScriptFunctionDotCallTargetSelector implements MethodTargetSele
|
|||
params[i] = i + 3;
|
||||
}
|
||||
// function being invoked is in v2
|
||||
S.addStatement(insts.Invoke(2, resultVal, params, resultVal + 1, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 2, resultVal, params, resultVal + 1, cs));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(resultVal, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), resultVal, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
JavaScriptSummarizedFunction t = new JavaScriptSummarizedFunction(ref, S, receiver);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class LoadFileTargetSelector implements MethodTargetSelector {
|
|||
Set<String> names = new HashSet<String>();
|
||||
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()];
|
||||
LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));
|
||||
OrdinalSet<? extends InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
|
||||
OrdinalSet<InstanceKey> ptrs = builder.getPointerAnalysis().getPointsToSet(fileNameV);
|
||||
for(InstanceKey k : ptrs) {
|
||||
if (k instanceof ConstantKey) {
|
||||
Object v = ((ConstantKey)k).getValue();
|
||||
|
|
|
@ -25,7 +25,7 @@ public class JavaScriptModRef extends AstModRef {
|
|||
|
||||
protected static class JavaScriptRefVisitor extends AstRefVisitor implements JSInstructionVisitor {
|
||||
|
||||
protected JavaScriptRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected JavaScriptRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
|
||||
super(n, result, pa, (AstHeapModel)h);
|
||||
}
|
||||
|
||||
|
@ -88,13 +88,13 @@ public class JavaScriptModRef extends AstModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
|
||||
return new JavaScriptRefVisitor(n, result, pa, h);
|
||||
}
|
||||
|
||||
protected static class JavaScriptModVisitor extends AstModVisitor implements JSInstructionVisitor {
|
||||
|
||||
protected JavaScriptModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis pa) {
|
||||
protected JavaScriptModVisitor(CGNode n, Collection<PointerKey> result, ExtendedHeapModel h, PointerAnalysis<InstanceKey> pa) {
|
||||
super(n, result, (AstHeapModel)h, pa);
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class JavaScriptModRef extends AstModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
return new JavaScriptModVisitor(n, result, h, pa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,20 +75,20 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
|
||||
|
||||
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
|
||||
S.addStatement(insts.SetPrototype(5, 4));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
|
||||
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addConstant(new Integer(8), new ConstantValue(value));
|
||||
S.addStatement(insts.PutInstruction(5, 8, "$value"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 8, "$value"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(9, new ConstantValue("__proto__"));
|
||||
|
@ -101,19 +101,19 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
|
||||
|
||||
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
|
||||
S.addStatement(insts.SetPrototype(6, 5));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 6, 5));
|
||||
//S.addStatement(insts.PutInstruction(6, 5, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.PutInstruction(6, 2, "$value"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "$value"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(6, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(7, new ConstantValue("__proto__"));
|
||||
|
@ -144,16 +144,16 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
|
||||
|
||||
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
|
||||
|
||||
S.addStatement(insts.SetPrototype(5, 4));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
|
||||
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(6, new ConstantValue("__proto__"));
|
||||
|
@ -166,7 +166,7 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(2, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Object));
|
||||
|
@ -204,19 +204,19 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Array);
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
|
||||
|
||||
S.addStatement(insts.GetInstruction(5, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
|
||||
|
||||
S.addStatement(insts.SetPrototype(6, 5));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 6, 5));
|
||||
//S.addStatement(insts.PutInstruction(6, 5, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.PutInstruction(6, 2, "length"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "length"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(6, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(7, new ConstantValue("__proto__"));
|
||||
|
@ -230,29 +230,29 @@ public class JavaScriptConstructorFunctions {
|
|||
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
|
||||
|
||||
S.addConstant(new Integer(nargs + 3), new ConstantValue("prototype"));
|
||||
S.addStatement(insts.PropertyRead(nargs + 4, 1, nargs + 3));
|
||||
S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), nargs + 4, 1, nargs + 3));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(
|
||||
insts.NewInstruction(nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
|
||||
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
|
||||
JavaScriptTypes.Array)));
|
||||
|
||||
S.addStatement(insts.SetPrototype(nargs + 5, nargs + 4));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), nargs + 5, nargs + 4));
|
||||
//S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addConstant(new Integer(nargs + 7), new ConstantValue(nargs));
|
||||
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 7, "length"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 7, "length"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
int vn = nargs + 9;
|
||||
for (int i = 0; i < nargs; i++, vn += 2) {
|
||||
S.addConstant(new Integer(vn), new ConstantValue(i));
|
||||
S.addStatement(insts.PropertyWrite(nargs + 5, vn, i + 1));
|
||||
S.addStatement(insts.PropertyWrite(S.getNumberOfStatements(), nargs + 5, vn, i + 1));
|
||||
S.getNextProgramCounter();
|
||||
}
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(vn, new ConstantValue("__proto__"));
|
||||
|
@ -275,7 +275,7 @@ public class JavaScriptConstructorFunctions {
|
|||
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
|
||||
|
||||
S.addConstant(new Integer(2), new ConstantValue(""));
|
||||
S.addStatement(insts.ReturnInstruction(2, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.String));
|
||||
|
@ -286,13 +286,13 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.String);
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
|
||||
|
||||
S.addStatement(insts.GetInstruction(4, 2, "toString"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toString"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
|
||||
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.String));
|
||||
|
@ -315,7 +315,7 @@ public class JavaScriptConstructorFunctions {
|
|||
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
|
||||
|
||||
S.addConstant(new Integer(2), new ConstantValue(0.0));
|
||||
S.addStatement(insts.ReturnInstruction(2, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Number));
|
||||
|
@ -326,13 +326,13 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.Number);
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 2);
|
||||
|
||||
S.addStatement(insts.GetInstruction(4, 2, "toNumber"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toNumber"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
|
||||
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return new JavaScriptConstructor(ref, S, cls, cha.lookupClass(JavaScriptTypes.Number));
|
||||
|
@ -358,25 +358,25 @@ public class JavaScriptConstructorFunctions {
|
|||
MethodReference ref = JavaScriptMethods.makeCtorReference(receiver.getReference());
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, 1);
|
||||
|
||||
S.addStatement(insts.GetInstruction(4, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
|
||||
|
||||
S.addStatement(insts.NewInstruction(7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
|
||||
S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
|
||||
|
||||
S.addStatement(insts.SetPrototype(5, 4));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), 5, 4));
|
||||
//S.addStatement(insts.PutInstruction(5, 4, "__proto__"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.PutInstruction(5, 7, "prototype"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 7, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.PutInstruction(7, 5, "constructor"));
|
||||
S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 5, "constructor"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
// TODO we need to set v7.__proto__ to Object.prototype
|
||||
S.addStatement(insts.ReturnInstruction(5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
//S.addConstant(8, new ConstantValue("__proto__"));
|
||||
|
@ -464,15 +464,15 @@ public class JavaScriptConstructorFunctions {
|
|||
|
||||
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
|
||||
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
|
||||
S.addStatement(insts.GetInstruction(nargs + 4, 1, "prototype"));
|
||||
S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), nargs + 4, 1, "prototype"));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(
|
||||
insts.NewInstruction(nargs + 5,
|
||||
insts.NewInstruction(S.getNumberOfStatements(), nargs + 5,
|
||||
NewSiteReference.make(S.getNextProgramCounter(),
|
||||
JavaScriptTypes.Object)));
|
||||
|
||||
S.addStatement(insts.SetPrototype(nargs + 5, nargs + 4));
|
||||
S.addStatement(insts.SetPrototype(S.getNumberOfStatements(), nargs + 5, nargs + 4));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
|
||||
|
@ -480,17 +480,17 @@ public class JavaScriptConstructorFunctions {
|
|||
args[0] = nargs + 5;
|
||||
for (int i = 0; i < nargs; i++)
|
||||
args[i + 1] = i + 2;
|
||||
S.addStatement(insts.Invoke(1, nargs + 7, args, nargs + 8, cs));
|
||||
S.addStatement(insts.Invoke(S.getNumberOfStatements(), 1, nargs + 7, args, nargs + 8, cs));
|
||||
int pc = S.getNextProgramCounter();
|
||||
|
||||
S.addConstant(nargs + 9, null);
|
||||
S.addStatement(insts.ConditionalBranchInstruction(Operator.EQ, JavaScriptTypes.Root, nargs + 7, nargs + 9, pc+2));
|
||||
S.addStatement(insts.ConditionalBranchInstruction(S.getNumberOfStatements(), Operator.EQ, JavaScriptTypes.Root, nargs + 7, nargs + 9, pc+2));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(nargs + 7, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 7, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
S.addStatement(insts.ReturnInstruction(nargs + 5, false));
|
||||
S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 5, false));
|
||||
S.getNextProgramCounter();
|
||||
|
||||
return record(key, new JavaScriptConstructor(ref, S, cls, cls));
|
||||
|
|
|
@ -25,7 +25,7 @@ public class JavaScriptSummary extends MethodSummary {
|
|||
super(ref);
|
||||
this.declaredParameters = declaredParameters;
|
||||
addStatement(
|
||||
JavaScriptLoader.JS.instructionFactory().NewInstruction(
|
||||
JavaScriptLoader.JS.instructionFactory().NewInstruction(getNumberOfStatements(),
|
||||
declaredParameters+1,
|
||||
NewSiteReference.make(
|
||||
getNextProgramCounter(),
|
||||
|
|
|
@ -209,51 +209,51 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
return new JSInstructionFactory() {
|
||||
|
||||
@Override
|
||||
public JavaScriptCheckReference CheckReference(int ref) {
|
||||
return new JavaScriptCheckReference(ref);
|
||||
public JavaScriptCheckReference CheckReference(int iindex, int ref) {
|
||||
return new JavaScriptCheckReference(iindex, ref);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAGetInstruction GetInstruction(int result, int ref, String field) {
|
||||
return GetInstruction(result, ref,
|
||||
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field) {
|
||||
return GetInstruction(iindex, result, ref,
|
||||
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field), JavaScriptTypes.Root));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal) {
|
||||
return new JavaScriptInstanceOf(result, objVal, typeVal);
|
||||
public JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal) {
|
||||
return new JavaScriptInstanceOf(iindex, result, objVal, typeVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(function, results, params, exception, site);
|
||||
public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(iindex, function, results, params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(function, result, params, exception, site);
|
||||
public JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(iindex, function, result, params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(function, params, exception, site);
|
||||
public JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
|
||||
return new JavaScriptInvoke(iindex, function, params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef) {
|
||||
return new JavaScriptPropertyRead(result, objectRef, memberRef);
|
||||
public JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
|
||||
return new JavaScriptPropertyRead(iindex, result, objectRef, memberRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value) {
|
||||
return new JavaScriptPropertyWrite(objectRef, memberRef, value);
|
||||
public JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value) {
|
||||
return new JavaScriptPropertyWrite(iindex, objectRef, memberRef, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAPutInstruction PutInstruction(int ref, int value, String field) {
|
||||
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field) {
|
||||
try {
|
||||
byte[] utf8 = field.getBytes("UTF-8");
|
||||
return PutInstruction(ref, value,
|
||||
return PutInstruction(iindex, ref, value,
|
||||
FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length), JavaScriptTypes.Root));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Assertions.UNREACHABLE();
|
||||
|
@ -262,119 +262,119 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object) {
|
||||
return new JavaScriptTypeOfInstruction(lval, object);
|
||||
public JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object) {
|
||||
return new JavaScriptTypeOfInstruction(iindex, lval, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaScriptWithRegion WithRegion(int expr, boolean isEnter) {
|
||||
return new JavaScriptWithRegion(expr, isEnter);
|
||||
public JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter) {
|
||||
return new JavaScriptWithRegion(iindex, expr, isEnter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) {
|
||||
return new AstAssertInstruction(value, fromSpecification);
|
||||
public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
|
||||
return new AstAssertInstruction(iindex, value, fromSpecification);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) {
|
||||
return new AssignInstruction(result, val);
|
||||
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
|
||||
return new AssignInstruction(iindex, result, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int value, int objectRef) {
|
||||
return new EachElementGetInstruction(value, objectRef);
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementGetInstruction EachElementGetInstruction(int iindex, int value, int objectRef) {
|
||||
return new EachElementGetInstruction(iindex, value, objectRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int value, int objectRef) {
|
||||
return new EachElementHasNextInstruction(value, objectRef);
|
||||
public com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int value, int objectRef) {
|
||||
return new EachElementHasNextInstruction(iindex, value, objectRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstEchoInstruction EchoInstruction(int[] rvals) {
|
||||
return new AstEchoInstruction(rvals);
|
||||
public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
|
||||
return new AstEchoInstruction(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstGlobalRead GlobalRead(int lhs, FieldReference global) {
|
||||
return new AstGlobalRead(lhs, global);
|
||||
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
|
||||
return new AstGlobalRead(iindex, lhs, global);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) {
|
||||
return new AstGlobalWrite(global, rhs);
|
||||
public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
|
||||
return new AstGlobalWrite(iindex, global, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
return new AstIsDefinedInstruction(lval, rval, fieldVal, fieldRef);
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal, fieldRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
|
||||
return new AstIsDefinedInstruction(lval, rval, fieldRef);
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
|
||||
return new AstIsDefinedInstruction(iindex, lval, rval, fieldRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) {
|
||||
return new AstIsDefinedInstruction(lval, rval, fieldVal);
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
|
||||
return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) {
|
||||
return new AstIsDefinedInstruction(lval, rval);
|
||||
public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
|
||||
return new AstIsDefinedInstruction(iindex, lval, rval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(Access[] accesses) {
|
||||
return new AstLexicalRead(accesses);
|
||||
public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
|
||||
return new AstLexicalRead(iindex, accesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(Access access) {
|
||||
return new AstLexicalRead(access);
|
||||
public AstLexicalRead LexicalRead(int iindex, Access access) {
|
||||
return new AstLexicalRead(iindex, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type) {
|
||||
return new AstLexicalRead(lhs, definer, globalName, type);
|
||||
public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
|
||||
return new AstLexicalRead(iindex, lhs, definer, globalName, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(Access[] accesses) {
|
||||
return new AstLexicalWrite(accesses);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
|
||||
return new AstLexicalWrite(iindex, accesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(Access access) {
|
||||
return new AstLexicalWrite(access);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, Access access) {
|
||||
return new AstLexicalWrite(iindex, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
|
||||
return new AstLexicalWrite(definer, globalName, type, rhs);
|
||||
public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
|
||||
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAArrayLengthInstruction ArrayLengthInstruction(int result, int arrayref) {
|
||||
public SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType) {
|
||||
public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType) {
|
||||
public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSABinaryOpInstruction BinaryOpInstruction(IOperator operator, boolean overflow, boolean unsigned, int result,
|
||||
public SSABinaryOpInstruction BinaryOpInstruction(int iindex, IOperator operator, boolean overflow, boolean unsigned, int result,
|
||||
int val1, int val2, boolean mayBeInteger) {
|
||||
return new SSABinaryOpInstruction(operator, result, val1, val2, mayBeInteger) {
|
||||
return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) {
|
||||
@Override
|
||||
public boolean isPEI() {
|
||||
return false;
|
||||
|
@ -382,74 +382,74 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return insts.BinaryOpInstruction(getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
|
||||
return insts.BinaryOpInstruction(iindex, getOperator(), false, false, defs == null || defs.length == 0 ? getDef(0) : defs[0],
|
||||
uses == null ? getUse(0) : uses[0], uses == null ? getUse(1) : uses[1], mayBeIntegerOp());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types, boolean isPEI) {
|
||||
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types, boolean isPEI) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues, boolean isPEI) {
|
||||
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues, boolean isPEI) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue, boolean isPEI) {
|
||||
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue, boolean isPEI) {
|
||||
assert isPEI;
|
||||
return CheckCastInstruction(result, val, new int[]{ typeValue }, true);
|
||||
return CheckCastInstruction(iindex, result, val, new int[]{ typeValue }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type, boolean isPEI) {
|
||||
public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type, boolean isPEI) {
|
||||
assert isPEI;
|
||||
return CheckCastInstruction(result, val, new TypeReference[]{ type }, true);
|
||||
return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type }, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAComparisonInstruction ComparisonInstruction(Operator operator, int result, int val1, int val2) {
|
||||
return new SSAComparisonInstruction(operator, result, val1, val2);
|
||||
public SSAComparisonInstruction ComparisonInstruction(int iindex, Operator operator, int result, int val1, int val2) {
|
||||
return new SSAComparisonInstruction(iindex, operator, result, val1, val2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAConditionalBranchInstruction ConditionalBranchInstruction(
|
||||
public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex,
|
||||
com.ibm.wala.shrikeBT.IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target) {
|
||||
return new SSAConditionalBranchInstruction(operator, type, val1, val2, target);
|
||||
return new SSAConditionalBranchInstruction(iindex, operator, type, val1, val2, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAConversionInstruction ConversionInstruction(int result, int val, TypeReference fromType, TypeReference toType,
|
||||
public SSAConversionInstruction ConversionInstruction(int iindex, int result, int val, TypeReference fromType, TypeReference toType,
|
||||
boolean overflow) {
|
||||
assert !overflow;
|
||||
return new SSAConversionInstruction(result, val, fromType, toType) {
|
||||
return new SSAConversionInstruction(iindex, result, val, fromType, toType) {
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException {
|
||||
if (uses != null && uses.length == 0) {
|
||||
throw new IllegalArgumentException("(uses != null) and (uses.length == 0)");
|
||||
}
|
||||
return insts.ConversionInstruction(defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
|
||||
return insts.ConversionInstruction(iindex, defs == null || defs.length == 0 ? getDef(0) : defs[0], uses == null ? getUse(0)
|
||||
: uses[0], getFromType(), getToType(), false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber) {
|
||||
return new SSAGetCaughtExceptionInstruction(bbNumber, exceptionValueNumber);
|
||||
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber) {
|
||||
return new SSAGetCaughtExceptionInstruction(iindex, bbNumber, exceptionValueNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAGetInstruction GetInstruction(int result, FieldReference field) {
|
||||
public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAGetInstruction GetInstruction(int result, int ref, FieldReference field) {
|
||||
return new SSAGetInstruction(result, ref, field) {
|
||||
public SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field) {
|
||||
return new SSAGetInstruction(iindex, result, ref, field) {
|
||||
@Override
|
||||
public boolean isPEI() {
|
||||
return false;
|
||||
|
@ -458,38 +458,38 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SSAGotoInstruction GotoInstruction(int target) {
|
||||
return new SSAGotoInstruction(target);
|
||||
public SSAGotoInstruction GotoInstruction(int iindex, int target) {
|
||||
return new SSAGotoInstruction(iindex, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType) {
|
||||
public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
|
||||
public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site) {
|
||||
public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token) {
|
||||
public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter) {
|
||||
public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSANewInstruction NewInstruction(int result, NewSiteReference site) {
|
||||
return new SSANewInstruction(result, site) {
|
||||
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site) {
|
||||
return new SSANewInstruction(iindex, result, site) {
|
||||
@Override
|
||||
public boolean isPEI() {
|
||||
return true;
|
||||
|
@ -503,23 +503,23 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params) {
|
||||
public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAPhiInstruction PhiInstruction(int result, int[] params) {
|
||||
return new SSAPhiInstruction(result, params);
|
||||
public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) {
|
||||
return new SSAPhiInstruction(iindex, result, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAPiInstruction PiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
|
||||
return new SSAPiInstruction(result, val, piBlock, successorBlock, cause);
|
||||
public SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
|
||||
return new SSAPiInstruction(iindex, result, val, piBlock, successorBlock, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAPutInstruction PutInstruction(int ref, int value, FieldReference field) {
|
||||
return new SSAPutInstruction(ref, value, field) {
|
||||
public SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field) {
|
||||
return new SSAPutInstruction(iindex, ref, value, field) {
|
||||
@Override
|
||||
public boolean isPEI() {
|
||||
return false;
|
||||
|
@ -528,28 +528,28 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SSAPutInstruction PutInstruction(int value, FieldReference field) {
|
||||
public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAReturnInstruction ReturnInstruction() {
|
||||
return new SSAReturnInstruction();
|
||||
public SSAReturnInstruction ReturnInstruction(int iindex) {
|
||||
return new SSAReturnInstruction(iindex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAReturnInstruction ReturnInstruction(int result, boolean isPrimitive) {
|
||||
return new SSAReturnInstruction(result, isPrimitive);
|
||||
public SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive) {
|
||||
return new SSAReturnInstruction(iindex, result, isPrimitive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSASwitchInstruction SwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) {
|
||||
return new SSASwitchInstruction(val, defaultLabel, casesAndLabels);
|
||||
public SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels) {
|
||||
return new SSASwitchInstruction(iindex, val, defaultLabel, casesAndLabels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAThrowInstruction ThrowInstruction(int exception) {
|
||||
return new SSAThrowInstruction(exception) {
|
||||
public SSAThrowInstruction ThrowInstruction(int iindex, int exception) {
|
||||
return new SSAThrowInstruction(iindex, exception) {
|
||||
@Override
|
||||
public boolean isPEI() {
|
||||
return true;
|
||||
|
@ -563,44 +563,44 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SSAUnaryOpInstruction UnaryOpInstruction(com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
|
||||
public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
|
||||
int val) {
|
||||
return new SSAUnaryOpInstruction(operator, result, val);
|
||||
return new SSAUnaryOpInstruction(iindex, operator, result, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType) {
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, int indexVal, TypeReference pointeeType) {
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, int indexVal, TypeReference pointeeType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, FieldReference field, TypeReference pointeeType) {
|
||||
public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, FieldReference field, TypeReference pointeeType) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSALoadIndirectInstruction LoadIndirectInstruction(int lval, TypeReference t, int addressVal) {
|
||||
public SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference t) {
|
||||
public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference t) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrototypeLookup PrototypeLookup(int lval, int object) {
|
||||
return new PrototypeLookup(lval, object);
|
||||
public PrototypeLookup PrototypeLookup(int iindex, int lval, int object) {
|
||||
return new PrototypeLookup(iindex, lval, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPrototype SetPrototype(int object, int prototype) {
|
||||
return new SetPrototype(object, prototype);
|
||||
public SetPrototype SetPrototype(int iindex, int object, int prototype) {
|
||||
return new SetPrototype(iindex, object, prototype);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -649,7 +649,7 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public PrimitiveType getPrimitive(TypeReference reference) {
|
||||
return JSPrimitiveType.getPrimitive(reference);
|
||||
return PrimitiveType.getPrimitive(reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,30 +17,30 @@ import com.ibm.wala.ssa.SSAPutInstruction;
|
|||
|
||||
public interface JSInstructionFactory extends AstInstructionFactory {
|
||||
|
||||
JavaScriptCheckReference CheckReference(int ref);
|
||||
JavaScriptCheckReference CheckReference(int iindex, int ref);
|
||||
|
||||
SSAGetInstruction GetInstruction(int result, int ref, String field);
|
||||
SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field);
|
||||
|
||||
JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal);
|
||||
JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal);
|
||||
|
||||
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site);
|
||||
JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site);
|
||||
|
||||
JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site);
|
||||
JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site);
|
||||
|
||||
JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site);
|
||||
JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site);
|
||||
|
||||
JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef);
|
||||
JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef);
|
||||
|
||||
JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value);
|
||||
JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value);
|
||||
|
||||
SSAPutInstruction PutInstruction(int ref, int value, String field);
|
||||
SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field);
|
||||
|
||||
JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object);
|
||||
JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object);
|
||||
|
||||
JavaScriptWithRegion WithRegion(int expr, boolean isEnter);
|
||||
JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter);
|
||||
|
||||
PrototypeLookup PrototypeLookup(int lval, int object);
|
||||
PrototypeLookup PrototypeLookup(int iindex, int lval, int object);
|
||||
|
||||
SetPrototype SetPrototype(int object, int prototype);
|
||||
SetPrototype SetPrototype(int iindex, int object, int prototype);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,13 +26,14 @@ import com.ibm.wala.types.TypeReference;
|
|||
public class JavaScriptCheckReference extends SSAInstruction {
|
||||
private final int ref;
|
||||
|
||||
public JavaScriptCheckReference(int ref) {
|
||||
public JavaScriptCheckReference(int iindex, int ref) {
|
||||
super(iindex);
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).CheckReference(uses==null? ref: uses[0]);
|
||||
return ((JSInstructionFactory)insts).CheckReference(iindex, uses==null? ref: uses[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,8 @@ public class JavaScriptInstanceOf extends SSAInstruction {
|
|||
private final int typeVal;
|
||||
private final int result;
|
||||
|
||||
public JavaScriptInstanceOf(int result, int objVal, int typeVal) {
|
||||
public JavaScriptInstanceOf(int iindex, int result, int objVal, int typeVal) {
|
||||
super(iindex);
|
||||
this.objVal = objVal;
|
||||
this.typeVal = typeVal;
|
||||
this.result = result;
|
||||
|
@ -34,7 +35,7 @@ public class JavaScriptInstanceOf extends SSAInstruction {
|
|||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return
|
||||
((JSInstructionFactory)insts).InstanceOf(
|
||||
((JSInstructionFactory)insts).InstanceOf(iindex,
|
||||
defs==null? result: defs[0],
|
||||
uses==null? objVal: uses[0],
|
||||
uses==null? typeVal: uses[1]);
|
||||
|
|
|
@ -28,18 +28,18 @@ public class JavaScriptInvoke extends MultiReturnValueInvokeInstruction {
|
|||
|
||||
private int function;
|
||||
|
||||
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(results, exception, site);
|
||||
public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(iindex, results, exception, site);
|
||||
this.function = function;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(function, new int[] { result }, params, exception, site);
|
||||
public JavaScriptInvoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, function, new int[] { result }, params, exception, site);
|
||||
}
|
||||
|
||||
public JavaScriptInvoke(int function, int[] params, int exception, CallSiteReference site) {
|
||||
this(function, null, params, exception, site);
|
||||
public JavaScriptInvoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, function, null, params, exception, site);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +74,7 @@ public class JavaScriptInvoke extends MultiReturnValueInvokeInstruction {
|
|||
|
||||
}
|
||||
|
||||
return ((JSInstructionFactory)insts).Invoke(fn, newLvals, newParams, newExp, site);
|
||||
return ((JSInstructionFactory)insts).Invoke(iindex, fn, newLvals, newParams, newExp, site);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ import com.ibm.wala.ssa.SSAInstructionFactory;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
|
||||
public class JavaScriptPropertyRead extends AbstractReflectiveGet {
|
||||
public JavaScriptPropertyRead(int result, int objectRef, int memberRef) {
|
||||
super(result, objectRef, memberRef);
|
||||
public JavaScriptPropertyRead(int iindex, int result, int objectRef, int memberRef) {
|
||||
super(iindex, result, objectRef, memberRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return
|
||||
((JSInstructionFactory)insts).PropertyRead(
|
||||
((JSInstructionFactory)insts).PropertyRead(iindex,
|
||||
defs==null? getDef(): defs[0],
|
||||
uses==null? getObjectRef(): uses[0],
|
||||
uses==null? getMemberRef(): uses[1]);
|
||||
|
|
|
@ -20,13 +20,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
|
||||
public class JavaScriptPropertyWrite extends AbstractReflectivePut {
|
||||
|
||||
public JavaScriptPropertyWrite(int objectRef, int memberRef, int value) {
|
||||
super(objectRef, memberRef, value);
|
||||
public JavaScriptPropertyWrite(int iindex, int objectRef, int memberRef, int value) {
|
||||
super(iindex, objectRef, memberRef, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).PropertyWrite(uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
|
||||
return ((JSInstructionFactory)insts).PropertyWrite(iindex, uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
|
||||
uses == null ? getValue() : uses[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
|
||||
public class JavaScriptTypeOfInstruction extends SSAAbstractUnaryInstruction {
|
||||
|
||||
public JavaScriptTypeOfInstruction(int lval, int object) {
|
||||
super(lval, object);
|
||||
public JavaScriptTypeOfInstruction(int iindex, int lval, int object) {
|
||||
super(iindex, lval, object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).TypeOfInstruction((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
|
||||
return ((JSInstructionFactory)insts).TypeOfInstruction(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,14 +21,15 @@ public class JavaScriptWithRegion extends SSAInstruction {
|
|||
private final int expr;
|
||||
private final boolean isEnter;
|
||||
|
||||
public JavaScriptWithRegion(int expr, boolean isEnter) {
|
||||
public JavaScriptWithRegion(int iindex, int expr, boolean isEnter) {
|
||||
super(iindex);
|
||||
this.expr = expr;
|
||||
this.isEnter = isEnter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).WithRegion(uses==null? expr: uses[0], isEnter);
|
||||
return ((JSInstructionFactory)insts).WithRegion(iindex, uses==null? expr: uses[0], isEnter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,13 +21,13 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
*/
|
||||
public class PrototypeLookup extends SSAAbstractUnaryInstruction {
|
||||
|
||||
public PrototypeLookup(int result, int val) {
|
||||
super(result, val);
|
||||
public PrototypeLookup(int iindex, int result, int val) {
|
||||
super(iindex, result, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).PrototypeLookup((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
|
||||
return ((JSInstructionFactory)insts).PrototypeLookup(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,8 @@ public class SetPrototype extends SSAInstruction {
|
|||
private final int object;
|
||||
private final int prototype;
|
||||
|
||||
public SetPrototype(int object, int prototype) {
|
||||
public SetPrototype(int iindex, int object, int prototype) {
|
||||
super(iindex);
|
||||
this.object = object;
|
||||
this.prototype = prototype;
|
||||
}
|
||||
|
@ -36,7 +37,7 @@ public class SetPrototype extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((JSInstructionFactory)insts).SetPrototype((uses != null ? uses[0] : object), (uses != null ? uses[1] : prototype));
|
||||
return ((JSInstructionFactory)insts).SetPrototype(iindex, (uses != null ? uses[0] : object), (uses != null ? uses[1] : prototype));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -108,8 +108,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
*/
|
||||
private void addDefinedCheck(CAstNode n, WalkContext context, int readVn) {
|
||||
context.cfg().addPreNode(n);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).CheckReference(readVn));
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(context.cfg().getCurrentInstruction(), readVn));
|
||||
CAstNode target = context.getControlFlow().getTarget(n, JavaScriptTypes.ReferenceError);
|
||||
if (target != null) {
|
||||
context.cfg().addPreEdge(n, target, true);
|
||||
|
@ -185,7 +184,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
|
||||
@Override
|
||||
protected void doThrow(WalkContext context, int exception) {
|
||||
context.cfg().addInstruction(insts.ThrowInstruction(exception));
|
||||
context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,7 +195,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
: AstMethodReference.fnReference(JavaScriptTypes.CodeBody);
|
||||
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).Invoke(receiver, result, arguments, exception,
|
||||
((JSInstructionFactory) insts).Invoke(context.cfg().getCurrentInstruction(), receiver, result, arguments, exception,
|
||||
new JSCallSiteReference(ref, context.cfg().getCurrentInstruction())));
|
||||
|
||||
context.cfg().addPreNode(call, context.getUnwindState());
|
||||
|
@ -216,8 +215,8 @@ public class JSAstTranslator extends AstTranslator {
|
|||
assert arguments == null;
|
||||
TypeReference typeRef = TypeReference.findOrCreate(JavaScriptTypes.jsLoader, TypeName.string2TypeName("L" + type));
|
||||
|
||||
context.cfg().addInstruction(
|
||||
insts.NewInstruction(result, NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef)));
|
||||
context.cfg().addInstruction(insts.NewInstruction(context.cfg().getCurrentInstruction(), result,
|
||||
NewSiteReference.make(context.cfg().getCurrentInstruction(), typeRef)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,8 +225,8 @@ public class JSAstTranslator extends AstTranslator {
|
|||
// "Function" is the name we use to model the constructor of function values
|
||||
int tmp = super.doGlobalRead(n, context, "Function", JavaScriptTypes.Function);
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).Invoke(tmp, result, new int[] { nm }, exception, new JSCallSiteReference(
|
||||
JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction())));
|
||||
((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), tmp, result, new int[]{ nm }, exception,
|
||||
new JSCallSiteReference(JavaScriptMethods.ctorReference, context.cfg().getCurrentInstruction())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -245,17 +244,18 @@ public class JSAstTranslator extends AstTranslator {
|
|||
this.visit(elt, context, this);
|
||||
int x = context.currentScope().allocateTempValue();
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).AssignInstruction(x, receiver));
|
||||
context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(), x, receiver));
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PrototypeLookup(x, x));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PrototypeLookup(context.cfg().getCurrentInstruction(), x, x));
|
||||
|
||||
if (elt.getKind() == CAstNode.CONSTANT && elt.getValue() instanceof String) {
|
||||
String field = (String) elt.getValue();
|
||||
// symtab needs to have this value
|
||||
context.currentScope().getConstantValue(field);
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).GetInstruction(result, x, field));
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory)insts).GetInstruction(context.cfg().getCurrentInstruction(), result, x, field));
|
||||
} else {
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyRead(result, x, context.getValue(elt)));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyRead(context.cfg().getCurrentInstruction(), result, x, context.getValue(elt)));
|
||||
}
|
||||
|
||||
// generate code to handle read of property from null or undefined
|
||||
|
@ -275,14 +275,14 @@ public class JSAstTranslator extends AstTranslator {
|
|||
if (elt.getKind() == CAstNode.CONSTANT && elt.getValue() instanceof String) {
|
||||
String field = (String) elt.getValue();
|
||||
if (isPrologueScript(context) && "__proto__".equals(field)) {
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).SetPrototype(receiver, rval));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).SetPrototype(context.cfg().getCurrentInstruction(), receiver, rval));
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
} else {
|
||||
context.currentScope().getConstantValue(field);
|
||||
SSAPutInstruction put = ((JSInstructionFactory) insts).PutInstruction(receiver, rval, field);
|
||||
SSAPutInstruction put = ((JSInstructionFactory) insts).PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, field);
|
||||
try {
|
||||
assert field.equals(put.getDeclaredField().getName().toUnicodeString());
|
||||
} catch (UTFDataFormatException e) {
|
||||
|
@ -292,7 +292,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
}
|
||||
} else {
|
||||
*/
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyWrite(receiver, context.getValue(elt), rval));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PropertyWrite(context.cfg().getCurrentInstruction(), receiver, context.getValue(elt), rval));
|
||||
context.cfg().addPreNode(parent, context.getUnwindState());
|
||||
|
||||
// generate code to handle read of property from null or undefined
|
||||
|
@ -310,45 +310,46 @@ public class JSAstTranslator extends AstTranslator {
|
|||
// set the class property of the new object
|
||||
int rval = context.currentScope().getConstantValue(typeName);
|
||||
context.currentScope().getConstantValue("class");
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(resultVal, rval, "class"));
|
||||
}
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), resultVal, rval, "class"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) {
|
||||
try {
|
||||
String name = (String) primitiveCall.getChild(0).getValue();
|
||||
if (name.equals("GlobalNaN")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Float(Float.NaN))));
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Float(Float.NaN))));
|
||||
} else if (name.equals("GlobalInfinity")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
|
||||
} else if (name.equals("MathE")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts)
|
||||
.AssignInstruction(resultVal, context.currentScope().getConstantValue(new Double(Math.E))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.E))));
|
||||
} else if (name.equals("MathPI")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal, context.currentScope()
|
||||
.getConstantValue(new Double(Math.PI))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.PI))));
|
||||
} else if (name.equals("MathSQRT1_2")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
|
||||
} else if (name.equals("MathSQRT2")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
|
||||
} else if (name.equals("MathLN2")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Double(Math.log(2)))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.log(2)))));
|
||||
} else if (name.equals("MathLN10")) {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal,
|
||||
context.currentScope().getConstantValue(new Double(Math.log(10)))));
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue(new Double(Math.log(10)))));
|
||||
} else if (name.equals("NewObject")) {
|
||||
doNewObject(context, null, resultVal, "Object", null);
|
||||
|
||||
|
@ -371,8 +372,9 @@ public class JSAstTranslator extends AstTranslator {
|
|||
doNewObject(context, null, resultVal, "Undefined", null);
|
||||
|
||||
} else {
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory) insts).AssignInstruction(resultVal, context.currentScope().getConstantValue(null)));
|
||||
context.cfg().addInstruction(
|
||||
((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
|
||||
resultVal, context.currentScope().getConstantValue( null )));
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
throw new RuntimeException("Cannot translate primitive " + primitiveCall.getChild(0).getValue());
|
||||
|
@ -387,11 +389,11 @@ public class JSAstTranslator extends AstTranslator {
|
|||
FieldReference fieldRef = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
|
||||
JavaScriptTypes.Root);
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(result, ref, fieldRef));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, fieldRef));
|
||||
|
||||
} else {
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(result, ref, context.getValue(f)));
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, context.getValue(f)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,7 +416,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
visit(n.getChild(1), context, visitor);
|
||||
int type = context.getValue(n.getChild(1));
|
||||
|
||||
context.cfg().addInstruction(new JavaScriptInstanceOf(result, value, type));
|
||||
context.cfg().addInstruction(new JavaScriptInstanceOf(context.cfg().getCurrentInstruction(), result, value, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -425,7 +427,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
doNewObject(context, null, tempVal, "Array", null);
|
||||
CAstSymbol args = new CAstSymbolImpl("arguments", Any);
|
||||
context.currentScope().declare(args, tempVal);
|
||||
//context.cfg().addInstruction(((JSInstructionFactory) insts).PutInstruction(1, tempVal, "arguments"));
|
||||
//context.cfg().addInstruction(((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), 1, tempVal, "arguments"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -437,7 +439,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
this.visit(n.getChild(0), context, this);
|
||||
int ref = context.getValue(n.getChild(0));
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).TypeOfInstruction(result, ref));
|
||||
context.cfg().addInstruction(((JSInstructionFactory)insts).TypeOfInstruction(context.cfg().getCurrentInstruction(), result, ref));
|
||||
|
||||
context.setValue(n, result);
|
||||
return true;
|
||||
|
@ -449,7 +451,8 @@ public class JSAstTranslator extends AstTranslator {
|
|||
this.visit(n.getChild(0), context, this);
|
||||
int ref = context.getValue(n.getChild(0));
|
||||
|
||||
context.cfg().addInstruction(((JSInstructionFactory) insts).WithRegion(ref, n.getKind() == JavaScriptCAstNode.ENTER_WITH));
|
||||
context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(context.cfg().getCurrentInstruction(), ref,
|
||||
n.getKind() == JavaScriptCAstNode.ENTER_WITH));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ public class JsPaPanel extends PaPanel {
|
|||
private MutableMapping<List<ObjectPropertyCatalogKey>> instanceKeyIdToObjectPropertyCatalogKey = MutableMapping.<List<ObjectPropertyCatalogKey>> make();
|
||||
private List<AstGlobalPointerKey> globalsPointerKeys = new ArrayList<AstGlobalPointerKey>();
|
||||
|
||||
public JsPaPanel(CallGraph cg, PointerAnalysis pa) {
|
||||
public JsPaPanel(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
|
||||
super(cg, pa);
|
||||
initDataStructures(pa);
|
||||
}
|
||||
|
||||
private void initDataStructures(PointerAnalysis pa) {
|
||||
private void initDataStructures(PointerAnalysis<InstanceKey> pa) {
|
||||
HeapGraph heapGraph = pa.getHeapGraph();
|
||||
OrdinalSetMapping<InstanceKey> instanceKeyMapping = pa.getInstanceKeyMapping();
|
||||
for (Object n : heapGraph){
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.ibm.wala.cast.js.vis;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.viz.viewer.PaPanel;
|
||||
import com.ibm.wala.viz.viewer.WalaViewer;
|
||||
|
@ -19,12 +20,12 @@ public class JsViewer extends WalaViewer{
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public JsViewer(CallGraph cg, PointerAnalysis pa) {
|
||||
public JsViewer(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
|
||||
super(cg, pa);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaPanel createPaPanel(CallGraph cg, PointerAnalysis pa) {
|
||||
protected PaPanel createPaPanel(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
|
||||
return new JsPaPanel(cg, pa);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
|
|
@ -60,7 +60,7 @@ public class AstCallGraph extends ExplicitCallGraph {
|
|||
}
|
||||
|
||||
public AstLexicalRead addGlobalRead(TypeReference type, String name) {
|
||||
AstLexicalRead s = new AstLexicalRead(nextLocal++, null, name, type);
|
||||
AstLexicalRead s = new AstLexicalRead(statements.size(), nextLocal++, null, name, type);
|
||||
statements.add(s);
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
|
|||
protected PropagationSystem makeSystem(AnalysisOptions options) {
|
||||
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
|
||||
@Override
|
||||
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
return new AstPointerAnalysisImpl(builder, cg, pointsToMap, instanceKeys, pointerKeyFactory, instanceKeyFactory);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
|||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
|
@ -98,7 +99,7 @@ public class CAstCallGraphUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void dumpCG(PointerAnalysis PA, CallGraph CG) {
|
||||
public static void dumpCG(PointerAnalysis<InstanceKey> PA, CallGraph CG) {
|
||||
if (AVOID_DUMP)
|
||||
return;
|
||||
for (Iterator x = CG.iterator(); x.hasNext();) {
|
||||
|
|
|
@ -77,7 +77,7 @@ public abstract class CrossLanguageSSAPropagationCallGraphBuilder extends AstSSA
|
|||
protected PropagationSystem makeSystem(AnalysisOptions options) {
|
||||
return new PropagationSystem(callGraph, pointerKeyFactory, instanceKeyFactory) {
|
||||
@Override
|
||||
public PointerAnalysis makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
public PointerAnalysis<InstanceKey> makePointerAnalysis(PropagationCallGraphBuilder builder) {
|
||||
assert builder == CrossLanguageSSAPropagationCallGraphBuilder.this;
|
||||
return new CrossLanguagePointerAnalysisImpl(CrossLanguageSSAPropagationCallGraphBuilder.this, cg, pointsToMap,
|
||||
instanceKeys, pointerKeyFactory, instanceKeyFactory);
|
||||
|
|
|
@ -274,5 +274,10 @@ public class CrossLanguageClassHierarchy implements IClassHierarchy {
|
|||
return new CrossLanguageClassHierarchy(scope, factory, hierarchies);
|
||||
}
|
||||
|
||||
/** BEGIN Custom change: unresolved classes */
|
||||
public Set<TypeReference> getUnresolvedClasses() {
|
||||
return HashSetFactory.make();
|
||||
}
|
||||
/** END Custom change: unresolved classes */
|
||||
|
||||
}
|
||||
|
|
|
@ -36,15 +36,15 @@ import com.ibm.wala.util.intset.OrdinalSet;
|
|||
*/
|
||||
public class LexicalModRef {
|
||||
|
||||
public static LexicalModRef make(CallGraph cg, PointerAnalysis pa) {
|
||||
public static LexicalModRef make(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
|
||||
return new LexicalModRef(cg, pa);
|
||||
}
|
||||
|
||||
private final CallGraph cg;
|
||||
|
||||
private final PointerAnalysis pa;
|
||||
private final PointerAnalysis<InstanceKey> pa;
|
||||
|
||||
protected LexicalModRef(CallGraph cg, PointerAnalysis pa) {
|
||||
protected LexicalModRef(CallGraph cg, PointerAnalysis<InstanceKey> pa) {
|
||||
this.cg = cg;
|
||||
this.pa = pa;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class LexicalModRef {
|
|||
Collection<Pair<CGNode, String>> result = HashSetFactory.make();
|
||||
// use scope-mapping instance keys in pointer analysis. may need a different
|
||||
// scheme for CG construction not based on pointer analysis
|
||||
OrdinalSet<? extends InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
|
||||
OrdinalSet<InstanceKey> functionValues = pa.getPointsToSet(pa.getHeapModel().getPointerKeyForLocal(n, 1));
|
||||
for (InstanceKey ik : functionValues) {
|
||||
if (ik instanceof ScopeMappingInstanceKey) {
|
||||
ScopeMappingInstanceKey smik = (ScopeMappingInstanceKey) ik;
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
|||
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
|
||||
import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
|
||||
import com.ibm.wala.ipa.modref.ExtendedHeapModel;
|
||||
|
@ -38,7 +39,7 @@ public class AstModRef extends ModRef {
|
|||
|
||||
protected static class AstRefVisitor extends RefVisitor<AstHeapModel> implements AstInstructionVisitor {
|
||||
|
||||
protected AstRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, AstHeapModel h) {
|
||||
protected AstRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, AstHeapModel h) {
|
||||
super(n, result, pa, h);
|
||||
}
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class AstModRef extends ModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h) {
|
||||
protected RefVisitor makeRefVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h) {
|
||||
return new AstRefVisitor(n, result, pa, (AstHeapModel)h);
|
||||
}
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class AstModRef extends ModRef {
|
|||
implements AstInstructionVisitor
|
||||
{
|
||||
|
||||
protected AstModVisitor(CGNode n, Collection<PointerKey> result, AstHeapModel h, PointerAnalysis pa) {
|
||||
protected AstModVisitor(CGNode n, Collection<PointerKey> result, AstHeapModel h, PointerAnalysis<InstanceKey> pa) {
|
||||
super(n, result, h, pa, true);
|
||||
}
|
||||
|
||||
|
@ -149,7 +150,7 @@ public class AstModRef extends ModRef {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
protected ModVisitor makeModVisitor(CGNode n, Collection<PointerKey> result, PointerAnalysis<InstanceKey> pa, ExtendedHeapModel h, boolean ignoreAllocHeapDefs) {
|
||||
return new AstModVisitor(n, result, (AstHeapModel)h, pa);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
public abstract class AbstractReflectiveGet extends ReflectiveMemberAccess {
|
||||
private final int result;
|
||||
|
||||
public AbstractReflectiveGet(int result, int objectRef, int memberRef) {
|
||||
super(objectRef, memberRef);
|
||||
public AbstractReflectiveGet(int iindex, int result, int objectRef, int memberRef) {
|
||||
super(iindex, objectRef, memberRef);
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ import com.ibm.wala.ssa.SymbolTable;
|
|||
public abstract class AbstractReflectivePut extends ReflectiveMemberAccess {
|
||||
private final int value;
|
||||
|
||||
public AbstractReflectivePut(int objectRef, int memberRef, int value) {
|
||||
super(objectRef, memberRef);
|
||||
public AbstractReflectivePut(int iindex, int objectRef, int memberRef, int value) {
|
||||
super(iindex, objectRef, memberRef);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ public class AssignInstruction extends SSAUnaryOpInstruction {
|
|||
* @param result
|
||||
* @param val
|
||||
*/
|
||||
public AssignInstruction(int result, int val) {
|
||||
super(null, result, val);
|
||||
public AssignInstruction(int iindex, int result, int val) {
|
||||
super(iindex, null, result, val);
|
||||
assert result != val;
|
||||
assert result != -1;
|
||||
assert val != -1;
|
||||
|
@ -43,7 +43,7 @@ public class AssignInstruction extends SSAUnaryOpInstruction {
|
|||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory) insts)
|
||||
.AssignInstruction(defs == null ? getDef(0) : defs[0], uses == null ? getUse(0) : uses[0]);
|
||||
.AssignInstruction(iindex, defs == null ? getDef(0) : defs[0], uses == null ? getUse(0) : uses[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -32,7 +32,8 @@ public class AstAssertInstruction extends SSAInstruction {
|
|||
|
||||
private final boolean fromSpecification;
|
||||
|
||||
public AstAssertInstruction(int value, boolean fromSpecification) {
|
||||
public AstAssertInstruction(int iindex, int value, boolean fromSpecification) {
|
||||
super(iindex);
|
||||
this.value = value;
|
||||
this.fromSpecification = fromSpecification;
|
||||
}
|
||||
|
@ -50,7 +51,7 @@ public class AstAssertInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).AssertInstruction(uses == null ? value : uses[0], fromSpecification);
|
||||
return ((AstInstructionFactory)insts).AssertInstruction(iindex, uses == null ? value : uses[0], fromSpecification);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,13 +22,14 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
public class AstEchoInstruction extends SSAInstruction {
|
||||
private final int[] rvals;
|
||||
|
||||
public AstEchoInstruction(int[] rvals) {
|
||||
public AstEchoInstruction(int iindex, int[] rvals) {
|
||||
super(iindex);
|
||||
this.rvals = rvals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).EchoInstruction(uses==null? rvals: uses);
|
||||
return ((AstInstructionFactory)insts).EchoInstruction(iindex, uses==null? rvals: uses);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,13 +26,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class AstGlobalRead extends SSAGetInstruction {
|
||||
|
||||
public AstGlobalRead(int lhs, FieldReference global) {
|
||||
super(lhs, global);
|
||||
public AstGlobalRead(int iindex, int lhs, FieldReference global) {
|
||||
super(iindex, lhs, global);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).GlobalRead((defs==null)? getDef(): defs[0], getDeclaredField());
|
||||
return ((AstInstructionFactory)insts).GlobalRead(iindex, (defs==null)? getDef(): defs[0], getDeclaredField());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,13 +26,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class AstGlobalWrite extends SSAPutInstruction {
|
||||
|
||||
public AstGlobalWrite(FieldReference global, int rhs) {
|
||||
super(rhs, global);
|
||||
public AstGlobalWrite(int iindex, FieldReference global, int rhs) {
|
||||
super(iindex, rhs, global);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).GlobalWrite(getDeclaredField(), (uses==null)? getVal(): uses[0]);
|
||||
return ((AstInstructionFactory)insts).GlobalWrite(iindex, getDeclaredField(), (uses==null)? getVal(): uses[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,38 +17,38 @@ import com.ibm.wala.types.TypeReference;
|
|||
|
||||
public interface AstInstructionFactory extends SSAInstructionFactory {
|
||||
|
||||
AssignInstruction AssignInstruction(int result, int val);
|
||||
AssignInstruction AssignInstruction(int iindex, int result, int val);
|
||||
|
||||
AstAssertInstruction AssertInstruction(int value, boolean fromSpecification);
|
||||
AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification);
|
||||
|
||||
AstEchoInstruction EchoInstruction(int[] rvals);
|
||||
AstEchoInstruction EchoInstruction(int iindex, int[] rvals);
|
||||
|
||||
AstGlobalRead GlobalRead(int lhs, FieldReference global);
|
||||
AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global);
|
||||
|
||||
AstGlobalWrite GlobalWrite(FieldReference global, int rhs);
|
||||
AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs);
|
||||
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef);
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef);
|
||||
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef);
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef);
|
||||
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal);
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal);
|
||||
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval);
|
||||
AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval);
|
||||
|
||||
AstLexicalRead LexicalRead(Access[] accesses);
|
||||
AstLexicalRead LexicalRead(int iindex, Access[] accesses);
|
||||
|
||||
AstLexicalRead LexicalRead(Access access);
|
||||
AstLexicalRead LexicalRead(int iindex, Access access);
|
||||
|
||||
AstLexicalRead LexicalRead(int lhs, String definer, String globalName, TypeReference type);
|
||||
AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type);
|
||||
|
||||
AstLexicalWrite LexicalWrite(Access[] accesses);
|
||||
AstLexicalWrite LexicalWrite(int iindex, Access[] accesses);
|
||||
|
||||
AstLexicalWrite LexicalWrite(Access access);
|
||||
AstLexicalWrite LexicalWrite(int iindex, Access access);
|
||||
|
||||
AstLexicalWrite LexicalWrite(String definer, String globalName, TypeReference type, int rhs);
|
||||
AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs);
|
||||
|
||||
EachElementGetInstruction EachElementGetInstruction(int lValue, int objectRef);
|
||||
EachElementGetInstruction EachElementGetInstruction(int iindex, int lValue, int objectRef);
|
||||
|
||||
EachElementHasNextInstruction EachElementHasNextInstruction(int lValue, int objectRef);
|
||||
EachElementHasNextInstruction EachElementHasNextInstruction(int iindex, int lValue, int objectRef);
|
||||
|
||||
}
|
||||
|
|
|
@ -49,28 +49,32 @@ public class AstIsDefinedInstruction extends SSAInstruction {
|
|||
/**
|
||||
* This constructor should only be used from {@link SSAInstruction#copyForSSA(SSAInstructionFactory, int[], int[])}
|
||||
*/
|
||||
public AstIsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
public AstIsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.rval = rval;
|
||||
this.fieldVal = fieldVal;
|
||||
this.fieldRef = fieldRef;
|
||||
}
|
||||
|
||||
public AstIsDefinedInstruction(int lval, int rval, FieldReference fieldRef) {
|
||||
public AstIsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.rval = rval;
|
||||
this.fieldVal = -1;
|
||||
this.fieldRef = fieldRef;
|
||||
}
|
||||
|
||||
public AstIsDefinedInstruction(int lval, int rval, int fieldVal) {
|
||||
public AstIsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.rval = rval;
|
||||
this.fieldVal = fieldVal;
|
||||
this.fieldRef = null;
|
||||
}
|
||||
|
||||
public AstIsDefinedInstruction(int lval, int rval) {
|
||||
public AstIsDefinedInstruction(int iindex, int lval, int rval) {
|
||||
super(iindex);
|
||||
this.lval = lval;
|
||||
this.rval = rval;
|
||||
this.fieldVal = -1;
|
||||
|
@ -81,7 +85,7 @@ public class AstIsDefinedInstruction extends SSAInstruction {
|
|||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
assert fieldVal == -1 || fieldRef == null;
|
||||
|
||||
return ((AstInstructionFactory) insts).IsDefinedInstruction((defs == null) ? lval : defs[0], (uses == null) ? rval : uses[0],
|
||||
return ((AstInstructionFactory) insts).IsDefinedInstruction(iindex, (defs == null) ? lval : defs[0], (uses == null) ? rval : uses[0],
|
||||
(uses == null || fieldVal == -1) ? fieldVal : uses[1], fieldRef);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,8 @@ public abstract class AstLexicalAccess extends SSAInstruction {
|
|||
|
||||
private Access[] accesses;
|
||||
|
||||
AstLexicalAccess(Access[] accesses) {
|
||||
AstLexicalAccess(int iindex, Access[] accesses) {
|
||||
super(iindex);
|
||||
setAccesses( accesses );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,22 +25,22 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class AstLexicalRead extends AstLexicalAccess {
|
||||
|
||||
public AstLexicalRead(Access[] accesses) {
|
||||
super(accesses);
|
||||
public AstLexicalRead(int iindex, Access[] accesses) {
|
||||
super(iindex, accesses);
|
||||
}
|
||||
|
||||
public AstLexicalRead(Access access) {
|
||||
this(new Access[] { access });
|
||||
public AstLexicalRead(int iindex, Access access) {
|
||||
this(iindex, new Access[] { access });
|
||||
}
|
||||
|
||||
public AstLexicalRead(int lhs, String definer, String globalName, TypeReference type) {
|
||||
this(new Access(globalName, definer, type, lhs));
|
||||
public AstLexicalRead(int iindex, int lhs, String definer, String globalName, TypeReference type) {
|
||||
this(iindex, new Access(globalName, definer, type, lhs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
if (defs == null) {
|
||||
return new AstLexicalRead(getAccesses());
|
||||
return new AstLexicalRead(iindex, getAccesses());
|
||||
} else {
|
||||
Access[] accesses = new Access[getAccessCount()];
|
||||
for (int i = 0; i < accesses.length; i++) {
|
||||
|
@ -48,7 +48,7 @@ public class AstLexicalRead extends AstLexicalAccess {
|
|||
accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, oldAccess.type, defs[i]);
|
||||
}
|
||||
|
||||
return ((AstInstructionFactory)insts).LexicalRead(accesses);
|
||||
return ((AstInstructionFactory)insts).LexicalRead(iindex, accesses);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,22 +25,22 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class AstLexicalWrite extends AstLexicalAccess {
|
||||
|
||||
public AstLexicalWrite(String definer, String globalName, TypeReference type, int rhs) {
|
||||
this(new Access(globalName, definer, type, rhs));
|
||||
public AstLexicalWrite(int iindex, String definer, String globalName, TypeReference type, int rhs) {
|
||||
this(iindex, new Access(globalName, definer, type, rhs));
|
||||
}
|
||||
|
||||
public AstLexicalWrite(Access access) {
|
||||
this(new Access[] { access });
|
||||
public AstLexicalWrite(int iindex, Access access) {
|
||||
this(iindex, new Access[] { access });
|
||||
}
|
||||
|
||||
public AstLexicalWrite(Access[] accesses) {
|
||||
super(accesses);
|
||||
public AstLexicalWrite(int iindex, Access[] accesses) {
|
||||
super(iindex, accesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
if (uses == null) {
|
||||
return new AstLexicalWrite(getAccesses());
|
||||
return new AstLexicalWrite(iindex, getAccesses());
|
||||
} else {
|
||||
Access[] accesses = new Access[getAccessCount()];
|
||||
for (int i = 0; i < accesses.length; i++) {
|
||||
|
@ -48,7 +48,7 @@ public class AstLexicalWrite extends AstLexicalAccess {
|
|||
accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, oldAccess.type, uses[i]);
|
||||
}
|
||||
|
||||
return ((AstInstructionFactory)insts).LexicalWrite(accesses);
|
||||
return ((AstInstructionFactory)insts).LexicalWrite(iindex, accesses);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class EachElementGetInstruction extends SSAAbstractUnaryInstruction {
|
||||
|
||||
public EachElementGetInstruction(int lValue, int objectRef) {
|
||||
super(lValue, objectRef);
|
||||
public EachElementGetInstruction(int iindex, int lValue, int objectRef) {
|
||||
super(iindex, lValue, objectRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).EachElementGetInstruction((defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
|
||||
return ((AstInstructionFactory)insts).EachElementGetInstruction(iindex, (defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,13 +31,13 @@ import com.ibm.wala.types.TypeReference;
|
|||
*/
|
||||
public class EachElementHasNextInstruction extends SSAAbstractUnaryInstruction {
|
||||
|
||||
public EachElementHasNextInstruction(int lValue, int objectRef) {
|
||||
super(lValue, objectRef);
|
||||
public EachElementHasNextInstruction(int iindex, int lValue, int objectRef) {
|
||||
super(iindex, lValue, objectRef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).EachElementHasNextInstruction((defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
|
||||
return ((AstInstructionFactory)insts).EachElementHasNextInstruction(iindex, (defs == null) ? getDef(0) : defs[0], (uses == null) ? getUse(0) : uses[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,13 +34,13 @@ public abstract class FixedParametersInvokeInstruction
|
|||
*/
|
||||
private final int[] params;
|
||||
|
||||
public FixedParametersInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(results, exception, site);
|
||||
public FixedParametersInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site) {
|
||||
super(iindex, results, exception, site);
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public FixedParametersInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(new int[]{result}, params, exception, site);
|
||||
public FixedParametersInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, new int[]{result}, params, exception, site);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,8 +49,8 @@ public abstract class FixedParametersInvokeInstruction
|
|||
* @param exception
|
||||
* @param site
|
||||
*/
|
||||
public FixedParametersInvokeInstruction(int[] params, int exception, CallSiteReference site) {
|
||||
this(null, params, exception, site);
|
||||
public FixedParametersInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
|
||||
this(iindex, null, params, exception, site);
|
||||
}
|
||||
|
||||
protected abstract SSAInstruction copyInstruction(SSAInstructionFactory insts, int result[], int[] params, int exception);
|
||||
|
|
|
@ -18,8 +18,8 @@ public abstract class MultiReturnValueInvokeInstruction
|
|||
{
|
||||
protected final int results[];
|
||||
|
||||
protected MultiReturnValueInvokeInstruction(int results[], int exception, CallSiteReference site) {
|
||||
super(exception, site);
|
||||
protected MultiReturnValueInvokeInstruction(int iindex, int results[], int exception, CallSiteReference site) {
|
||||
super(iindex, exception, site);
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ public class SSAConversion extends AbstractSSAConversion {
|
|||
private void undo(int rhs) {
|
||||
int lhs = symtab.newSymbol();
|
||||
|
||||
instructions[instructionIndex] = new AssignInstruction(lhs, rhs);
|
||||
instructions[instructionIndex] = new AssignInstruction(instructionIndex, lhs, rhs);
|
||||
|
||||
if (DEBUG_UNDO)
|
||||
System.err.println(("recreating assignment at " + instructionIndex + " as " + lhs + " = " + rhs));
|
||||
|
@ -391,7 +391,7 @@ public class SSAConversion extends AbstractSSAConversion {
|
|||
for (int i = 0; i < params.length; i++)
|
||||
params[i] = value;
|
||||
|
||||
SSAPhiInstruction phi = new SSAPhiInstruction(value, params);
|
||||
SSAPhiInstruction phi = new SSAPhiInstruction(SSAInstruction.NO_INDEX, value, params);
|
||||
|
||||
if (DEBUG)
|
||||
System.err.println(("Placing " + phi + " at " + Y));
|
||||
|
|
|
@ -270,7 +270,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
(CAstType)((CAstType.Method)entity.getType()).getArgumentTypes().get(i):
|
||||
topType();
|
||||
Access A = new Access(arg, context.getEntityName(entity), makeType(type), argVN);
|
||||
context.cfg().addInstruction(new AstLexicalWrite(A));
|
||||
context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
int lval = context.currentScope().lookup(nm).valueNumber();
|
||||
if (lval != rval) {
|
||||
context.cfg().addInstruction(new AssignInstruction(lval, rval));
|
||||
context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, lval, rval));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
final String entityName = context.getEntityName(E);
|
||||
int result = context.currentScope().allocateTempValue();
|
||||
Access A = new Access(name, entityName, type, result);
|
||||
context.cfg().addInstruction(new AstLexicalRead(A));
|
||||
context.cfg().addInstruction(new AstLexicalRead(context.cfg().currentInstruction, A));
|
||||
markExposedInEnclosingEntities(context, name, definingScope, type, E, entityName, false);
|
||||
return result;
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
// lexically-scoped variables must be written in their scope each time
|
||||
Access A = new Access(name, context.getEntityName(E), type, rval);
|
||||
context.cfg().addInstruction(new AstLexicalWrite(A));
|
||||
context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A));
|
||||
markExposedInEnclosingEntities(context, name, definingScope, type, E, context.getEntityName(E), true);
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
int result = context.currentScope().allocateTempValue();
|
||||
Access A = new Access(name, null, type, result);
|
||||
context.cfg().addInstruction(new AstLexicalRead(A));
|
||||
context.cfg().addInstruction(new AstLexicalRead(context.cfg().currentInstruction, A));
|
||||
addAccess(context, context.top(), A);
|
||||
return result;
|
||||
|
||||
|
@ -423,7 +423,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
} else {
|
||||
int result = context.currentScope().allocateTempValue();
|
||||
FieldReference global = makeGlobalRef(name);
|
||||
context.cfg().addInstruction(new AstGlobalRead(result, global));
|
||||
context.cfg().addInstruction(new AstGlobalRead(context.cfg().currentInstruction, result, global));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -437,13 +437,13 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
if (treatGlobalsAsLexicallyScoped()) {
|
||||
|
||||
Access A = new Access(name, null, type, rval);
|
||||
context.cfg().addInstruction(new AstLexicalWrite(A));
|
||||
context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A));
|
||||
addAccess(context, context.top(), A);
|
||||
|
||||
// globals can be treated as a single static location
|
||||
} else {
|
||||
FieldReference global = makeGlobalRef(name);
|
||||
context.cfg().addInstruction(new AstGlobalWrite(global, rval));
|
||||
context.cfg().addInstruction(new AstGlobalWrite(context.cfg().currentInstruction, global, rval));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,14 +753,14 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
int e = -1;
|
||||
PreBasicBlock currentBlock = getCurrentBlock();
|
||||
if (!isDeadBlock(currentBlock)) {
|
||||
addInstruction(insts.GotoInstruction(-1));
|
||||
addInstruction(insts.GotoInstruction(currentInstruction, -1));
|
||||
newBlock(false);
|
||||
}
|
||||
PreBasicBlock startBlock = getCurrentBlock();
|
||||
if (exception) {
|
||||
setCurrentBlockAsHandler();
|
||||
e = sourceContext.astContext.currentScope().allocateTempValue();
|
||||
addInstruction(insts.GetCaughtExceptionInstruction(startBlock.getNumber(), e));
|
||||
addInstruction(insts.GetCaughtExceptionInstruction(currentInstruction, startBlock.getNumber(), e));
|
||||
sourceContext.astContext.setCatchType(startBlock, defaultCatchType());
|
||||
}
|
||||
|
||||
|
@ -797,7 +797,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
addPreNode(dummy);
|
||||
doThrow(astContext, e);
|
||||
} else {
|
||||
addInstruction(insts.GotoInstruction(-1));
|
||||
addInstruction(insts.GotoInstruction(currentInstruction, -1));
|
||||
}
|
||||
newBlock(false);
|
||||
|
||||
|
@ -1277,14 +1277,14 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
if (inst instanceof SSAGetCaughtExceptionInstruction) {
|
||||
SSAGetCaughtExceptionInstruction ci = (SSAGetCaughtExceptionInstruction) inst;
|
||||
if (ci.getBasicBlockNumber() != blocks.get(i).getNumber()) {
|
||||
inst = insts.GetCaughtExceptionInstruction(blocks.get(i).getNumber(), ci.getException());
|
||||
inst = insts.GetCaughtExceptionInstruction(x, blocks.get(i).getNumber(), ci.getException());
|
||||
}
|
||||
} else if (inst instanceof SSAGotoInstruction) {
|
||||
Iterator<PreBasicBlock> succs = this.getNormalSuccessors(blocks.get(i)).iterator();
|
||||
if (succs.hasNext()) {
|
||||
PreBasicBlock target = succs.next();
|
||||
assert !succs.hasNext() : "unexpected successors for block " + blocks.get(i) + ": " + target + " and " + succs.next();
|
||||
inst = insts.GotoInstruction(target.firstIndex);
|
||||
inst = insts.GotoInstruction(x, target.firstIndex);
|
||||
} else {
|
||||
// goto to the end of the method, so the instruction is unnecessary
|
||||
inst = null;
|
||||
|
@ -1305,7 +1305,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
target = t1;
|
||||
}
|
||||
SSAConditionalBranchInstruction branch = (SSAConditionalBranchInstruction) inst;
|
||||
inst = insts.ConditionalBranchInstruction(branch.getOperator(), branch.getType(), branch.getUse(0), branch.getUse(1), target);
|
||||
inst = insts.ConditionalBranchInstruction(x, branch.getOperator(), branch.getType(), branch.getUse(0), branch.getUse(1), target);
|
||||
}
|
||||
|
||||
instructions[x++] = inst;
|
||||
|
@ -3480,7 +3480,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
assert c.getValue(n.getChild(0)) != -1 : "error in loop test " + CAstPrinter.print(n.getChild(0), context.top().getSourceMap())
|
||||
+ " of loop " + CAstPrinter.print(n, context.top().getSourceMap());
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(n.getChild(0)), context
|
||||
insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(n.getChild(0)), context
|
||||
.currentScope().getConstantValue(new Integer(0)), -1));
|
||||
PreBasicBlock branchB = context.cfg().getCurrentBlock();
|
||||
|
||||
|
@ -3488,7 +3488,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
context.cfg().newBlock(true);
|
||||
visitor.visit(n.getChild(1), context, visitor);
|
||||
if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) {
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
PreBasicBlock bodyB = context.cfg().getCurrentBlock();
|
||||
context.cfg().addEdge(bodyB, headerB);
|
||||
|
||||
|
@ -3523,7 +3523,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
String nm = (String) n.getChild(0).getValue();
|
||||
context.currentScope().declare(new FinalCAstSymbol(nm, exceptionType()));
|
||||
context.cfg().addInstruction(
|
||||
insts.GetCaughtExceptionInstruction(context.cfg().getCurrentBlock().getNumber(), context.currentScope().lookup(nm)
|
||||
insts.GetCaughtExceptionInstruction(context.cfg().currentInstruction, context.cfg().getCurrentBlock().getNumber(), context.currentScope().lookup(nm)
|
||||
.valueNumber()));
|
||||
}
|
||||
|
||||
|
@ -3645,7 +3645,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
boolean mayBeInteger = handleBinaryOpThrow(n, n.getChild(0), context);
|
||||
|
||||
context.cfg().addInstruction(
|
||||
insts.BinaryOpInstruction(translateBinaryOpcode(n.getChild(0)), false, false, result, c.getValue(l), c.getValue(r),
|
||||
insts.BinaryOpInstruction(context.cfg().currentInstruction, translateBinaryOpcode(n.getChild(0)), false, false, result, c.getValue(l), c.getValue(r),
|
||||
mayBeInteger));
|
||||
|
||||
if (mayBeInteger) {
|
||||
|
@ -3666,7 +3666,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
WalkContext context = c;
|
||||
int result = c.getValue(n);
|
||||
CAstNode v = n.getChild(1);
|
||||
context.cfg().addInstruction(insts.UnaryOpInstruction(translateUnaryOpcode(n.getChild(0)), result, c.getValue(v)));
|
||||
context.cfg().addInstruction(insts.UnaryOpInstruction(context.cfg().currentInstruction, translateUnaryOpcode(n.getChild(0)), result, c.getValue(v)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3682,7 +3682,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
WalkContext context = c;
|
||||
int result = c.getValue(n);
|
||||
int arrayValue = c.getValue(n.getChild(0));
|
||||
context.cfg().addInstruction(insts.ArrayLengthInstruction(result, arrayValue));
|
||||
context.cfg().addInstruction(insts.ArrayLengthInstruction(context.cfg().currentInstruction, result, arrayValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3736,9 +3736,9 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
protected void leaveReturn(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
|
||||
WalkContext context = c;
|
||||
if (n.getChildCount() > 0) {
|
||||
context.cfg().addInstruction(insts.ReturnInstruction(c.getValue(n.getChild(0)), false));
|
||||
context.cfg().addInstruction(insts.ReturnInstruction(context.cfg().currentInstruction, c.getValue(n.getChild(0)), false));
|
||||
} else {
|
||||
context.cfg().addInstruction(insts.ReturnInstruction());
|
||||
context.cfg().addInstruction(insts.ReturnInstruction(context.cfg().currentInstruction));
|
||||
}
|
||||
|
||||
context.cfg().addPreNode(n, context.getUnwindState());
|
||||
|
@ -3756,11 +3756,11 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
WalkContext context = c;
|
||||
if (n.getChildCount() == 1) {
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_NE), null, c.getValue(n.getChild(0)), context
|
||||
insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_NE), null, c.getValue(n.getChild(0)), context
|
||||
.currentScope().getConstantValue(new Integer(0)), -1));
|
||||
} else if (n.getChildCount() == 3) {
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(translateConditionOpcode(n.getChild(0)), null, c.getValue(n.getChild(1)),
|
||||
insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(n.getChild(0)), null, c.getValue(n.getChild(1)),
|
||||
c.getValue(n.getChild(2)), -1));
|
||||
} else {
|
||||
Assertions.UNREACHABLE();
|
||||
|
@ -3782,7 +3782,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) {
|
||||
context.cfg().addPreNode(n, context.getUnwindState());
|
||||
context.cfg().addPreEdge(n, context.getControlFlow().getTarget(n, null), false);
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
if (context.getControlFlow().getTarget(n, null) == null) {
|
||||
assert context.getControlFlow().getTarget(n, null) != null : context.getControlFlow() + " does not map " + n + " ("
|
||||
+ context.getSourceMap().getPosition(n) + ")";
|
||||
|
@ -3812,7 +3812,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
CAstNode l = n.getChild(0);
|
||||
visitor.visit(l, context, visitor);
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(l), context.currentScope()
|
||||
insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, c.getValue(l), context.currentScope()
|
||||
.getConstantValue(new Integer(0)), -1));
|
||||
PreBasicBlock srcB = context.cfg().getCurrentBlock();
|
||||
// true clause
|
||||
|
@ -3820,10 +3820,10 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
CAstNode r = n.getChild(1);
|
||||
visitor.visit(r, context, visitor);
|
||||
if (isExpr)
|
||||
context.cfg().addInstruction(new AssignInstruction(c.getValue(n), c.getValue(r)));
|
||||
context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, c.getValue(n), c.getValue(r)));
|
||||
if (n.getChildCount() == 3) {
|
||||
if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) {
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
trueB = context.cfg().getCurrentBlock();
|
||||
|
||||
// false clause
|
||||
|
@ -3834,7 +3834,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
CAstNode f = n.getChild(2);
|
||||
visitor.visit(f, context, visitor);
|
||||
if (isExpr)
|
||||
context.cfg().addInstruction(new AssignInstruction(c.getValue(n), c.getValue(f)));
|
||||
context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, c.getValue(n), c.getValue(f)));
|
||||
}
|
||||
|
||||
// end
|
||||
|
@ -4000,7 +4000,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
boolean mayBeInteger = handleBinaryOpThrow(a, op, context);
|
||||
|
||||
context.cfg().addInstruction(
|
||||
insts.BinaryOpInstruction(translateBinaryOpcode(op), false, false, temp2, temp, rval, mayBeInteger));
|
||||
insts.BinaryOpInstruction(context.cfg().currentInstruction, translateBinaryOpcode(op), false, false, temp2, temp, rval, mayBeInteger));
|
||||
|
||||
if (mayBeInteger) {
|
||||
context.cfg().newBlock(true);
|
||||
|
@ -4141,7 +4141,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
if (!pre) {
|
||||
int ret = context.currentScope().allocateTempValue();
|
||||
context.cfg().addInstruction(new AssignInstruction(ret, temp));
|
||||
context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, ret, temp));
|
||||
c.setValue(n, ret);
|
||||
}
|
||||
|
||||
|
@ -4209,12 +4209,12 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
int defaultBlock = context.cfg().getCurrentBlock().getGraphNodeId() + 1;
|
||||
|
||||
context.cfg().addInstruction(insts.SwitchInstruction(v, defaultBlock, casesAndLabels));
|
||||
context.cfg().addInstruction(insts.SwitchInstruction(context.cfg().currentInstruction, v, defaultBlock, casesAndLabels));
|
||||
context.cfg().addPreNode(n, context.getUnwindState());
|
||||
// PreBasicBlock switchB = context.cfg().getCurrentBlock();
|
||||
context.cfg().newBlock(true);
|
||||
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
defaultHackBlock = context.cfg().getCurrentBlock();
|
||||
context.cfg().newBlock(false);
|
||||
|
||||
|
@ -4258,14 +4258,14 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
if (x != CAstControlFlowMap.SWITCH_DEFAULT) {
|
||||
visitor.visit((CAstNode) x, context, visitor);
|
||||
context.cfg().addInstruction(
|
||||
insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_EQ), null, v, context.getValue((CAstNode) x), -1));
|
||||
insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, v, context.getValue((CAstNode) x), -1));
|
||||
labelToBlock.put(x, context.cfg().getCurrentBlock());
|
||||
context.cfg().newBlock(true);
|
||||
}
|
||||
}
|
||||
|
||||
PreBasicBlock defaultGotoBlock = context.cfg().getCurrentBlock();
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
context.cfg().newBlock(false);
|
||||
|
||||
CAstNode switchBody = n.getChild(1);
|
||||
|
@ -4347,7 +4347,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
context.currentScope().declare(new FinalCAstSymbol(id, exceptionType()));
|
||||
}
|
||||
context.cfg().addInstruction(
|
||||
insts.GetCaughtExceptionInstruction(context.cfg().getCurrentBlock().getNumber(), context.currentScope().lookup(id)
|
||||
insts.GetCaughtExceptionInstruction(context.cfg().currentInstruction, context.cfg().getCurrentBlock().getNumber(), context.currentScope().lookup(id)
|
||||
.valueNumber()));
|
||||
|
||||
context.cfg().addPreNode(n, context.getUnwindState());
|
||||
|
@ -4411,7 +4411,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) {
|
||||
addSkipCatchGoto = true;
|
||||
context.cfg().addInstruction(insts.GotoInstruction(-1));
|
||||
context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction, -1));
|
||||
context.cfg().newBlock(false);
|
||||
}
|
||||
|
||||
|
@ -4488,7 +4488,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
assert n.getChild(1).getValue() instanceof Boolean;
|
||||
fromSpec = n.getChild(1).getValue().equals(Boolean.TRUE);
|
||||
}
|
||||
context.cfg().addInstruction(new AstAssertInstruction(result, fromSpec));
|
||||
context.cfg().addInstruction(new AstAssertInstruction(context.cfg().currentInstruction, result, fromSpec));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4500,7 +4500,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
protected void leaveEachElementGet(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
|
||||
int result = c.currentScope().allocateTempValue();
|
||||
c.setValue(n, result);
|
||||
c.cfg().addInstruction(new EachElementGetInstruction(result, c.getValue(n.getChild(0))));
|
||||
c.cfg().addInstruction(new EachElementGetInstruction(c.cfg().currentInstruction, result, c.getValue(n.getChild(0))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4512,7 +4512,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
protected void leaveEachElementHasNext(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
|
||||
int result = c.currentScope().allocateTempValue();
|
||||
c.setValue(n, result);
|
||||
c.cfg().addInstruction(new EachElementHasNextInstruction(result, c.getValue(n.getChild(0))));
|
||||
c.cfg().addInstruction(new EachElementHasNextInstruction(c.cfg().currentInstruction, result, c.getValue(n.getChild(0))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4531,7 +4531,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
int result = wc.currentScope().allocateTempValue();
|
||||
c.setValue(n, result);
|
||||
|
||||
wc.cfg().addInstruction(insts.LoadMetadataInstruction(result, loader.getLanguage().getConstantType(typeRef), typeRef));
|
||||
wc.cfg().addInstruction(insts.LoadMetadataInstruction(wc.cfg().currentInstruction, result, loader.getLanguage().getConstantType(typeRef), typeRef));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4546,7 +4546,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
int result = wc.currentScope().allocateTempValue();
|
||||
c.setValue(n, result);
|
||||
if (n.getChildCount() == 1) {
|
||||
wc.cfg().addInstruction(new AstIsDefinedInstruction(result, ref));
|
||||
wc.cfg().addInstruction(new AstIsDefinedInstruction(wc.cfg().currentInstruction, result, ref));
|
||||
} else {
|
||||
doIsFieldDefined(wc, result, ref, n.getChild(1));
|
||||
}
|
||||
|
@ -4566,7 +4566,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
rvals[i] = c.getValue(n.getChild(i));
|
||||
}
|
||||
|
||||
wc.cfg().addInstruction(new AstEchoInstruction(rvals));
|
||||
wc.cfg().addInstruction(new AstEchoInstruction(wc.cfg().currentInstruction, rvals));
|
||||
}
|
||||
|
||||
public CAstEntity getIncludedEntity(CAstNode n) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.ibm.wala.cfg.ControlFlowGraph;
|
|||
import com.ibm.wala.cfg.IBasicBlock;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.shrikeCT.InvalidClassFileException;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.Descriptor;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
|
@ -313,6 +314,15 @@ public abstract class AstMethod implements IMethod {
|
|||
public int getNumberOfParameters() {
|
||||
return symtab.getParameterValueNumbers().length;
|
||||
}
|
||||
/** BEGIN Custom change: precise bytecode positions */
|
||||
|
||||
/*
|
||||
* @see com.ibm.wala.classLoader.IMethod#getParameterSourcePosition(int)
|
||||
*/
|
||||
public SourcePosition getParameterSourcePosition(int paramNum) throws InvalidClassFileException {
|
||||
return null;
|
||||
}
|
||||
/** END Custom change: precise bytecode positions */
|
||||
|
||||
@Override
|
||||
public int getLineNumber(int instructionIndex) {
|
||||
|
|
|
@ -15,6 +15,8 @@ import java.io.Reader;
|
|||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.classLoader.IMethod.SourcePosition;
|
||||
|
||||
/**
|
||||
* The assumption is that a typical CAst is derived from some kind of
|
||||
* textual source file, for which it makes sense to record source
|
||||
|
@ -35,13 +37,7 @@ public interface CAstSourcePositionMap {
|
|||
*
|
||||
* @author Julian Dolby (dolby@us.ibm.com)
|
||||
*/
|
||||
public interface Position extends Comparable {
|
||||
int getFirstLine();
|
||||
int getLastLine();
|
||||
int getFirstCol();
|
||||
int getLastCol();
|
||||
int getFirstOffset();
|
||||
int getLastOffset();
|
||||
public interface Position extends SourcePosition {
|
||||
URL getURL();
|
||||
Reader getReader() throws IOException;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package staticInit;
|
||||
|
||||
public class TestStaticInitOrder {
|
||||
|
||||
private static class A {
|
||||
|
||||
static int f;
|
||||
|
||||
static {
|
||||
doNothing();
|
||||
}
|
||||
|
||||
private static void doNothing() {
|
||||
B.b = 3;
|
||||
}
|
||||
}
|
||||
|
||||
private static class B {
|
||||
static int b;
|
||||
|
||||
static {
|
||||
foo();
|
||||
}
|
||||
|
||||
private static void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static class C extends B {
|
||||
|
||||
static int c = 5;
|
||||
|
||||
public static void dostuff() {
|
||||
c++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
A.f = 3;
|
||||
A.f++;
|
||||
C.dostuff();
|
||||
B.b = 13;
|
||||
B.b = 14;
|
||||
C.dostuff();
|
||||
A.f++;
|
||||
}
|
||||
}
|
|
@ -18,9 +18,9 @@
|
|||
<property name="compilerArg" value="" />
|
||||
<property name="javacSource" value="1.5" />
|
||||
<property name="javacTarget" value="1.5" />
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<!-- <condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac" />
|
||||
</condition>
|
||||
</condition> -->
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib" />
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../com.ibm.wala.core.testdata/bin/com.ibm.wala.core.testdata_1.0.0.jar
|
|
@ -0,0 +1,32 @@
|
|||
###############################################################################
|
||||
# WALA Examples property file
|
||||
# This file defines the default settings for the WALA examples
|
||||
###############################################################################
|
||||
|
||||
################# Mandatory settings without default value ####################
|
||||
|
||||
################### Mandatory settings with default value ######################
|
||||
|
||||
|
||||
############################ Optional settings ################################
|
||||
|
||||
### These are needed to run various individual examples
|
||||
|
||||
|
||||
##### PDF viewer executable
|
||||
# Path to the PDF viewer executable
|
||||
# For instance, on a windows OS it's typically something like c:/Progra~1/Adobe/Reader 8.0/Reader/AcroRd32.exe
|
||||
# On Mac OSX typically /Applications/Preview.app/Contents/MacOS/Preview
|
||||
# Default value: none
|
||||
# Info: Must be absolute path
|
||||
#####
|
||||
pdfview_exe = /Applications/Preview.app/Contents/MacOS/Preview
|
||||
|
||||
##### DOT executable
|
||||
# Path to the AT&T Graphview DOT executable
|
||||
# For instance, on a windows OS it's typically something like c:/Progra~1/Graphviz2.22/bin/dot.exe
|
||||
# On Mac OSX /usr/local/bin/dot if you install Graphviz from http://www.graphviz.org/Download_macos.php
|
||||
# Default value: none
|
||||
# Info: Must be absolute path
|
||||
#####
|
||||
dot_exe = /usr/local/bin/dot
|
|
@ -254,10 +254,10 @@ public class CallGraphTest extends WalaTestCase {
|
|||
AnalysisCache cache = new AnalysisCache();
|
||||
CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
CGNode mainMethod = AbstractPtrTest.findMainMethod(cg);
|
||||
PointerKey keyToQuery = AbstractPtrTest.getParam(mainMethod, "testThisVar", pa.getHeapModel());
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery);
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery);
|
||||
Assert.assertEquals(1, pointsToSet.size());
|
||||
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TunedRefinementTest extends AbstractPtrTest {
|
|||
// we know this one fails...
|
||||
// @Test public void testOnTheFlyCS() throws ClassHierarchyException {
|
||||
// String mainClass = TestInfo.TEST_ONTHEFLY_CS;
|
||||
// final IDemandPointerAnalysis dmp =
|
||||
// final IDemandPointerAnalysis<InstanceKey> dmp =
|
||||
// makeDemandPointerAnalysis(TestInfo.SCOPE_FILE, mainClass);
|
||||
// CGNode testMethod =
|
||||
// AbstractPtrTest.findInstanceMethod(dmp.getBaseCallGraph(),
|
||||
|
|
|
@ -65,12 +65,12 @@ public class MultiDimArrayTest extends WalaTestCase {
|
|||
|
||||
CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCache(),cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
System.err.println(pa);
|
||||
|
||||
CGNode node = findDoNothingNode(cg);
|
||||
PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
OrdinalSet<? extends InstanceKey> ptsTo = pa.getPointsToSet(pk);
|
||||
OrdinalSet<InstanceKey> ptsTo = pa.getPointsToSet(pk);
|
||||
Assert.assertEquals(1, ptsTo.size());
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TypeBasedArrayAliasTest extends WalaTestCase {
|
|||
// RTA yields a TypeBasedPointerAnalysis
|
||||
CallGraphBuilder builder = Util.makeRTABuilder(options, new AnalysisCache(),cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
|
||||
CGNode node = findNode(cg, "testMayAlias1");
|
||||
PointerKey pk1 = pa.getHeapModel().getPointerKeyForLocal(node, 1);
|
||||
|
@ -77,9 +77,9 @@ public class TypeBasedArrayAliasTest extends WalaTestCase {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static boolean mayAliased(PointerKey pk1, PointerKey pk2, PointerAnalysis pa) {
|
||||
OrdinalSet<? extends InstanceKey> ptsTo1 = pa.getPointsToSet(pk1);
|
||||
OrdinalSet<? extends InstanceKey> ptsTo2 = pa.getPointsToSet(pk2);
|
||||
private static boolean mayAliased(PointerKey pk1, PointerKey pk2, PointerAnalysis<InstanceKey> pa) {
|
||||
OrdinalSet<InstanceKey> ptsTo1 = pa.getPointsToSet(pk1);
|
||||
OrdinalSet<InstanceKey> ptsTo2 = pa.getPointsToSet(pk2);
|
||||
boolean foundIntersection = false;
|
||||
outer: for (InstanceKey i : ptsTo1) {
|
||||
for (InstanceKey j : ptsTo2) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ZeroLengthArrayTest {
|
|||
|
||||
CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
// System.err.println(pa);
|
||||
|
||||
HeapModel heapModel = pa.getHeapModel();
|
||||
|
@ -60,10 +60,10 @@ public class ZeroLengthArrayTest {
|
|||
cha.resolveMethod(MethodReference.findOrCreate(
|
||||
TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.ZERO_LENGTH_ARRAY_MAIN),
|
||||
Selector.make("main([Ljava/lang/String;)V"))), Everywhere.EVERYWHERE);
|
||||
OrdinalSet<? extends InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4));
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4));
|
||||
Assert.assertEquals(1, pointsToSet.size());
|
||||
InstanceKey arrayKey = pointsToSet.iterator().next();
|
||||
OrdinalSet<? extends InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey));
|
||||
OrdinalSet<InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey));
|
||||
System.err.println(arrayContents);
|
||||
Assert.assertEquals(0, arrayContents.size());
|
||||
|
||||
|
|
|
@ -141,7 +141,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 AnalysisCache(), cha, scope);
|
||||
final CallGraph oldCG = builder.makeCallGraph(options,null);
|
||||
final PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
final PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
|
||||
// now, run our analysis
|
||||
// build an RTA call graph
|
||||
|
@ -174,7 +174,7 @@ public class CompareToZeroOneCFADriver {
|
|||
LocalPointerKey pk = (LocalPointerKey) heapModel.getPointerKeyForLocal(node, i);
|
||||
LocalPointerKey oldPk = (LocalPointerKey) CallGraphMapUtil.mapPointerKey(pk, cg, oldCG, heapModel);
|
||||
Collection<InstanceKey> p2set = dmp.getPointsTo(pk);
|
||||
OrdinalSet<? extends InstanceKey> otherP2Set = pa.getPointsToSet(oldPk);
|
||||
OrdinalSet<InstanceKey> otherP2Set = pa.getPointsToSet(oldPk);
|
||||
System.err.println(("OLD POINTS-TO " + otherP2Set));
|
||||
for (InstanceKey key : otherP2Set) {
|
||||
if (knownBug(key)) {
|
||||
|
|
|
@ -204,7 +204,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
// extract data for analysis
|
||||
//
|
||||
CallGraph cg = getCallGraph();
|
||||
PointerAnalysis pa = getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = getPointerAnalysis();
|
||||
|
||||
//
|
||||
// collect all places where objects can escape their creating thread:
|
||||
|
@ -256,8 +256,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
//
|
||||
for (Iterator<PointerKey> rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
|
||||
PointerKey root = rts.next();
|
||||
OrdinalSet<? extends InstanceKey> objects = pa.getPointsToSet(root);
|
||||
for (Iterator<? extends InstanceKey> objs = objects.iterator(); objs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> objects = pa.getPointsToSet(root);
|
||||
for (Iterator<InstanceKey> objs = objects.iterator(); objs.hasNext();) {
|
||||
InstanceKey obj = objs.next();
|
||||
escapingInstanceKeys.add(obj);
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
if (type.isArrayClass()) {
|
||||
if (((ArrayClass) type).getElementClass() != null) {
|
||||
PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
|
||||
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
InstanceKey fobj = fobjs.next();
|
||||
if (!escapingInstanceKeys.contains(fobj)) {
|
||||
newKeys.add(fobj);
|
||||
|
@ -290,8 +290,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine {
|
|||
IField f = fs.next();
|
||||
if (f.getFieldTypeReference().isReferenceType()) {
|
||||
PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
|
||||
OrdinalSet<? extends InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<? extends InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
|
||||
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
|
||||
InstanceKey fobj = fobjs.next();
|
||||
if (!escapingInstanceKeys.contains(fobj)) {
|
||||
newKeys.add(fobj);
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
package com.ibm.wala.examples.analysis.dataflow;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.dataflow.IFDS.ISupergraph;
|
||||
import com.ibm.wala.dataflow.IFDS.TabulationResult;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.cfg.BasicBlockInContext;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.config.AnalysisScopeReader;
|
||||
import com.ibm.wala.util.intset.IntIterator;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.io.FileProvider;
|
||||
|
||||
public class InitializerTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
AnalysisScope scope = null;
|
||||
try {
|
||||
scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA,
|
||||
(new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), InitializerTest.class.getClassLoader());
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
IClassHierarchy cha = null;
|
||||
|
||||
try {
|
||||
cha = ClassHierarchy.make(scope);
|
||||
} catch (ClassHierarchyException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "LstaticInit/TestStaticInit");
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = null;
|
||||
try {
|
||||
cg = builder.makeCallGraph(options, null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (CallGraphBuilderCancelException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Start");
|
||||
|
||||
AnalysisCache cache = new AnalysisCache();
|
||||
StaticInitializer reachingDefs = new StaticInitializer(cg, cache);
|
||||
TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, IClass> result = reachingDefs.analyze();
|
||||
ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> supergraph = reachingDefs.getSupergraph();
|
||||
for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
|
||||
if (bb.getNode().toString().contains("doNothing")) {
|
||||
// System.out.println("Do!");
|
||||
IExplodedBasicBlock delegate = bb.getDelegate();
|
||||
if (delegate.getNumber() == 4) {
|
||||
IntSet solution = result.getResult(bb);
|
||||
IntIterator intIterator = solution.intIterator();
|
||||
while (intIterator.hasNext()) {
|
||||
int next = intIterator.next();
|
||||
System.out.println(reachingDefs.getDomain().getMappedObject(next));
|
||||
}
|
||||
Assert.assertEquals(3, solution.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("End");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
package com.ibm.wala.examples.analysis.dataflow;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IField;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.dataflow.IFDS.ICFGSupergraph;
|
||||
import com.ibm.wala.dataflow.IFDS.IFlowFunction;
|
||||
import com.ibm.wala.dataflow.IFDS.IMergeFunction;
|
||||
import com.ibm.wala.dataflow.IFDS.IPartiallyBalancedFlowFunctions;
|
||||
import com.ibm.wala.dataflow.IFDS.ISupergraph;
|
||||
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
|
||||
import com.ibm.wala.dataflow.IFDS.IdentityFlowFunction;
|
||||
import com.ibm.wala.dataflow.IFDS.KillEverything;
|
||||
import com.ibm.wala.dataflow.IFDS.PartiallyBalancedTabulationProblem;
|
||||
import com.ibm.wala.dataflow.IFDS.PartiallyBalancedTabulationSolver;
|
||||
import com.ibm.wala.dataflow.IFDS.PathEdge;
|
||||
import com.ibm.wala.dataflow.IFDS.TabulationDomain;
|
||||
import com.ibm.wala.dataflow.IFDS.TabulationResult;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.cfg.BasicBlockInContext;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.SSAGetInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInvokeInstruction;
|
||||
import com.ibm.wala.ssa.SSANewInstruction;
|
||||
import com.ibm.wala.ssa.SSAPutInstruction;
|
||||
import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
import com.ibm.wala.util.intset.MutableMapping;
|
||||
import com.ibm.wala.util.intset.MutableSparseIntSet;
|
||||
|
||||
public class StaticInitializer {
|
||||
|
||||
/**
|
||||
* used for resolving field references in putstatic instructions
|
||||
*/
|
||||
private final IClassHierarchy cha;
|
||||
|
||||
/**
|
||||
* the supergraph over which tabulation is performed
|
||||
*/
|
||||
private final ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> supergraph;
|
||||
|
||||
|
||||
private final InitializerDomain domain = new InitializerDomain();
|
||||
|
||||
private Map<BasicBlockInContext<IExplodedBasicBlock>, List<IClass>> initialized;
|
||||
|
||||
|
||||
public final Map<BasicBlockInContext<IExplodedBasicBlock>, List<IClass>> getInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public StaticInitializer(CallGraph cg, AnalysisCache cache) {
|
||||
cha = cg.getClassHierarchy();
|
||||
supergraph = ICFGSupergraph.make(cg, cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* controls numbering of putstatic instructions for use in tabulation
|
||||
*/
|
||||
private class InitializerDomain extends MutableMapping<IClass> implements
|
||||
TabulationDomain<IClass, BasicBlockInContext<IExplodedBasicBlock>> {
|
||||
|
||||
public boolean hasPriorityOver(PathEdge<BasicBlockInContext<IExplodedBasicBlock>> p1,
|
||||
PathEdge<BasicBlockInContext<IExplodedBasicBlock>> p2) {
|
||||
// don't worry about worklist priorities
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class InitializerFlowFunctions implements IPartiallyBalancedFlowFunctions<BasicBlockInContext<IExplodedBasicBlock>> {
|
||||
|
||||
private final InitializerDomain domain;
|
||||
|
||||
protected InitializerFlowFunctions(InitializerDomain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* the flow function for flow from a callee to caller where there was no flow from caller to callee; just the identity function
|
||||
*
|
||||
* @see ReachingDefsProblem
|
||||
*/
|
||||
public IFlowFunction getUnbalancedReturnFlowFunction(BasicBlockInContext<IExplodedBasicBlock> src,
|
||||
BasicBlockInContext<IExplodedBasicBlock> dest) {
|
||||
return IdentityFlowFunction.identity();
|
||||
}
|
||||
|
||||
/**
|
||||
* flow function from caller to callee; just the identity function
|
||||
*/
|
||||
public IUnaryFlowFunction getCallFlowFunction(BasicBlockInContext<IExplodedBasicBlock> src,
|
||||
BasicBlockInContext<IExplodedBasicBlock> dest, BasicBlockInContext<IExplodedBasicBlock> ret) {
|
||||
return IdentityFlowFunction.identity();
|
||||
}
|
||||
|
||||
/**
|
||||
* flow function from call node to return node when there are no targets for the call site; not a case we are expecting
|
||||
*/
|
||||
public IUnaryFlowFunction getCallNoneToReturnFlowFunction(BasicBlockInContext<IExplodedBasicBlock> src,
|
||||
BasicBlockInContext<IExplodedBasicBlock> dest) {
|
||||
// if we're missing callees, just keep what information we have
|
||||
return IdentityFlowFunction.identity();
|
||||
}
|
||||
|
||||
/**
|
||||
* flow function from call node to return node at a call site when callees exist. We kill everything; surviving facts should
|
||||
* flow out of the callee
|
||||
*/
|
||||
public IUnaryFlowFunction getCallToReturnFlowFunction(BasicBlockInContext<IExplodedBasicBlock> src,
|
||||
BasicBlockInContext<IExplodedBasicBlock> dest) {
|
||||
return KillEverything.singleton();
|
||||
}
|
||||
|
||||
/**
|
||||
* flow function for normal intraprocedural edges
|
||||
*/
|
||||
public IUnaryFlowFunction getNormalFlowFunction(final BasicBlockInContext<IExplodedBasicBlock> src,
|
||||
BasicBlockInContext<IExplodedBasicBlock> dest) {
|
||||
final IExplodedBasicBlock ebb = src.getDelegate();
|
||||
SSAInstruction instruction = ebb.getInstruction();
|
||||
if (instruction instanceof SSAPutInstruction) {
|
||||
final SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
|
||||
if (putInstr.isStatic()) {
|
||||
return new IUnaryFlowFunction() {
|
||||
|
||||
public IntSet getTargets(int d1) {
|
||||
System.out.println(ebb.toString());
|
||||
System.out.println(d1);
|
||||
// first, gen this statement
|
||||
int factNum = domain.getMappedIndex(cha.lookupClass(putInstr.getDeclaredField().getDeclaringClass()));
|
||||
System.out.println(factNum);
|
||||
assert factNum != -1;
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
result.add(factNum);
|
||||
// if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it
|
||||
if (d1 != factNum) {
|
||||
result.add(d1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Initializer Normal Flow";
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if(instruction instanceof SSAGetInstruction) {
|
||||
final SSAGetInstruction getInstr = (SSAGetInstruction) instruction;
|
||||
if (getInstr.isStatic()) { //Auf konstante überprüfen
|
||||
return new IUnaryFlowFunction() {
|
||||
|
||||
public IntSet getTargets(int d1) {
|
||||
// first, gen this statement
|
||||
int factNum = domain.getMappedIndex(cha.lookupClass(getInstr.getDeclaredField().getDeclaringClass()));
|
||||
assert factNum != -1;
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
result.add(factNum);
|
||||
// if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it
|
||||
if (d1 != factNum) {
|
||||
result.add(d1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Initializer Normal Flow";
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (instruction instanceof SSANewInstruction) {
|
||||
final SSANewInstruction newInstr = (SSANewInstruction) instruction;
|
||||
return new IUnaryFlowFunction() {
|
||||
|
||||
public IntSet getTargets(int d1) {
|
||||
// first, gen this statement
|
||||
int factNum = domain.getMappedIndex(cha.lookupClass(newInstr.getConcreteType()));
|
||||
assert factNum != -1;
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
result.add(factNum);
|
||||
// if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it
|
||||
if (d1 != factNum) {
|
||||
result.add(d1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Initializer Normal Flow";
|
||||
}
|
||||
};
|
||||
|
||||
} else if (instruction instanceof SSAInvokeInstruction) {
|
||||
final SSAInvokeInstruction invInstr = (SSAInvokeInstruction) instruction;
|
||||
if (invInstr.isStatic()) {
|
||||
return new IUnaryFlowFunction() {
|
||||
|
||||
public IntSet getTargets(int d1) {
|
||||
System.out.println("Invoke!");
|
||||
// first, gen this statement
|
||||
int factNum = domain.getMappedIndex(cha.lookupClass(invInstr.getDeclaredTarget().getDeclaringClass()));
|
||||
assert factNum != -1;
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
result.add(factNum);
|
||||
// if incoming statement is some different statement that defs the same static field, kill it; otherwise, keep it
|
||||
if (d1 != factNum) {
|
||||
result.add(d1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Initializer Normal Flow";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// identity function when src block isn't for a putstatic
|
||||
return IdentityFlowFunction.identity();
|
||||
}
|
||||
|
||||
/**
|
||||
* standard flow function from callee to caller; just identity
|
||||
*/
|
||||
public IFlowFunction getReturnFlowFunction(BasicBlockInContext<IExplodedBasicBlock> call,
|
||||
BasicBlockInContext<IExplodedBasicBlock> src, BasicBlockInContext<IExplodedBasicBlock> dest) {
|
||||
return IdentityFlowFunction.identity();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ReachingDefsProblem implements
|
||||
PartiallyBalancedTabulationProblem<BasicBlockInContext<IExplodedBasicBlock>, CGNode, IClass> {
|
||||
|
||||
private InitializerFlowFunctions flowFunctions = new InitializerFlowFunctions(domain);
|
||||
|
||||
/**
|
||||
* path edges corresponding to all putstatic instructions, used as seeds for the analysis
|
||||
*/
|
||||
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> initialSeeds = collectInitialSeeds();
|
||||
|
||||
/**
|
||||
* we use the entry block of the CGNode as the fake entry when propagating from callee to caller with unbalanced parens
|
||||
*/
|
||||
public BasicBlockInContext<IExplodedBasicBlock> getFakeEntry(BasicBlockInContext<IExplodedBasicBlock> node) {
|
||||
final CGNode cgNode = node.getNode();
|
||||
return getFakeEntry(cgNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* we use the entry block of the CGNode as the "fake" entry when propagating from callee to caller with unbalanced parens
|
||||
*/
|
||||
private BasicBlockInContext<IExplodedBasicBlock> getFakeEntry(final CGNode cgNode) {
|
||||
BasicBlockInContext<IExplodedBasicBlock>[] entriesForProcedure = supergraph.getEntriesForProcedure(cgNode);
|
||||
assert entriesForProcedure.length == 1;
|
||||
return entriesForProcedure[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
|
||||
*/
|
||||
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
|
||||
Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
|
||||
for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
|
||||
IExplodedBasicBlock ebb = bb.getDelegate();
|
||||
SSAInstruction instruction = ebb.getInstruction();
|
||||
if (instruction instanceof SSAPutInstruction) {
|
||||
SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
|
||||
if (putInstr.isStatic()) {
|
||||
final CGNode cgNode = bb.getNode();
|
||||
IClass fact = cha.lookupClass(putInstr.getDeclaredField().getDeclaringClass());
|
||||
int factNum = domain.add(fact);
|
||||
BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
|
||||
// note that the fact number used for the source of this path edge doesn't really matter
|
||||
result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));
|
||||
|
||||
}
|
||||
} else if (instruction instanceof SSAGetInstruction) {
|
||||
SSAGetInstruction getInstr = (SSAGetInstruction) instruction;
|
||||
if (getInstr.isStatic()) {
|
||||
final CGNode cgNode = bb.getNode();
|
||||
IClass fact = cha.lookupClass(getInstr.getDeclaredField().getDeclaringClass());
|
||||
int factNum = domain.add(fact);
|
||||
BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
|
||||
// note that the fact number used for the source of this path edge doesn't really matter
|
||||
result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));
|
||||
|
||||
}
|
||||
} else if (instruction instanceof SSANewInstruction) {
|
||||
SSANewInstruction newInstr = (SSANewInstruction) instruction;
|
||||
final CGNode cgNode = bb.getNode();
|
||||
IClass fact = cha.lookupClass(newInstr.getConcreteType());
|
||||
int factNum = domain.add(fact);
|
||||
BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
|
||||
// note that the fact number used for the source of this path edge doesn't really matter
|
||||
result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));
|
||||
} else if (instruction instanceof SSAInvokeInstruction) {
|
||||
SSAInvokeInstruction invInstr = (SSAInvokeInstruction) instruction;
|
||||
if (invInstr.isStatic()) {
|
||||
final CGNode cgNode = bb.getNode();
|
||||
IClass fact = cha.lookupClass(invInstr.getDeclaredTarget().getDeclaringClass());
|
||||
int factNum = domain.add(fact);
|
||||
BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
|
||||
// note that the fact number used for the source of this path edge doesn't really matter
|
||||
result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public IPartiallyBalancedFlowFunctions<BasicBlockInContext<IExplodedBasicBlock>> getFunctionMap() {
|
||||
return flowFunctions;
|
||||
}
|
||||
|
||||
public TabulationDomain<IClass, BasicBlockInContext<IExplodedBasicBlock>> getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* we don't need a merge function; the default unioning of tabulation works fine
|
||||
*/
|
||||
public IMergeFunction getMergeFunction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> getSupergraph() {
|
||||
return supergraph;
|
||||
}
|
||||
|
||||
public Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> initialSeeds() {
|
||||
return initialSeeds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* perform the tabulation analysis and return the {@link TabulationResult}
|
||||
*/
|
||||
public TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, IClass> analyze() {
|
||||
PartiallyBalancedTabulationSolver<BasicBlockInContext<IExplodedBasicBlock>, CGNode, IClass> solver = PartiallyBalancedTabulationSolver
|
||||
.createPartiallyBalancedTabulationSolver(new ReachingDefsProblem(), null);
|
||||
TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, IClass> result = null;
|
||||
try {
|
||||
result = solver.solve();
|
||||
} catch (CancelException e) {
|
||||
// this shouldn't happen
|
||||
assert false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> getSupergraph() {
|
||||
return supergraph;
|
||||
}
|
||||
|
||||
public TabulationDomain<IClass, BasicBlockInContext<IExplodedBasicBlock>> getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import com.ibm.wala.ipa.callgraph.CallGraph;
|
|||
import com.ibm.wala.ipa.callgraph.CallGraphBuilderCancelException;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
|
@ -65,7 +66,7 @@ public class JavaViewerDriver {
|
|||
com.ibm.wala.ipa.callgraph.CallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
|
||||
new WalaViewer(cg, pa);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
|
||||
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
|
||||
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
|
||||
org.eclipse.jdt.core.builder.invalidClasspath=abort
|
||||
org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
|
||||
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=,*.g
|
||||
org.eclipse.jdt.core.circularClasspath=error
|
||||
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
|
||||
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
|
||||
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
|
@ -14,6 +23,7 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
|||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
|
@ -381,3 +391,5 @@ org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
|||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
|
||||
org.eclipse.jdt.core.incompleteClasspath=error
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
|
|
@ -17,6 +17,9 @@ Export-Package: .,
|
|||
com.ibm.wala.analysis.typeInference,
|
||||
com.ibm.wala.cfg,
|
||||
com.ibm.wala.cfg.cdg,
|
||||
com.ibm.wala.cfg.exc,
|
||||
com.ibm.wala.cfg.exc.inter,
|
||||
com.ibm.wala.cfg.exc.intra,
|
||||
com.ibm.wala.classLoader,
|
||||
com.ibm.wala.client,
|
||||
com.ibm.wala.core.plugin,
|
||||
|
@ -34,6 +37,7 @@ Export-Package: .,
|
|||
com.ibm.wala.ipa.callgraph.propagation,
|
||||
com.ibm.wala.ipa.callgraph.propagation.cfa,
|
||||
com.ibm.wala.ipa.callgraph.propagation.rta,
|
||||
com.ibm.wala.ipa.callgraph.pruned,
|
||||
com.ibm.wala.ipa.cfg,
|
||||
com.ibm.wala.ipa.cha,
|
||||
com.ibm.wala.ipa.modref,
|
||||
|
@ -56,9 +60,11 @@ Export-Package: .,
|
|||
com.ibm.wala.util.ref,
|
||||
com.ibm.wala.util.scope,
|
||||
com.ibm.wala.util.shrike,
|
||||
com.ibm.wala.util.ssa,
|
||||
com.ibm.wala.util.strings,
|
||||
com.ibm.wala.util.warnings,
|
||||
com.ibm.wala.viz,
|
||||
com.ibm.wala.viz.viewer
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Eclipse-BuddyPolicy: registered
|
||||
Bundle-ClassPath: .
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
bin.includes = lib/primordial.jar.model,\
|
||||
plugin.properties,\
|
||||
bin.includes = plugin.properties,\
|
||||
dat/natives.xml,\
|
||||
META-INF/,\
|
||||
.
|
||||
.,\
|
||||
lib/
|
||||
jars.compile.order = .
|
||||
output.. = bin/
|
||||
source.. = dat/,\
|
||||
|
|
|
@ -449,12 +449,21 @@
|
|||
</method>
|
||||
<method name="setErr0"
|
||||
descriptor="(Ljava/io/PrintStream;)V" static="true">
|
||||
<putstatic class="Ljava/lang/System"
|
||||
field="err" fieldType="Ljava/lang/PrintStream"
|
||||
value="arg0" />
|
||||
</method>
|
||||
<method name="setIn0"
|
||||
descriptor="(Ljava/io/InputStream;)V" static="true">
|
||||
<putstatic class="Ljava/lang/System"
|
||||
field="in" fieldType="Ljava/lang/InputStream"
|
||||
value="arg0" />
|
||||
</method>
|
||||
<method name="setOut0"
|
||||
descriptor="(Ljava/io/PrintStream;)V" static="true">
|
||||
<putstatic class="Ljava/lang/System"
|
||||
field="out" fieldType="Ljava/lang/PrintStream"
|
||||
value="arg0" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="Thread">
|
||||
|
|
|
@ -0,0 +1,882 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!-- native methods in the IBM Windows DK 1.3.1 -->
|
||||
<summary-spec>
|
||||
<classloader name="Primordial">
|
||||
|
||||
<package name="com/ibm/wala/model">
|
||||
<class name="SyntheticFactory">
|
||||
<method name="getObject"
|
||||
descriptor="()Ljava/lang/Object;" factory="true" static="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="com/ibm/jvm">
|
||||
<class name="ExtendedSystem">
|
||||
<method name="isResettableJVM" descriptor="()Z"
|
||||
static="true">
|
||||
</method>
|
||||
<method name="setJVMUnresettableConditionally"
|
||||
descriptor="(ILjava/lang/String;)V" static="true">
|
||||
</method>
|
||||
<method name="resizeArray"
|
||||
descriptor="(ILjava/lang/Object;II)Ljava/lang/Object;"
|
||||
factory="true" static="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
|
||||
</package>
|
||||
|
||||
<package name="java/io">
|
||||
<class name="FileDescriptor">
|
||||
<method name="sync" descriptor="()V"></method>
|
||||
</class>
|
||||
<class name="FileInputStream">
|
||||
<method name="available" descriptor="()I">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="close" descriptor="()V">
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="open"
|
||||
descriptor="(Ljava/lang/String;)V">
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="read" descriptor="()I">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="readBytes" descriptor="([BII)I">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<constant name="the-answer" type="int" value="42"/>
|
||||
<aastore ref="arg1" index="no" value="the-answer" type="B"/>
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="readBytes"
|
||||
descriptor="([BIILjava/io/FileDescriptor;)I">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="skip" descriptor="(J)J">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="FileOutputStream">
|
||||
<method name="close" descriptor="()V"></method>
|
||||
<method name="open"
|
||||
descriptor="(Ljava/lang/String;)V">
|
||||
</method>
|
||||
<method name="openAppend"
|
||||
descriptor="(Ljava/lang/String;)V">
|
||||
</method>
|
||||
<method name="write" descriptor="(I)V"></method>
|
||||
<method name="writeBytes" descriptor="([BIIZ)V">
|
||||
<constant name="the-answer" type="byte" value="42"/>
|
||||
<aaload def="foo" ref="arg1" index="the-answer" type="B"/>
|
||||
<putfield class="Ljava/io/FileOutputStream" field="realWorld"
|
||||
fieldType="I" value="foo" ref="arg0" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="writeBytes" descriptor="([BII)V">
|
||||
<constant name="the-answer" type="byte" value="42"/>
|
||||
<aaload def="foo" ref="arg1" index="the-answer" type="B"/>
|
||||
<putfield class="Ljava/io/FileOutputStream" field="realWorld"
|
||||
fieldType="I" value="foo" ref="arg0" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="ObjectOutputStream">
|
||||
<method name="doublesToBytes" descriptor="([DI[BII)V"
|
||||
static="true" />
|
||||
<method name="floatsToBytes" descriptor="([FI[BII)V"
|
||||
static="true" />
|
||||
</class>
|
||||
<class name="ObjectStreamClass">
|
||||
<method name="hasStaticInitializer"
|
||||
descriptor="(Ljava/lang/Class;)Z" static="true">
|
||||
</method>
|
||||
</class>
|
||||
<class name="RandomAccessFile">
|
||||
<method name="close" descriptor="()V"></method>
|
||||
<method name="getFilePointer" descriptor="()J"></method>
|
||||
<method name="length" descriptor="()J"></method>
|
||||
<method name="open"
|
||||
descriptor="(Ljava/lang/String;Z)V">
|
||||
</method>
|
||||
<method name="open"
|
||||
descriptor="(Ljava/lang/String;I)V">
|
||||
</method>
|
||||
<method name="read" descriptor="()I"></method>
|
||||
<method name="readBytes"
|
||||
descriptor="([BIILjava/io/FileDescriptor;)I">
|
||||
</method>
|
||||
<method name="seek" descriptor="(J)V"></method>
|
||||
<method name="write" descriptor="(I)V"></method>
|
||||
<method name="writeBytes"
|
||||
descriptor="([BIILjava/io/FileDescriptor;)V">
|
||||
</method>
|
||||
<method name="writeBytes" descriptor="([BII)V"></method>
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/lang">
|
||||
<class name="Class">
|
||||
<method name="forName"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/Class;"
|
||||
static="true">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/lang/ClassNotFoundException" />
|
||||
<throw value="y" />
|
||||
<new def="z" class="Ljava/lang/ClassFormatError" />
|
||||
<throw value="z" />
|
||||
</method>
|
||||
<method name="forName0"
|
||||
descriptor="(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;"
|
||||
static="true">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/lang/ClassNotFoundException" />
|
||||
<throw value="y" />
|
||||
<new def="z" class="Ljava/lang/ClassFormatError" />
|
||||
<throw value="z" />
|
||||
</method>
|
||||
<method name="forName1"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/Class;" static="true">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/lang/ClassNotFoundException" />
|
||||
<throw value="y" />
|
||||
<new def="z" class="Ljava/lang/ClassFormatError" />
|
||||
<throw value="z" />
|
||||
</method>
|
||||
<method name="getClassLoader0"
|
||||
descriptor="()Ljava/lang/ClassLoader;">
|
||||
<new def="x" class="Ljava/lang/ClassLoader" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getComponentType"
|
||||
descriptor="()Ljava/lang/Class;">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getConstructor0"
|
||||
descriptor="([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;">
|
||||
<new def="x" class="Ljava/lang/reflect/Constructor" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getField0"
|
||||
descriptor="(Ljava/lang/String;I)Ljava/lang/reflect/Field;">
|
||||
<new def="x" class="Ljava/lang/reflect/Field" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getInterfaces"
|
||||
descriptor="()[Ljava/lang/Class;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[Ljava/lang/Class" size="size" />
|
||||
<new def="y" class="Ljava/lang/Class" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getMethod0"
|
||||
descriptor="(Ljava/lang/String;[Ljava/lang/Class;I)Ljava/lang/reflect/Method;">
|
||||
<new def="x" class="Ljava/lang/reflect/Method" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getMethods0"
|
||||
descriptor="(I)[Ljava/lang/reflect/Method;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[Ljava/lang/reflect/Method"
|
||||
size="size" />
|
||||
<new def="y" class="Ljava/lang/reflect/Method" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getModifiers" descriptor="()I"></method>
|
||||
<method name="getName"
|
||||
descriptor="()Ljava/lang/String;">
|
||||
<new def="x" class="Ljava/lang/String" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getPrimitiveClass"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/Class;" static="true">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getSigners"
|
||||
descriptor="()[Ljava/lang/Object;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[Ljava/lang/Object" size="size" />
|
||||
<new def="y" class="Ljava/lang/Class" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getSuperclass"
|
||||
descriptor="()Ljava/lang/Class;">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getFields"
|
||||
descriptor="()[Ljava/lang/reflect/Field;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[Ljava/lang/reflect/Field" size="size"/>
|
||||
<new def="y" class="Ljava/lang/reflect/Field" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getConstructors"
|
||||
descriptor="()[Ljava/lang/reflect/Constructor;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x"
|
||||
class="[Ljava/lang/reflect/Constructor" size="size"/>
|
||||
<new def="y" class="Ljava/lang/reflect/Constructor" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="isAssignableFrom"
|
||||
descriptor="(Ljava/lang/Class;)Z">
|
||||
</method>
|
||||
<method name="isArray" descriptor="()Z"></method>
|
||||
<method name="isInstance"
|
||||
descriptor="(Ljava/lang/Object;)Z">
|
||||
</method>
|
||||
<method name="isInterface" descriptor="()Z"></method>
|
||||
<method name="isPrimitive" descriptor="()Z"></method>
|
||||
<method name="newInstance"
|
||||
descriptor="()Ljava/lang/Object;" factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="ClassLoader" allocatable="true">
|
||||
<method name="findBootstrapClass"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/Class;">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="findLoadedClass"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/Class;">
|
||||
<call type="static" name="forName"
|
||||
class="Ljava/lang/Class" descriptor="(Ljava/lang/String;)Ljava/lang/Class;"
|
||||
arg0="arg0" def="x" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getCallerClassLoader"
|
||||
descriptor="()Ljava/lang/ClassLoader;" static="true">
|
||||
<new def="x" class="Ljava/lang/ClassLoader" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="Double">
|
||||
<method name="doubleToLongBits" descriptor="(D)J"
|
||||
static="true">
|
||||
</method>
|
||||
<method name="longBitsToDouble" descriptor="(J)D"
|
||||
static="true">
|
||||
</method>
|
||||
</class>
|
||||
<class name="Float">
|
||||
<method name="floatToIntBits" descriptor="(F)I"
|
||||
static="true">
|
||||
</method>
|
||||
<method name="intBitsToFloat" descriptor="(I)F"
|
||||
static="true">
|
||||
</method>
|
||||
</class>
|
||||
<class name="Object">
|
||||
<method name="clone"
|
||||
descriptor="()Ljava/lang/Object;">
|
||||
<return value="null" />
|
||||
<!-- Note that propagation-style builders should intercept calls to clone, and this model is OK for RTA -->
|
||||
</method>
|
||||
<method name="getClass"
|
||||
descriptor="()Ljava/lang/Class;">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="hashCode" descriptor="()I"></method>
|
||||
<method name="notify" descriptor="()V"></method>
|
||||
<method name="notifyAll" descriptor="()V"></method>
|
||||
<method name="wait" descriptor="(J)V"></method>
|
||||
</class>
|
||||
<class name="Runtime">
|
||||
<method name="freeMemory" descriptor="()J"></method>
|
||||
<method name="gc" descriptor="()V"></method>
|
||||
<method name="totalMemory" descriptor="()J"></method>
|
||||
</class>
|
||||
<class name="SecurityManager">
|
||||
<method name="getClassContext"
|
||||
descriptor="()[Ljava/lang/Class;">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[Ljava/lang/Class" size="size"/>
|
||||
<new def="y" class="Ljava/lang/Class" />
|
||||
<aastore ref="x" value="y" index="0" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="StrictMath">
|
||||
<method name="ceil" descriptor="(D)D" static="true"></method>
|
||||
<method name="exp" descriptor="(D)D" static="true"></method>
|
||||
<method name="floor" descriptor="(D)D" static="true"></method>
|
||||
<method name="pow" descriptor="(DD)D" static="true"></method>
|
||||
</class>
|
||||
<class name="String">
|
||||
<method name="intern"
|
||||
descriptor="()Ljava/lang/String;">
|
||||
<new def="x" class="Ljava/lang/String" />
|
||||
<return value="x" />
|
||||
<poison
|
||||
reason="questionable model of java/lang/String/intern()"
|
||||
level="mild" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="System">
|
||||
<method name="<clinit>" static="true"
|
||||
descriptor="()V">
|
||||
<new def="secure"
|
||||
class="Ljava/lang/SecurityManager" />
|
||||
<putstatic class="Ljava/lang/System"
|
||||
field="security" fieldType="Ljava/lang/SecurityManager"
|
||||
value="secure" />
|
||||
<call type="static" name="initializeSystemClass"
|
||||
class="Ljava/lang/System" descriptor="()V" />
|
||||
</method>
|
||||
|
||||
<method name="initializeSystemClass" descriptor="()V"
|
||||
static="true">
|
||||
<new def="x" class="Ljava/util/Properties" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/util/Properties" descriptor="()V" arg0="x" />
|
||||
<new def="key" class="Ljava/lang/String" />
|
||||
<new def="value" class="Ljava/lang/String" />
|
||||
<call type="virtual" name="put"
|
||||
class="Ljava/util/Hashtable"
|
||||
descriptor="(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"
|
||||
arg0="x" arg1="key" arg2="value" def="ignore" />
|
||||
|
||||
<new def="in" class="Ljava/io/FileInputStream" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/io/FileInputStream" descriptor="()V" arg0="in" />
|
||||
|
||||
<new def="o" class="Ljava/io/FileOutputStream" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/io/FileOutputStream" descriptor="()V" arg0="o" />
|
||||
<new def="e" class="Ljava/io/FileOutputStream" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/io/FileOutputStream" descriptor="()V" arg0="e" />
|
||||
|
||||
<new def="out" class="Ljava/io/PrintStream" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/io/PrintStream"
|
||||
descriptor="(Ljava/io/OutputStream;)V" arg0="out" arg1="o" />
|
||||
<new def="err" class="Ljava/io/PrintStream" />
|
||||
<call type="special" name="<init>"
|
||||
class="Ljava/io/PrintStream"
|
||||
descriptor="(Ljava/io/OutputStream;)V" arg0="err" arg1="e" />
|
||||
|
||||
<putstatic class="Ljava/lang/System" field="in"
|
||||
fieldType="Ljava/io/InputStream" value="in" />
|
||||
<putstatic class="Ljava/lang/System" field="out"
|
||||
fieldType="Ljava/io/PrintStream" value="out" />
|
||||
<putstatic class="Ljava/lang/System" field="err"
|
||||
fieldType="Ljava/io/PrintStream" value="err" />
|
||||
</method>
|
||||
<!-- <method name="arraycopy"
|
||||
descriptor="(Ljava/lang/Object;ILjava/lang/Object;II)V"
|
||||
static="true">
|
||||
<call type="static" name="arraycopy"
|
||||
class="Lcom/ibm/wala/model/java/lang/System"
|
||||
descriptor="(Ljava/lang/Object;Ljava/lang/Object;)V" arg0="arg0"
|
||||
arg1="arg2" />
|
||||
<return />
|
||||
</method> -->
|
||||
<method name="currentTimeMillis" descriptor="()J"
|
||||
static="true">
|
||||
</method>
|
||||
<method name="getCallerClass"
|
||||
descriptor="()Ljava/lang/Class;" static="true">
|
||||
<new def="x" class="Ljava/lang/Class" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="identityHashCode"
|
||||
descriptor="(Ljava/lang/Object;)I" static="true">
|
||||
</method>
|
||||
<method name="initProperties"
|
||||
descriptor="(Ljava/util/Properties;)Ljava/util/Properties;"
|
||||
static="true">
|
||||
<new def="dummy1" class="Ljava/lang/Object" />
|
||||
<new def="dummy2" class="Ljava/lang/Object" />
|
||||
<call type="virtual" name="put"
|
||||
class="Ljava/util/Properties"
|
||||
descriptor="(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"
|
||||
arg0="arg0" arg1="dummy1" arg2="dummy2" def="ignore" />
|
||||
<new def="x" class="Ljava/util/Properties" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getProperty"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/String;"
|
||||
static="true">
|
||||
<new def="x" class="Ljava/lang/String" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="getProperty"
|
||||
descriptor="(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"
|
||||
static="true">
|
||||
<return value="arg1" />
|
||||
<new def="x" class="Ljava/lang/String" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="mapLibraryName"
|
||||
descriptor="(Ljava/lang/String;)Ljava/lang/String;"
|
||||
static="true">
|
||||
<return value="arg0" />
|
||||
</method>
|
||||
<method name="setErr0"
|
||||
descriptor="(Ljava/io/PrintStream;)V" static="true">
|
||||
</method>
|
||||
<method name="setIn0"
|
||||
descriptor="(Ljava/io/InputStream;)V" static="true">
|
||||
</method>
|
||||
<method name="setOut0"
|
||||
descriptor="(Ljava/io/PrintStream;)V" static="true">
|
||||
</method>
|
||||
</class>
|
||||
<class name="Thread">
|
||||
<method name="currentThread"
|
||||
descriptor="()Ljava/lang/Thread;" static="true">
|
||||
<new def="x" class="Ljava/lang/Thread" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="interrupt0" descriptor="()V"></method>
|
||||
<method name="<init>" descriptor="()V">
|
||||
<putfield class="Ljava/lang/Thread" field="runnable"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg0" />
|
||||
<putfield class="Ljava/lang/Thread" field="target"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg0" />
|
||||
</method>
|
||||
<method name="<init>"
|
||||
descriptor="(Ljava/lang/Runnable;)V">
|
||||
<putfield class="Ljava/lang/Thread" field="runnable"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg1" />
|
||||
<putfield class="Ljava/lang/Thread" field="target"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg1" />
|
||||
</method>
|
||||
<method name="isAlive" descriptor="()Z"></method>
|
||||
<method name="resume0" descriptor="()V" />
|
||||
<method name="sleep" descriptor="(J)V" static="true">
|
||||
<new def="x"
|
||||
class="Ljava/lang/InterruptedException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
<method name="start" descriptor="()V">
|
||||
<putfield class="Ljava/lang/Thread" field="runnable"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg0" />
|
||||
<getfield class="Ljava/lang/Thread" field="runnable"
|
||||
fieldType="Ljava/lang/Runnable" def="x" ref="arg0" />
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/lang/Runnable" descriptor="()V" arg0="x" />
|
||||
<putfield class="Ljava/lang/Thread" field="target"
|
||||
fieldType="Ljava/lang/Runnable" ref="arg0" value="arg0" />
|
||||
<getfield class="Ljava/lang/Thread" field="target"
|
||||
fieldType="Ljava/lang/Runnable" def="y" ref="arg0" />
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/lang/Runnable" descriptor="()V" arg0="y" />
|
||||
</method>
|
||||
<method name="stop0" descriptor="()V" />
|
||||
<method name="yield" descriptor="()V" static="true" />
|
||||
</class>
|
||||
<class name="Throwable">
|
||||
<method name="fillInStackTrace"
|
||||
descriptor="()Ljava/lang/Throwable;">
|
||||
<return value="arg0" />
|
||||
</method>
|
||||
<method name="getStackTraceElement"
|
||||
descriptor="(I)Ljava/lang/StackTraceElement;">
|
||||
<new def="x" class="Ljava/lang/StackTraceElement" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="printStackTrace0"
|
||||
descriptor="(Ljava/lang/Object;)V" />
|
||||
<method name="getStackTraceDepth" descriptor="()I" />
|
||||
|
||||
</class>
|
||||
</package>
|
||||
<package name="java/lang/reflect">
|
||||
<class name="Array">
|
||||
<!-- <method name="get" descriptor="(Ljava/lang/Object;I)Ljava/lang/Object;" static="true">
|
||||
<call type="static" name="get"
|
||||
class="Lcom/ibm/wala/model/java/lang/reflect/Array"
|
||||
descriptor="(Ljava/lang/Object;I)Ljava/lang/Object;" arg0="arg0"
|
||||
arg1="arg1" def="x"/>
|
||||
<return value="x" />
|
||||
</method> -->
|
||||
<method name="getByte"
|
||||
descriptor="(Ljava/lang/Object;I)B" static="true">
|
||||
</method>
|
||||
<method name="getLength"
|
||||
descriptor="(Ljava/lang/Object;)I" static="true">
|
||||
</method>
|
||||
<method name="multiNewArray"
|
||||
descriptor="(Ljava/lang/Class;[I)Ljava/lang/Object;" static="true"
|
||||
factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<!-- THIS KIND OF TREATMENT OF ARRAYS IS BOGUS and TOO IMPRECISE. TODO: FIX THIS.
|
||||
<method name="newArray"
|
||||
descriptor="(Ljava/lang/Class;I)Ljava/lang/Object;" static="true"
|
||||
factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="newInstance"
|
||||
descriptor="(Ljava/lang/Class;I)Ljava/lang/Object;" static="true"
|
||||
factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
-->
|
||||
<method name="set"
|
||||
descriptor="(Ljava/lang/Object;ILjava/lang/Object;)V"
|
||||
static="true">
|
||||
</method>
|
||||
<method name="setByte"
|
||||
descriptor="(Ljava/lang/Object;IB)V" static="true">
|
||||
</method>
|
||||
</class>
|
||||
<class name="Constructor">
|
||||
<method name="newInstance"
|
||||
descriptor="([Ljava/lang/Object;)Ljava/lang/Object;" factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="Field">
|
||||
<method name="get"
|
||||
descriptor="(Ljava/lang/Object;)Ljava/lang/Object;"
|
||||
factory="true">
|
||||
<new def="x" class="Lcom/ibm/wala/Malleable" />
|
||||
<return value="x" />
|
||||
<poison
|
||||
reason="bogus model of java/lang/reflect/Field/get"
|
||||
level="severe" />
|
||||
</method>
|
||||
<method name="getBoolean"
|
||||
descriptor="(Ljava/lang/Object;)Z">
|
||||
</method>
|
||||
<method name="getByte"
|
||||
descriptor="(Ljava/lang/Object;)B">
|
||||
</method>
|
||||
<method name="getChar"
|
||||
descriptor="(Ljava/lang/Object;)C">
|
||||
</method>
|
||||
<method name="getDouble"
|
||||
descriptor="(Ljava/lang/Object;)D">
|
||||
</method>
|
||||
<method name="getFloat"
|
||||
descriptor="(Ljava/lang/Object;)F">
|
||||
</method>
|
||||
<method name="getInt"
|
||||
descriptor="(Ljava/lang/Object;)I">
|
||||
</method>
|
||||
<method name="getLong"
|
||||
descriptor="(Ljava/lang/Object;)J">
|
||||
</method>
|
||||
<method name="getShort"
|
||||
descriptor="(Ljava/lang/Object;)S">
|
||||
</method>
|
||||
<method name="set"
|
||||
descriptor="(Ljava/lang/Object;Ljava/lang/Object;)V">
|
||||
</method>
|
||||
<method name="setBoolean"
|
||||
descriptor="(Ljava/lang/Object;Z)V">
|
||||
</method>
|
||||
<method name="setByte"
|
||||
descriptor="(Ljava/lang/Object;B)V">
|
||||
</method>
|
||||
<method name="setChar"
|
||||
descriptor="(Ljava/lang/Object;C)V">
|
||||
</method>
|
||||
<method name="setDouble"
|
||||
descriptor="(Ljava/lang/Object;D)V">
|
||||
</method>
|
||||
<method name="setFloat"
|
||||
descriptor="(Ljava/lang/Object;F)V">
|
||||
</method>
|
||||
<method name="setInt"
|
||||
descriptor="(Ljava/lang/Object;I)V">
|
||||
</method>
|
||||
<method name="setLong"
|
||||
descriptor="(Ljava/lang/Object;J)V">
|
||||
</method>
|
||||
<method name="setShort"
|
||||
descriptor="(Ljava/lang/Object;S)V">
|
||||
</method>
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/net">
|
||||
<class name="PlainDatagramSocketImpl">
|
||||
<method name="bind"
|
||||
descriptor="(ILjava/net/InetAddress;)V">
|
||||
</method>
|
||||
</class>
|
||||
<class name="PlainSocketImpl">
|
||||
<method name="initProto" descriptor="()V" static="true" />
|
||||
<method name="socketAvailable" descriptor="()I" />
|
||||
<method name="socketBind"
|
||||
descriptor="(Ljava/net/InetAddress;I)V" />
|
||||
<method name="socketClose0" descriptor="(Z)V" />
|
||||
<method name="socketConnect"
|
||||
descriptor="(Ljava/net/InetAddress;II)V" />
|
||||
<method name="socketCreate" descriptor="(Z)V" />
|
||||
<method name="socketGetOption"
|
||||
descriptor="(ILjava/lang/Object;)I" />
|
||||
<method name="socketListen" descriptor="(I)V" />
|
||||
<method name="socketSetOption"
|
||||
descriptor="(IZLjava/lang/Object;)V" />
|
||||
</class>
|
||||
<class name="SocketInputStream">
|
||||
<method name="init" descriptor="()V" static="true" />
|
||||
<method name="socketRead0"
|
||||
descriptor="(Ljava/io/FileDescriptor;[BIII)I">
|
||||
<constant name="yes" type="int" value="1" />
|
||||
<constant name="no" type="int" value="0" />
|
||||
<constant name="the-answer" type="byte" value="42"/>
|
||||
<aastore ref="arg2" index="no" value="the-answer"/>
|
||||
<return value="yes" />
|
||||
<return value="no" />
|
||||
<new def="x" class="Ljava/io/IOException" />
|
||||
<throw value="x" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="SocketOutputStream">
|
||||
<method name="init" descriptor="()V" static="true" />
|
||||
<method name="socketWrite0"
|
||||
descriptor="(Ljava/io/FileDescriptor;[BII)V" />
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/security">
|
||||
<class name="AccessControlContext">
|
||||
<method name="getInheritedAccessControlContext"
|
||||
descriptor="()Ljava/security/AccessControlContext;">
|
||||
<new def="x" class="Ljava/lang/Object" />
|
||||
<return value="x" />
|
||||
<poison
|
||||
reason="questionable model of java/security/AccessControlContext/getInheritedAccessControlContext"
|
||||
level="moderate" />
|
||||
</method>
|
||||
</class>
|
||||
<class name="AccessController">
|
||||
<method name="doPrivileged"
|
||||
descriptor="(Ljava/security/PrivilegedAction;)Ljava/lang/Object;"
|
||||
static="true">
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/security/PrivilegedAction"
|
||||
descriptor="()Ljava/lang/Object;" def="x" arg0="arg0" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/security/PrivilegedActionException" />
|
||||
<throw value="y" />
|
||||
<poison
|
||||
reason="incorrect model of java/security/AccessController/doPrivileged"
|
||||
level="severe" />
|
||||
</method>
|
||||
<method name="doPrivileged"
|
||||
descriptor="(Ljava/security/PrivilegedExceptionAction;)Ljava/lang/Object;"
|
||||
static="true">
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/security/PrivilegedExceptionAction"
|
||||
descriptor="()Ljava/lang/Object;" def="x" arg0="arg0" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/security/PrivilegedActionException" />
|
||||
<throw value="y" />
|
||||
<poison
|
||||
reason="incorrect model of java/security/AccessController/doPrivileged"
|
||||
level="severe" />
|
||||
</method>
|
||||
<method name="doPrivileged"
|
||||
descriptor="(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;"
|
||||
static="true">
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/security/PrivilegedAction"
|
||||
descriptor="()Ljava/lang/Object;" def="x" arg0="arg0" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/security/PrivilegedActionException" />
|
||||
<throw value="y" />
|
||||
<poison
|
||||
reason="incorrect model of java/security/AccessController/doPrivileged"
|
||||
level="severe" />
|
||||
</method>
|
||||
<method name="doPrivileged"
|
||||
descriptor="(Ljava/security/PrivilegedExceptionAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;"
|
||||
static="true">
|
||||
<call type="interface" name="run"
|
||||
class="Ljava/security/PrivilegedExceptionAction"
|
||||
descriptor="()Ljava/lang/Object;" def="x" arg0="arg0" />
|
||||
<return value="x" />
|
||||
<new def="y"
|
||||
class="Ljava/security/PrivilegedActionException" />
|
||||
<throw value="y" />
|
||||
<poison
|
||||
reason="incorrect model of java/security/AccessController/doPrivileged"
|
||||
level="severe" />
|
||||
</method>
|
||||
<method name="getStackAccessControlContext"
|
||||
descriptor="()Ljava/security/AccessControlContext;"
|
||||
static="true">
|
||||
<new def="x"
|
||||
class="Ljava/security/AccessControlContext" />
|
||||
<return value="x" />
|
||||
<poison
|
||||
reason="questionable model of java/security/AccessController/getStackAccessControlContext"
|
||||
level="moderate" />
|
||||
</method>
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/util">
|
||||
<class name="TimeZone">
|
||||
<method name="getSystemTimeZoneID"
|
||||
descriptor="(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"
|
||||
static="true">
|
||||
<new def="x" class="Ljava/lang/String" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/util/logging">
|
||||
<class name="FileHandler">
|
||||
<method name="isSetUID" descriptor="()Z" static="true" />
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="java/util/prefs">
|
||||
<class name="FileSystemPreferences">
|
||||
<method name="chmod" descriptor="(Ljava/lang/String;I)I"
|
||||
static="true" />
|
||||
<method name="lockFile0"
|
||||
descriptor="(Ljava/lang/String;IZ)[I" static="true">
|
||||
<constant name="size" type="int" value="1" />
|
||||
<new def="x" class="[I" size="size"/>
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="unlockFile0" descriptor="(I)I"
|
||||
static="true" />
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="sun/misc">
|
||||
<class name="AtomicLongCSImpl">
|
||||
<method name="attemptUpdate" descriptor="(JJ)Z" />
|
||||
</class>
|
||||
<class name="AtomicLong">
|
||||
<method name="VMSupportsCS8" descriptor="()Z"
|
||||
static="true" />
|
||||
</class>
|
||||
<class name="Signal">
|
||||
<method name="handle0" descriptor="(IJ)J" static="true" />
|
||||
<method name="findSignal"
|
||||
descriptor="(Ljava/lang/String;)I" static="true" />
|
||||
</class>
|
||||
<class name="Unsafe" allocatable="true">
|
||||
<method name="getUnsafe" descriptor="()Lsun/misc/Unsafe"
|
||||
static="true">
|
||||
<new def="x" class="Lsun/misc/Unsafe" />
|
||||
<return value="x" />
|
||||
</method>
|
||||
<method name="allocateMemory" descriptor="(J)J" />
|
||||
<method name="copyMemory" descriptor="(JJJ)V" />
|
||||
<method name="freeMemory" descriptor="(J)V" />
|
||||
<method name="objectFieldOffset"
|
||||
descriptor="(Ljava/lang/reflect/Field;)J" />
|
||||
<method name="getBoolean" descriptor="(J)Z" />
|
||||
<method name="getByte" descriptor="(J)B" />
|
||||
<method name="getChar" descriptor="(J)C" />
|
||||
<method name="getDouble" descriptor="(J)D" />
|
||||
<method name="getFloat" descriptor="(J)F" />
|
||||
<method name="getInt" descriptor="(J)I" />
|
||||
<method name="getLong" descriptor="(J)J" />
|
||||
<method name="getShort" descriptor="(J)S" />
|
||||
<method name="getBoolean"
|
||||
descriptor="(Ljava/lang/Object;J)Z" />
|
||||
<method name="getByte"
|
||||
descriptor="(Ljava/lang/Object;J)B" />
|
||||
<method name="getChar"
|
||||
descriptor="(Ljava/lang/Object;J)C" />
|
||||
<method name="getDouble"
|
||||
descriptor="(Ljava/lang/Object;J)D" />
|
||||
<method name="getFloat"
|
||||
descriptor="(Ljava/lang/Object;J)F" />
|
||||
<method name="getInt"
|
||||
descriptor="(Ljava/lang/Object;J)I" />
|
||||
<method name="getLong"
|
||||
descriptor="(Ljava/lang/Object;J)J" />
|
||||
<method name="getShort"
|
||||
descriptor="(Ljava/lang/Object;J)S" />
|
||||
<method name="putBoolean" descriptor="(JZ)V" />
|
||||
<method name="putByte" descriptor="(JB)V" />
|
||||
<method name="putChar" descriptor="(JC)V" />
|
||||
<method name="putDouble" descriptor="(JD)V" />
|
||||
<method name="putFloat" descriptor="(JF)V" />
|
||||
<method name="putInt" descriptor="(JI)V" />
|
||||
<method name="putLong" descriptor="(JJ)V" />
|
||||
<method name="putShort" descriptor="(JS)V" />
|
||||
<method name="registerNatives" descriptor="()V"
|
||||
static="true" />
|
||||
</class>
|
||||
</package>
|
||||
|
||||
<package name="sun/nio/ch">
|
||||
<class name="IOUtil">
|
||||
<method name="initIDs" descriptor="()V" static="true" />
|
||||
</class>
|
||||
<class name="FileDispatcher">
|
||||
<method name="init" descriptor="()V" static="true" />
|
||||
</class>
|
||||
<class name="FileChannelImpl">
|
||||
<method name="lock0"
|
||||
descriptor="(Ljava/io/FileDescriptor;ZJJZ)I" />
|
||||
<method name="initIDs" descriptor="()J" static="true" />
|
||||
</class>
|
||||
</package>
|
||||
|
||||
</classloader>
|
||||
</summary-spec>
|
|
@ -70,7 +70,7 @@ public class BasicHeapGraph extends HeapGraph {
|
|||
* @param P governing pointer analysis
|
||||
* @throws NullPointerException if P is null
|
||||
*/
|
||||
public BasicHeapGraph(final PointerAnalysis P, final CallGraph callGraph) throws NullPointerException {
|
||||
public BasicHeapGraph(final PointerAnalysis<InstanceKey> P, final CallGraph callGraph) throws NullPointerException {
|
||||
super(P);
|
||||
this.callGraph = callGraph;
|
||||
|
||||
|
@ -256,10 +256,10 @@ public class BasicHeapGraph extends HeapGraph {
|
|||
private int[] computeSuccNodeNumbers(Object N, NumberedNodeManager<Object> nodeManager) {
|
||||
if (N instanceof PointerKey) {
|
||||
PointerKey P = (PointerKey) N;
|
||||
OrdinalSet<? extends InstanceKey> S = getPointerAnalysis().getPointsToSet(P);
|
||||
OrdinalSet<InstanceKey> S = getPointerAnalysis().getPointsToSet(P);
|
||||
int[] result = new int[S.size()];
|
||||
int i = 0;
|
||||
for (Iterator<? extends InstanceKey> it = S.iterator(); it.hasNext();) {
|
||||
for (Iterator<InstanceKey> it = S.iterator(); it.hasNext();) {
|
||||
result[i] = nodeManager.getNumber(it.next());
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ import com.ibm.wala.util.intset.IntSet;
|
|||
*/
|
||||
public abstract class HeapGraph implements NumberedGraph<Object> {
|
||||
|
||||
private final PointerAnalysis pa;
|
||||
private final PointerAnalysis<InstanceKey> pa;
|
||||
|
||||
protected HeapGraph(PointerAnalysis pa) {
|
||||
protected HeapGraph(PointerAnalysis<InstanceKey> pa) {
|
||||
if (pa == null) {
|
||||
throw new IllegalArgumentException("null pa ");
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public abstract class HeapGraph implements NumberedGraph<Object> {
|
|||
return pa.getHeapModel();
|
||||
}
|
||||
|
||||
public PointerAnalysis getPointerAnalysis() {
|
||||
public PointerAnalysis<InstanceKey> getPointerAnalysis() {
|
||||
return pa;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,15 +243,15 @@ public abstract class AbstractReflectionInterpreter implements SSAContextInterpr
|
|||
|
||||
int[] extents = new int[dims];
|
||||
Arrays.fill(extents, 1);
|
||||
SSANewInstruction a = insts.NewInstruction(alloc, ref, extents);
|
||||
SSANewInstruction a = insts.NewInstruction(allInstructions.size(), alloc, ref, extents);
|
||||
addInstruction(t, a, true);
|
||||
} else {
|
||||
SSANewInstruction a = insts.NewInstruction(alloc, ref);
|
||||
SSANewInstruction a = insts.NewInstruction(allInstructions.size(), alloc, ref);
|
||||
addInstruction(t, a, true);
|
||||
addCtorInvokeInstruction(t, alloc);
|
||||
}
|
||||
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(alloc, false);
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(allInstructions.size(), alloc, false);
|
||||
addInstruction(t, r, false);
|
||||
return alloc;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ public abstract class AbstractReflectionInterpreter implements SSAContextInterpr
|
|||
int[] params = new int[1];
|
||||
params[0] = alloc;
|
||||
int exc = getExceptionsForType(t);
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(params, exc, site);
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(allInstructions.size(), params, exc, site);
|
||||
calls.add(s);
|
||||
allInstructions.add(s);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package com.ibm.wala.analysis.reflection;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.cfg.InducedCFG;
|
||||
|
@ -34,6 +35,7 @@ import com.ibm.wala.ssa.SSAThrowInstruction;
|
|||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
|
||||
/**
|
||||
|
@ -44,6 +46,10 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
|||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/** BEGIN Custom change: caching */
|
||||
private final Map<String, IR> cache = HashMapFactory.make();
|
||||
|
||||
/** END Custom change: caching */
|
||||
@Override
|
||||
public IR getIR(CGNode node) {
|
||||
if (node == null) {
|
||||
|
@ -53,7 +59,20 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
|||
if (DEBUG) {
|
||||
System.err.println("generating IR for " + node);
|
||||
}
|
||||
IR result = makeIR(node.getMethod(), (JavaTypeContext) node.getContext());
|
||||
/** BEGIN Custom change: caching */
|
||||
|
||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
||||
final IMethod method = node.getMethod();
|
||||
final String hashKey = method.toString() + "@" + context.toString();
|
||||
|
||||
IR result = cache.get(hashKey);
|
||||
|
||||
if (result == null) {
|
||||
result = makeIR(method, context);
|
||||
cache.put(hashKey, result);
|
||||
}
|
||||
|
||||
/** END Custom change: caching */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -110,12 +129,12 @@ public class ClassFactoryContextInterpreter implements SSAContextInterpreter {
|
|||
int retValue = 2;
|
||||
TypeReference tr = context.getType().getTypeReference();
|
||||
if (tr != null) {
|
||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(retValue, TypeReference.JavaLangClass, tr);
|
||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
||||
statements.add(l);
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(retValue, false);
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false);
|
||||
statements.add(R);
|
||||
} else {
|
||||
SSAThrowInstruction t = insts.ThrowInstruction(retValue);
|
||||
SSAThrowInstruction t = insts.ThrowInstruction(statements.size(), retValue);
|
||||
statements.add(t);
|
||||
}
|
||||
SSAInstruction[] result = new SSAInstruction[statements.size()];
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package com.ibm.wala.analysis.reflection;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.cfg.InducedCFG;
|
||||
|
@ -35,6 +36,7 @@ import com.ibm.wala.types.MethodReference;
|
|||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
import com.ibm.wala.util.collections.NonNullSingletonIterator;
|
||||
import com.ibm.wala.util.strings.Atom;
|
||||
|
||||
|
@ -59,6 +61,10 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
|||
|
||||
private final IClassHierarchy cha;
|
||||
|
||||
/** BEGIN Custom change: caching */
|
||||
private final Map<String, IR> cache = HashMapFactory.make();
|
||||
|
||||
/** END Custom change: caching */
|
||||
public ClassNewInstanceContextInterpreter(IClassHierarchy cha) {
|
||||
this.cha = cha;
|
||||
}
|
||||
|
@ -72,7 +78,20 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
|||
if (DEBUG) {
|
||||
System.err.println("generating IR for " + node);
|
||||
}
|
||||
IR result = makeIR(node.getMethod(), (JavaTypeContext) node.getContext());
|
||||
/** BEGIN Custom change: caching */
|
||||
|
||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
||||
final IMethod method = node.getMethod();
|
||||
final String hashKey = method.toString() + "@" + context.toString();
|
||||
|
||||
IR result = cache.get(hashKey);
|
||||
|
||||
if (result == null) {
|
||||
result = makeIR(method, context);
|
||||
cache.put(hashKey, result);
|
||||
}
|
||||
|
||||
/** END Custom change: caching */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -126,17 +145,17 @@ public class ClassNewInstanceContextInterpreter extends AbstractReflectionInterp
|
|||
TypeReference instantiationExceptionRef = TypeReference.findOrCreateClass(ClassLoaderReference.Primordial, "java/lang",
|
||||
"InstantiationException");
|
||||
int xobj = method.getNumberOfParameters() + 1;
|
||||
SSAInstruction newStatement = insts.NewInstruction(xobj, NewSiteReference.make(2, instantiationExceptionRef));
|
||||
SSAInstruction newStatement = insts.NewInstruction(m.allInstructions.size(), xobj, NewSiteReference.make(2, instantiationExceptionRef));
|
||||
m.addInstruction(tr, newStatement, true);
|
||||
SSAInstruction throwStatement = insts.ThrowInstruction(xobj);
|
||||
SSAInstruction throwStatement = insts.ThrowInstruction(m.allInstructions.size(), xobj);
|
||||
m.addInstruction(tr, throwStatement, false);
|
||||
} else {
|
||||
TypeReference illegalAccessExceptionRef = TypeReference.findOrCreateClass(ClassLoaderReference.Primordial, "java/lang",
|
||||
"IllegalAccessException");
|
||||
int xobj = method.getNumberOfParameters() + 1;
|
||||
SSAInstruction newStatement = insts.NewInstruction(xobj, NewSiteReference.make(2, illegalAccessExceptionRef));
|
||||
SSAInstruction newStatement = insts.NewInstruction(m.allInstructions.size(), xobj, NewSiteReference.make(2, illegalAccessExceptionRef));
|
||||
m.addInstruction(tr, newStatement, true);
|
||||
SSAInstruction throwStatement = insts.ThrowInstruction(xobj);
|
||||
SSAInstruction throwStatement = insts.ThrowInstruction(m.allInstructions.size(), xobj);
|
||||
m.addInstruction(tr, throwStatement, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,12 +160,12 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
SSANewInstruction N = null;
|
||||
if (klass.isArrayClass()) {
|
||||
int length = nextLocal++;
|
||||
statements.add(insts.ArrayLengthInstruction(length, 1));
|
||||
statements.add(insts.ArrayLengthInstruction(statements.size(), length, 1));
|
||||
int[] sizes = new int[((ArrayClass)klass).getDimensionality()];
|
||||
Arrays.fill(sizes, length);
|
||||
N = insts.NewInstruction(retValue, ref, sizes);
|
||||
N = insts.NewInstruction(statements.size(), retValue, ref, sizes);
|
||||
} else {
|
||||
N = insts.NewInstruction(retValue, ref);
|
||||
N = insts.NewInstruction(statements.size(), retValue, ref);
|
||||
}
|
||||
statements.add(N);
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
int[] params = new int[2];
|
||||
params[0] = 1;
|
||||
params[1] = retValue;
|
||||
SSAInvokeInstruction S = insts.InvokeInstruction(params, exceptionValue, ARRAYCOPY_SITE);
|
||||
SSAInvokeInstruction S = insts.InvokeInstruction(statements.size(), params, exceptionValue, ARRAYCOPY_SITE);
|
||||
statements.add(S);
|
||||
} else {
|
||||
// copy the fields over, one by one.
|
||||
|
@ -186,9 +186,9 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
for (Iterator<IField> it = klass.getDeclaredInstanceFields().iterator(); it.hasNext();) {
|
||||
IField f = it.next();
|
||||
int tempValue = nextLocal++;
|
||||
SSAGetInstruction G = insts.GetInstruction(tempValue, 1, f.getReference());
|
||||
SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference());
|
||||
statements.add(G);
|
||||
SSAPutInstruction P = insts.PutInstruction(retValue, tempValue, f.getReference());
|
||||
SSAPutInstruction P = insts.PutInstruction(statements.size(), retValue, tempValue, f.getReference());
|
||||
statements.add(P);
|
||||
}
|
||||
k = k.getSuperclass();
|
||||
|
@ -196,7 +196,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
|
||||
}
|
||||
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(retValue, false);
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false);
|
||||
statements.add(R);
|
||||
|
||||
SSAInstruction[] result = new SSAInstruction[statements.size()];
|
||||
|
|
|
@ -490,7 +490,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
int[] params = new int[1];
|
||||
params[0] = alloc;
|
||||
int exc = getExceptionsForType(T);
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(params, exc, site);
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(allInstructions.size(), params, exc, site);
|
||||
calls.add(s);
|
||||
allInstructions.add(s);
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
|
||||
private void addStatementsForSetOfTypes(Iterator<IClass> it) {
|
||||
if (!it.hasNext()) { // Uh. No types. Hope the caller reported a warning.
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(nextLocal, false);
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(allInstructions.size(), nextLocal, false);
|
||||
allInstructions.add(r);
|
||||
}
|
||||
|
||||
|
@ -545,20 +545,20 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
int[] sizes = new int[((ArrayClass)klass).getDimensionality()];
|
||||
initValueNumberForConstantOne();
|
||||
Arrays.fill(sizes, valueNumberForConstantOne);
|
||||
a = insts.NewInstruction(i, ref, sizes);
|
||||
a = insts.NewInstruction(allInstructions.size(), i, ref, sizes);
|
||||
|
||||
} else {
|
||||
a = insts.NewInstruction(i, ref);
|
||||
a = insts.NewInstruction(allInstructions.size(), i, ref);
|
||||
}
|
||||
allocations.add(a);
|
||||
allInstructions.add(a);
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(i, false);
|
||||
SSAReturnInstruction r = insts.ReturnInstruction(allInstructions.size(), i, false);
|
||||
allInstructions.add(r);
|
||||
MethodReference init = MethodReference.findOrCreate(T, MethodReference.initAtom, MethodReference.defaultInitDesc);
|
||||
CallSiteReference site = CallSiteReference.make(getCallSiteForType(T), init, IInvokeInstruction.Dispatch.SPECIAL);
|
||||
int[] params = new int[1];
|
||||
params[0] = i;
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(params, getExceptionsForType(T), site);
|
||||
SSAInvokeInstruction s = insts.InvokeInstruction(allInstructions.size(), params, getExceptionsForType(T), site);
|
||||
calls.add(s);
|
||||
allInstructions.add(s);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ package com.ibm.wala.analysis.reflection;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.cfg.InducedCFG;
|
||||
|
@ -33,12 +34,17 @@ import com.ibm.wala.ssa.SSAReturnInstruction;
|
|||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.collections.EmptyIterator;
|
||||
import com.ibm.wala.util.collections.HashMapFactory;
|
||||
|
||||
/**
|
||||
* {@link SSAContextInterpreter} specialized to interpret Object.getClass() in a {@link JavaTypeContext}
|
||||
*/
|
||||
public class GetClassContextInterpeter implements SSAContextInterpreter {
|
||||
|
||||
/** BEGIN Custom change: caching */
|
||||
private final Map<String, IR> cache = HashMapFactory.make();
|
||||
|
||||
/** END Custom change: caching */
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +56,20 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
|||
if (DEBUG) {
|
||||
System.err.println("generating IR for " + node);
|
||||
}
|
||||
IR result = makeIR(node.getMethod(), (JavaTypeContext) node.getContext());
|
||||
/** BEGIN Custom change: caching */
|
||||
|
||||
final JavaTypeContext context = (JavaTypeContext) node.getContext();
|
||||
final IMethod method = node.getMethod();
|
||||
final String hashKey = method.toString() + "@" + context.toString();
|
||||
|
||||
IR result = cache.get(hashKey);
|
||||
|
||||
if (result == null) {
|
||||
result = makeIR(method, context);
|
||||
cache.put(hashKey, result);
|
||||
}
|
||||
|
||||
/** END Custom change: caching */
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -88,9 +107,9 @@ public class GetClassContextInterpeter implements SSAContextInterpreter {
|
|||
TypeReference tr = context.getType().getTypeReference();
|
||||
SSAInstructionFactory insts = context.getType().getType().getClassLoader().getInstructionFactory();
|
||||
if (tr != null) {
|
||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(retValue, TypeReference.JavaLangClass, tr);
|
||||
SSALoadMetadataInstruction l = insts.LoadMetadataInstruction(statements.size(), retValue, TypeReference.JavaLangClass, tr);
|
||||
statements.add(l);
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(retValue, false);
|
||||
SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false);
|
||||
statements.add(R);
|
||||
}
|
||||
SSAInstruction[] result = new SSAInstruction[statements.size()];
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue