i.e. the number of bytes to allocate for field members of the object.
... not the amount of (virtual) methods this object has.
what an ugly bug :-(
getClassInfo,
getClassFile,
getMethodTable,
getClassInfo,
getClassFile,
getMethodTable,
getMethodOffset,
getFieldOffset,
getStaticFieldAddr
getMethodOffset,
getFieldOffset,
getStaticFieldAddr
ci <- getClassInfo path
return $ ciMethodBase ci
ci <- getClassInfo path
return $ ciMethodBase ci
-getMethodSize :: B.ByteString -> IO (Word32)
-getMethodSize path = do
+getObjectSize :: B.ByteString -> IO (Word32)
+getObjectSize path = do
ci <- getClassInfo path
-- TODO(bernhard): correct sizes for different types...
ci <- getClassInfo path
-- TODO(bernhard): correct sizes for different types...
- let msize = fromIntegral $ M.size $ ciMethodMap ci
- return $ (1 + msize) * 4
+ let fsize = fromIntegral $ M.size $ ciFieldMap ci
+ -- one slot for "method-table-ptr"
+ return $ (1 + fsize) * 4
foreign export ccall getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt
getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt
foreign export ccall getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt
getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt
push eax -- push ref again
emit (NEW objidx) = do
let objname = buildClassID cls objidx
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
push (amount :: Word32)
callMalloc
-- TODO(bernhard): save reference somewhere for GC