* Merged with default branch at rev 16f3633aaa5a.
[cacao.git] / src / mm / boehm.c
index bae18f2b59ea148845ea3d7ac8f01d41c5a415f7..c4f6a18b8ce2e56ac4973f538a52061845d16073 100644 (file)
@@ -50,6 +50,7 @@
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
+#include "vmcore/rt-timing.h"
 
 
 /* global variables ***********************************************************/
@@ -113,37 +114,42 @@ static void gc_ignore_warnings(char *msg, GC_word arg)
 }
 
 
-void *heap_alloc_uncollectable(u4 bytelength)
+void *heap_alloc_uncollectable(u4 size)
 {
        void *p;
 
-       p = GC_MALLOC_UNCOLLECTABLE(bytelength);
+       p = GC_MALLOC_UNCOLLECTABLE(size);
 
        /* clear allocated memory region */
 
-       MSET(p, 0, u1, bytelength);
+       MSET(p, 0, u1, size);
 
        return p;
 }
 
 
-/* heap_allocate ***************************************************************
+/* heap_alloc ******************************************************************
 
    Allocates memory on the Java heap.
 
 *******************************************************************************/
 
-void *heap_allocate(u4 bytelength, u4 references, methodinfo *finalizer)
+void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
 {
        void *p;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
 
        /* We can't use a bool here for references, as it's passed as a
           bitmask in builtin_new.  Thus we check for != 0. */
 
        if (references != 0)
-               p = GC_MALLOC(bytelength);
+               p = GC_MALLOC(size);
        else
-               p = GC_MALLOC_ATOMIC(bytelength);
+               p = GC_MALLOC_ATOMIC(size);
 
        if (p == NULL)
                return NULL;
@@ -153,7 +159,10 @@ void *heap_allocate(u4 bytelength, u4 references, methodinfo *finalizer)
 
        /* clear allocated memory region */
 
-       MSET(p, 0, u1, bytelength);
+       MSET(p, 0, u1, size);
+
+       RT_TIMING_GET_TIME(time_end);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
 
        return p;
 }