From 7c518d18678dabb7b3a1a546efb6a3133e0007b4 Mon Sep 17 00:00:00 2001 From: Juergen Graf Date: Tue, 12 Apr 2011 19:49:06 +0200 Subject: [PATCH] added instruction index field to SSAInstruction (javascript not working atm) --- .gitignore | 3 + .../java/loader/JavaSourceLoaderImpl.java | 70 ++++----- .../java/ssa/AstJavaInstructionFactory.java | 10 +- .../java/ssa/AstJavaInvokeInstruction.java | 18 +-- .../ssa/AstJavaNewEnclosingInstruction.java | 6 +- .../java/ssa/EnclosingObjectReference.java | 5 +- .../translator/JavaCAst2IRTranslator.java | 36 ++--- com.ibm.wala.cast.js.rhino/build.xml | 2 +- .../wala/cast/ipa/callgraph/AstCallGraph.java | 2 +- .../cast/ir/ssa/AbstractLexicalInvoke.java | 12 +- .../cast/ir/ssa/AbstractReflectiveGet.java | 4 +- .../cast/ir/ssa/AbstractReflectivePut.java | 4 +- .../wala/cast/ir/ssa/AssignInstruction.java | 6 +- .../cast/ir/ssa/AstAssertInstruction.java | 5 +- .../wala/cast/ir/ssa/AstEchoInstruction.java | 5 +- .../ibm/wala/cast/ir/ssa/AstGlobalRead.java | 6 +- .../ibm/wala/cast/ir/ssa/AstGlobalWrite.java | 6 +- .../cast/ir/ssa/AstInstructionFactory.java | 34 ++--- .../cast/ir/ssa/AstIsDefinedInstruction.java | 14 +- .../wala/cast/ir/ssa/AstLexicalAccess.java | 3 +- .../ibm/wala/cast/ir/ssa/AstLexicalRead.java | 16 +-- .../ibm/wala/cast/ir/ssa/AstLexicalWrite.java | 16 +-- .../ir/ssa/EachElementGetInstruction.java | 6 +- .../ir/ssa/EachElementHasNextInstruction.java | 6 +- ...xedParametersLexicalInvokeInstruction.java | 16 +-- .../MultiReturnValueInvokeInstruction.java | 4 +- .../ibm/wala/cast/ir/ssa/SSAConversion.java | 4 +- .../cast/ir/translator/AstTranslator.java | 92 ++++++------ .../AbstractReflectionInterpreter.java | 8 +- .../ClassFactoryContextInterpreter.java | 6 +- .../ClassNewInstanceContextInterpreter.java | 8 +- .../analysis/reflection/CloneInterpreter.java | 14 +- .../reflection/FactoryBypassInterpreter.java | 12 +- .../reflection/GetClassContextInterpeter.java | 4 +- .../JavaLangClassContextInterpreter.java | 8 +- .../ReflectiveInvocationInterpreter.java | 18 +-- .../src/com/ibm/wala/cfg/InducedCFG.java | 2 +- .../ibm/wala/classLoader/JavaLanguage.java | 136 +++++++++--------- .../callgraph/impl/AbstractRootMethod.java | 34 ++--- .../summaries/BypassMethodTargetSelector.java | 2 +- .../ibm/wala/ipa/summaries/MethodSummary.java | 4 + .../ipa/summaries/XMLMethodSummaryReader.java | 22 +-- .../ibm/wala/ssa/ReflectiveMemberAccess.java | 4 +- .../ssa/SSAAbstractInvokeInstruction.java | 3 +- .../wala/ssa/SSAAbstractThrowInstruction.java | 4 +- .../wala/ssa/SSAAbstractUnaryInstruction.java | 4 +- .../ibm/wala/ssa/SSAAddressOfInstruction.java | 9 +- .../wala/ssa/SSAArrayLengthInstruction.java | 6 +- .../ibm/wala/ssa/SSAArrayLoadInstruction.java | 6 +- .../ssa/SSAArrayReferenceInstruction.java | 11 +- .../wala/ssa/SSAArrayStoreInstruction.java | 6 +- .../ibm/wala/ssa/SSABinaryOpInstruction.java | 4 +- .../src/com/ibm/wala/ssa/SSABuilder.java | 71 +++++---- .../ibm/wala/ssa/SSACheckCastInstruction.java | 6 +- .../wala/ssa/SSAComparisonInstruction.java | 6 +- .../ssa/SSAConditionalBranchInstruction.java | 6 +- .../wala/ssa/SSAConversionInstruction.java | 4 +- .../wala/ssa/SSAFieldAccessInstruction.java | 4 +- .../ssa/SSAGetCaughtExceptionInstruction.java | 6 +- .../com/ibm/wala/ssa/SSAGetInstruction.java | 12 +- .../com/ibm/wala/ssa/SSAGotoInstruction.java | 6 +- .../wala/ssa/SSAInstanceofInstruction.java | 6 +- .../src/com/ibm/wala/ssa/SSAInstruction.java | 7 +- .../ibm/wala/ssa/SSAInstructionFactory.java | 72 +++++----- .../ibm/wala/ssa/SSAInvokeInstruction.java | 10 +- .../wala/ssa/SSALoadIndirectInstruction.java | 4 +- .../wala/ssa/SSALoadMetadataInstruction.java | 5 +- .../ibm/wala/ssa/SSAMonitorInstruction.java | 6 +- .../com/ibm/wala/ssa/SSANewInstruction.java | 12 +- .../com/ibm/wala/ssa/SSAPhiInstruction.java | 6 +- .../com/ibm/wala/ssa/SSAPiInstruction.java | 6 +- .../com/ibm/wala/ssa/SSAPutInstruction.java | 12 +- .../ibm/wala/ssa/SSAReturnInstruction.java | 12 +- .../wala/ssa/SSAStoreIndirectInstruction.java | 3 +- .../ibm/wala/ssa/SSASwitchInstruction.java | 6 +- .../com/ibm/wala/ssa/SSAThrowInstruction.java | 6 +- .../ibm/wala/ssa/SSAUnaryOpInstruction.java | 6 +- .../src/com/ibm/wala/ssa/SymbolTable.java | 2 +- 78 files changed, 536 insertions(+), 512 deletions(-) diff --git a/.gitignore b/.gitignore index 6e9cf59bd..5eaf35f16 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ com.ibm.wala.core/dat/wala.properties com.ibm.wala.cast.java.polyglot/lib/java_cup.jar com.ibm.wala.cast.java.polyglot/lib/polyglot.jar +com.ibm.wala.cast.java.test.data/src/JLex/ +com.ibm.wala.cast.js.rhino/lib/ +com.ibm.wala.cast.js/lib/ diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java index 7524d53e6..14ffc6506 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/loader/JavaSourceLoaderImpl.java @@ -468,96 +468,96 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl { public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory { - 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); } - 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); } - public AstJavaInvokeInstruction JavaInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) { + public AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) { return new AstJavaInvokeInstruction(result, params, exception, site); } - public AstJavaInvokeInstruction JavaInvokeInstruction(int[] params, int exception, CallSiteReference site) { - return new AstJavaInvokeInstruction(params, exception, site); + public AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) { + return new AstJavaInvokeInstruction(iindex, params, exception, site); } - public AstJavaInvokeInstruction JavaInvokeInstruction(int[] results, int[] params, int exception, CallSiteReference site, + public AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int[] results, int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) { - return new AstJavaInvokeInstruction(results, params, exception, site, lexicalReads, lexicalWrites); + return new AstJavaInvokeInstruction(iindex, results, params, exception, site, lexicalReads, lexicalWrites); } - 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); } - 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); } - 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(); } - 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(); } - public AstEchoInstruction EchoInstruction(int[] rvals) { + public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) { throw new UnsupportedOperationException(); } - public AstGlobalRead GlobalRead(int lhs, FieldReference global) { + public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) { throw new UnsupportedOperationException(); } - public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) { + public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) { throw new UnsupportedOperationException(); } - 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(); } - public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) { + public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) { throw new UnsupportedOperationException(); } - public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) { + public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) { throw new UnsupportedOperationException(); } - public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) { + public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) { throw new UnsupportedOperationException(); } - public AstLexicalRead LexicalRead(Access[] accesses) { - return new AstLexicalRead(accesses); + public AstLexicalRead LexicalRead(int iindex, Access[] accesses) { + return new AstLexicalRead(iindex, accesses); } - public AstLexicalRead LexicalRead(Access access) { - return new AstLexicalRead(access); + public AstLexicalRead LexicalRead(int iindex, Access access) { + return new AstLexicalRead(iindex, access); } - public AstLexicalRead LexicalRead(int lhs, String definer, String globalName) { - return new AstLexicalRead(lhs, definer, globalName); + public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName) { + return new AstLexicalRead(iindex, lhs, definer, globalName); } - public AstLexicalWrite LexicalWrite(Access[] accesses) { - return new AstLexicalWrite(accesses); + public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) { + return new AstLexicalWrite(iindex, accesses); } - public AstLexicalWrite LexicalWrite(Access access) { - return new AstLexicalWrite(access); + public AstLexicalWrite LexicalWrite(int iindex, Access access) { + return new AstLexicalWrite(iindex, access); } - public AstLexicalWrite LexicalWrite(String definer, String globalName, int rhs) { - return new AstLexicalWrite(definer, globalName, rhs); + public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, int rhs) { + return new AstLexicalWrite(iindex, definer, globalName, rhs); } - public SSAThrowInstruction NonExceptingThrowInstruction(int exception) { + public SSAThrowInstruction NonExceptingThrowInstruction(int iindex, int exception) { throw new UnsupportedOperationException(); } } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInstructionFactory.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInstructionFactory.java index 1d30fe6fe..e95cae79c 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInstructionFactory.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInstructionFactory.java @@ -8,14 +8,14 @@ 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); - AstJavaInvokeInstruction JavaInvokeInstruction(int[] params, int exception, CallSiteReference site); + AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site); - AstJavaInvokeInstruction JavaInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites); + AstJavaInvokeInstruction JavaInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites); - EnclosingObjectReference EnclosingObjectReference(int lval, TypeReference type); + EnclosingObjectReference EnclosingObjectReference(int iidnex, int lval, TypeReference type); - AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int result, NewSiteReference site, int enclosing); + AstJavaNewEnclosingInstruction JavaNewEnclosingInstruction(int iindex, int result, NewSiteReference site, int enclosing); } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInvokeInstruction.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInvokeInstruction.java index eb9b816df..df72b95b2 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInvokeInstruction.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaInvokeInstruction.java @@ -31,30 +31,30 @@ import com.ibm.wala.types.TypeReference; */ public class AstJavaInvokeInstruction extends FixedParametersLexicalInvokeInstruction { - 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); } - public AstJavaInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, + public AstJavaInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) { - super(results, params, exception, site, lexicalReads, lexicalWrites); + super(iindex, results, params, exception, site, lexicalReads, lexicalWrites); } protected SSAInstruction copyInstruction(SSAInstructionFactory insts, int results[], int[] params, int exception, Access[] lexicalReads, Access[] lexicalWrites) { - return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(results, params, exception, getCallSite(), lexicalReads, + return ((AstJavaInstructionFactory) insts).JavaInvokeInstruction(iindex, results, params, exception, getCallSite(), lexicalReads, lexicalWrites); } diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaNewEnclosingInstruction.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaNewEnclosingInstruction.java index f0f481cb6..8c028f549 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaNewEnclosingInstruction.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/AstJavaNewEnclosingInstruction.java @@ -23,8 +23,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; } @@ -37,7 +37,7 @@ public class AstJavaNewEnclosingInstruction extends SSANewInstruction { } 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]); } public Collection getExceptionTypes() { diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/EnclosingObjectReference.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/EnclosingObjectReference.java index 6dae54b6f..fdca16c41 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/EnclosingObjectReference.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/ssa/EnclosingObjectReference.java @@ -20,7 +20,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; } @@ -48,7 +49,7 @@ public class EnclosingObjectReference extends SSAInstruction { } 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); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java index da633fd5a..839f398f6 100644 --- a/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java +++ b/com.ibm.wala.cast.java/src/com/ibm/wala/cast/java/translator/JavaCAst2IRTranslator.java @@ -91,12 +91,12 @@ public class JavaCAst2IRTranslator extends AstTranslator { protected void doThrow(WalkContext context, int exception) { - context.cfg().addInstruction(insts.ThrowInstruction(exception)); + context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception)); } 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); } @@ -109,7 +109,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { context.cfg().addInstruction( - insts.ArrayStoreInstruction( + insts.ArrayStoreInstruction(context.cfg().getCurrentInstruction(), arrayValue, dimValues[0], rval, @@ -123,9 +123,9 @@ public class JavaCAst2IRTranslator extends AstTranslator { FieldReference fieldRef= (FieldReference) elt.getValue(); 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); } } @@ -134,9 +134,9 @@ public class JavaCAst2IRTranslator extends AstTranslator { FieldReference fieldRef= (FieldReference) elt.getValue(); 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,12 +158,12 @@ public class JavaCAst2IRTranslator extends AstTranslator { 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)); + insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site): + insts.NewInstruction(context.cfg().getCurrentInstruction(), result, site, arguments)); } processExceptions(newNode, context); } @@ -199,9 +199,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); } @@ -329,7 +329,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { WalkContext wc = (WalkContext)c; int result = wc.currentScope().allocateTempValue(); setValue(n, result); - wc.cfg().addInstruction(new EnclosingObjectReference(result, (TypeReference)n.getChild(0).getValue())); + wc.cfg().addInstruction(new EnclosingObjectReference(wc.cfg().getCurrentInstruction(), result, (TypeReference)n.getChild(0).getValue())); } } @@ -350,7 +350,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { if (toRef.isPrimitiveType()) { context.cfg().addInstruction( - insts.ConversionInstruction( + insts.ConversionInstruction(context.cfg().getCurrentInstruction(), result, getValue(n.getChild(1)), fromRef, @@ -359,7 +359,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { } else { context.cfg().addInstruction( - insts.CheckCastInstruction( + insts.CheckCastInstruction(context.cfg().getCurrentInstruction(), result, getValue(n.getChild(1)), toRef)); @@ -380,7 +380,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { TypeReference ref = makeType( type ); context.cfg().addInstruction( - insts.InstanceofInstruction( + insts.InstanceofInstruction(context.cfg().getCurrentInstruction(), result, getValue(n.getChild(1)), ref)); @@ -391,7 +391,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { if (n.getKind() == CAstNode.MONITOR_ENTER) { visitor.visit(n.getChild(0), wc, visitor); wc.cfg().addInstruction( - insts.MonitorInstruction( + insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), getValue(n.getChild(0)), true)); processExceptions(n, wc); @@ -400,7 +400,7 @@ public class JavaCAst2IRTranslator extends AstTranslator { } else if (n.getKind() == CAstNode.MONITOR_EXIT) { visitor.visit(n.getChild(0), wc, visitor); wc.cfg().addInstruction( - insts.MonitorInstruction( + insts.MonitorInstruction(wc.cfg().getCurrentInstruction(), getValue(n.getChild(0)), false)); processExceptions(n, wc); diff --git a/com.ibm.wala.cast.js.rhino/build.xml b/com.ibm.wala.cast.js.rhino/build.xml index f3c689484..874f77cca 100644 --- a/com.ibm.wala.cast.js.rhino/build.xml +++ b/com.ibm.wala.cast.js.rhino/build.xml @@ -39,7 +39,7 @@ - + diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java index 45daf3378..f2826fc5a 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ipa/callgraph/AstCallGraph.java @@ -59,7 +59,7 @@ public class AstCallGraph extends ExplicitCallGraph { } public AstLexicalRead addGlobalRead(TypeReference type, String name) { - AstLexicalRead s = new AstLexicalRead(nextLocal++, null, name); + AstLexicalRead s = new AstLexicalRead(statements.size(), nextLocal++, null, name); statements.add(s); return s; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractLexicalInvoke.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractLexicalInvoke.java index 6a5121525..80dc67ebd 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractLexicalInvoke.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractLexicalInvoke.java @@ -30,17 +30,17 @@ public abstract class AbstractLexicalInvoke extends MultiReturnValueInvokeInstru protected Access[] lexicalWrites = null; - protected AbstractLexicalInvoke(int results[], int exception, CallSiteReference site) { - super(results, exception, site); + protected AbstractLexicalInvoke(int iindex, int results[], int exception, CallSiteReference site) { + super(iindex, results, exception, site); } - protected AbstractLexicalInvoke(int result, int exception, CallSiteReference site) { - this(new int[] { result }, exception, site); + protected AbstractLexicalInvoke(int iindex, int result, int exception, CallSiteReference site) { + this(iindex, new int[] { result }, exception, site); } - protected AbstractLexicalInvoke(int results[], int exception, CallSiteReference site, Access[] lexicalReads, + protected AbstractLexicalInvoke(int iindex, int results[], int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) { - this(results, exception, site); + this(iindex, results, exception, site); this.lexicalReads = lexicalReads; this.lexicalWrites = lexicalWrites; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java index fcf756105..529f8234d 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectiveGet.java @@ -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; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java index e2afea811..45eac66ae 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AbstractReflectivePut.java @@ -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; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AssignInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AssignInstruction.java index 76cc1d1f3..b810e2db7 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AssignInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AssignInstruction.java @@ -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; @@ -42,7 +42,7 @@ public class AssignInstruction extends SSAUnaryOpInstruction { */ 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]); } /* diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstAssertInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstAssertInstruction.java index 68029ea3e..bdccc33c7 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstAssertInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstAssertInstruction.java @@ -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; } @@ -47,7 +48,7 @@ public class AstAssertInstruction extends SSAInstruction { } 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); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstEchoInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstEchoInstruction.java index e16d18a8f..3a3ac14bc 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstEchoInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstEchoInstruction.java @@ -12,12 +12,13 @@ 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; } 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); } public int getNumberOfDefs() { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalRead.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalRead.java index ace71ce68..b7420fd5e 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalRead.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalRead.java @@ -26,12 +26,12 @@ 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); } 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()); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalWrite.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalWrite.java index 85d9dc773..3f86d47de 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalWrite.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstGlobalWrite.java @@ -26,12 +26,12 @@ 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); } 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]); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstInstructionFactory.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstInstructionFactory.java index 3adac9fa3..b02a63fa7 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstInstructionFactory.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstInstructionFactory.java @@ -16,38 +16,38 @@ import com.ibm.wala.types.FieldReference; 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); + AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName); - 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, int rhs); + AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, 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); } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstIsDefinedInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstIsDefinedInstruction.java index 7a7632505..5774be4ec 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstIsDefinedInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstIsDefinedInstruction.java @@ -19,28 +19,32 @@ public class AstIsDefinedInstruction extends SSAInstruction { private final int lval; - 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; @@ -50,7 +54,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); } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalAccess.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalAccess.java index 9594cced1..f8ed8d169 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalAccess.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalAccess.java @@ -60,7 +60,8 @@ public abstract class AstLexicalAccess extends SSAInstruction { private Access[] accesses; - AstLexicalAccess(Access[] accesses) { + AstLexicalAccess(int iindex, Access[] accesses) { + super(iindex); setAccesses( accesses ); } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalRead.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalRead.java index 60175fcfd..d4c051d05 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalRead.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalRead.java @@ -24,21 +24,21 @@ import com.ibm.wala.ssa.SymbolTable; */ 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) { - this(new Access(globalName, definer, lhs)); + public AstLexicalRead(int iindex, int lhs, String definer, String globalName) { + this(iindex, new Access(globalName, definer, lhs)); } 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++) { @@ -46,7 +46,7 @@ public class AstLexicalRead extends AstLexicalAccess { accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, defs[i]); } - return ((AstInstructionFactory)insts).LexicalRead(accesses); + return ((AstInstructionFactory)insts).LexicalRead(iindex, accesses); } } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalWrite.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalWrite.java index 9324b5ac0..a71887da4 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalWrite.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/AstLexicalWrite.java @@ -24,21 +24,21 @@ import com.ibm.wala.ssa.SymbolTable; */ public class AstLexicalWrite extends AstLexicalAccess { - public AstLexicalWrite(String definer, String globalName, int rhs) { - this(new Access(globalName, definer, rhs)); + public AstLexicalWrite(int iindex, String definer, String globalName, int rhs) { + this(iindex, new Access(globalName, definer, 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); } 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++) { @@ -46,7 +46,7 @@ public class AstLexicalWrite extends AstLexicalAccess { accesses[i] = new Access(oldAccess.variableName, oldAccess.variableDefiner, uses[i]); } - return ((AstInstructionFactory)insts).LexicalWrite(accesses); + return ((AstInstructionFactory)insts).LexicalWrite(iindex, accesses); } } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementGetInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementGetInstruction.java index 095a5eb98..76371e028 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementGetInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementGetInstruction.java @@ -31,12 +31,12 @@ 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); } 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]); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementHasNextInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementHasNextInstruction.java index 8bf5d9463..e5992d0f3 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementHasNextInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/EachElementHasNextInstruction.java @@ -31,12 +31,12 @@ 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); } 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]); } public String toString(SymbolTable symbolTable) { diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/FixedParametersLexicalInvokeInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/FixedParametersLexicalInvokeInstruction.java index ccf036fcd..31e7c378e 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/FixedParametersLexicalInvokeInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/FixedParametersLexicalInvokeInstruction.java @@ -34,13 +34,13 @@ public abstract class FixedParametersLexicalInvokeInstruction */ private final int[] params; - public FixedParametersLexicalInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site) { - super(results, exception, site); + public FixedParametersLexicalInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site) { + super(iindex, results, exception, site); this.params = params; } - public FixedParametersLexicalInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) { - this(new int[]{result}, params, exception, site); + public FixedParametersLexicalInvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) { + this(iindex, new int[]{result}, params, exception, site); } /** @@ -48,12 +48,12 @@ public abstract class FixedParametersLexicalInvokeInstruction * @param i * @param params */ - public FixedParametersLexicalInvokeInstruction(int[] params, int exception, CallSiteReference site) { - this(null, params, exception, site); + public FixedParametersLexicalInvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) { + this(iindex, null, params, exception, site); } - protected FixedParametersLexicalInvokeInstruction(int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) { - super(results, exception, site, lexicalReads, lexicalWrites); + protected FixedParametersLexicalInvokeInstruction(int iindex, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites) { + super(iindex, results, exception, site, lexicalReads, lexicalWrites); this.params = params; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/MultiReturnValueInvokeInstruction.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/MultiReturnValueInvokeInstruction.java index be35d594e..cd77837b9 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/MultiReturnValueInvokeInstruction.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/MultiReturnValueInvokeInstruction.java @@ -8,8 +8,8 @@ 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; } diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/SSAConversion.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/SSAConversion.java index 0c3c41eb8..46174c5f6 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/SSAConversion.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/ssa/SSAConversion.java @@ -178,7 +178,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)); @@ -323,7 +323,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)); diff --git a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java index 72a17f823..7abc8c342 100644 --- a/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java +++ b/com.ibm.wala.cast/source/java/com/ibm/wala/cast/ir/translator/AstTranslator.java @@ -161,7 +161,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void doPrologue(WalkContext context) { if (useLocalValuesForLexicalVars()) { - context.cfg().addInstruction(new AstLexicalRead(new Access[0])); + context.cfg().addInstruction(new AstLexicalRead(context.cfg().currentInstruction, new Access[0])); } } @@ -174,7 +174,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void doLocalWrite(WalkContext context, String nm, int rval) { 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)); } } @@ -197,7 +197,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle } else { int result = context.currentScope().allocateTempValue(); Access A = new Access(name, getEntityName(E), result); - context.cfg().addInstruction(new AstLexicalRead(A)); + context.cfg().addInstruction(new AstLexicalRead(context.cfg().currentInstruction, A)); return result; } } @@ -215,13 +215,13 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle addExposedName(context.top(), E, name, vn); addAccess(context.top(), A); - context.cfg().addInstruction(new AssignInstruction(vn, rval)); - context.cfg().addInstruction(new AstLexicalWrite(A)); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, vn, rval)); + context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A)); // lexically-scoped variables can be read from their scope each time } else { Access A = new Access(name, getEntityName(E), rval); - context.cfg().addInstruction(new AstLexicalWrite(A)); + context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A)); } } @@ -245,7 +245,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle } else { int result = context.currentScope().allocateTempValue(); Access A = new Access(name, null, result); - context.cfg().addInstruction(new AstLexicalRead(A)); + context.cfg().addInstruction(new AstLexicalRead(context.cfg().currentInstruction, A)); return result; } @@ -253,7 +253,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle } 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; } } @@ -272,19 +272,19 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle addExposedName(context.top(), null, name, vn); addAccess(context.top(), A); - context.cfg().addInstruction(new AssignInstruction(vn, rval)); - context.cfg().addInstruction(new AstLexicalWrite(A)); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, vn, rval)); + context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, A)); // lexically-scoped variables can be read from their scope each time } else { Access A = new Access(name, null, rval); - context.cfg().addInstruction(new AstLexicalWrite(A)); + context.cfg().addInstruction(new AstLexicalWrite(context.cfg().currentInstruction, 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)); } } @@ -544,14 +544,14 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle int e = -1; PreBasicBlock currentBlock = getCurrentBlock(); if (!isDeadBlock(currentBlock)) { - addInstruction(insts.GotoInstruction()); + addInstruction(insts.GotoInstruction(currentInstruction)); 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.getNumber(), defaultCatchType()); } @@ -585,7 +585,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle addPreNode(dummy); doThrow(astContext, e); } else { - addInstruction(insts.GotoInstruction()); + addInstruction(insts.GotoInstruction(currentInstruction)); } newBlock(false); @@ -2572,7 +2572,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle + 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, getValue(n + insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, getValue(n .getChild(0)), context.currentScope().getConstantValue(new Integer(0)))); PreBasicBlock branchB = context.cfg().getCurrentBlock(); @@ -2580,7 +2580,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle context.cfg().newBlock(true); visitor.visit(n.getChild(1), context, visitor); if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) { - context.cfg().addInstruction(insts.GotoInstruction()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); PreBasicBlock bodyB = context.cfg().getCurrentBlock(); context.cfg().addEdge(bodyB, headerB); @@ -2611,7 +2611,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle String nm = (String) n.getChild(0).getValue(); context.currentScope().declare(new FinalCAstSymbol(nm)); context.cfg().addInstruction( - insts.GetCaughtExceptionInstruction(context.cfg().getCurrentBlock().getNumber(), context.currentScope() + insts.GetCaughtExceptionInstruction(context.cfg().currentInstruction, context.cfg().getCurrentBlock().getNumber(), context.currentScope() .lookup(nm).valueNumber())); } @@ -2719,7 +2719,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle boolean mayBeInteger = handleBinaryOpThrow(n, n.getChild(0), context); context.cfg().addInstruction( - insts.BinaryOpInstruction(translateBinaryOpcode(n.getChild(0)), false, false, result, getValue(l), getValue(r), + insts.BinaryOpInstruction(context.cfg().currentInstruction, translateBinaryOpcode(n.getChild(0)), false, false, result, getValue(l), getValue(r), mayBeInteger)); if (mayBeInteger) { @@ -2739,7 +2739,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle int result = getValue(n); CAstNode v = n.getChild(1); context.cfg() - .addInstruction(insts.UnaryOpInstruction(translateUnaryOpcode(n.getChild(0)), result, getValue(v))); + .addInstruction(insts.UnaryOpInstruction(context.cfg().currentInstruction, translateUnaryOpcode(n.getChild(0)), result, getValue(v))); } protected boolean visitArrayLength(CAstNode n, Context c, CAstVisitor visitor) { @@ -2753,7 +2753,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle WalkContext context = (WalkContext) c; int result = getValue(n); int arrayValue = getValue(n.getChild(0)); - context.cfg().addInstruction(insts.ArrayLengthInstruction(result, arrayValue)); + context.cfg().addInstruction(insts.ArrayLengthInstruction(context.cfg().currentInstruction, result, arrayValue)); } protected boolean visitArrayRef(CAstNode n, Context c, CAstVisitor visitor) { /* empty */ @@ -2782,12 +2782,12 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle CAstNode v = n.getChild(1); if (scope.contains(nm) && scope.lookup(nm).getDefiningScope() == scope) { assert !s.isFinal(); - context.cfg().addInstruction(new AssignInstruction(scope.lookup(nm).valueNumber(), getValue(v))); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, scope.lookup(nm).valueNumber(), getValue(v))); } else if (v.getKind() != CAstNode.CONSTANT && v.getKind() != CAstNode.VAR && v.getKind() != CAstNode.THIS) { scope.declare(s, getValue(v)); } else { scope.declare(s); - context.cfg().addInstruction(new AssignInstruction(context.currentScope().lookup(nm).valueNumber(), getValue(v))); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, context.currentScope().lookup(nm).valueNumber(), getValue(v))); } } else { context.currentScope().declare(s); @@ -2801,9 +2801,9 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void leaveReturn(CAstNode n, Context c, CAstVisitor visitor) { WalkContext context = (WalkContext) c; if (n.getChildCount() > 0) { - context.cfg().addInstruction(insts.ReturnInstruction(getValue(n.getChild(0)), false)); + context.cfg().addInstruction(insts.ReturnInstruction(context.cfg().currentInstruction, 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()); @@ -2819,11 +2819,11 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle WalkContext context = (WalkContext) c; if (n.getChildCount() == 1) { context.cfg().addInstruction( - insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_NE), null, getValue(n + insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_NE), null, getValue(n .getChild(0)), context.currentScope().getConstantValue(new Integer(0)))); } else if (n.getChildCount() == 3) { context.cfg().addInstruction( - insts.ConditionalBranchInstruction(translateConditionOpcode(n.getChild(0)), null, + insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(n.getChild(0)), null, getValue(n.getChild(1)), getValue(n.getChild(2)))); } else { Assertions.UNREACHABLE(); @@ -2841,7 +2841,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void leaveGoto(CAstNode n, Context c, CAstVisitor visitor) { WalkContext context = (WalkContext) c; context.cfg().addPreNode(n, context.getUnwindState()); - context.cfg().addInstruction(insts.GotoInstruction()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); context.cfg().newBlock(false); if (context.getControlFlow().getTarget(n, null) == null) { assert context.getControlFlow().getTarget(n, null) != null : context.getControlFlow() + " does not map " + n @@ -2869,7 +2869,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle CAstNode l = n.getChild(0); visitor.visit(l, context, visitor); context.cfg().addInstruction( - insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_EQ), null, getValue(l), context + insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, getValue(l), context .currentScope().getConstantValue(new Integer(0)))); PreBasicBlock srcB = context.cfg().getCurrentBlock(); // true clause @@ -2877,10 +2877,10 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle CAstNode r = n.getChild(1); visitor.visit(r, context, visitor); if (isExpr) - context.cfg().addInstruction(new AssignInstruction(getValue(n), getValue(r))); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, getValue(n), getValue(r))); if (n.getChildCount() == 3) { if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) { - context.cfg().addInstruction(insts.GotoInstruction()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); trueB = context.cfg().getCurrentBlock(); // false clause @@ -2891,7 +2891,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle CAstNode f = n.getChild(2); visitor.visit(f, context, visitor); if (isExpr) - context.cfg().addInstruction(new AssignInstruction(getValue(n), getValue(f))); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, getValue(n), getValue(f))); } // end @@ -3036,7 +3036,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle 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); @@ -3157,7 +3157,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle if (!pre) { int ret = context.currentScope().allocateTempValue(); - context.cfg().addInstruction(new AssignInstruction(ret, temp)); + context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, ret, temp)); setValue(n, ret); } @@ -3225,12 +3225,12 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle 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()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); defaultHackBlock = context.cfg().getCurrentBlock(); context.cfg().newBlock(false); @@ -3274,7 +3274,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle if (x != CAstControlFlowMap.SWITCH_DEFAULT) { visitor.visit((CAstNode) x, context, visitor); context.cfg().addInstruction( - insts.ConditionalBranchInstruction(translateConditionOpcode(CAstOperator.OP_EQ), null, v, + insts.ConditionalBranchInstruction(context.cfg().currentInstruction, translateConditionOpcode(CAstOperator.OP_EQ), null, v, getValue((CAstNode) x))); labelToBlock.put(x, context.cfg().getCurrentBlock()); context.cfg().newBlock(true); @@ -3282,7 +3282,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle } PreBasicBlock defaultGotoBlock = context.cfg().getCurrentBlock(); - context.cfg().addInstruction(insts.GotoInstruction()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); context.cfg().newBlock(false); CAstNode switchBody = n.getChild(1); @@ -3358,7 +3358,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle context.currentScope().declare(new FinalCAstSymbol(id)); } context.cfg().addInstruction( - insts.GetCaughtExceptionInstruction(context.cfg().getCurrentBlock().getNumber(), context.currentScope() + insts.GetCaughtExceptionInstruction(context.cfg().currentInstruction, context.cfg().getCurrentBlock().getNumber(), context.currentScope() .lookup(id).valueNumber())); context.cfg().addPreNode(n, context.getUnwindState()); @@ -3393,7 +3393,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle if (!context.cfg().isDeadBlock(context.cfg().getCurrentBlock())) { addSkipCatchGoto = true; ; - context.cfg().addInstruction(insts.GotoInstruction()); + context.cfg().addInstruction(insts.GotoInstruction(context.cfg().currentInstruction)); context.cfg().newBlock(false); } @@ -3460,7 +3460,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle 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)); } protected boolean visitEachElementGet(CAstNode n, Context c, CAstVisitor visitor) { @@ -3470,7 +3470,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void leaveEachElementGet(CAstNode n, Context c, CAstVisitor visitor) { int result = ((WalkContext) c).currentScope().allocateTempValue(); setValue(n, result); - ((WalkContext) c).cfg().addInstruction(new EachElementGetInstruction(result, getValue(n.getChild(0)))); + ((WalkContext) c).cfg().addInstruction(new EachElementGetInstruction(((WalkContext) c).cfg().currentInstruction, result, getValue(n.getChild(0)))); } protected boolean visitEachElementHasNext(CAstNode n, Context c, CAstVisitor visitor) { @@ -3480,7 +3480,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle protected void leaveEachElementHasNext(CAstNode n, Context c, CAstVisitor visitor) { int result = ((WalkContext) c).currentScope().allocateTempValue(); setValue(n, result); - ((WalkContext) c).cfg().addInstruction(new EachElementHasNextInstruction(result, getValue(n.getChild(0)))); + ((WalkContext) c).cfg().addInstruction(new EachElementHasNextInstruction(((WalkContext) c).cfg().currentInstruction, result, getValue(n.getChild(0)))); } protected boolean visitTypeLiteralExpr(CAstNode n, Context c, CAstVisitor visitor) { @@ -3497,7 +3497,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle int result = wc.currentScope().allocateTempValue(); 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)); } protected boolean visitIsDefinedExpr(CAstNode n, Context c, CAstVisitor visitor) { @@ -3510,7 +3510,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle int result = wc.currentScope().allocateTempValue(); 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)); } @@ -3528,7 +3528,7 @@ public abstract class AstTranslator extends CAstVisitor implements ArrayOpHandle rvals[i] = getValue(n.getChild(i)); } - wc.cfg().addInstruction(new AstEchoInstruction(rvals)); + wc.cfg().addInstruction(new AstEchoInstruction(wc.cfg().currentInstruction, rvals)); } public CAstEntity getIncludedEntity(CAstNode n) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/AbstractReflectionInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/AbstractReflectionInterpreter.java index 80507c9de..a0db60720 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/AbstractReflectionInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/AbstractReflectionInterpreter.java @@ -230,15 +230,15 @@ public abstract class AbstractReflectionInterpreter implements SSAContextInterpr int dim = t.getDimensionality(); int[] extents = new int[dim]; 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; } @@ -252,7 +252,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); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java index e6ae9d4d6..9eb7cf106 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassFactoryContextInterpreter.java @@ -124,12 +124,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()]; diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java index 6aa2d1850..daa975085 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ClassNewInstanceContextInterpreter.java @@ -140,17 +140,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); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/CloneInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/CloneInterpreter.java index 1a30fb6ed..836e963b3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/CloneInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/CloneInterpreter.java @@ -154,12 +154,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[klass.getReference().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); @@ -170,7 +170,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. @@ -180,9 +180,9 @@ public class CloneInterpreter implements SSAContextInterpreter { for (Iterator 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(); @@ -190,7 +190,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()]; diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java index c95dc411f..5448de32d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/FactoryBypassInterpreter.java @@ -476,7 +476,7 @@ 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); } @@ -513,7 +513,7 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter { private void addStatementsForSetOfTypes(Iterator 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); } @@ -531,20 +531,20 @@ class FactoryBypassInterpreter extends AbstractReflectionInterpreter { int[] sizes = new int[T.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); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java index ee07fe33c..7ddb73d35 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/GetClassContextInterpeter.java @@ -102,9 +102,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()]; diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java index e42ee6263..a461fc8e5 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/JavaLangClassContextInterpreter.java @@ -281,7 +281,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { NewSiteReference site = new NewSiteReference(retValue, arrType); int sizeVn = nextLocal++; constants.put(sizeVn, new ConstantValue(returnValues.size())); - SSANewInstruction allocArr = insts.NewInstruction(retValue, site, new int[] { sizeVn }); + SSANewInstruction allocArr = insts.NewInstruction(statements.size(), retValue, site, new int[] { sizeVn }); statements.add(allocArr); int i = 0; @@ -292,10 +292,10 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { int indexVn = nextLocal++; constants.put(indexVn, new ConstantValue(index)); SSAArrayStoreInstruction store = insts - .ArrayStoreInstruction(retValue, indexVn, c, TypeReference.JavaLangReflectConstructor); + .ArrayStoreInstruction(statements.size(), retValue, indexVn, c, TypeReference.JavaLangReflectConstructor); statements.add(store); } - SSAReturnInstruction R = insts.ReturnInstruction(retValue, false); + SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), retValue, false); statements.add(R); } else { // SJF: This is incorrect. TODO: fix and enable. @@ -326,7 +326,7 @@ public class JavaLangClassContextInterpreter implements SSAContextInterpreter { for (IMethod m : returnValues) { int c = nextLocal++; constants.put(c, new ConstantValue(m)); - SSAReturnInstruction R = insts.ReturnInstruction(c, false); + SSAReturnInstruction R = insts.ReturnInstruction(statements.size(), c, false); statements.add(R); } } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java index b4c466040..40f33b0a5 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectiveInvocationInterpreter.java @@ -153,7 +153,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret // allocate the new object constructed TypeReference allocatedType = target.getDeclaringClass().getReference(); m - .addInstruction(allocatedType, insts.NewInstruction(args[0] = nextLocal++, NewSiteReference.make(pc++, allocatedType)), + .addInstruction(allocatedType, insts.NewInstruction(m.allInstructions.size(), args[0] = nextLocal++, NewSiteReference.make(pc++, allocatedType)), true); parametersVn = 2; } else { @@ -166,7 +166,7 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret // insert a cast for v2 to filter out bogus types args[0] = nextLocal++; TypeReference type = target.getParameterType(0); - SSACheckCastInstruction cast = insts.CheckCastInstruction(args[0], 2, type); + SSACheckCastInstruction cast = insts.CheckCastInstruction(m.allInstructions.size(), args[0], 2, type); m.addInstruction(null, cast, false); } } @@ -179,14 +179,14 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret int indexConst = nextLocal++; constants.put(new Integer(indexConst), new ConstantValue(nextParameter++)); int temp = nextLocal++; - m.addInstruction(null, insts.ArrayLoadInstruction(temp, parametersVn, indexConst, TypeReference.JavaLangObject), false); + m.addInstruction(null, insts.ArrayLoadInstruction(m.allInstructions.size(), temp, parametersVn, indexConst, TypeReference.JavaLangObject), false); pc++; // cast v_temp to the appropriate type and store it in args[j] args[j] = nextLocal++; TypeReference type = target.getParameterType(j); // we insert a cast to filter out bogus types - SSACheckCastInstruction cast = insts.CheckCastInstruction(args[j], temp, type); + SSACheckCastInstruction cast = insts.CheckCastInstruction(m.allInstructions.size(), args[j], temp, type); m.addInstruction(null, cast, false); pc++; } @@ -196,19 +196,19 @@ public class ReflectiveInvocationInterpreter extends AbstractReflectionInterpret // emit the dispatch and return instructions if (method.getReference().equals(CTOR_NEW_INSTANCE)) { - m.addInstruction(null, insts.InvokeInstruction(args, exceptions, CallSiteReference.make(pc++, target.getReference(), + m.addInstruction(null, insts.InvokeInstruction(m.allInstructions.size(), args, exceptions, CallSiteReference.make(pc++, target.getReference(), IInvokeInstruction.Dispatch.SPECIAL)), false); - m.addInstruction(null, insts.ReturnInstruction(args[0], false), false); + m.addInstruction(null, insts.ReturnInstruction(m.allInstructions.size(), args[0], false), false); } else { Dispatch d = target.isStatic() ? Dispatch.STATIC : Dispatch.VIRTUAL; if (target.getReturnType().equals(TypeReference.Void)) { - m.addInstruction(null, insts.InvokeInstruction(args, exceptions, CallSiteReference.make(pc++, target.getReference(), d)), + m.addInstruction(null, insts.InvokeInstruction(m.allInstructions.size(), args, exceptions, CallSiteReference.make(pc++, target.getReference(), d)), false); } else { result = nextLocal++; - m.addInstruction(null, insts.InvokeInstruction(result, args, exceptions, CallSiteReference.make(pc++, + m.addInstruction(null, insts.InvokeInstruction(m.allInstructions.size(), result, args, exceptions, CallSiteReference.make(pc++, target.getReference(), d)), false); - m.addInstruction(null, insts.ReturnInstruction(result, false), false); + m.addInstruction(null, insts.ReturnInstruction(m.allInstructions.size(), result, false), false); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/InducedCFG.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/InducedCFG.java index 9dfac2f80..0c244af50 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/InducedCFG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/InducedCFG.java @@ -475,7 +475,7 @@ public class InducedCFG extends AbstractCFG getExceptionTypes() { return getNullPointerException(); @@ -83,8 +83,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType) { - return new SSAArrayLoadInstruction(result, arrayref, index, declaredType) { + public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) { + return new SSAArrayLoadInstruction(iindex, result, arrayref, index, declaredType) { @Override public Collection getExceptionTypes() { return getArrayAccessExceptions(); @@ -92,8 +92,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType) { - return new SSAArrayStoreInstruction(arrayref, index, value, declaredType) { + public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) { + return new SSAArrayStoreInstruction(iindex, arrayref, index, value, declaredType) { @Override public Collection getExceptionTypes() { if (typeIsPrimitive()) { @@ -105,15 +105,15 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSABinaryOpInstruction BinaryOpInstruction(IBinaryOpInstruction.IOperator operator, boolean overflow, boolean unsigned, + public SSABinaryOpInstruction BinaryOpInstruction(int iindex, IBinaryOpInstruction.IOperator operator, boolean overflow, boolean unsigned, int result, int val1, int val2, boolean mayBeInteger) { assert !overflow; assert !unsigned; - return new SSABinaryOpInstruction(operator, result, val1, val2, mayBeInteger) { + return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) { @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()); } @@ -128,13 +128,13 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues) { + public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues) { throw new UnsupportedOperationException(); } - public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types) { + public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types) { assert types.length == 1; - return new SSACheckCastInstruction(result, val, types) { + return new SSACheckCastInstruction(iindex, result, val, types) { @Override public Collection getExceptionTypes() { return getClassCastException(); @@ -142,49 +142,49 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue) { - return CheckCastInstruction(result, val, new int[]{ typeValue }); + public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue) { + return CheckCastInstruction(iindex, result, val, new int[]{ typeValue }); } - public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type) { - return CheckCastInstruction(result, val, new TypeReference[]{ type }); + public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type) { + return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type }); } - public SSAComparisonInstruction ComparisonInstruction(IComparisonInstruction.Operator operator, int result, int val1, int val2) { - return new SSAComparisonInstruction(operator, result, val1, val2); + public SSAComparisonInstruction ComparisonInstruction(int iindex, IComparisonInstruction.Operator operator, int result, int val1, int val2) { + return new SSAComparisonInstruction(iindex, operator, result, val1, val2); } - public SSAConditionalBranchInstruction ConditionalBranchInstruction(IConditionalBranchInstruction.IOperator operator, + public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2) { - return new SSAConditionalBranchInstruction(operator, type, val1, val2); + return new SSAConditionalBranchInstruction(iindex, operator, type, val1, val2); } - 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); } }; } - 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); } - public SSAGetInstruction GetInstruction(int result, FieldReference field) { - return new SSAGetInstruction(result, field) { + public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) { + return new SSAGetInstruction(iindex, result, field) { }; } - 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 Collection getExceptionTypes() { return getNullPointerException(); @@ -192,16 +192,16 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAGotoInstruction GotoInstruction() { - return new SSAGotoInstruction(); + public SSAGotoInstruction GotoInstruction(int iindex) { + return new SSAGotoInstruction(iindex); } - public SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType) { - return new SSAInstanceofInstruction(result, ref, checkedType); + public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) { + return new SSAInstanceofInstruction(iindex, result, ref, checkedType); } - public SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site) { - return new SSAInvokeInstruction(result, params, exception, site) { + public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) { + return new SSAInvokeInstruction(iindex, result, params, exception, site) { @Override public Collection getExceptionTypes() { if (!isStatic()) { @@ -213,8 +213,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site) { - return new SSAInvokeInstruction(params, exception, site) { + public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) { + return new SSAInvokeInstruction(iindex, params, exception, site) { @Override public Collection getExceptionTypes() { if (!isStatic()) { @@ -226,8 +226,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter) { - return new SSAMonitorInstruction(ref, isEnter) { + public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) { + return new SSAMonitorInstruction(iindex, ref, isEnter) { @Override public Collection getExceptionTypes() { return getNullPointerException(); @@ -235,8 +235,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - 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 Collection getExceptionTypes() { if (getNewSite().getDeclaredType().isArrayType()) { @@ -248,13 +248,13 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAPhiInstruction PhiInstruction(int result, int[] params) throws IllegalArgumentException { - return new SSAPhiInstruction(result, params) { + public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) throws IllegalArgumentException { + return new SSAPhiInstruction(iindex, result, params) { }; } - 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 Collection getExceptionTypes() { return getNullPointerException(); @@ -262,25 +262,25 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAPutInstruction PutInstruction(int value, FieldReference field) { - return new SSAPutInstruction(value, field) { + public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) { + return new SSAPutInstruction(iindex, value, field) { }; } - public SSAReturnInstruction ReturnInstruction() { - return new SSAReturnInstruction(); + public SSAReturnInstruction ReturnInstruction(int iindex) { + return new SSAReturnInstruction(iindex); } - 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); } - 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); } - public SSAThrowInstruction ThrowInstruction(int exception) { - return new SSAThrowInstruction(exception) { + public SSAThrowInstruction ThrowInstruction(int iindex, int exception) { + return new SSAThrowInstruction(iindex, exception) { @Override public Collection getExceptionTypes() { return getNullPointerException(); @@ -288,12 +288,12 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSAUnaryOpInstruction UnaryOpInstruction(IUnaryOpInstruction.IOperator operator, int result, int val) { - return new SSAUnaryOpInstruction(operator, result, val); + public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, IUnaryOpInstruction.IOperator operator, int result, int val) { + return new SSAUnaryOpInstruction(iindex, operator, result, val); } - public SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token) { - return new SSALoadMetadataInstruction(lval, entityType, token) { + public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) { + return new SSALoadMetadataInstruction(iindex, lval, entityType, token) { @Override public Collection getExceptionTypes() { return loadClassExceptions; @@ -301,8 +301,8 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - public SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params) { - return new SSANewInstruction(result, site, params) { + public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) { + return new SSANewInstruction(iindex, result, site, params) { @Override public Collection getExceptionTypes() { return getNewArrayExceptions(); @@ -310,27 +310,27 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons }; } - 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); } - public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType) { + public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) { throw new UnsupportedOperationException(); } - 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(); } - 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(); } - public SSALoadIndirectInstruction LoadIndirectInstruction(int lval, TypeReference t, int addressVal) { + public SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal) { throw new UnsupportedOperationException(); } - public SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference pointeeType) { + public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference pointeeType) { throw new UnsupportedOperationException(); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java index bc3c1cf30..25394fa62 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/AbstractRootMethod.java @@ -136,9 +136,9 @@ public abstract class AbstractRootMethod extends SyntheticMethod { CallSiteReference newSite = CallSiteReference.make(statements.size(), site.getDeclaredTarget(), site.getInvocationCode()); SSAInvokeInstruction s = null; if (newSite.getDeclaredTarget().getReturnType().equals(TypeReference.Void)) { - s = insts.InvokeInstruction(params, nextLocal++, newSite); + s = insts.InvokeInstruction(statements.size(), params, nextLocal++, newSite); } else { - s = insts.InvokeInstruction(nextLocal++, params, nextLocal++, newSite); + s = insts.InvokeInstruction(statements.size(), nextLocal++, params, nextLocal++, newSite); } statements.add(s); cache.invalidate(this, Everywhere.EVERYWHERE); @@ -149,7 +149,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod { * Add a return statement */ public SSAReturnInstruction addReturn(int vn, boolean isPrimitive) { - SSAReturnInstruction s = insts.ReturnInstruction(vn, isPrimitive); + SSAReturnInstruction s = insts.ReturnInstruction(statements.size(), vn, isPrimitive); statements.add(s); cache.invalidate(this, Everywhere.EVERYWHERE); return s; @@ -177,7 +177,7 @@ public abstract class AbstractRootMethod extends SyntheticMethod { assert T.getDimensionality() == 1; int[] sizes = new int[1]; Arrays.fill(sizes, getValueNumberForIntConstant(length)); - SSANewInstruction result = insts.NewInstruction(instance, ref, sizes); + SSANewInstruction result = insts.NewInstruction(statements.size(), instance, ref, sizes); statements.add(result); cache.invalidate(this, Everywhere.EVERYWHERE); return result; @@ -208,9 +208,9 @@ public abstract class AbstractRootMethod extends SyntheticMethod { if (T.isArrayType()) { int[] sizes = new int[T.getDimensionality()]; Arrays.fill(sizes, getValueNumberForIntConstant(1)); - result = insts.NewInstruction(instance, ref, sizes); + result = insts.NewInstruction(statements.size(), instance, ref, sizes); } else { - result = insts.NewInstruction(instance, ref); + result = insts.NewInstruction(statements.size(), instance, ref); } statements.add(result); @@ -231,14 +231,14 @@ public abstract class AbstractRootMethod extends SyntheticMethod { if (e.isArrayType()) { int[] sizes = new int[T.getDimensionality()]; Arrays.fill(sizes, getValueNumberForIntConstant(1)); - ni = insts.NewInstruction(alloc, n, sizes); + ni = insts.NewInstruction(statements.size(), alloc, n, sizes); } else { - ni = insts.NewInstruction(alloc, n); + ni = insts.NewInstruction(statements.size(), alloc, n); } statements.add(ni); // emit an astore - SSAArrayStoreInstruction store = insts.ArrayStoreInstruction(arrayRef, getValueNumberForIntConstant(0), alloc, e); + SSAArrayStoreInstruction store = insts.ArrayStoreInstruction(statements.size(), arrayRef, getValueNumberForIntConstant(0), alloc, e); statements.add(store); e = e.isArrayType() ? e.getArrayElementType() : null; @@ -313,46 +313,46 @@ public abstract class AbstractRootMethod extends SyntheticMethod { public int addPhi(int[] values) { int result = nextLocal++; - SSAPhiInstruction phi = insts.PhiInstruction(result, values); + SSAPhiInstruction phi = insts.PhiInstruction(statements.size(), result, values); statements.add(phi); return result; } public int addGetInstance(FieldReference ref, int object) { int result = nextLocal++; - statements.add(insts.GetInstruction(result, object, ref)); + statements.add(insts.GetInstruction(statements.size(), result, object, ref)); return result; } public int addGetStatic(FieldReference ref) { int result = nextLocal++; - statements.add(insts.GetInstruction(result, ref)); + statements.add(insts.GetInstruction(statements.size(), result, ref)); return result; } public int addCheckcast(TypeReference[] types, int rv) { int lv = nextLocal++; - statements.add(insts.CheckCastInstruction(lv, rv, types)); + statements.add(insts.CheckCastInstruction(statements.size(), lv, rv, types)); return lv; } /** BEGIN Custom change: advanced synthetic instructions */ public void addSetInstance(final FieldReference ref, final int baseObject, final int value) { - statements.add(insts.PutInstruction(baseObject, value, ref)); + statements.add(insts.PutInstruction(statements.size(), baseObject, value, ref)); } public void addSetStatic(final FieldReference ref, final int value) { - statements.add(insts.PutInstruction(value, ref)); + statements.add(insts.PutInstruction(statements.size(), value, ref)); } public void addSetArrayField(final TypeReference elementType, final int baseObject, final int indexValue, final int value) { - statements.add(insts.ArrayStoreInstruction(baseObject, indexValue, value, elementType)); + statements.add(insts.ArrayStoreInstruction(statements.size(), baseObject, indexValue, value, elementType)); } public int addGetArrayField(final TypeReference elementType, final int baseObject, final int indexValue) { int result = nextLocal++; - statements.add(insts.ArrayLoadInstruction(result, baseObject, indexValue, elementType)); + statements.add(insts.ArrayLoadInstruction(statements.size(), result, baseObject, indexValue, elementType)); return result; } /** END Custom change: advanced synthetic instructions */ diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java index 86c26fb7c..01af65412 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/BypassMethodTargetSelector.java @@ -250,7 +250,7 @@ public class BypassMethodTargetSelector implements MethodTargetSelector { int nullValue = getNumberOfParameters() + 1; SSAInstruction[] result = new SSAInstruction[1]; SSAInstructionFactory insts = l.instructionFactory(); - result[0] = insts.ReturnInstruction(nullValue, getReturnType().isPrimitiveType()); + result[0] = insts.ReturnInstruction(0, nullValue, getReturnType().isPrimitiveType()); return result; } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/MethodSummary.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/MethodSummary.java index 210d14e65..9480c242d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/MethodSummary.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/MethodSummary.java @@ -75,6 +75,10 @@ public class MethodSummary { } this.method = method; } + + public int getNumberOfStatements() { + return (statements == null ? 0 : statements.size()); + } public void addStatement(SSAInstruction statement) { if (statements == null) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java index cdd4bdafb..01cbae468 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/XMLMethodSummaryReader.java @@ -473,10 +473,10 @@ public class XMLMethodSummaryReader implements BytecodeConstants { int defNum = nextLocal; symbolTable.put(defVar, new Integer(nextLocal++)); - governingMethod.addStatement(insts.InvokeInstruction(defNum, params, exceptionValue, site)); + governingMethod.addStatement(insts.InvokeInstruction(governingMethod.getNumberOfStatements(), defNum, params, exceptionValue, site)); } else { // ignore return value, if any - governingMethod.addStatement(insts.InvokeInstruction(params, exceptionValue, site)); + governingMethod.addStatement(insts.InvokeInstruction(governingMethod.getNumberOfStatements(), params, exceptionValue, site)); } } @@ -516,9 +516,9 @@ public class XMLMethodSummaryReader implements BytecodeConstants { Integer sNumber = symbolTable.get(size); Assertions.productionAssertion(sNumber != null); Assertions.productionAssertion(type.getDimensionality() == 1); - a = insts.NewInstruction(defNum, ref, new int[] { sNumber.intValue() }); + a = insts.NewInstruction(governingMethod.getNumberOfStatements(), defNum, ref, new int[] { sNumber.intValue() }); } else { - a = insts.NewInstruction(defNum, ref); + a = insts.NewInstruction(governingMethod.getNumberOfStatements(), defNum, ref); } governingMethod.addStatement(a); } @@ -542,7 +542,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { Assertions.UNREACHABLE("Cannot lookup value: " + V); } - SSAThrowInstruction T = insts.ThrowInstruction(valueNumber.intValue()); + SSAThrowInstruction T = insts.ThrowInstruction(governingMethod.getNumberOfStatements(), valueNumber.intValue()); governingMethod.addStatement(T); } @@ -588,7 +588,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { Assertions.UNREACHABLE("Cannot lookup ref: " + R); } - SSAGetInstruction G = insts.GetInstruction(defNum, refNumber.intValue(), field); + SSAGetInstruction G = insts.GetInstruction(governingMethod.getNumberOfStatements(), defNum, refNumber.intValue(), field); governingMethod.addStatement(G); } @@ -633,7 +633,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { Assertions.UNREACHABLE("Cannot lookup ref: " + R); } - SSAPutInstruction P = insts.PutInstruction(refNumber.intValue(), valueNumber.intValue(), field); + SSAPutInstruction P = insts.PutInstruction(governingMethod.getNumberOfStatements(), refNumber.intValue(), valueNumber.intValue(), field); governingMethod.addStatement(P); } @@ -667,7 +667,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { if (valueNumber == null) { Assertions.UNREACHABLE("Cannot lookup value: " + V); } - SSAPutInstruction P = insts.PutInstruction(valueNumber.intValue(), field); + SSAPutInstruction P = insts.PutInstruction(governingMethod.getNumberOfStatements(), valueNumber.intValue(), field); governingMethod.addStatement(P); } @@ -701,7 +701,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { if (valueNumber == null) { Assertions.UNREACHABLE("Cannot lookup value: " + V); } - SSAArrayStoreInstruction S = insts.ArrayStoreInstruction(refNumber.intValue(), 0, valueNumber.intValue(), + SSAArrayStoreInstruction S = insts.ArrayStoreInstruction(governingMethod.getNumberOfStatements(), refNumber.intValue(), 0, valueNumber.intValue(), TypeReference.JavaLangObject); governingMethod.addStatement(S); } @@ -718,7 +718,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { if (governingMethod.getReturnType() != null) { String retV = atts.getValue(A_VALUE); if (retV == null) { - SSAReturnInstruction R = insts.ReturnInstruction(); + SSAReturnInstruction R = insts.ReturnInstruction(governingMethod.getNumberOfStatements()); governingMethod.addStatement(R); } else { Integer valueNumber = symbolTable.get(retV); @@ -734,7 +734,7 @@ public class XMLMethodSummaryReader implements BytecodeConstants { } } boolean isPrimitive = governingMethod.getReturnType().isPrimitiveType(); - SSAReturnInstruction R = insts.ReturnInstruction(valueNumber.intValue(), isPrimitive); + SSAReturnInstruction R = insts.ReturnInstruction(governingMethod.getNumberOfStatements(), valueNumber.intValue(), isPrimitive); governingMethod.addStatement(R); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/ReflectiveMemberAccess.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/ReflectiveMemberAccess.java index 26ac43c7a..f2dd0141f 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/ReflectiveMemberAccess.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/ReflectiveMemberAccess.java @@ -19,8 +19,8 @@ public abstract class ReflectiveMemberAccess extends SSAInstruction { protected final int memberRef; - protected ReflectiveMemberAccess(int objectRef, int memberRef) { - super(); + protected ReflectiveMemberAccess(int index, int objectRef, int memberRef) { + super(index); this.objectRef = objectRef; this.memberRef = memberRef; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractInvokeInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractInvokeInstruction.java index 81d0a8b54..02b0958a4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractInvokeInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractInvokeInstruction.java @@ -37,7 +37,8 @@ public abstract class SSAAbstractInvokeInstruction extends SSAInstruction { * @param exception The value number which represents the exception object which the call may throw. * @param site The call site, containing the program counter location and the method being called. */ - protected SSAAbstractInvokeInstruction(int exception, CallSiteReference site) { + protected SSAAbstractInvokeInstruction(int index, int exception, CallSiteReference site) { + super(index); this.exception = exception; this.site = site; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractThrowInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractThrowInstruction.java index f9896b390..a6107792d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractThrowInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractThrowInstruction.java @@ -17,8 +17,8 @@ package com.ibm.wala.ssa; public abstract class SSAAbstractThrowInstruction extends SSAInstruction { private final int exception; - public SSAAbstractThrowInstruction(int exception) { - super(); + public SSAAbstractThrowInstruction(int index, int exception) { + super(index); //assert exception > 0; this.exception = exception; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractUnaryInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractUnaryInstruction.java index 7576eac5f..dfaced533 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractUnaryInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAbstractUnaryInstruction.java @@ -19,8 +19,8 @@ public abstract class SSAAbstractUnaryInstruction extends SSAInstruction { protected final int val; - protected SSAAbstractUnaryInstruction(int result, int val) { - super(); + protected SSAAbstractUnaryInstruction(int index, int result, int val) { + super(index); this.result = result; this.val = val; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAddressOfInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAddressOfInstruction.java index f335463d6..6eb844616 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAddressOfInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAAddressOfInstruction.java @@ -51,7 +51,8 @@ public class SSAAddressOfInstruction extends SSAInstruction { /** * Use this constructor when taking the address of a local variable. */ - public SSAAddressOfInstruction(int lval, int local, TypeReference pointeeType) { + public SSAAddressOfInstruction(int index, int lval, int local, TypeReference pointeeType) { + super(index); if (local <= 0) { throw new IllegalArgumentException("Invalid local address load of " + local); } @@ -65,7 +66,8 @@ public class SSAAddressOfInstruction extends SSAInstruction { /** * Use this constructor when taking the address of an array element. */ - public SSAAddressOfInstruction(int lval, int basePointer, int indexVal, TypeReference pointeeType) { + public SSAAddressOfInstruction(int index, int lval, int basePointer, int indexVal, TypeReference pointeeType) { + super(index); this.lval = lval; this.addressVal = basePointer; this.indexVal = indexVal; @@ -76,7 +78,8 @@ public class SSAAddressOfInstruction extends SSAInstruction { /** * Use this constructor when taking the address of a field in an object. */ - public SSAAddressOfInstruction(int lval, int basePointer, FieldReference field, TypeReference pointeeType) { + public SSAAddressOfInstruction(int index, int lval, int basePointer, FieldReference field, TypeReference pointeeType) { + super(index); this.lval = lval; this.addressVal = basePointer; this.indexVal = -1; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLengthInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLengthInstruction.java index 9b4964e01..7dca946cc 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLengthInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLengthInstruction.java @@ -19,8 +19,8 @@ public abstract class SSAArrayLengthInstruction extends SSAInstruction { private final int arrayref; - protected SSAArrayLengthInstruction(int result, int arrayref) { - super(); + protected SSAArrayLengthInstruction(int index, int result, int arrayref) { + super(index); this.result = result; this.arrayref = arrayref; } @@ -33,7 +33,7 @@ public abstract class SSAArrayLengthInstruction extends SSAInstruction { if (uses != null && uses.length != 1) { throw new IllegalArgumentException(); } - return insts.ArrayLengthInstruction(defs == null ? result : defs[0], uses == null ? arrayref : uses[0]); + return insts.ArrayLengthInstruction(iindex, defs == null ? result : defs[0], uses == null ? arrayref : uses[0]); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java index 1a8f04811..3fefa1d7c 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java @@ -18,8 +18,8 @@ import com.ibm.wala.types.TypeReference; public abstract class SSAArrayLoadInstruction extends SSAArrayReferenceInstruction { private final int result; - protected SSAArrayLoadInstruction(int result, int arrayref, int index, TypeReference elementType) { - super(arrayref, index, elementType); + protected SSAArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference elementType) { + super(iindex, arrayref, index, elementType); this.result = result; } @@ -31,7 +31,7 @@ public abstract class SSAArrayLoadInstruction extends SSAArrayReferenceInstructi if (uses != null && uses.length < 2) { throw new IllegalArgumentException("uses.length < 2"); } - return insts.ArrayLoadInstruction(defs == null ? result : defs[0], uses == null ? getArrayRef() : uses[0], + return insts.ArrayLoadInstruction(iindex, defs == null ? result : defs[0], uses == null ? getArrayRef() : uses[0], uses == null ? getIndex() : uses[1], getElementType()); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java index a0095379f..ffbdaa3a0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java @@ -19,13 +19,14 @@ public abstract class SSAArrayReferenceInstruction extends SSAInstruction { private final int arrayref; - private final int index; + private final int idx; private final TypeReference elementType; - SSAArrayReferenceInstruction(int arrayref, int index, TypeReference elementType) { + SSAArrayReferenceInstruction(int iindex, int arrayref, int index, TypeReference elementType) { + super(iindex); this.arrayref = arrayref; - this.index = index; + this.idx = index; this.elementType = elementType; if (elementType == null) { throw new IllegalArgumentException("null elementType"); @@ -46,7 +47,7 @@ public abstract class SSAArrayReferenceInstruction extends SSAInstruction { @Override public int getUse(int j) { assert j <= 1; - return (j == 0) ? arrayref : index; + return (j == 0) ? arrayref : idx; } /** @@ -60,7 +61,7 @@ public abstract class SSAArrayReferenceInstruction extends SSAInstruction { * Return the value number of the index of the array reference. */ public int getIndex() { - return index; + return idx; } public TypeReference getElementType() { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java index 2ef1d4fc0..93475be54 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java @@ -19,8 +19,8 @@ public abstract class SSAArrayStoreInstruction extends SSAArrayReferenceInstruct private final int value; - protected SSAArrayStoreInstruction(int arrayref, int index, int value, TypeReference elementType) { - super(arrayref, index, elementType); + protected SSAArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference elementType) { + super(iindex, arrayref, index, elementType); this.value = value; } @@ -29,7 +29,7 @@ public abstract class SSAArrayStoreInstruction extends SSAArrayReferenceInstruct if (uses != null && uses.length < 3) { throw new IllegalArgumentException("uses.length < 3"); } - return insts.ArrayStoreInstruction(uses == null ? getArrayRef() : uses[0], uses == null ? getIndex() : uses[1], + return insts.ArrayStoreInstruction(iindex, uses == null ? getArrayRef() : uses[0], uses == null ? getIndex() : uses[1], uses == null ? value : uses[2], getElementType()); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABinaryOpInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABinaryOpInstruction.java index 95c792de0..f9e2863dd 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABinaryOpInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABinaryOpInstruction.java @@ -28,8 +28,8 @@ public abstract class SSABinaryOpInstruction extends SSAInstruction { */ private final boolean mayBeInteger; - protected SSABinaryOpInstruction(IBinaryOpInstruction.IOperator operator, int result, int val1, int val2, boolean mayBeInteger) { - super(); + protected SSABinaryOpInstruction(int index, IBinaryOpInstruction.IOperator operator, int result, int val1, int val2, boolean mayBeInteger) { + super(index); this.result = result; this.val1 = val1; this.val2 = val2; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java index 04edbe478..9a0b166b7 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java @@ -120,15 +120,12 @@ public class SSABuilder extends AbstractIntStackMachine { final SSACFG cfg; - final SSAInstruction[] instructions; - final SymbolTable symbolTable; final ShrikeCFG shrikeCFG; SymbolTableMeeter(SymbolTable symbolTable, SSACFG cfg, SSAInstruction[] instructions, ShrikeCFG shrikeCFG) { this.cfg = cfg; - this.instructions = instructions; this.symbolTable = symbolTable; this.shrikeCFG = shrikeCFG; } @@ -241,7 +238,7 @@ public class SSABuilder extends AbstractIntStackMachine { int exceptionValue; if (s == null) { exceptionValue = symbolTable.newSymbol(); - s = insts.GetCaughtExceptionInstruction(bbNumber, exceptionValue); + s = insts.GetCaughtExceptionInstruction(SSAInstruction.NO_INDEX, bbNumber, exceptionValue); newBB.setCatchInstruction(s); } else { exceptionValue = s.getException(); @@ -390,7 +387,7 @@ public class SSABuilder extends AbstractIntStackMachine { int length = reuseOrCreateDef(); workingState.push(length); - emitInstruction(insts.ArrayLengthInstruction(length, arrayRef)); + emitInstruction(insts.ArrayLengthInstruction(getCurrentInstructionIndex(), length, arrayRef)); } /** @@ -404,9 +401,9 @@ public class SSABuilder extends AbstractIntStackMachine { workingState.push(result); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); if (instruction.isAddressOf()) { - emitInstruction(insts.AddressOfInstruction(result, arrayRef, index, t)); + emitInstruction(insts.AddressOfInstruction(getCurrentInstructionIndex(), result, arrayRef, index, t)); } else { - emitInstruction(insts.ArrayLoadInstruction(result, arrayRef, index, t)); + emitInstruction(insts.ArrayLoadInstruction(getCurrentInstructionIndex(), result, arrayRef, index, t)); } } @@ -420,7 +417,7 @@ public class SSABuilder extends AbstractIntStackMachine { int index = workingState.pop(); int arrayRef = workingState.pop(); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.ArrayStoreInstruction(arrayRef, index, value, t)); + emitInstruction(insts.ArrayStoreInstruction(getCurrentInstructionIndex(), arrayRef, index, value, t)); } /** @@ -433,7 +430,7 @@ public class SSABuilder extends AbstractIntStackMachine { int result = reuseOrCreateDef(); workingState.push(result); boolean isFloat = instruction.getType().equals(TYPE_double) || instruction.getType().equals(TYPE_float); - emitInstruction(insts.BinaryOpInstruction(instruction.getOperator(), instruction.throwsExceptionOnOverflow(), instruction + emitInstruction(insts.BinaryOpInstruction(getCurrentInstructionIndex(), instruction.getOperator(), instruction.throwsExceptionOnOverflow(), instruction .isUnsigned(), result, val1, val2, !isFloat)); } @@ -451,7 +448,7 @@ public class SSABuilder extends AbstractIntStackMachine { for(int i = 0; i < typeNames.length; i++) { t[i] = ShrikeUtil.makeTypeReference(loader, typeNames[i]); } - emitInstruction(insts.CheckCastInstruction(result, val, t)); + emitInstruction(insts.CheckCastInstruction(getCurrentInstructionIndex(), result, val, t)); } } @@ -465,7 +462,7 @@ public class SSABuilder extends AbstractIntStackMachine { int val1 = workingState.pop(); int result = reuseOrCreateDef(); workingState.push(result); - emitInstruction(insts.ComparisonInstruction(instruction.getOperator(), result, val1, val2)); + emitInstruction(insts.ComparisonInstruction(getCurrentInstructionIndex(), instruction.getOperator(), result, val1, val2)); } /** @@ -477,7 +474,7 @@ public class SSABuilder extends AbstractIntStackMachine { int val1 = workingState.pop(); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.ConditionalBranchInstruction(instruction.getOperator(), t, val1, val2)); + emitInstruction(insts.ConditionalBranchInstruction(getCurrentInstructionIndex(), instruction.getOperator(), t, val1, val2)); } /** @@ -508,7 +505,7 @@ public class SSABuilder extends AbstractIntStackMachine { } else if (l.isMetadataType(type)) { Object rval = l.getMetadataToken(instruction.getValue()); symbol = reuseOrCreateDef(); - emitInstruction(insts.LoadMetadataInstruction(symbol, type, rval)); + emitInstruction(insts.LoadMetadataInstruction(getCurrentInstructionIndex(), symbol, type, rval)); } else { Assertions.UNREACHABLE("unexpected " + type); } @@ -528,7 +525,7 @@ public class SSABuilder extends AbstractIntStackMachine { TypeReference fromType = ShrikeUtil.makeTypeReference(loader, instruction.getFromType()); TypeReference toType = ShrikeUtil.makeTypeReference(loader, instruction.getToType()); - emitInstruction(insts.ConversionInstruction(result, val, fromType, toType, instruction.throwsExceptionOnOverflow())); + emitInstruction(insts.ConversionInstruction(getCurrentInstructionIndex(), result, val, fromType, toType, instruction.throwsExceptionOnOverflow())); } /** @@ -541,12 +538,12 @@ public class SSABuilder extends AbstractIntStackMachine { instruction.getFieldType()); if (instruction.isAddressOf()) { int ref = instruction.isStatic()? -1: workingState.pop(); - emitInstruction(insts.AddressOfInstruction(result, ref, f, f.getFieldType())); + emitInstruction(insts.AddressOfInstruction(getCurrentInstructionIndex(), result, ref, f, f.getFieldType())); } else if (instruction.isStatic()) { - emitInstruction(insts.GetInstruction(result, f)); + emitInstruction(insts.GetInstruction(getCurrentInstructionIndex(), result, f)); } else { int ref = workingState.pop(); - emitInstruction(insts.GetInstruction(result, ref, f)); + emitInstruction(insts.GetInstruction(getCurrentInstructionIndex(), result, ref, f)); } workingState.push(result); } @@ -556,7 +553,7 @@ public class SSABuilder extends AbstractIntStackMachine { */ @Override public void visitGoto(com.ibm.wala.shrikeBT.GotoInstruction instruction) { - emitInstruction(insts.GotoInstruction()); + emitInstruction(insts.GotoInstruction(getCurrentInstructionIndex())); } /** @@ -569,7 +566,7 @@ public class SSABuilder extends AbstractIntStackMachine { int result = reuseOrCreateDef(); workingState.push(result); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.InstanceofInstruction(result, ref, t)); + emitInstruction(insts.InstanceofInstruction(getCurrentInstructionIndex(), result, ref, t)); } /** @@ -592,9 +589,9 @@ public class SSABuilder extends AbstractIntStackMachine { if (instruction.getPushedWordSize() > 0) { int result = reuseOrCreateDef(); workingState.push(result); - emitInstruction(insts.InvokeInstruction(result, params, exc, site)); + emitInstruction(insts.InvokeInstruction(getCurrentInstructionIndex(), result, params, exc, site)); } else { - emitInstruction(insts.InvokeInstruction(params, exc, site)); + emitInstruction(insts.InvokeInstruction(getCurrentInstructionIndex(), params, exc, site)); } doIndirectWrites(bytecodeIndirections.indirectlyWrittenLocals(getCurrentInstructionIndex()), -1); } @@ -611,7 +608,7 @@ public class SSABuilder extends AbstractIntStackMachine { } TypeReference type = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.AddressOfInstruction(result, t, type)); + emitInstruction(insts.AddressOfInstruction(getCurrentInstructionIndex(), result, t, type)); workingState.push(result); } else { super.visitLocalLoad(instruction); @@ -636,7 +633,7 @@ public class SSABuilder extends AbstractIntStackMachine { public void visitMonitor(com.ibm.wala.shrikeBT.MonitorInstruction instruction) { int ref = workingState.pop(); - emitInstruction(insts.MonitorInstruction(ref, instruction.isEnter())); + emitInstruction(insts.MonitorInstruction(getCurrentInstructionIndex(), ref, instruction.isEnter())); } /** @@ -652,9 +649,9 @@ public class SSABuilder extends AbstractIntStackMachine { for (int i = 0; i < instruction.getArrayBoundsCount(); i++) { sizes[instruction.getArrayBoundsCount() - 1 - i] = workingState.pop(); } - emitInstruction(insts.NewInstruction(result, ref, sizes)); + emitInstruction(insts.NewInstruction(getCurrentInstructionIndex(), result, ref, sizes)); } else { - emitInstruction(insts.NewInstruction(result, ref)); + emitInstruction(insts.NewInstruction(getCurrentInstructionIndex(), result, ref)); popN(instruction); } workingState.push(result); @@ -669,12 +666,12 @@ public class SSABuilder extends AbstractIntStackMachine { if (instruction.isStatic()) { FieldReference f = FieldReference.findOrCreate(loader, instruction.getClassType(), instruction.getFieldName(), instruction.getFieldType()); - emitInstruction(insts.PutInstruction(value, f)); + emitInstruction(insts.PutInstruction(getCurrentInstructionIndex(), value, f)); } else { int ref = workingState.pop(); FieldReference f = FieldReference.findOrCreate(loader, instruction.getClassType(), instruction.getFieldName(), instruction.getFieldType()); - emitInstruction(insts.PutInstruction(ref, value, f)); + emitInstruction(insts.PutInstruction(getCurrentInstructionIndex(), ref, value, f)); } } @@ -686,9 +683,9 @@ public class SSABuilder extends AbstractIntStackMachine { if (instruction.getPoppedCount() == 1) { int result = workingState.pop(); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.ReturnInstruction(result, t.isPrimitiveType())); + emitInstruction(insts.ReturnInstruction(getCurrentInstructionIndex(), result, t.isPrimitiveType())); } else { - emitInstruction(insts.ReturnInstruction()); + emitInstruction(insts.ReturnInstruction(getCurrentInstructionIndex())); } } @@ -701,7 +698,7 @@ public class SSABuilder extends AbstractIntStackMachine { int val1 = workingState.pop(); int result = reuseOrCreateDef(); workingState.push(result); - emitInstruction(insts.BinaryOpInstruction(instruction.getOperator(), false, instruction.isUnsigned(), result, val1, val2, + emitInstruction(insts.BinaryOpInstruction(getCurrentInstructionIndex(), instruction.getOperator(), false, instruction.isUnsigned(), result, val1, val2, true)); } @@ -711,7 +708,7 @@ public class SSABuilder extends AbstractIntStackMachine { @Override public void visitSwitch(com.ibm.wala.shrikeBT.SwitchInstruction instruction) { int val = workingState.pop(); - emitInstruction(insts.SwitchInstruction(val, instruction.getDefaultLabel(), instruction.getCasesAndLabels())); + emitInstruction(insts.SwitchInstruction(getCurrentInstructionIndex(), val, instruction.getDefaultLabel(), instruction.getCasesAndLabels())); } private Dominators dom = null; @@ -753,12 +750,12 @@ public class SSABuilder extends AbstractIntStackMachine { public void visitThrow(com.ibm.wala.shrikeBT.ThrowInstruction instruction) { if (instruction.isRethrow()) { workingState.clearStack(); - emitInstruction(insts.ThrowInstruction(findRethrowException())); + emitInstruction(insts.ThrowInstruction(getCurrentInstructionIndex(), findRethrowException())); } else { int exception = workingState.pop(); workingState.clearStack(); workingState.push(exception); - emitInstruction(insts.ThrowInstruction(exception)); + emitInstruction(insts.ThrowInstruction(getCurrentInstructionIndex(), exception)); } } @@ -770,7 +767,7 @@ public class SSABuilder extends AbstractIntStackMachine { int val = workingState.pop(); int result = reuseOrCreateDef(); workingState.push(result); - emitInstruction(insts.UnaryOpInstruction(instruction.getOperator(), result, val)); + emitInstruction(insts.UnaryOpInstruction(getCurrentInstructionIndex(), instruction.getOperator(), result, val)); } private void doIndirectReads(int[] locals) { @@ -785,7 +782,7 @@ public class SSABuilder extends AbstractIntStackMachine { int result = reuseOrCreateDef(); doIndirectReads(bytecodeIndirections.indirectlyReadLocals(getCurrentInstructionIndex())); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getPushedType(null)); - emitInstruction(insts.LoadIndirectInstruction(result, t, addressVal)); + emitInstruction(insts.LoadIndirectInstruction(getCurrentInstructionIndex(), result, t, addressVal)); workingState.push(result); } @@ -806,7 +803,7 @@ public class SSABuilder extends AbstractIntStackMachine { int addressVal = workingState.pop(); doIndirectWrites(bytecodeIndirections.indirectlyWrittenLocals(getCurrentInstructionIndex()), val); TypeReference t = ShrikeUtil.makeTypeReference(loader, instruction.getType()); - emitInstruction(insts.StoreIndirectInstruction(addressVal, val, t)); + emitInstruction(insts.StoreIndirectInstruction(getCurrentInstructionIndex(), addressVal, val, t)); } } @@ -824,7 +821,7 @@ public class SSABuilder extends AbstractIntStackMachine { SSAPiInstruction pi = bb.getPiForRefAndPath(ref, path); if (pi == null) { - pi = insts.PiInstruction(symbolTable.newSymbol(), ref, bb.getNumber(), outNum, piCause); + pi = insts.PiInstruction(SSAInstruction.NO_INDEX, symbolTable.newSymbol(), ref, bb.getNumber(), outNum, piCause); bb.addPiForRefAndPath(ref, path, pi); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSACheckCastInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSACheckCastInstruction.java index 1991b0f79..0a70623a3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSACheckCastInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSACheckCastInstruction.java @@ -43,8 +43,8 @@ public abstract class SSACheckCastInstruction extends SSAInstruction { * @param val The value being checked by this instruction * @param type The type which this instruction checks */ - protected SSACheckCastInstruction(int result, int val, TypeReference[] types) { - super(); + protected SSACheckCastInstruction(int index, int result, int val, TypeReference[] types) { + super(index); this.result = result; this.val = val; this.declaredResultTypes = types; @@ -58,7 +58,7 @@ public abstract class SSACheckCastInstruction extends SSAInstruction { if (uses != null && uses.length == 0) { throw new IllegalArgumentException("(uses != null) and (uses.length == 0)"); } - return insts.CheckCastInstruction(defs == null ? result : defs[0], uses == null ? val : uses[0], declaredResultTypes); + return insts.CheckCastInstruction(iindex, defs == null ? result : defs[0], uses == null ? val : uses[0], declaredResultTypes); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAComparisonInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAComparisonInstruction.java index 58331f1c6..5664c6aa7 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAComparisonInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAComparisonInstruction.java @@ -26,8 +26,8 @@ public class SSAComparisonInstruction extends SSAInstruction { /** */ - public SSAComparisonInstruction(IComparisonInstruction.Operator operator, int result, int val1, int val2) { - super(); + public SSAComparisonInstruction(int index, IComparisonInstruction.Operator operator, int result, int val1, int val2) { + super(index); this.operator = operator; this.result = result; this.val1 = val1; @@ -39,7 +39,7 @@ public class SSAComparisonInstruction extends SSAInstruction { if (uses != null && uses.length != 2) { throw new IllegalArgumentException("expected 2 uses or null, but got " + uses.length); } - return insts.ComparisonInstruction(operator, defs == null || defs.length == 0 ? result : defs[0], + return insts.ComparisonInstruction(iindex, operator, defs == null || defs.length == 0 ? result : defs[0], uses == null ? val1 : uses[0], uses == null ? val2 : uses[1]); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConditionalBranchInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConditionalBranchInstruction.java index 5b89f6085..2ebdf3b0a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConditionalBranchInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConditionalBranchInstruction.java @@ -26,9 +26,9 @@ public class SSAConditionalBranchInstruction extends SSAInstruction { private final TypeReference type; - public SSAConditionalBranchInstruction(IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2) + public SSAConditionalBranchInstruction(int index, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2) throws IllegalArgumentException { - super(); + super(index); this.operator = operator; this.val1 = val1; this.val2 = val2; @@ -46,7 +46,7 @@ public class SSAConditionalBranchInstruction extends SSAInstruction { if (uses != null && uses.length < 2) { throw new IllegalArgumentException("(uses != null) and (uses.length < 2)"); } - return insts.ConditionalBranchInstruction(operator, type, uses == null ? val1 : uses[0], uses == null ? val2 : uses[1]); + return insts.ConditionalBranchInstruction(iindex, operator, type, uses == null ? val1 : uses[0], uses == null ? val2 : uses[1]); } public IConditionalBranchInstruction.IOperator getOperator() { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConversionInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConversionInstruction.java index 7386024fa..913cc00c0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConversionInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAConversionInstruction.java @@ -24,8 +24,8 @@ public abstract class SSAConversionInstruction extends SSAInstruction { private final TypeReference toType; - protected SSAConversionInstruction(int result, int val, TypeReference fromType, TypeReference toType) { - super(); + protected SSAConversionInstruction(int index, int result, int val, TypeReference fromType, TypeReference toType) { + super(index); this.result = result; this.val = val; this.fromType = fromType; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAFieldAccessInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAFieldAccessInstruction.java index 1106d0fe8..124cf57e6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAFieldAccessInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAFieldAccessInstruction.java @@ -23,8 +23,8 @@ public abstract class SSAFieldAccessInstruction extends SSAInstruction { private final int ref; - protected SSAFieldAccessInstruction(FieldReference field, int ref) throws IllegalArgumentException { - super(); + protected SSAFieldAccessInstruction(int index, FieldReference field, int ref) throws IllegalArgumentException { + super(index); this.field = field; this.ref = ref; if (field == null) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetCaughtExceptionInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetCaughtExceptionInstruction.java index faebc011e..bbd743be8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetCaughtExceptionInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetCaughtExceptionInstruction.java @@ -22,8 +22,8 @@ public class SSAGetCaughtExceptionInstruction extends SSAInstruction { private final int bbNumber; - public SSAGetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber) { - super(); + public SSAGetCaughtExceptionInstruction(int index, int bbNumber, int exceptionValueNumber) { + super(index); this.exceptionValueNumber = exceptionValueNumber; this.bbNumber = bbNumber; } @@ -31,7 +31,7 @@ public class SSAGetCaughtExceptionInstruction extends SSAInstruction { @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { assert defs == null || defs.length == 1; - return insts.GetCaughtExceptionInstruction(bbNumber, defs == null ? exceptionValueNumber : defs[0]); + return insts.GetCaughtExceptionInstruction(iindex, bbNumber, defs == null ? exceptionValueNumber : defs[0]); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetInstruction.java index c04f5e624..91353b5ff 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGetInstruction.java @@ -19,22 +19,22 @@ import com.ibm.wala.types.FieldReference; public abstract class SSAGetInstruction extends SSAFieldAccessInstruction { private final int result; - protected SSAGetInstruction(int result, int ref, FieldReference field) { - super(field, ref); + protected SSAGetInstruction(int index, int result, int ref, FieldReference field) { + super(index, field, ref); this.result = result; } - protected SSAGetInstruction(int result, FieldReference field) { - super(field, -1); + protected SSAGetInstruction(int index, int result, FieldReference field) { + super(index, field, -1); this.result = result; } @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) - return insts.GetInstruction(defs == null || defs.length == 0 ? result : defs[0], getDeclaredField()); + return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], getDeclaredField()); else - return insts.GetInstruction(defs == null || defs.length == 0 ? result : defs[0], uses == null ? getRef() : uses[0], + return insts.GetInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], uses == null ? getRef() : uses[0], getDeclaredField()); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGotoInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGotoInstruction.java index 0779a8c0c..d4e10285a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGotoInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAGotoInstruction.java @@ -15,13 +15,13 @@ package com.ibm.wala.ssa; */ public class SSAGotoInstruction extends SSAInstruction { - public SSAGotoInstruction() { - super(); + public SSAGotoInstruction(int index) { + super(index); } @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { - return insts.GotoInstruction(); + return insts.GotoInstruction(iindex); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstanceofInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstanceofInstruction.java index c101e3f2d..dff006aa4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstanceofInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstanceofInstruction.java @@ -22,8 +22,8 @@ public class SSAInstanceofInstruction extends SSAInstruction { private final TypeReference checkedType; - public SSAInstanceofInstruction(int result, int ref, TypeReference checkedType) { - super(); + public SSAInstanceofInstruction(int index, int result, int ref, TypeReference checkedType) { + super(index); this.result = result; this.ref = ref; this.checkedType = checkedType; @@ -37,7 +37,7 @@ public class SSAInstanceofInstruction extends SSAInstruction { if (uses != null && uses.length == 0) { throw new IllegalArgumentException("uses.length == 0"); } - return insts.InstanceofInstruction(defs == null || defs.length == 0 ? result : defs[0], uses == null ? ref : uses[0], + return insts.InstanceofInstruction(iindex, defs == null || defs.length == 0 ? result : defs[0], uses == null ? ref : uses[0], checkedType); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstruction.java index 50f844a57..2a89f9850 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstruction.java @@ -20,10 +20,15 @@ import com.ibm.wala.types.TypeReference; */ public abstract class SSAInstruction { + public static final int NO_INDEX = -1; + + public final int iindex; + /** * prevent instantiation by the outside */ - protected SSAInstruction() { + protected SSAInstruction(int iindex) { + this.iindex = iindex; } /** diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstructionFactory.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstructionFactory.java index 2c37bc72e..bc7804012 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstructionFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInstructionFactory.java @@ -25,78 +25,78 @@ import com.ibm.wala.types.TypeReference; */ public interface SSAInstructionFactory { - SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType); + SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType); - SSAAddressOfInstruction AddressOfInstruction(int lval, int local, int indexVal, TypeReference pointeeType); + SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, int indexVal, TypeReference pointeeType); - SSAAddressOfInstruction AddressOfInstruction(int lval, int local, FieldReference field, TypeReference pointeeType); + SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, FieldReference field, TypeReference pointeeType); - SSAArrayLengthInstruction ArrayLengthInstruction(int result, int arrayref); + SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref); - SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType); + SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType); - SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType); + SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType); - SSABinaryOpInstruction BinaryOpInstruction(IBinaryOpInstruction.IOperator operator, boolean overflow, boolean unsigned, + SSABinaryOpInstruction BinaryOpInstruction(int iindex, IBinaryOpInstruction.IOperator operator, boolean overflow, boolean unsigned, int result, int val1, int val2, boolean mayBeInteger); - SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues); + SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues); - SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue); + SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue); - SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types); + SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types); - SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type); + SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type); - SSAComparisonInstruction ComparisonInstruction(IComparisonInstruction.Operator operator, int result, int val1, int val2); + SSAComparisonInstruction ComparisonInstruction(int iindex, IComparisonInstruction.Operator operator, int result, int val1, int val2); - SSAConditionalBranchInstruction ConditionalBranchInstruction(IConditionalBranchInstruction.IOperator operator, + SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2); - SSAConversionInstruction ConversionInstruction(int result, int val, TypeReference fromType, TypeReference toType, boolean overflow); + SSAConversionInstruction ConversionInstruction(int iindex, int result, int val, TypeReference fromType, TypeReference toType, boolean overflow); - SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber); + SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber); - SSAGetInstruction GetInstruction(int result, FieldReference field); + SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field); - SSAGetInstruction GetInstruction(int result, int ref, FieldReference field); + SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field); - SSAGotoInstruction GotoInstruction(); + SSAGotoInstruction GotoInstruction(int iindex); - SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType); + SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType); - SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site); + SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site); - SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site); + SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site); - SSALoadIndirectInstruction LoadIndirectInstruction(int lval, TypeReference t, int addressVal); + SSALoadIndirectInstruction LoadIndirectInstruction(int iindex, int lval, TypeReference t, int addressVal); - SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token); + SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token); - SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter); + SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter); - SSANewInstruction NewInstruction(int result, NewSiteReference site); + SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site); - SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params); + SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params); - SSAPhiInstruction PhiInstruction(int result, int[] params); + SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params); - SSAPiInstruction PiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause); + SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause); - SSAPutInstruction PutInstruction(int ref, int value, FieldReference field); + SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field); - SSAPutInstruction PutInstruction(int value, FieldReference field); + SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field); - SSAReturnInstruction ReturnInstruction(); + SSAReturnInstruction ReturnInstruction(int iindex); - SSAReturnInstruction ReturnInstruction(int result, boolean isPrimitive); + SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive); - SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference pointeeType); + SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference pointeeType); - SSASwitchInstruction SwitchInstruction(int val, int defaultLabel, int[] casesAndLabels); + SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels); - SSAThrowInstruction ThrowInstruction(int exception); + SSAThrowInstruction ThrowInstruction(int iindex, int exception); - SSAUnaryOpInstruction UnaryOpInstruction(IUnaryOpInstruction.IOperator operator, int result, int val); + SSAUnaryOpInstruction UnaryOpInstruction(int iindex, IUnaryOpInstruction.IOperator operator, int result, int val); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInvokeInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInvokeInstruction.java index 7c364d06c..0a18d6486 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInvokeInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAInvokeInstruction.java @@ -26,8 +26,8 @@ public abstract class SSAInvokeInstruction extends SSAAbstractInvokeInstruction */ private final int[] params; - protected SSAInvokeInstruction(int result, int[] params, int exception, CallSiteReference site) { - super(exception, site); + protected SSAInvokeInstruction(int index, int result, int[] params, int exception, CallSiteReference site) { + super(index, exception, site); this.result = result; this.params = params; assertParamsKosher(result, params, site); @@ -36,15 +36,15 @@ public abstract class SSAInvokeInstruction extends SSAAbstractInvokeInstruction /** * Constructor InvokeInstruction. This case for void return values */ - protected SSAInvokeInstruction(int[] params, int exception, CallSiteReference site) { - this(-1, params, exception, site); + protected SSAInvokeInstruction(int index, int[] params, int exception, CallSiteReference site) { + this(index, -1, params, exception, site); } @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { // result == -1 for void-returning methods, which are the only calls // that have a single value def. - return insts.InvokeInstruction(defs == null || result == -1 ? result : defs[0], uses == null ? params : uses, + return insts.InvokeInstruction(iindex, defs == null || result == -1 ? result : defs[0], uses == null ? params : uses, defs == null ? exception : defs[result == -1 ? 0 : 1], site); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadIndirectInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadIndirectInstruction.java index cb8e28d84..c20b9147b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadIndirectInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadIndirectInstruction.java @@ -26,8 +26,8 @@ public class SSALoadIndirectInstruction extends SSAAbstractUnaryInstruction { * @param lval the value number which is def'fed by this instruction. * @param addressVal the value number holding the pointer p deferenced (*p) */ - public SSALoadIndirectInstruction(int lval, TypeReference t, int addressVal) { - super(lval, addressVal); + public SSALoadIndirectInstruction(int index, int lval, TypeReference t, int addressVal) { + super(index, lval, addressVal); this.loadedType = t; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadMetadataInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadMetadataInstruction.java index acfe42659..d977a8e2f 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadMetadataInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSALoadMetadataInstruction.java @@ -30,7 +30,8 @@ public abstract class SSALoadMetadataInstruction extends SSAInstruction { */ private final TypeReference entityType; - protected SSALoadMetadataInstruction(int lval, TypeReference entityType, Object token) { + protected SSALoadMetadataInstruction(int index, int lval, TypeReference entityType, Object token) { + super(index); this.lval = lval; this.token = token; this.entityType = entityType; @@ -44,7 +45,7 @@ public abstract class SSALoadMetadataInstruction extends SSAInstruction { if (defs != null && defs.length == 0) { throw new IllegalArgumentException("(defs != null) and (defs.length == 0)"); } - return insts.LoadMetadataInstruction(defs == null ? lval : defs[0], entityType, token); + return insts.LoadMetadataInstruction(iindex, defs == null ? lval : defs[0], entityType, token); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAMonitorInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAMonitorInstruction.java index 727e899b7..9b410d1e6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAMonitorInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAMonitorInstruction.java @@ -29,8 +29,8 @@ public abstract class SSAMonitorInstruction extends SSAInstruction { * @param ref The value number of the object being locked or unlocked * @param isEnter Does this instruction represent a monitorenter? */ - protected SSAMonitorInstruction(int ref, boolean isEnter) { - super(); + protected SSAMonitorInstruction(int index, int ref, boolean isEnter) { + super(index); this.ref = ref; this.isEnter = isEnter; } @@ -38,7 +38,7 @@ public abstract class SSAMonitorInstruction extends SSAInstruction { @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { assert uses == null || uses.length == 1; - return insts.MonitorInstruction(uses == null ? ref : uses[0], isEnter); + return insts.MonitorInstruction(iindex, uses == null ? ref : uses[0], isEnter); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSANewInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSANewInstruction.java index 97acd59df..2bb4967ca 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSANewInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSANewInstruction.java @@ -33,8 +33,8 @@ public abstract class SSANewInstruction extends SSAInstruction { /** * Create a new instruction to allocate a scalar. */ - protected SSANewInstruction(int result, NewSiteReference site) throws IllegalArgumentException { - super(); + protected SSANewInstruction(int index, int result, NewSiteReference site) throws IllegalArgumentException { + super(index); if (site == null) { throw new IllegalArgumentException("site cannot be null"); } @@ -51,8 +51,8 @@ public abstract class SSANewInstruction extends SSAInstruction { * @throws IllegalArgumentException if site is null * @throws IllegalArgumentException if params is null */ - protected SSANewInstruction(int result, NewSiteReference site, int[] params) { - super(); + protected SSANewInstruction(int index, int result, NewSiteReference site, int[] params) { + super(index); if (params == null) { throw new IllegalArgumentException("params is null"); } @@ -70,9 +70,9 @@ public abstract class SSANewInstruction extends SSAInstruction { @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (params == null) { - return insts.NewInstruction(defs == null ? result : defs[0], site); + return insts.NewInstruction(iindex, defs == null ? result : defs[0], site); } else { - return insts.NewInstruction(defs == null ? result : defs[0], site, uses == null ? params : uses); + return insts.NewInstruction(iindex, defs == null ? result : defs[0], site, uses == null ? params : uses); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPhiInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPhiInstruction.java index 483371eb6..05b0e62e3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPhiInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPhiInstruction.java @@ -28,8 +28,8 @@ public class SSAPhiInstruction extends SSAInstruction { private int[] params; - public SSAPhiInstruction(int result, int[] params) throws IllegalArgumentException { - super(); + public SSAPhiInstruction(int index, int result, int[] params) throws IllegalArgumentException { + super(index); if (params == null) { throw new IllegalArgumentException("params is null"); } @@ -50,7 +50,7 @@ public class SSAPhiInstruction extends SSAInstruction { if (defs != null && defs.length == 0) { throw new IllegalArgumentException(); } - return insts.PhiInstruction(defs == null ? result : defs[0], uses == null ? params : uses); + return insts.PhiInstruction(iindex, defs == null ? result : defs[0], uses == null ? params : uses); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPiInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPiInstruction.java index 690d114ea..22d3004f5 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPiInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPiInstruction.java @@ -53,8 +53,8 @@ public class SSAPiInstruction extends SSAUnaryOpInstruction { * @param successorBlock the successor block; this PI assignment happens on the transition between this basic block and * the successor block. */ - public SSAPiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause) { - super(null, result, val); + public SSAPiInstruction(int index, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) { + super(index, null, result, val); this.cause = cause; this.successorBlock = successorBlock; this.piBlock = piBlock; @@ -64,7 +64,7 @@ public class SSAPiInstruction extends SSAUnaryOpInstruction { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { assert defs == null || defs.length == 1; assert uses == null || uses.length == 1; - return insts.PiInstruction(defs == null ? result : defs[0], uses == null ? val : uses[0], piBlock, successorBlock, cause); + return insts.PiInstruction(iindex, defs == null ? result : defs[0], uses == null ? val : uses[0], piBlock, successorBlock, cause); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPutInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPutInstruction.java index 76c487e89..eb75c52f0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPutInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAPutInstruction.java @@ -19,22 +19,22 @@ public abstract class SSAPutInstruction extends SSAFieldAccessInstruction { private final int val; - protected SSAPutInstruction(int ref, int val, FieldReference field) { - super(field, ref); + protected SSAPutInstruction(int index, int ref, int val, FieldReference field) { + super(index, field, ref); this.val = val; } - protected SSAPutInstruction(int val, FieldReference field) { - super(field, -1); + protected SSAPutInstruction(int index, int val, FieldReference field) { + super(index, field, -1); this.val = val; } @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (isStatic()) - return insts.PutInstruction(uses == null ? val : uses[0], getDeclaredField()); + return insts.PutInstruction(iindex, uses == null ? val : uses[0], getDeclaredField()); else - return insts.PutInstruction(uses == null ? getRef() : uses[0], uses == null ? val : uses[1], getDeclaredField()); + return insts.PutInstruction(iindex, uses == null ? getRef() : uses[0], uses == null ? val : uses[1], getDeclaredField()); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAReturnInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAReturnInstruction.java index ae832b80c..811256187 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAReturnInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAReturnInstruction.java @@ -23,14 +23,14 @@ public class SSAReturnInstruction extends SSAInstruction { private final boolean isPrimitive; - public SSAReturnInstruction(int result, boolean isPrimitive) { - super(); + public SSAReturnInstruction(int index, int result, boolean isPrimitive) { + super(index); this.result = result; this.isPrimitive = isPrimitive; } - public SSAReturnInstruction() { - super(); + public SSAReturnInstruction(int index) { + super(index); this.result = -1; this.isPrimitive = false; } @@ -38,12 +38,12 @@ public class SSAReturnInstruction extends SSAInstruction { @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { if (result == -1) - return insts.ReturnInstruction(); + return insts.ReturnInstruction(iindex); else { if (uses != null && uses.length != 1) { throw new IllegalArgumentException("invalid uses. must have exactly one use."); } - return insts.ReturnInstruction(uses == null ? result : uses[0], isPrimitive); + return insts.ReturnInstruction(iindex, uses == null ? result : uses[0], isPrimitive); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAStoreIndirectInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAStoreIndirectInstruction.java index 58288126f..c132d586a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAStoreIndirectInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAStoreIndirectInstruction.java @@ -30,7 +30,8 @@ public class SSAStoreIndirectInstruction extends SSAInstruction { * @param addressVal the value number holding the pointer p deferenced (*p) * @param rval the value number which is stored into the pointer location */ - public SSAStoreIndirectInstruction(int addressVal, int rval, TypeReference pointeeType) { + public SSAStoreIndirectInstruction(int index, int addressVal, int rval, TypeReference pointeeType) { + super(index); this.addressVal = addressVal; this.rval = rval; this.pointeeType = pointeeType; diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSASwitchInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSASwitchInstruction.java index df0a01d51..3d5bc3ea3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSASwitchInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSASwitchInstruction.java @@ -26,8 +26,8 @@ public class SSASwitchInstruction extends SSAInstruction { /** * The labels in casesAndLabels represent instruction indices in the IR that each switch case branches to. */ - public SSASwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) { - super(); + public SSASwitchInstruction(int index, int val, int defaultLabel, int[] casesAndLabels) { + super(index); this.val = val; this.defaultLabel = defaultLabel; this.casesAndLabels = casesAndLabels; @@ -36,7 +36,7 @@ public class SSASwitchInstruction extends SSAInstruction { @Override public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { assert uses == null || uses.length == 1; - return insts.SwitchInstruction(uses == null ? val : uses[0], defaultLabel, casesAndLabels); + return insts.SwitchInstruction(iindex, uses == null ? val : uses[0], defaultLabel, casesAndLabels); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAThrowInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAThrowInstruction.java index 4de0220be..9b43e1eef 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAThrowInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAThrowInstruction.java @@ -15,8 +15,8 @@ package com.ibm.wala.ssa; */ public abstract class SSAThrowInstruction extends SSAAbstractThrowInstruction { - protected SSAThrowInstruction(int exception) { - super(exception); + protected SSAThrowInstruction(int index, int exception) { + super(index, exception); } /* @@ -27,7 +27,7 @@ public abstract class SSAThrowInstruction extends SSAAbstractThrowInstruction { if (uses != null && uses.length != 1) { throw new IllegalArgumentException("if non-null, uses.length must be 1"); } - return insts.ThrowInstruction(uses == null ? getException() : uses[0]); + return insts.ThrowInstruction(iindex, uses == null ? getException() : uses[0]); } /** diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAUnaryOpInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAUnaryOpInstruction.java index a0692b7fa..79cb31437 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAUnaryOpInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAUnaryOpInstruction.java @@ -21,8 +21,8 @@ public class SSAUnaryOpInstruction extends SSAAbstractUnaryInstruction { private final IUnaryOpInstruction.IOperator operator; - public SSAUnaryOpInstruction(IUnaryOpInstruction.IOperator operator, int result, int val) { - super(result, val); + public SSAUnaryOpInstruction(int index, IUnaryOpInstruction.IOperator operator, int result, int val) { + super(index, result, val); this.operator = operator; } @@ -31,7 +31,7 @@ public class SSAUnaryOpInstruction extends SSAAbstractUnaryInstruction { if (uses != null && uses.length == 0) { throw new IllegalArgumentException("(uses != null) and (uses.length == 0)"); } - return insts.UnaryOpInstruction(operator, defs == null || defs.length == 0 ? result : defs[0], uses == null ? val : uses[0]); + return insts.UnaryOpInstruction(iindex, operator, defs == null || defs.length == 0 ? result : defs[0], uses == null ? val : uses[0]); } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java index 9b6ce7eca..1fe0a16b5 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java @@ -339,7 +339,7 @@ public class SymbolTable implements Cloneable { throw new IllegalArgumentException("rhs is null"); } int result = getNewValueNumber(); - SSAPhiInstruction phi = new SSAPhiInstruction(result, rhs.clone()); + SSAPhiInstruction phi = new SSAPhiInstruction(SSAInstruction.NO_INDEX, result, rhs.clone()); assert result < nextFreeValueNumber; values[result] = new PhiValue(phi); return result;