codegen: print every jvm instruction as label in disasm output
authorBernhard Urban <lewurm@gmail.com>
Wed, 13 Jun 2012 14:37:56 +0000 (16:37 +0200)
committerBernhard Urban <lewurm@gmail.com>
Wed, 13 Jun 2012 22:09:46 +0000 (00:09 +0200)
Mate/X86CodeGen.hs
tests/WhileArray1.java

index 2b820b6379274638ebf5f6c8a93042e3144c0dcd..d895d63991857363ade7bfc903435f241630d6f8 100644 (file)
@@ -74,7 +74,7 @@ emitFromBB method sig cls hmap =  do
           bb_offset <- getCodeOffset
           let bbstarts' = M.insert bid bb_offset bbstarts
           defineLabel $ getLabel bid lmap
-          cs <- mapM emit' $ code bb
+          cs <- mapM emit'' $ code bb
           let calls' = calls `M.union` M.fromList (catMaybes cs)
           case successor bb of
             Return -> return (calls', bbstarts')
@@ -123,6 +123,9 @@ emitFromBB method sig cls hmap =  do
         let imm8 = is8BitOffset offset
         return $ Just (calladdr + (if imm8 then 3 else 6), trapcause imm8)
 
+    emit'' :: J.Instruction -> CodeGen e s (Maybe (Word32, TrapCause))
+    emit'' insn = newNamedLabel ("jvm_insn: " ++ show insn) >>= defineLabel >> emit' insn
+
     emit' :: J.Instruction -> CodeGen e s (Maybe (Word32, TrapCause))
     emit' (INVOKESPECIAL cpidx) = emitInvoke cpidx True
     emit' (INVOKESTATIC cpidx) = emitInvoke cpidx False
index 912d0434892e989543288f93d9c19f760960c645..f652a5c516754d3fcb44b44040c719d8b55c3c97 100644 (file)
@@ -1,28 +1,30 @@
 package tests;
 
 public class WhileArray1 {
+       public char arr[] = new char[10];
+
        public static void main(String args[]) {
-               char a[] = new char[10];
-               char b[] = new char[10];
+               WhileArray1 a = new WhileArray1();
+               WhileArray1 b = new WhileArray1();
                for (int i = 0; i < 10; i++) {
-                       a[i] = b[i] = (char) i;
+                       a.arr[i] = b.arr[i] = (char) i;
                }
-               System.out.printf("success? %d\n", equal(a, b, 5) ? 1 : 0);
+               System.out.printf("success? %d\n", equal(a, b, 10) ? 1 : 0);
 
                for (int i = 0; i < 10; i++) {
-                       b[i] = (char) i;
-                       a[i] = (char) (b[i] + 2);
+                       b.arr[i] = (char) i;
+                       a.arr[i] = (char) (b.arr[i] + 2);
                }
-               System.out.printf("success? %d\n", equal(a, b, 5) ? 1 : 0);
+               System.out.printf("success? %d\n", equal(a, b, 10) ? 1 : 0);
        }
 
-       public static boolean equal(char[] a, char[] b, int len) {
+       public static boolean equal(WhileArray1 a, WhileArray1 b, int len) {
                /* stolen from the equals implementation of java.lang.String of
                 * GNU Classpath */
                int x = 0, y = 0;
                while (--len >= 0) {
                        System.out.printf("idx: x: %d, y: %d\n", x, y);
-                       if (a[x++] != b[y++]) {
+                       if (a.arr[x++] != b.arr[y++]) {
                                return false;
                        }
                }