X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FClassFileCompiler.java;h=bcd069e22c06663fd61db33feccb27f3b08f1a8c;hp=0f0b418f210489ce34f9bc9d0de67377ecabb6ed;hb=e289c033a45055578e162c220a2bfb48c19dbc13;hpb=ad692a248f2ed9412db5b313b85fd8365488017f diff --git a/src/org/ibex/nestedvm/ClassFileCompiler.java b/src/org/ibex/nestedvm/ClassFileCompiler.java index 0f0b418..bcd069e 100644 --- a/src/org/ibex/nestedvm/ClassFileCompiler.java +++ b/src/org/ibex/nestedvm/ClassFileCompiler.java @@ -1,6 +1,8 @@ package org.ibex.nestedvm; import java.io.*; +import java.util.Hashtable; + import org.ibex.nestedvm.util.*; import org.apache.bcel.generic.*; @@ -45,7 +47,7 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const // Handy wrappers around the BCEL functions private InstructionList insnList; - private void selectMethod(MethodGen m) { insnList = m.getInstructionList(); } + private void selectMethod(MethodGen m) { insnList = m.getInstructionList(); } private void selectList(InstructionList l) { insnList = l; } private InstructionHandle a(Instruction i) { return insnList.append(i); } private BranchHandle a(BranchInstruction i) { return insnList.append(i); } @@ -151,11 +153,11 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const int end = ((text.addr + text.size) >>> methodShift); // This data is redundant but BCEL wants it - int[] matches = new int[end-beg]; - for(int i=beg;i R && reg < R+32) field="r"+(reg-R); - else if(reg >= F && reg < F+32) field="f"+(reg-F); + if(reg > R && reg < R+32) regFieldR[reg-R]; + else if(reg >= F && reg < F+32) return regFieldF[ else throw new IllegalArgumentException(""+reg); } - return field; + return field;*/ } private boolean doLocal(int reg) { @@ -1953,9 +1959,12 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const return h; } + private Hashtable intCache = new Hashtable(); + private InstructionHandle pushConst(int n) { - if(n >= 0 && n <= 5) { + if(n >= -1 && n <= 5) { switch(n) { + case -1: return a(InstructionConstants.ICONST_M1); case 0: return a(InstructionConstants.ICONST_0); case 1: return a(InstructionConstants.ICONST_1); case 2: return a(InstructionConstants.ICONST_2); @@ -1964,8 +1973,6 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const case 5: return a(InstructionConstants.ICONST_5); default: return null; } - } else if(n == -1) { - return a(InstructionConstants.ICONST_M1); } else if(n >= -128 && n <= 127) { return a(new BIPUSH((byte) n)); } else if(n >= -32768 && n <= 32767) {