From: megacz Date: Fri, 30 Jan 2004 07:41:33 +0000 (+0000) Subject: 2003/11/16 10:21:07 X-Git-Tag: RC3~344 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=785dcda35c460163595f2c05c0a955ce1b9f6221;p=org.ibex.core.git 2003/11/16 10:21:07 darcs-hash:20040130074133-2ba56-d8e2a6a3a87b40d5732e4d8e92b52de785e02f1e.gz --- diff --git a/src/org/xwt/mips/Compiler.java b/src/org/xwt/mips/Compiler.java index 80d127c..37735b1 100644 --- a/src/org/xwt/mips/Compiler.java +++ b/src/org/xwt/mips/Compiler.java @@ -28,15 +28,12 @@ public class Compiler implements Registers { // a FaultException will be throw which is easier to catch and deal with, however. as the name implies, this is slower private static boolean fastMem = true; - // This MUST be a power of two. If it is not horrible things will happen + // log_2 of the maximum bytes per method // NOTE: This value can be much higher without breaking the classfile // specs (around 1024) but Hotstop seems to do much better with smaller // methods. - private static int MAX_INSN_PER_METHOD = 32; - - // Don't touch this - private static int MAX_BYTES_PER_METHOD = MAX_INSN_PER_METHOD*4; - private static int METHOD_MASK = ~(MAX_BYTES_PER_METHOD-1); + private static int LOG_MAX_BYTES_PER_METHOD = 9; + private static int MAX_BYTES_PER_METHOD = 512; // Store frequently used registers in local variables // Unfortunately this doesn't seem to speed things up much @@ -198,7 +195,7 @@ public class Compiler implements Registers { p(" private final void trampoline() throws ExecutionException {"); p(" boolean finished = false;"); p(" while(!finished) {"); - p(" switch(this.pc & " + toHex(~(MAX_BYTES_PER_METHOD-1)) + ") {"); + p(" switch(this.pc >> " + LOG_MAX_BYTES_PER_METHOD + ") {"); p(runs.toString()); p(" default: throw new Error(\"invalid address 0x\" + Long.toString(this.pc&0xffffffffL,16));"); p(" }"); @@ -212,9 +209,9 @@ public class Compiler implements Registers { private static void startMethod(int addr) { addr &= ~(MAX_BYTES_PER_METHOD-1); - endOfMethod = addr + MAX_BYTES_PER_METHOD; + endOfMethod= addr + MAX_BYTES_PER_METHOD; String methodName = "run_" + Long.toString(addr & 0xffffffffL, 16); - runs.append(indents[4] + "case " + toHex(addr) + ": finished = !" + methodName + "(); break;\n"); + runs.append(indents[4] + "case " + toHex(addr>>LOG_MAX_BYTES_PER_METHOD) + ": finished = !" + methodName + "(); break;\n"); p("private final boolean " + methodName + "() throws ExecutionException { /"+"* " + toHex(addr) + " - " + toHex(endOfMethod) + " *" + "/"); indent++; p("int addr, tmp;"); @@ -222,7 +219,7 @@ public class Compiler implements Registers { p("int " + freqRegs[i] + " = this." + freqRegs[i] + ";"); p("for(;;) {"); indent++; - p("switch(pc) {"); + p("switch(pc>>2) {"); indent++; startOfMethod = addr; @@ -231,7 +228,7 @@ public class Compiler implements Registers { private static void endMethod(int lastAddr) { if(startOfMethod == 0) return; // This isn't strictly necessary; its just here to work around unreachable code errors - p("case " + toHex(lastAddr) + ":"); + p("case " + toHex(lastAddr>>2) + ":"); indent++; p("pc=" + toHex(lastAddr) + ";"); leaveMethod(); @@ -254,7 +251,7 @@ public class Compiler implements Registers { if(debugCompiler) p("lastPC = " + toHex(pc) + ";"); p("pc=" + toHex(target) + ";"); - if((pc&METHOD_MASK) == (target&METHOD_MASK)) + if((pc>>LOG_MAX_BYTES_PER_METHOD) == (target>>LOG_MAX_BYTES_PER_METHOD)) p("continue;"); else leaveMethod(); @@ -281,7 +278,7 @@ public class Compiler implements Registers { nextInsn = (i == count-1) ? -1 : dis.readInt(); if(addr >= endOfMethod) { endMethod(); startMethod(addr); } if(jumpableAddresses==null || addr == startOfMethod || jumpableAddresses.contains(new Integer(addr))) { - p("case " + toHex(addr) + ":"); + p("case " + toHex(addr>>2) + ":"); unreachable = false; } else if(unreachable) { continue;