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=1220b34698c37843122a5e0899b623e8b9c91b20;hb=7b7d64efd6761d48aabe652945e907e9309bccd0;hpb=5ab1e745d06879276d00ff6bf3438e8dd3edd85c diff --git a/src/org/ibex/classgen/JSSA.java b/src/org/ibex/classgen/JSSA.java index 1220b34..2fc521a 100644 --- a/src/org/ibex/classgen/JSSA.java +++ b/src/org/ibex/classgen/JSSA.java @@ -37,6 +37,7 @@ public class JSSA extends MethodGen implements CGConst { ops[numOps] = o; ofs[numOps++] = pc; } + if (o!=null && o instanceof Branch) ((Branch)o).branchTo(); if (o==null || (!(o instanceof Branch))) branchTo(pc+1); } catch(RuntimeException e) { System.err.println("Had a problem at PC: " + pc + " of " + method); @@ -47,12 +48,15 @@ public class JSSA extends MethodGen implements CGConst { } public void branchTo(int newPC) { + System.out.println("!!!branchTo("+newPC+")!!!"); if (stacks[newPC] == null) { stacks[newPC] = new Phi[sp]; for(int i=0; i>"; } } public class New extends Expr { @@ -547,6 +578,7 @@ 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) { @@ -614,26 +646,26 @@ 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()), label); - case IFNE: return new Branch(new Not(new Eq(new Constant(0), pop())), label); - case IFLT: return new Branch( new Lt(new Constant(0), pop()), label); - case IFGE: return new Branch(new Not(new Lt(new Constant(0), pop())), label); - case IFGT: return new Branch( new Gt(new Constant(0), pop()), label); - case IFLE: return new Branch(new Not(new Gt(new Constant(0), pop())), label); - case IF_ICMPEQ: return new Branch( new Eq(pop(), pop()), label); - case IF_ICMPNE: return new Branch(new Not(new Eq(pop(), pop())), label); - case IF_ICMPLT: return new Branch( new Lt(pop(), pop()), label); - case IF_ICMPGE: return new Branch(new Not(new Lt(pop(), pop())), label); - case IF_ICMPGT: return new Branch( new Gt(pop(), pop()), label); - case IF_ICMPLE: return new Branch(new Not(new Gt(pop(), pop())), label); - case IF_ACMPEQ: return new Branch( new Eq(pop(), pop()), label); - case IF_ACMPNE: return new Branch(new Not(new Eq(pop(), pop())), label); + 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 Branch(locals[pc][i1]); - case JSR: push(new Label(pc+3)); return new JSR(new Label(pc+i1)); - case RET: return new RET(); + 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());