codegen: approx. initial codebuffer size according to codesize @ bytecode
authorBernhard Urban <lewurm@gmail.com>
Fri, 17 Aug 2012 17:21:45 +0000 (19:21 +0200)
committerBernhard Urban <lewurm@gmail.com>
Fri, 17 Aug 2012 17:12:57 +0000 (19:12 +0200)
Mate/BasicBlocks.hs
Mate/MethodPool.hs
Mate/Types.hs

index 996c6728aa92291c6c76910dc05c0d26226b6df0..955f4f51191d1eae16ebef98636f75d4a4a58a22 100644 (file)
@@ -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
index c8cb0848499f9ab74c4b1b828397c218b7037107..5a0f70e73605fa0e256cfcea9b925cbddd2d1520 100644 (file)
@@ -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
index b1fc6def65492c31543668631c7fcb5284a56063..0fe838e0edd9524f62fc186659ce75757402d296 100644 (file)
@@ -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