GarbageAlloc: little refactoring - all GC allocate methods should have GC suffix...
authorHarald Steinlechner <haraldsteinlechner@gmail.com>
Fri, 24 Aug 2012 13:03:27 +0000 (15:03 +0200)
committerHarald Steinlechner <haraldsteinlechner@gmail.com>
Fri, 24 Aug 2012 13:03:27 +0000 (15:03 +0200)
Mate/GarbageAlloc.hs
Mate/Strings.hs
Mate/X86CodeGen.hs
tools/installBoehm.sh [new file with mode: 0755]

index dc806b7418a99a90ab10fe3f5f1a77baacf4ca3f..c2b622c95f1b6f2f601cbcbbdb6cf3d90a583724 100644 (file)
@@ -3,13 +3,13 @@
 #include "debug.h"
 module Mate.GarbageAlloc(
     mallocClassData,
-    mallocString,
-    mallocObject,
+    mallocStringGC,
+    mallocObjectGC,
     getHeapMemory,
     printMemoryUsage,
-    mallocStringVM,
-    mallocObjectVM,
-    printGCStats)  where
+    printGCStats,
+    mallocObjectUnmanaged,
+    mallocStringUnmanaged)  where
 
 import Foreign
 import Foreign.C
@@ -29,27 +29,30 @@ mallocClassData size = do
   addRootGC mem (plusPtr mem size)
   return mem
 
-mallocString :: Int -> IO (Ptr a)
-mallocString size = do
+mallocStringGC :: Int -> IO (Ptr a)
+mallocStringGC size = do
   printfStr "mallocString: %d\n" size
   mallocBytesGC size
 
-mallocStringVM :: Int -> IO (Ptr a)
-mallocStringVM = mallocBytes
-
-foreign export ccall mallocObject :: Int -> IO CPtrdiff
-mallocObject :: Int -> IO CPtrdiff
-mallocObject size = do
+foreign export ccall mallocObjectGC :: Int -> IO CPtrdiff
+mallocObjectGC :: Int -> IO CPtrdiff
+mallocObjectGC size = do
   ptr <- mallocBytesGC size
   printfStr "mallocObject: %d\n" size
   return $ fromIntegral $ ptrToIntPtr ptr
 
-mallocObjectVM :: Int -> IO CPtrdiff
-mallocObjectVM size = do
+mallocObjectUnmanaged :: Int -> IO CPtrdiff
+mallocObjectUnmanaged size = do
   ptr <- mallocBytes size
-  printfStr "mallocObject VM: %d\n" size
+  printfStr "mallocObjectUnmanged: %d\n" size
   return $ fromIntegral $ ptrToIntPtr ptr
 
+mallocStringUnmanaged :: Int -> IO (Ptr a)
+mallocStringUnmanaged size = do
+  printfStr "mallocStringUnamaged: %d\n" size
+  mallocBytes size
+
+
 getHeapMemory :: IO Int
 getHeapMemory = getHeapSizeGC
 
index e5f0fd99f21de81003b2f91b5bd43368f11e4f19..2f7504ac2aa4a24daf2db17fb1081273b49004a9 100644 (file)
@@ -57,7 +57,7 @@ allocateJavaString str = do
   -- build object layout
   fsize <- getObjectSize "java/lang/String"
   printfStr "string: fsize: %d (should be 4 * 5)\n" fsize
-  tblptr <- mallocObjectVM $ fromIntegral fsize
+  tblptr <- mallocObjectUnmanaged $ fromIntegral fsize
   let ptr = intPtrToPtr (fromIntegral tblptr) :: Ptr CPtrdiff
   mtbl <- getMethodTable "java/lang/String"
   poke ptr $ fromIntegral mtbl
@@ -65,7 +65,7 @@ allocateJavaString str = do
   -- build array layout
   let strlen = fromIntegral $ B.length str
   -- (+1) for \0, (+4) for length
-  newstr <- mallocStringVM (strlen + 5)
+  newstr <- mallocStringUnmanaged (strlen + 5) --[TODO hs,bernhard: should be managed right?]
   BI.memset newstr 0 (fromIntegral $ strlen + 5)
   arr <- newArray ((map fromIntegral $ B.unpack str) :: [Word8])
   copyBytes (plusPtr newstr 4) arr strlen
index 68cc70eb185ff9a939cc9c920a117675cdc1131b..40b826214bb7dc0561a8bf8f53b742f8e909cf89 100644 (file)
@@ -35,7 +35,7 @@ import Text.Printf
 #endif
 
 
-foreign import ccall "&mallocObject"
+foreign import ccall "&mallocObjectGC"
   mallocObjectAddr :: FunPtr (Int -> IO CPtrdiff)
 
 type EntryPoint = Ptr Word8
diff --git a/tools/installBoehm.sh b/tools/installBoehm.sh
new file mode 100755 (executable)
index 0000000..9e3fedc
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash -x
+git clone git://wien.tomnetworks.com/hs-boehmgc.git hs-boehmgc
+cd hs-boehmgc
+runhaskell Setup.hs configure --user $CABAL_OPT
+runhaskell Setup.hs build 
+runhaskell Setup.hs install
+cd ..
+echo DONE