X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=Mate%2FGarbageAlloc.hs;h=617e571ba6d1407d7ad99200e4724478b94a6a6d;hb=dc7082de1fff3158da5682d683502128b5f6cc0b;hp=dc806b7418a99a90ab10fe3f5f1a77baacf4ca3f;hpb=e86237a8a051d37d42be21d469c36aacf8a86e8f;p=mate.git diff --git a/Mate/GarbageAlloc.hs b/Mate/GarbageAlloc.hs index dc806b7..617e571 100644 --- a/Mate/GarbageAlloc.hs +++ b/Mate/GarbageAlloc.hs @@ -1,22 +1,19 @@ {-# LANGUAGE ForeignFunctionInterface #-} -{-# LANGUAGE CPP #-} -#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 import Mate.GC.Boehm ---import Text.Printf import Mate.Debug -- unified place for allocating Memory @@ -24,32 +21,35 @@ import Mate.Debug mallocClassData :: Int -> IO (Ptr a) mallocClassData size = do - printfStr "mallocClassData: %d\n" size + printfStr $ printf "mallocClassData: %d\n" size mem <- mallocBytes size addRootGC mem (plusPtr mem size) return mem -mallocString :: Int -> IO (Ptr a) -mallocString size = do - printfStr "mallocString: %d\n" size +mallocStringGC :: Int -> IO (Ptr a) +mallocStringGC size = do + printfStr $ printf "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 + printfStr $ printf "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 $ printf "mallocObjectUnmanged: %d\n" size return $ fromIntegral $ ptrToIntPtr ptr +mallocStringUnmanaged :: Int -> IO (Ptr a) +mallocStringUnmanaged size = do + printfStr $ printf "mallocStringUnamaged: %d\n" size + mallocBytes size + + getHeapMemory :: IO Int getHeapMemory = getHeapSizeGC