* src/vm/vm.c, src/vm/vm.h: Moved to .cpp.
[cacao.git] / src / mm / boehm.c
index 42f002b93a3494d25a429cad48d2bc1db7fc5c83..796f2ef2654d30a3b28de4296d01e1829c017b7e 100644 (file)
@@ -1,9 +1,7 @@
 /* src/mm/boehm.c - interface for boehm gc
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: boehm.c 8150 2007-06-27 18:35:40Z twisti $
-
 */
 
 
 #include "config.h"
-#include "vm/types.h"
+
+#include <stdint.h>
 
 #if defined(ENABLE_THREADS) && defined(__LINUX__)
 #define GC_LINUX_THREADS
 #if defined(ENABLE_THREADS) && defined(__IRIX__)
 #define GC_IRIX_THREADS
 #endif
+#if defined(ENABLE_THREADS) && defined(__DARWIN__)
+#define GC_DARWIN_THREADS
+#endif
 
 #include "boehm-gc/include/gc.h"
-#include "mm/gc-common.h"
+#include "mm/gc.hpp"
 #include "mm/memory.h"
 
 #include "toolbox/logging.h"
 #include "vm/finalizer.h"
 #include "vm/global.h"
 #include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
+#include "vmcore/rt-timing.h"
 
 
 /* global variables ***********************************************************/
@@ -70,10 +71,12 @@ static void gc_ignore_warnings(char *msg, GC_word arg);
 
 *******************************************************************************/
 
-void gc_init(u4 heapmaxsize, u4 heapstartsize)
+void gc_init(size_t heapmaxsize, size_t heapstartsize)
 {
        size_t heapcurrentsize;
 
+       TRACESUBSYSTEMINITIALIZATION("gc_init");
+
        /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */
 
        GC_java_finalization = 1;
@@ -115,47 +118,55 @@ static void gc_ignore_warnings(char *msg, GC_word arg)
 }
 
 
-void *heap_alloc_uncollectable(u4 bytelength)
+void *heap_alloc_uncollectable(size_t 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, uint8_t, 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(size_t size, int 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;
 
        if (finalizer != NULL)
-               GC_REGISTER_FINALIZER(p, finalizer_run, 0, 0, 0);
+               GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0);
 
        /* clear allocated memory region */
 
-       MSET(p, 0, u1, bytelength);
+       MSET(p, 0, uint8_t, size);
+
+       RT_TIMING_GET_TIME(time_end);
+       RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
 
        return p;
 }
@@ -176,13 +187,13 @@ void gc_call(void)
 }
 
 
-s8 gc_get_heap_size(void)
+int64_t gc_get_heap_size(void)
 {
        return GC_get_heap_size();
 }
 
 
-s8 gc_get_free_bytes(void)
+int64_t gc_get_free_bytes(void)
 {
        return GC_get_free_bytes();
 }
@@ -194,13 +205,13 @@ s8 gc_get_free_bytes(void)
 
 *******************************************************************************/
 
-s8 gc_get_total_bytes(void)
+int64_t gc_get_total_bytes(void)
 {
        return GC_get_total_bytes();
 }
 
 
-s8 gc_get_max_heap_size(void)
+int64_t gc_get_max_heap_size(void)
 {
        return GC_get_max_heap_size();
 }