type BBStarts = M.Map BlockID Int
-type CompileInfo = (EntryPoint, BBStarts, Int, TMap)
+type CompileInfo = (EntryPoint, BBStarts, Int, TrapMap)
emitFromBB :: B.ByteString -> Class Resolved -> MapBB -> CodeGen e s (CompileInfo, [Instruction])
getLabel _ [] = error "label not found!"
getLabel i ((x,l):xs) = if i==x then l else getLabel i xs
- efBB :: (BlockID, BasicBlock) -> TMap -> BBStarts -> [(BlockID, Label)] -> CodeGen e s (TMap, BBStarts)
+ efBB :: (BlockID, BasicBlock) -> TrapMap -> BBStarts -> [(BlockID, Label)] -> CodeGen e s (TrapMap, BBStarts)
efBB (bid, bb) calls bbstarts lmap =
if M.member bid bbstarts then
return (calls, bbstarts)
emit' insn = emit insn >> return Nothing
emit :: J.Instruction -> CodeGen e s ()
- emit POP = do -- print dropped value
- calladdr <- getCurrentOffset
- -- '5' is the size of the `call' instruction ( + immediate)
- let w32_calladdr = 5 + calladdr
- let trapaddr = (fromIntegral getaddr :: Word32)
- call (trapaddr - w32_calladdr)
+ emit POP = do -- dropp value
add esp (4 :: Word32)
emit DUP = push (Disp 0, esp)
emit AASTORE = emit IASTORE
push eax -- push ref again
emit (NEW objidx) = do
let objname = buildClassID cls objidx
- amount <- liftIO $ getMethodSize objname
+ amount <- liftIO $ getObjectSize objname
push (amount :: Word32)
callMalloc
-- TODO(bernhard): save reference somewhere for GC