X-Git-Url: http://git.megacz.com/?p=org.ibex.classgen.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fclassgen%2FJSSA.java;h=2fc521ace03c227e2eec2ee45040f42d2af51988;hp=16af019a09d6d6ed757df99ae0fbdce7ad38d801;hb=7b7d64efd6761d48aabe652945e907e9309bccd0;hpb=4b586655926ec3807715ede09e642f050c336f79 diff --git a/src/org/ibex/classgen/JSSA.java b/src/org/ibex/classgen/JSSA.java index 16af019..2fc521a 100644 --- a/src/org/ibex/classgen/JSSA.java +++ b/src/org/ibex/classgen/JSSA.java @@ -13,32 +13,32 @@ public class JSSA extends MethodGen implements CGConst { public JSSA(Type.Class c, DataInput in, ConstantPool cp) throws IOException { super(c, in, cp); - locals = new Phi[size()][maxLocals]; - stacks = new Phi[size()][maxStack]; - sps = new int [size()]; - sps[0] = 0; - int n=0; - locals[0] = new Phi[maxLocals]; - if (!isStatic()) - locals[0][n++] = phi(new Argument("this",method.getDeclaringClass())); - for(int i=0;i>"; } } public class New extends Expr { @@ -385,17 +440,6 @@ public class JSSA extends MethodGen implements CGConst { } } - public class Return extends Op { - final Expr e; - public Return() { this(VOID_EXPR); } - public Return(Expr e) { - this.e = e; - if (Type.unify(method.getReturnType(),e.getType()) != method.getReturnType()) - throw new IllegalArgumentException("type mismatch"); - } - public String toString() { return e.getType() == Type.VOID ? "return" : ("return "+e.toString()); } - } - /** GETFIELD and GETSTATIC */ public class Get extends Expr { final Type.Class.Field f; @@ -534,6 +578,8 @@ public class JSSA extends MethodGen implements CGConst { i1 = p.i1; i2 = p.i2; } + if (arg instanceof Number) i1 = ((Integer)arg).intValue(); + Label label = (arg instanceof Label) ? (Label)arg : null; switch(op) { case NOP: return null; @@ -565,8 +611,8 @@ public class JSSA extends MethodGen implements CGConst { locals[pc+1][3].merge(pop()); return null; case POP: pop(); return null; case POP2: pop(); pop(); return null; - case DUP: push(stacks[pc][sps[pc]-1]); return null; - case DUP2: push(stacks[pc][sps[pc]-2]); push(stacks[pc][sps[pc]-1]); return null; + case DUP: push(stack[sp-1]); return null; + case DUP2: push(stack[sp-2]); push(stack[sp-1]); return null; // Conversions ////////////////////////////////////////////////////////////////////////////// @@ -600,27 +646,27 @@ public class JSSA extends MethodGen implements CGConst { // Control and branching ////////////////////////////////////////////////////////////////////////////// - case IFNULL: return new Branch(new Eq(pop(), new Constant(null)), new Label(i1)); - case IFNONNULL: return new Branch(new Not(new Eq(pop(),new Constant(null))),new Label(i1)); - case IFEQ: return new Branch( new Eq(new Constant(0), pop()), arg); - case IFNE: return new Branch(new Not(new Eq(new Constant(0), pop())), arg); - case IFLT: return new Branch( new Lt(new Constant(0), pop()), arg); - case IFGE: return new Branch(new Not(new Lt(new Constant(0), pop())), arg); - case IFGT: return new Branch( new Gt(new Constant(0), pop()), arg); - case IFLE: return new Branch(new Not(new Gt(new Constant(0), pop())), arg); - case IF_ICMPEQ: return new Branch( new Eq(pop(), pop()), arg); - case IF_ICMPNE: return new Branch(new Not(new Eq(pop(), pop())), arg); - case IF_ICMPLT: return new Branch( new Lt(pop(), pop()), arg); - case IF_ICMPGE: return new Branch(new Not(new Lt(pop(), pop())), arg); - case IF_ICMPGT: return new Branch( new Gt(pop(), pop()), arg); - case IF_ICMPLE: return new Branch(new Not(new Gt(pop(), pop())), arg); - case IF_ACMPEQ: return new Branch( new Eq(pop(), pop()), arg); - case IF_ACMPNE: return new Branch(new Not(new Eq(pop(), pop())), arg); - case ATHROW: return new Throw(pop()); - case GOTO: return new Branch(new Label(i1)); - case JSR: return new JSR(new Label(i1)); - case RET: return new RET(); - case RETURN: return new Return(); + case IFNULL: return new If(new Eq(pop(), new Constant(null)), new Label(i1)); + case IFNONNULL: return new If(new Not(new Eq(pop(),new Constant(null))),new Label(i1)); + case IFEQ: return new If( new Eq(new Constant(0), pop()), new Label(i1)); + case IFNE: return new If(new Not(new Eq(new Constant(0), pop())), new Label(i1)); + case IFLT: return new If( new Lt(new Constant(0), pop()), new Label(i1)); + case IFGE: return new If(new Not(new Lt(new Constant(0), pop())), new Label(i1)); + case IFGT: return new If( new Gt(new Constant(0), pop()), new Label(i1)); + case IFLE: return new If(new Not(new Gt(new Constant(0), pop())), new Label(i1)); + case IF_ICMPEQ: return new If( new Eq(pop(), pop()), new Label(i1)); + case IF_ICMPNE: return new If(new Not(new Eq(pop(), pop())), new Label(i1)); + case IF_ICMPLT: return new If( new Lt(pop(), pop()), new Label(i1)); + case IF_ICMPGE: return new If(new Not(new Lt(pop(), pop())), new Label(i1)); + case IF_ICMPGT: return new If( new Gt(pop(), pop()), new Label(i1)); + case IF_ICMPLE: return new If(new Not(new Gt(pop(), pop())), new Label(i1)); + case IF_ACMPEQ: return new If( new Eq(pop(), pop()), new Label(i1)); + case IF_ACMPNE: return new If(new Not(new Eq(pop(), pop())), new Label(i1)); + case ATHROW: return new Throw(pop()); + case GOTO: return new Goto(locals[pc][i1]); + case JSR: push(new Label(pc)); return new JSR(new Label(i1)); + case RET: return new RET(pop()); + case RETURN: return new Return(); case IRETURN: case LRETURN: case FRETURN: case DRETURN: case ARETURN: return new Return(pop());