* src/vmcore/rt-timing.c: Added rt-timing for heap allocation time.
[cacao.git] / src / mm / cacao-gc / heap.c
index 64fea491ae1b53bcea7cecd7ca9494d6fd74aaab..9424bc62e657c63d290ccb99919e4c9d4ff1d83a 100644 (file)
@@ -42,6 +42,7 @@
 #include "src/native/include/java_lang_String.h" /* TODO: fix me! */
 #include "toolbox/logging.h"
 #include "vm/global.h"
+#include "vmcore/rt-timing.h"
 
 
 /* Global Variables ***********************************************************/
@@ -206,6 +207,11 @@ static java_objectheader *heap_alloc_intern(u4 bytelength, regioninfo_t *region)
 void *heap_allocate(u4 bytelength, u4 references, methodinfo *finalizer)
 {
        java_objectheader *p;
+#if defined(ENABLE_RT_TIMING)
+       struct timespec time_start, time_end;
+#endif
+
+       RT_TIMING_GET_TIME(time_start);
 
        p = heap_alloc_intern(bytelength, heap_region_main);
 
@@ -232,6 +238,9 @@ void *heap_allocate(u4 bytelength, u4 references, methodinfo *finalizer)
                final_register(p, finalizer);
        }
 
+       RT_TIMING_GET_TIME(time_end);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
+
        return p;
 }