instruction index in SSAInstruction for javascript

This commit is contained in:
Juergen Graf 2011-04-13 12:56:36 +02:00
parent 7c518d1867
commit ee3c56b9e9
14 changed files with 229 additions and 223 deletions

3
.gitignore vendored
View File

@ -10,3 +10,6 @@ com.ibm.wala.cast.java.polyglot/lib/polyglot.jar
com.ibm.wala.cast.java.test.data/src/JLex/ com.ibm.wala.cast.java.test.data/src/JLex/
com.ibm.wala.cast.js.rhino/lib/ com.ibm.wala.cast.js.rhino/lib/
com.ibm.wala.cast.js/lib/ com.ibm.wala.cast.js/lib/
com.ibm.wala.cast.js.rhino.test/2009_swine_flu_outbreak
com.ibm.wala.cast.js.rhino.test/*.html
com.ibm.wala.cast.js.test/examples-src/ajaxslt/

View File

@ -53,7 +53,7 @@ public class JSCallGraph extends AstCallGraph {
if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(JavaScriptTypes.Root))) { if (cha.isSubclassOf(cha.lookupClass(T), cha.lookupClass(JavaScriptTypes.Root))) {
int instance = nextLocal++; int instance = nextLocal++;
NewSiteReference ref = NewSiteReference.make(statements.size(), T); NewSiteReference ref = NewSiteReference.make(statements.size(), T);
SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(instance, ref); SSANewInstruction result = getDeclaringClass().getClassLoader().getInstructionFactory().NewInstruction(statements.size(), instance, ref);
statements.add(result); statements.add(result);
return result; return result;
} else { } else {

View File

@ -83,19 +83,19 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference()); MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1); JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference()))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.PutInstruction(5, 4, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 4, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addConstant(new Integer(8), new ConstantValue(value)); S.addConstant(new Integer(8), new ConstantValue(value));
S.addStatement(insts.PutInstruction(5, 8, "$value")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 8, "$value"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -106,18 +106,18 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference()); MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 2); JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference()))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.PutInstruction(6, 5, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 5, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "$value")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "$value"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -143,15 +143,15 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object); MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 1); JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(5, 4, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 4, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -162,7 +162,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object); MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Object);
JavaScriptSummary S = new JavaScriptSummary(ref, 2); JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.ReturnInstruction(2, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -200,18 +200,18 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Array); MethodReference ref = JavaScriptMethods.makeCtorReference(JavaScriptTypes.Array);
JavaScriptSummary S = new JavaScriptSummary(ref, 2); JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(5, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 5, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 6, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Array)));
S.addStatement(insts.PutInstruction(6, 5, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 5, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(6, 2, "length")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 6, 2, "length"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(6, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 6, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -223,28 +223,28 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1); JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addConstant(new Integer(nargs + 3), new ConstantValue("prototype")); S.addConstant(new Integer(nargs + 3), new ConstantValue("prototype"));
S.addStatement(insts.PropertyRead(nargs + 4, 1, nargs + 3)); S.addStatement(insts.PropertyRead(S.getNumberOfStatements(), nargs + 4, 1, nargs + 3));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement( S.addStatement(
insts.NewInstruction(nargs + 5, NewSiteReference.make(S.getNextProgramCounter(), insts.NewInstruction(S.getNumberOfStatements(), nargs + 5, NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Array))); JavaScriptTypes.Array)));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 4, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addConstant(new Integer(nargs + 7), new ConstantValue(nargs)); S.addConstant(new Integer(nargs + 7), new ConstantValue(nargs));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 7, "length")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 7, "length"));
S.getNextProgramCounter(); S.getNextProgramCounter();
int vn = nargs + 9; int vn = nargs + 9;
for (int i = 0; i < nargs; i++, vn += 2) { for (int i = 0; i < nargs; i++, vn += 2) {
S.addConstant(new Integer(vn), new ConstantValue(i)); S.addConstant(new Integer(vn), new ConstantValue(i));
S.addStatement(insts.PropertyWrite(nargs + 5, vn, i + 1)); S.addStatement(insts.PropertyWrite(S.getNumberOfStatements(), nargs + 5, vn, i + 1));
S.getNextProgramCounter(); S.getNextProgramCounter();
} }
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -265,7 +265,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, 1); JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue("")); S.addConstant(new Integer(2), new ConstantValue(""));
S.addStatement(insts.ReturnInstruction(2, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -276,13 +276,13 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.String); MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.String);
JavaScriptSummary S = new JavaScriptSummary(ref, 2); JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toString")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toString"));
S.getNextProgramCounter(); S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs)); S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -305,7 +305,7 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
JavaScriptSummary S = new JavaScriptSummary(ref, 1); JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addConstant(new Integer(2), new ConstantValue(0.0)); S.addConstant(new Integer(2), new ConstantValue(0.0));
S.addStatement(insts.ReturnInstruction(2, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 2, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -316,13 +316,13 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.Number); MethodReference ref = AstMethodReference.fnReference(JavaScriptTypes.Number);
JavaScriptSummary S = new JavaScriptSummary(ref, 2); JavaScriptSummary S = new JavaScriptSummary(ref, 2);
S.addStatement(insts.GetInstruction(4, 2, "toNumber")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 2, "toNumber"));
S.getNextProgramCounter(); S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
S.addStatement(insts.Invoke(4, 5, new int[] { 2 }, 6, cs)); S.addStatement(insts.Invoke(S.getNumberOfStatements(), 4, 5, new int[] { 2 }, 6, cs));
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return new JavaScriptConstructor(ref, S, cls); return new JavaScriptConstructor(ref, S, cls);
@ -348,23 +348,23 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(receiver.getReference()); MethodReference ref = JavaScriptMethods.makeCtorReference(receiver.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, 1); JavaScriptSummary S = new JavaScriptSummary(ref, 1);
S.addStatement(insts.GetInstruction(4, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), 4, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.NewInstruction(5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference()))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 5, NewSiteReference.make(S.getNextProgramCounter(), cls.getReference())));
S.addStatement(insts.NewInstruction(7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object))); S.addStatement(insts.NewInstruction(S.getNumberOfStatements(), 7, NewSiteReference.make(S.getNextProgramCounter(), JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(7, 4, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 4, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(5, 7, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 5, 7, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.PutInstruction(7, 5, "constructor")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), 7, 5, "constructor"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
if (receiver != cls) if (receiver != cls)
@ -458,15 +458,15 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference()); MethodReference ref = JavaScriptMethods.makeCtorReference(cls.getReference());
JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1); JavaScriptSummary S = new JavaScriptSummary(ref, nargs + 1);
S.addStatement(insts.GetInstruction(nargs + 4, 1, "prototype")); S.addStatement(insts.GetInstruction(S.getNumberOfStatements(), nargs + 4, 1, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement( S.addStatement(
insts.NewInstruction(nargs + 5, insts.NewInstruction(S.getNumberOfStatements(), nargs + 5,
NewSiteReference.make(S.getNextProgramCounter(), NewSiteReference.make(S.getNextProgramCounter(),
JavaScriptTypes.Object))); JavaScriptTypes.Object)));
S.addStatement(insts.PutInstruction(nargs + 5, nargs + 4, "prototype")); S.addStatement(insts.PutInstruction(S.getNumberOfStatements(), nargs + 5, nargs + 4, "prototype"));
S.getNextProgramCounter(); S.getNextProgramCounter();
CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter()); CallSiteReference cs = new JSCallSiteReference(S.getNextProgramCounter());
@ -476,10 +476,10 @@ public class JavaScriptConstructTargetSelector implements MethodTargetSelector {
args[i + 1] = i + 2; args[i + 1] = i + 2;
S.addStatement(insts.Invoke(1, nargs + 7, args, nargs + 8, cs)); S.addStatement(insts.Invoke(1, nargs + 7, args, nargs + 8, cs));
S.addStatement(insts.ReturnInstruction(nargs + 7, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 7, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
S.addStatement(insts.ReturnInstruction(nargs + 5, false)); S.addStatement(insts.ReturnInstruction(S.getNumberOfStatements(), nargs + 5, false));
S.getNextProgramCounter(); S.getNextProgramCounter();
return record(key, new JavaScriptConstructor(ref, S, cls)); return record(key, new JavaScriptConstructor(ref, S, cls));

View File

@ -25,7 +25,7 @@ public class JavaScriptSummary extends MethodSummary {
super(ref); super(ref);
this.declaredParameters = declaredParameters; this.declaredParameters = declaredParameters;
addStatement( addStatement(
JavaScriptLoader.JS.instructionFactory().NewInstruction( JavaScriptLoader.JS.instructionFactory().NewInstruction(getNumberOfStatements(),
declaredParameters+1, declaredParameters+1,
NewSiteReference.make( NewSiteReference.make(
getNextProgramCounter(), getNextProgramCounter(),

View File

@ -196,48 +196,48 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
public JSInstructionFactory instructionFactory() { public JSInstructionFactory instructionFactory() {
return new JSInstructionFactory() { return new JSInstructionFactory() {
public JavaScriptCheckReference CheckReference(int ref) { public JavaScriptCheckReference CheckReference(int iindex, int ref) {
return new JavaScriptCheckReference(ref); return new JavaScriptCheckReference(iindex, ref);
} }
public SSAGetInstruction GetInstruction(int result, int ref, String field) { public SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field) {
return GetInstruction(result, ref, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field), return GetInstruction(iindex, result, ref, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(field),
JavaScriptTypes.Root)); JavaScriptTypes.Root));
} }
public JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal) { public JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal) {
return new JavaScriptInstanceOf(result, objVal, typeVal); return new JavaScriptInstanceOf(iindex, result, objVal, typeVal);
} }
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, results, params, exception, site); return new JavaScriptInvoke(iindex, function, results, params, exception, site);
} }
public JavaScriptInvoke Invoke(int function, int[] results, int[] params, int exception, CallSiteReference site, public JavaScriptInvoke Invoke(int iindex, int function, int[] results, int[] params, int exception, CallSiteReference site,
Access[] lexicalReads, Access[] lexicalWrites) { Access[] lexicalReads, Access[] lexicalWrites) {
return new JavaScriptInvoke(function, results, params, exception, site, lexicalReads, lexicalWrites); return new JavaScriptInvoke(iindex, function, results, params, exception, site, lexicalReads, lexicalWrites);
} }
public JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, result, params, exception, site); return new JavaScriptInvoke(iindex, function, result, params, exception, site);
} }
public JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
return new JavaScriptInvoke(function, params, exception, site); return new JavaScriptInvoke(iindex, function, params, exception, site);
} }
public JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef) { public JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
return new JavaScriptPropertyRead(result, objectRef, memberRef); return new JavaScriptPropertyRead(iindex, result, objectRef, memberRef);
} }
public JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value) { public JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value) {
return new JavaScriptPropertyWrite(objectRef, memberRef, value); return new JavaScriptPropertyWrite(iindex, objectRef, memberRef, value);
} }
public SSAPutInstruction PutInstruction(int ref, int value, String field) { public SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field) {
try { try {
byte[] utf8 = field.getBytes("UTF-8"); byte[] utf8 = field.getBytes("UTF-8");
return PutInstruction(ref, value, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length), return PutInstruction(iindex, ref, value, FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreate(utf8, 0, utf8.length),
JavaScriptTypes.Root)); JavaScriptTypes.Root));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Assertions.UNREACHABLE(); Assertions.UNREACHABLE();
@ -245,190 +245,190 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
} }
} }
public JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object) { public JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object) {
return new JavaScriptTypeOfInstruction(lval, object); return new JavaScriptTypeOfInstruction(iindex, lval, object);
} }
public JavaScriptWithRegion WithRegion(int expr, boolean isEnter) { public JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter) {
return new JavaScriptWithRegion(expr, isEnter); return new JavaScriptWithRegion(iindex, expr, isEnter);
} }
public AstAssertInstruction AssertInstruction(int value, boolean fromSpecification) { public AstAssertInstruction AssertInstruction(int iindex, int value, boolean fromSpecification) {
return new AstAssertInstruction(value, fromSpecification); return new AstAssertInstruction(iindex, value, fromSpecification);
} }
public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int result, int val) { public com.ibm.wala.cast.ir.ssa.AssignInstruction AssignInstruction(int iindex, int result, int val) {
return new AssignInstruction(result, 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) {
return new EachElementGetInstruction(value, objectRef); return new EachElementGetInstruction(iindex, value, objectRef);
} }
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) {
return new EachElementHasNextInstruction(value, objectRef); return new EachElementHasNextInstruction(iindex, value, objectRef);
} }
public AstEchoInstruction EchoInstruction(int[] rvals) { public AstEchoInstruction EchoInstruction(int iindex, int[] rvals) {
return new AstEchoInstruction(rvals); return new AstEchoInstruction(iindex, rvals);
} }
public AstGlobalRead GlobalRead(int lhs, FieldReference global) { public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
return new AstGlobalRead(lhs, global); return new AstGlobalRead(iindex, lhs, global);
} }
public AstGlobalWrite GlobalWrite(FieldReference global, int rhs) { public AstGlobalWrite GlobalWrite(int iindex, FieldReference global, int rhs) {
return new AstGlobalWrite(global, rhs); return new AstGlobalWrite(iindex, global, rhs);
} }
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal, FieldReference fieldRef) { public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldVal, fieldRef); return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal, fieldRef);
} }
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, FieldReference fieldRef) { public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, FieldReference fieldRef) {
return new AstIsDefinedInstruction(lval, rval, fieldRef); return new AstIsDefinedInstruction(iindex, lval, rval, fieldRef);
} }
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval, int fieldVal) { public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval, int fieldVal) {
return new AstIsDefinedInstruction(lval, rval, fieldVal); return new AstIsDefinedInstruction(iindex, lval, rval, fieldVal);
} }
public AstIsDefinedInstruction IsDefinedInstruction(int lval, int rval) { public AstIsDefinedInstruction IsDefinedInstruction(int iindex, int lval, int rval) {
return new AstIsDefinedInstruction(lval, rval); return new AstIsDefinedInstruction(iindex, lval, rval);
} }
public AstLexicalRead LexicalRead(Access[] accesses) { public AstLexicalRead LexicalRead(int iindex, Access[] accesses) {
return new AstLexicalRead(accesses); return new AstLexicalRead(iindex, accesses);
} }
public AstLexicalRead LexicalRead(Access access) { public AstLexicalRead LexicalRead(int iindex, Access access) {
return new AstLexicalRead(access); return new AstLexicalRead(iindex, access);
} }
public AstLexicalRead LexicalRead(int lhs, String definer, String globalName) { public AstLexicalRead LexicalRead(int iindex, int lhs, String definer, String globalName) {
return new AstLexicalRead(lhs, definer, globalName); return new AstLexicalRead(iindex, lhs, definer, globalName);
} }
public AstLexicalWrite LexicalWrite(Access[] accesses) { public AstLexicalWrite LexicalWrite(int iindex, Access[] accesses) {
return new AstLexicalWrite(accesses); return new AstLexicalWrite(iindex, accesses);
} }
public AstLexicalWrite LexicalWrite(Access access) { public AstLexicalWrite LexicalWrite(int iindex, Access access) {
return new AstLexicalWrite(access); return new AstLexicalWrite(iindex, access);
} }
public AstLexicalWrite LexicalWrite(String definer, String globalName, int rhs) { public AstLexicalWrite LexicalWrite(int iindex, String definer, String globalName, int rhs) {
return new AstLexicalWrite(definer, globalName, rhs); return new AstLexicalWrite(iindex, definer, globalName, rhs);
} }
public SSAArrayLengthInstruction ArrayLengthInstruction(int result, int arrayref) { public SSAArrayLengthInstruction ArrayLengthInstruction(int iindex, int result, int arrayref) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAArrayLoadInstruction ArrayLoadInstruction(int result, int arrayref, int index, TypeReference declaredType) { public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, int result, int arrayref, int index, TypeReference declaredType) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAArrayStoreInstruction ArrayStoreInstruction(int arrayref, int index, int value, TypeReference declaredType) { public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, int arrayref, int index, int value, TypeReference declaredType) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSABinaryOpInstruction BinaryOpInstruction(IOperator operator, boolean overflow, boolean unsigned, int result, public SSABinaryOpInstruction BinaryOpInstruction(int iindex, IOperator operator, boolean overflow, boolean unsigned, int result,
int val1, int val2, boolean mayBeInteger) { int val1, int val2, boolean mayBeInteger) {
return new SSABinaryOpInstruction(operator, result, val1, val2, mayBeInteger) { return new SSABinaryOpInstruction(iindex, operator, result, val1, val2, mayBeInteger) {
public boolean isPEI() { public boolean isPEI() {
return false; return false;
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { 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()); uses == null ? getUse(0) : uses[0], uses == null ? getUse(1) : uses[1], mayBeIntegerOp());
} }
}; };
} }
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference[] types) { public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference[] types) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int[] typeValues) { public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int[] typeValues) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSACheckCastInstruction CheckCastInstruction(int result, int val, int typeValue) { public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, int typeValue) {
return CheckCastInstruction(result, val, new int[]{ typeValue }); return CheckCastInstruction(iindex, result, val, new int[]{ typeValue });
} }
public SSACheckCastInstruction CheckCastInstruction(int result, int val, TypeReference type) { public SSACheckCastInstruction CheckCastInstruction(int iindex, int result, int val, TypeReference type) {
return CheckCastInstruction(result, val, new TypeReference[]{ type }); return CheckCastInstruction(iindex, result, val, new TypeReference[]{ type });
} }
public SSAComparisonInstruction ComparisonInstruction(Operator operator, int result, int val1, int val2) { public SSAComparisonInstruction ComparisonInstruction(int iindex, Operator operator, int result, int val1, int val2) {
return new SSAComparisonInstruction(operator, result, val1, val2); return new SSAComparisonInstruction(iindex, operator, result, val1, val2);
} }
public SSAConditionalBranchInstruction ConditionalBranchInstruction( public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex,
com.ibm.wala.shrikeBT.IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2) { com.ibm.wala.shrikeBT.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) { boolean overflow) {
assert !overflow; assert !overflow;
return new SSAConversionInstruction(result, val, fromType, toType) { return new SSAConversionInstruction(iindex, result, val, fromType, toType) {
@Override @Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) throws IllegalArgumentException {
if (uses != null && uses.length == 0) { if (uses != null && uses.length == 0) {
throw new IllegalArgumentException("(uses != null) and (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); : uses[0], getFromType(), getToType(), false);
} }
}; };
} }
public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int bbNumber, int exceptionValueNumber) { public SSAGetCaughtExceptionInstruction GetCaughtExceptionInstruction(int iindex, int bbNumber, int exceptionValueNumber) {
return new SSAGetCaughtExceptionInstruction(bbNumber, exceptionValueNumber); return new SSAGetCaughtExceptionInstruction(iindex, bbNumber, exceptionValueNumber);
} }
public SSAGetInstruction GetInstruction(int result, FieldReference field) { public SSAGetInstruction GetInstruction(int iindex, int result, FieldReference field) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAGetInstruction GetInstruction(int result, int ref, FieldReference field) { public SSAGetInstruction GetInstruction(int iindex, int result, int ref, FieldReference field) {
return new SSAGetInstruction(result, ref, field) { return new SSAGetInstruction(iindex, result, ref, field) {
public boolean isPEI() { public boolean isPEI() {
return false; return false;
} }
}; };
} }
public SSAGotoInstruction GotoInstruction() { public SSAGotoInstruction GotoInstruction(int iindex) {
return new SSAGotoInstruction(); return new SSAGotoInstruction(iindex);
} }
public SSAInstanceofInstruction InstanceofInstruction(int result, int ref, TypeReference checkedType) { public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAInvokeInstruction InvokeInstruction(int result, int[] params, int exception, CallSiteReference site) { public SSAInvokeInstruction InvokeInstruction(int iindex, int result, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAInvokeInstruction InvokeInstruction(int[] params, int exception, CallSiteReference site) { public SSAInvokeInstruction InvokeInstruction(int iindex, int[] params, int exception, CallSiteReference site) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSALoadMetadataInstruction LoadMetadataInstruction(int lval, TypeReference entityType, Object token) { public SSALoadMetadataInstruction LoadMetadataInstruction(int iindex, int lval, TypeReference entityType, Object token) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAMonitorInstruction MonitorInstruction(int ref, boolean isEnter) { public SSAMonitorInstruction MonitorInstruction(int iindex, int ref, boolean isEnter) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSANewInstruction NewInstruction(int result, NewSiteReference site) { public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site) {
return new SSANewInstruction(result, site) { return new SSANewInstruction(iindex, result, site) {
public boolean isPEI() { public boolean isPEI() {
return true; return true;
} }
@ -439,44 +439,44 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}; };
} }
public SSANewInstruction NewInstruction(int result, NewSiteReference site, int[] params) { public SSANewInstruction NewInstruction(int iindex, int result, NewSiteReference site, int[] params) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAPhiInstruction PhiInstruction(int result, int[] params) { public SSAPhiInstruction PhiInstruction(int iindex, int result, int[] params) {
return new SSAPhiInstruction(result, params); return new SSAPhiInstruction(iindex, result, params);
} }
public SSAPiInstruction PiInstruction(int result, int val, int piBlock, int successorBlock, SSAInstruction cause) { public SSAPiInstruction PiInstruction(int iindex, int result, int val, int piBlock, int successorBlock, SSAInstruction cause) {
return new SSAPiInstruction(result, val, piBlock, successorBlock, cause); return new SSAPiInstruction(iindex, result, val, piBlock, successorBlock, cause);
} }
public SSAPutInstruction PutInstruction(int ref, int value, FieldReference field) { public SSAPutInstruction PutInstruction(int iindex, int ref, int value, FieldReference field) {
return new SSAPutInstruction(ref, value, field) { return new SSAPutInstruction(iindex, ref, value, field) {
public boolean isPEI() { public boolean isPEI() {
return false; return false;
} }
}; };
} }
public SSAPutInstruction PutInstruction(int value, FieldReference field) { public SSAPutInstruction PutInstruction(int iindex, int value, FieldReference field) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public SSAReturnInstruction ReturnInstruction() { public SSAReturnInstruction ReturnInstruction(int iindex) {
return new SSAReturnInstruction(); return new SSAReturnInstruction(iindex);
} }
public SSAReturnInstruction ReturnInstruction(int result, boolean isPrimitive) { public SSAReturnInstruction ReturnInstruction(int iindex, int result, boolean isPrimitive) {
return new SSAReturnInstruction(result, isPrimitive); return new SSAReturnInstruction(iindex, result, isPrimitive);
} }
public SSASwitchInstruction SwitchInstruction(int val, int defaultLabel, int[] casesAndLabels) { public SSASwitchInstruction SwitchInstruction(int iindex, int val, int defaultLabel, int[] casesAndLabels) {
return new SSASwitchInstruction(val, defaultLabel, casesAndLabels); return new SSASwitchInstruction(iindex, val, defaultLabel, casesAndLabels);
} }
public SSAThrowInstruction ThrowInstruction(int exception) { public SSAThrowInstruction ThrowInstruction(int iindex, int exception) {
return new SSAThrowInstruction(exception) { return new SSAThrowInstruction(iindex, exception) {
public boolean isPEI() { public boolean isPEI() {
return true; return true;
} }
@ -487,28 +487,28 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
}; };
} }
public SSAUnaryOpInstruction UnaryOpInstruction(com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result, public SSAUnaryOpInstruction UnaryOpInstruction(int iindex, com.ibm.wala.shrikeBT.IUnaryOpInstruction.IOperator operator, int result,
int val) { int val) {
return new SSAUnaryOpInstruction(operator, result, val); return new SSAUnaryOpInstruction(iindex, operator, result, val);
} }
public SSAAddressOfInstruction AddressOfInstruction(int lval, int local, TypeReference pointeeType) { public SSAAddressOfInstruction AddressOfInstruction(int iindex, int lval, int local, TypeReference pointeeType) {
throw new UnsupportedOperationException(); 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(); 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(); 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(); throw new UnsupportedOperationException();
} }
public SSAStoreIndirectInstruction StoreIndirectInstruction(int addressVal, int rval, TypeReference t) { public SSAStoreIndirectInstruction StoreIndirectInstruction(int iindex, int addressVal, int rval, TypeReference t) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -8,28 +8,28 @@ import com.ibm.wala.ssa.SSAPutInstruction;
public interface JSInstructionFactory extends AstInstructionFactory { public interface JSInstructionFactory extends AstInstructionFactory {
JavaScriptCheckReference CheckReference(int ref); JavaScriptCheckReference CheckReference(int iindex, int ref);
SSAGetInstruction GetInstruction(int result, int ref, String field); SSAGetInstruction GetInstruction(int iindex, int result, int ref, String field);
JavaScriptInstanceOf InstanceOf(int result, int objVal, int typeVal); JavaScriptInstanceOf InstanceOf(int iindex, int result, int objVal, int typeVal);
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site); JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites); JavaScriptInvoke Invoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, Access[] lexicalWrites);
JavaScriptInvoke Invoke(int function, int result, int[] params, int exception, CallSiteReference site); JavaScriptInvoke Invoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site);
JavaScriptInvoke Invoke(int function, int[] params, int exception, CallSiteReference site); JavaScriptInvoke Invoke(int iindex, int function, int[] params, int exception, CallSiteReference site);
JavaScriptPropertyRead PropertyRead(int result, int objectRef, int memberRef); JavaScriptPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef);
JavaScriptPropertyWrite PropertyWrite(int objectRef, int memberRef, int value); JavaScriptPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value);
SSAPutInstruction PutInstruction(int ref, int value, String field); SSAPutInstruction PutInstruction(int iindex, int ref, int value, String field);
JavaScriptTypeOfInstruction TypeOfInstruction(int lval, int object); JavaScriptTypeOfInstruction TypeOfInstruction(int iindex, int lval, int object);
JavaScriptWithRegion WithRegion(int expr, boolean isEnter); JavaScriptWithRegion WithRegion(int iindex, int expr, boolean isEnter);
} }

View File

@ -12,13 +12,14 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptCheckReference extends SSAInstruction { public class JavaScriptCheckReference extends SSAInstruction {
private final int ref; private final int ref;
public JavaScriptCheckReference(int ref) { public JavaScriptCheckReference(int iindex, int ref) {
super(iindex);
this.ref = ref; this.ref = ref;
} }
@Override @Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).CheckReference(uses==null? ref: uses[0]); return ((JSInstructionFactory)insts).CheckReference(iindex, uses==null? ref: uses[0]);
} }
@Override @Override

View File

@ -15,7 +15,8 @@ public class JavaScriptInstanceOf extends SSAInstruction {
private final int typeVal; private final int typeVal;
private final int result; private final int result;
public JavaScriptInstanceOf(int result, int objVal, int typeVal) { public JavaScriptInstanceOf(int iindex, int result, int objVal, int typeVal) {
super(iindex);
this.objVal = objVal; this.objVal = objVal;
this.typeVal = typeVal; this.typeVal = typeVal;
this.result = result; this.result = result;
@ -24,7 +25,7 @@ public class JavaScriptInstanceOf extends SSAInstruction {
@Override @Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return return
((JSInstructionFactory)insts).InstanceOf( ((JSInstructionFactory)insts).InstanceOf(iindex,
defs==null? result: defs[0], defs==null? result: defs[0],
uses==null? objVal: uses[0], uses==null? objVal: uses[0],
uses==null? typeVal: uses[1]); uses==null? typeVal: uses[1]);

View File

@ -29,25 +29,25 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
private int function; private int function;
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site) {
super(results, exception, site); super(iindex, results, exception, site);
this.function = function; this.function = function;
this.params = params; this.params = params;
} }
public JavaScriptInvoke(int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads, public JavaScriptInvoke(int iindex, int function, int results[], int[] params, int exception, CallSiteReference site, Access[] lexicalReads,
Access[] lexicalWrites) { Access[] lexicalWrites) {
super(results, exception, site, lexicalReads, lexicalWrites); super(iindex, results, exception, site, lexicalReads, lexicalWrites);
this.function = function; this.function = function;
this.params = params; this.params = params;
} }
public JavaScriptInvoke(int function, int result, int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke(int iindex, int function, int result, int[] params, int exception, CallSiteReference site) {
this(function, new int[] { result }, params, exception, site); this(iindex, function, new int[] { result }, params, exception, site);
} }
public JavaScriptInvoke(int function, int[] params, int exception, CallSiteReference site) { public JavaScriptInvoke(int iindex, int function, int[] params, int exception, CallSiteReference site) {
this(function, null, params, exception, site); this(iindex, function, null, params, exception, site);
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
@ -93,7 +93,7 @@ public class JavaScriptInvoke extends AbstractLexicalInvoke {
} }
} }
return ((JSInstructionFactory)insts).Invoke(fn, newLvals, newParams, newExp, site, reads, writes); return ((JSInstructionFactory)insts).Invoke(iindex, fn, newLvals, newParams, newExp, site, reads, writes);
} }
public String toString(SymbolTable symbolTable) { public String toString(SymbolTable symbolTable) {

View File

@ -18,13 +18,13 @@ import com.ibm.wala.ssa.SSAInstructionFactory;
import com.ibm.wala.types.TypeReference; import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyRead extends AbstractReflectiveGet { public class JavaScriptPropertyRead extends AbstractReflectiveGet {
public JavaScriptPropertyRead(int result, int objectRef, int memberRef) { public JavaScriptPropertyRead(int iindex, int result, int objectRef, int memberRef) {
super(result, objectRef, memberRef); super(iindex, result, objectRef, memberRef);
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return return
((JSInstructionFactory)insts).PropertyRead( ((JSInstructionFactory)insts).PropertyRead(iindex,
defs==null? getDef(): defs[0], defs==null? getDef(): defs[0],
uses==null? getObjectRef(): uses[0], uses==null? getObjectRef(): uses[0],
uses==null? getMemberRef(): uses[1]); uses==null? getMemberRef(): uses[1]);

View File

@ -20,12 +20,12 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptPropertyWrite extends AbstractReflectivePut { public class JavaScriptPropertyWrite extends AbstractReflectivePut {
public JavaScriptPropertyWrite(int objectRef, int memberRef, int value) { public JavaScriptPropertyWrite(int iindex, int objectRef, int memberRef, int value) {
super(objectRef, memberRef, value); super(iindex, objectRef, memberRef, value);
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).PropertyWrite(uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1], return ((JSInstructionFactory)insts).PropertyWrite(iindex, uses == null ? getObjectRef() : uses[0], uses == null ? getMemberRef() : uses[1],
uses == null ? getValue() : uses[2]); uses == null ? getValue() : uses[2]);
} }

View File

@ -20,12 +20,12 @@ import com.ibm.wala.types.TypeReference;
public class JavaScriptTypeOfInstruction extends SSAAbstractUnaryInstruction { public class JavaScriptTypeOfInstruction extends SSAAbstractUnaryInstruction {
public JavaScriptTypeOfInstruction(int lval, int object) { public JavaScriptTypeOfInstruction(int iindex, int lval, int object) {
super(lval, object); super(iindex, lval, object);
} }
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).TypeOfInstruction((defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0))); return ((JSInstructionFactory)insts).TypeOfInstruction(iindex, (defs != null ? defs[0] : getDef(0)), (uses != null ? uses[0] : getUse(0)));
} }
public String toString(SymbolTable symbolTable) { public String toString(SymbolTable symbolTable) {

View File

@ -11,14 +11,15 @@ public class JavaScriptWithRegion extends SSAInstruction {
private final int expr; private final int expr;
private final boolean isEnter; private final boolean isEnter;
public JavaScriptWithRegion(int expr, boolean isEnter) { public JavaScriptWithRegion(int iindex, int expr, boolean isEnter) {
super(iindex);
this.expr = expr; this.expr = expr;
this.isEnter = isEnter; this.isEnter = isEnter;
} }
@Override @Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) { public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
return ((JSInstructionFactory)insts).WithRegion(uses==null? expr: uses[0], isEnter); return ((JSInstructionFactory)insts).WithRegion(iindex, uses==null? expr: uses[0], isEnter);
} }
@Override @Override

View File

@ -72,7 +72,7 @@ public class JSAstTranslator extends AstTranslator {
private void addDefinedCheck(CAstNode n, WalkContext context, int readVn) { private void addDefinedCheck(CAstNode n, WalkContext context, int readVn) {
context.cfg().addPreNode(n); context.cfg().addPreNode(n);
context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(readVn)); context.cfg().addInstruction(((JSInstructionFactory)insts).CheckReference(context.cfg().getCurrentInstruction(), readVn));
CAstNode target = context.getControlFlow().getTarget(n, JavaScriptTypes.ReferenceError); CAstNode target = context.getControlFlow().getTarget(n, JavaScriptTypes.ReferenceError);
if (target != null) { if (target != null) {
@ -159,7 +159,7 @@ public class JSAstTranslator extends AstTranslator {
} }
protected void doThrow(WalkContext context, int exception) { protected void doThrow(WalkContext context, int exception) {
context.cfg().addInstruction(insts.ThrowInstruction(exception)); context.cfg().addInstruction(insts.ThrowInstruction(context.cfg().getCurrentInstruction(), exception));
} }
protected void doCall(WalkContext context, CAstNode call, int result, int exception, CAstNode name, int receiver, int[] arguments) { protected void doCall(WalkContext context, CAstNode call, int result, int exception, CAstNode name, int receiver, int[] arguments) {
@ -169,7 +169,7 @@ public class JSAstTranslator extends AstTranslator {
AstMethodReference.fnReference(JavaScriptTypes.CodeBody); AstMethodReference.fnReference(JavaScriptTypes.CodeBody);
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).Invoke(receiver, result, arguments, exception, ((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), receiver, result, arguments, exception,
new JSCallSiteReference(ref, context.cfg().getCurrentInstruction()))); new JSCallSiteReference(ref, context.cfg().getCurrentInstruction())));
context.cfg().addPreNode(call, context.getUnwindState()); context.cfg().addPreNode(call, context.getUnwindState());
@ -190,7 +190,7 @@ public class JSAstTranslator extends AstTranslator {
TypeName.string2TypeName( "L" + type )); TypeName.string2TypeName( "L" + type ));
context.cfg().addInstruction( context.cfg().addInstruction(
insts.NewInstruction( insts.NewInstruction(context.cfg().getCurrentInstruction(),
result, result,
NewSiteReference.make( NewSiteReference.make(
context.cfg().getCurrentInstruction(), context.cfg().getCurrentInstruction(),
@ -201,7 +201,7 @@ public class JSAstTranslator extends AstTranslator {
int nm = context.currentScope().getConstantValue("L"+composeEntityName(context, fn)); int nm = context.currentScope().getConstantValue("L"+composeEntityName(context, fn));
int tmp = super.doGlobalRead(n, context, "Function"); int tmp = super.doGlobalRead(n, context, "Function");
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).Invoke(tmp, result, new int[]{ nm }, exception, ((JSInstructionFactory)insts).Invoke(context.cfg().getCurrentInstruction(), tmp, result, new int[]{ nm }, exception,
new JSCallSiteReference( new JSCallSiteReference(
JavaScriptMethods.ctorReference, JavaScriptMethods.ctorReference,
context.cfg().getCurrentInstruction()))); context.cfg().getCurrentInstruction())));
@ -219,17 +219,17 @@ public class JSAstTranslator extends AstTranslator {
this.visit(elt, context, this); this.visit(elt, context, this);
int x = context.currentScope().allocateTempValue(); int x = context.currentScope().allocateTempValue();
context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(x, receiver)); context.cfg().addInstruction(((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(), x, receiver));
if (elt.getKind()==CAstNode.CONSTANT && elt.getValue() instanceof String) { if (elt.getKind()==CAstNode.CONSTANT && elt.getValue() instanceof String) {
String field = (String)elt.getValue(); String field = (String)elt.getValue();
// symtab needs to have this value // symtab needs to have this value
context.currentScope().getConstantValue(field); context.currentScope().getConstantValue(field);
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).GetInstruction(result, x, field)); ((JSInstructionFactory)insts).GetInstruction(context.cfg().getCurrentInstruction(), result, x, field));
} else { } else {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).PropertyRead(result, x, getValue(elt) )); ((JSInstructionFactory)insts).PropertyRead(context.cfg().getCurrentInstruction(), result, x, getValue(elt) ));
} }
} }
@ -239,7 +239,7 @@ public class JSAstTranslator extends AstTranslator {
{ {
String field = (String)elt.getValue(); String field = (String)elt.getValue();
context.currentScope().getConstantValue(field); context.currentScope().getConstantValue(field);
SSAPutInstruction put = ((JSInstructionFactory)insts).PutInstruction(receiver, rval, field); SSAPutInstruction put = ((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), receiver, rval, field);
try { try {
assert field.equals(put.getDeclaredField().getName().toUnicodeString()); assert field.equals(put.getDeclaredField().getName().toUnicodeString());
} catch (UTFDataFormatException e) { } catch (UTFDataFormatException e) {
@ -248,7 +248,7 @@ public class JSAstTranslator extends AstTranslator {
context.cfg().addInstruction(put); context.cfg().addInstruction(put);
} else { } else {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).PropertyWrite(receiver, getValue(elt), rval)); ((JSInstructionFactory)insts).PropertyWrite(context.cfg().getCurrentInstruction(), receiver, getValue(elt), rval));
} }
} }
@ -259,7 +259,7 @@ public class JSAstTranslator extends AstTranslator {
int rval = context.currentScope().getConstantValue(typeName); int rval = context.currentScope().getConstantValue(typeName);
context.currentScope().getConstantValue("class"); context.currentScope().getConstantValue("class");
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).PutInstruction(resultVal, rval, "class")); ((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), resultVal, rval, "class"));
} }
protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) { protected void doPrimitive(int resultVal, WalkContext context, CAstNode primitiveCall) {
@ -267,42 +267,42 @@ public class JSAstTranslator extends AstTranslator {
String name = (String)primitiveCall.getChild(0).getValue(); String name = (String)primitiveCall.getChild(0).getValue();
if (name.equals("GlobalNaN")) { if (name.equals("GlobalNaN")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Float(Float.NaN)))); context.currentScope().getConstantValue(new Float(Float.NaN))));
} else if (name.equals("GlobalInfinity")) { } else if (name.equals("GlobalInfinity")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY)))); context.currentScope().getConstantValue(new Float(Float.POSITIVE_INFINITY))));
} else if (name.equals("MathE")) { } else if (name.equals("MathE")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.E)))); context.currentScope().getConstantValue(new Double(Math.E))));
} else if (name.equals("MathPI")) { } else if (name.equals("MathPI")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.PI)))); context.currentScope().getConstantValue(new Double(Math.PI))));
} else if (name.equals("MathSQRT1_2")) { } else if (name.equals("MathSQRT1_2")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(.5))))); context.currentScope().getConstantValue(new Double(Math.sqrt(.5)))));
} else if (name.equals("MathSQRT2")) { } else if (name.equals("MathSQRT2")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.sqrt(2))))); context.currentScope().getConstantValue(new Double(Math.sqrt(2)))));
} else if (name.equals("MathLN2")) { } else if (name.equals("MathLN2")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.log(2))))); context.currentScope().getConstantValue(new Double(Math.log(2)))));
} else if (name.equals("MathLN10")) { } else if (name.equals("MathLN10")) {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue(new Double(Math.log(10))))); context.currentScope().getConstantValue(new Double(Math.log(10)))));
} else if (name.equals("NewObject")) { } else if (name.equals("NewObject")) {
@ -328,7 +328,7 @@ public class JSAstTranslator extends AstTranslator {
} else { } else {
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).AssignInstruction( ((JSInstructionFactory)insts).AssignInstruction(context.cfg().getCurrentInstruction(),
resultVal, resultVal,
context.currentScope().getConstantValue( null ))); context.currentScope().getConstantValue( null )));
} }
@ -352,12 +352,12 @@ public class JSAstTranslator extends AstTranslator {
JavaScriptTypes.Root); JavaScriptTypes.Root);
context.cfg() context.cfg()
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(result, ref, fieldRef)); .addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, fieldRef));
} else { } else {
context.cfg() context.cfg()
.addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(result, ref, getValue(f))); .addInstruction(((JSInstructionFactory)insts).IsDefinedInstruction(context.cfg().getCurrentInstruction(), result, ref, getValue(f)));
} }
} }
@ -378,7 +378,7 @@ public class JSAstTranslator extends AstTranslator {
visit(n.getChild(1), context, visitor); visit(n.getChild(1), context, visitor);
int type = getValue(n.getChild(1)); int type = getValue(n.getChild(1));
context.cfg().addInstruction(new JavaScriptInstanceOf(result, value, type)); context.cfg().addInstruction(new JavaScriptInstanceOf(context.cfg().getCurrentInstruction(), result, value, type));
} }
protected void doPrologue(WalkContext context) { protected void doPrologue(WalkContext context) {
@ -388,7 +388,7 @@ public class JSAstTranslator extends AstTranslator {
CAstSymbol args = new CAstSymbolImpl("arguments"); CAstSymbol args = new CAstSymbolImpl("arguments");
context.currentScope().declare(args, tempVal); context.currentScope().declare(args, tempVal);
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).PutInstruction(1, tempVal, "arguments")); ((JSInstructionFactory)insts).PutInstruction(context.cfg().getCurrentInstruction(), 1, tempVal, "arguments"));
} }
protected boolean doVisit(CAstNode n, Context cntxt, CAstVisitor visitor) { protected boolean doVisit(CAstNode n, Context cntxt, CAstVisitor visitor) {
@ -401,7 +401,7 @@ public class JSAstTranslator extends AstTranslator {
int ref = getValue(n.getChild(0)); int ref = getValue(n.getChild(0));
context.cfg().addInstruction( context.cfg().addInstruction(
((JSInstructionFactory)insts).TypeOfInstruction(result, ref)); ((JSInstructionFactory)insts).TypeOfInstruction(context.cfg().getCurrentInstruction(), result, ref));
setValue(n, result); setValue(n, result);
return true; return true;
@ -413,7 +413,7 @@ public class JSAstTranslator extends AstTranslator {
this.visit(n.getChild(0), context, this); this.visit(n.getChild(0), context, this);
int ref = getValue(n.getChild(0)); int ref = getValue(n.getChild(0));
context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(ref, n.getKind()==JavaScriptCAstNode.ENTER_WITH)); context.cfg().addInstruction(((JSInstructionFactory)insts).WithRegion(context.cfg().getCurrentInstruction(), ref, n.getKind()==JavaScriptCAstNode.ENTER_WITH));
return true; return true;
} }