X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FClassFileCompiler.java;h=2dec150f4a0a8fbe35ac27642007f4a13eda1d99;hp=b799beba6ff0c4cddeb4d2ec37f16644a81b7707;hb=8eb5962b879977e1a7975f9077c9ac86859deb48;hpb=f09bb94fa4801c2b38ee572f025963051d5bc3fa diff --git a/src/org/ibex/nestedvm/ClassFileCompiler.java b/src/org/ibex/nestedvm/ClassFileCompiler.java index b799beb..2dec150 100644 --- a/src/org/ibex/nestedvm/ClassFileCompiler.java +++ b/src/org/ibex/nestedvm/ClassFileCompiler.java @@ -1,10 +1,13 @@ package org.ibex.nestedvm; import java.io.*; +import java.util.Hashtable; + import org.ibex.nestedvm.util.*; import org.apache.bcel.generic.*; +// FEATURE: Use IINC where possible // FEATURE: Use BCEL to do peephole optimization // FEATURE: Special mode to support single-precision only - regs are floats not ints @@ -148,14 +151,14 @@ public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const a(InstructionConstants.IUSHR); int beg = text.addr >>> methodShift; - int end = ((text.addr + text.size) >>> methodShift); + int end = ((text.addr + text.size + maxBytesPerMethod - 1) >>> methodShift); // This data is redundant but BCEL wants it - int[] matches = new int[end-beg+1]; - for(int i=beg;i<=end;i++) matches[i-beg] = i; + 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) { @@ -1941,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); @@ -1952,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) {