- mmap <- get_methodmap >>= ptr2mmap
- let newmap = M.fromList $ map (\x -> ((MethodInfo mmname x msig), entry)) clsnames
- mmap2ptr (mmap `M.union` newmap) >>= set_methodmap
-
-
-compileBB :: MapBB -> MethodInfo -> IO Word32
-compileBB hmap methodinfo = do
- tmap <- get_trapmap >>= ptr2tmap
-
- cls <- getClassFile (cName methodinfo)
- let ebb = emitFromBB (methName methodinfo) cls hmap
- (_, Right ((entry, _, _, new_tmap), disasm)) <- runCodeGen ebb () ()
-
- let tmap' = M.union tmap new_tmap -- prefers elements in cmap
- tmap2ptr tmap' >>= set_trapmap
-
- printf "disasm:\n"
- mapM_ (putStrLn . showAtt) disasm
- -- UNCOMMENT NEXT LINE FOR GDB FUN
- -- _ <- getLine
- -- (1) start it with `gdb ./mate' and then `run <classfile>'
- -- (2) on getLine, press ctrl+c
+ mmap <- getMethodMap
+ let newmap = foldr (\i -> M.insert (MethodInfo mmname i msig) entry) M.empty clsnames
+ setMethodMap $ mmap `M.union` newmap
+
+
+compileBB :: RawMethod -> MethodInfo -> IO Word32
+compileBB rawmethod methodinfo = do
+ tmap <- getTrapMap
+
+ cls <- getClassFile (methClassName methodinfo)
+ let ebb = emitFromBB (methName methodinfo) (methSignature methodinfo) cls rawmethod
+ (_, Right right) <- runCodeGen ebb () ()
+
+ let ((entry, _, _, new_tmap), _) = right
+ setTrapMap $ tmap `M.union` new_tmap -- prefers elements in tmap
+
+ printfJit "generated code of \"%s\" from \"%s\":\n" (toString $ methName methodinfo) (toString $ methClassName methodinfo)
+ printfJit "\tstacksize: 0x%04x, locals: 0x%04x\n" (rawStackSize rawmethod) (rawLocals rawmethod)
+ mapM_ (printfJit "%s\n" . showAtt) (snd right)
+ printfJit "\n\n"
+ -- UNCOMMENT NEXT LINES FOR GDB FUN
+ -- if (toString $ methName methodinfo) == "thejavamethodIwant2debug"
+ -- then putStrLn "press CTRL+C now for setting a breakpoint. then `c' and ENTER for continue" >> getLine
+ -- else return "foo"
+ -- (1) build a debug build (see HACKING) and execute `make tests/Fib.gdb'
+ -- for example, where the suffix is important
+ -- (2) on getLine, press CTRL+C