From 120517704ac01a6d957b1904d63ab707a0c4ee95 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Fri, 17 Aug 2012 19:21:45 +0200 Subject: [PATCH] codegen: approx. initial codebuffer size according to codesize @ bytecode --- Mate/BasicBlocks.hs | 3 ++- Mate/MethodPool.hs | 3 ++- Mate/Types.hs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Mate/BasicBlocks.hs b/Mate/BasicBlocks.hs index 996c672..955f4f5 100644 --- a/Mate/BasicBlocks.hs +++ b/Mate/BasicBlocks.hs @@ -100,6 +100,7 @@ parseMethod cls methodname sig = do let mapbb = testCFG decoded let locals = fromIntegral (codeMaxLocals decoded) let stacks = fromIntegral (codeStackSize decoded) + let codelen = fromIntegral (codeLength decoded) let methoddirect = methodInfoToMethod (MethodInfo methodname "" sig) cls let isStatic = methodIsStatic methoddirect let nametype = methodNameType methoddirect @@ -119,7 +120,7 @@ parseMethod cls methodname sig = do printfBb "exception: no handler for this method\n" Just exceptionstream -> printfBb "exception: \"%s\"\n" (show $ codeExceptions $ decodeMethod exceptionstream) - return $ RawMethod mapbb locals stacks argscount + return $ RawMethod mapbb locals stacks argscount codelen testCFG :: Code -> MapBB diff --git a/Mate/MethodPool.hs b/Mate/MethodPool.hs index c8cb084..5a0f70e 100644 --- a/Mate/MethodPool.hs +++ b/Mate/MethodPool.hs @@ -136,7 +136,8 @@ compileBB rawmethod methodinfo = do cls <- getClassFile (methClassName methodinfo) let ebb = emitFromBB cls rawmethod - (_, Right right) <- runCodeGen ebb () () + let cgconfig = defaultCodeGenConfig { codeBufferSize = fromIntegral $ (rawCodeLength rawmethod) * 32 } + (_, Right right) <- runCodeGenWithConfig ebb () () cgconfig let ((entry, _, _, new_tmap), _) = right setTrapMap $ tmap `M.union` new_tmap -- prefers elements in tmap diff --git a/Mate/Types.hs b/Mate/Types.hs index b1fc6de..0fe838e 100644 --- a/Mate/Types.hs +++ b/Mate/Types.hs @@ -30,7 +30,8 @@ data RawMethod = RawMethod { rawMapBB :: MapBB, rawLocals :: Int, rawStackSize :: Int, - rawArgCount :: NativeWord } + rawArgCount :: NativeWord, + rawCodeLength :: NativeWord } -- NativeWord = point of method call in generated code -- 2.25.1