traps: do more things in haskell world
[mate.git] / Mate / X86CodeGen.hs
index 893a397e8e084f897d83f924eaf7be333a5a0f6d..1b4ef954ce9def82da78439b50be1e3c5fa27352 100644 (file)
@@ -36,10 +36,6 @@ foreign import ccall "dynamic"
 foreign import ccall "getMallocObjectAddr"
   getMallocObjectAddr :: CUInt
 
-foreign import ccall "register_signal"
-  register_signal :: IO ()
-
-
 type EntryPoint = Ptr Word8
 type EntryPointOffset = Int
 type PatchInfo = (BlockID, EntryPointOffset)
@@ -110,7 +106,8 @@ emitFromBB method cls hmap =  do
         when (argcnt > 0) (add esp argcnt)
         -- push result on stack if method has a return value
         when (methodHaveReturnValue cls cpidx) (push eax)
-        return $ Just (calladdr, MI l)
+        -- +2 is for correcting eip in trap context
+        return $ Just (calladdr + 2, MI l)
 
     emit' :: J.Instruction -> CodeGen e s (Maybe (Word32, TrapInfo))
     emit' (INVOKESPECIAL cpidx) = emitInvoke cpidx True