* src/vm/vm.c, src/vm/vm.h: Moved to .cpp.
[cacao.git] / src / mm / boehm.c
index 7874228fd97d8550b6d63c330004b983b283d022..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 7615 2007-03-29 23:10:59Z michi $
-
 */
 
 
 #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"
@@ -48,7 +48,7 @@
 #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"
@@ -71,40 +71,45 @@ 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;
 
-       GC_INIT();
+       TRACESUBSYSTEMINITIALIZATION("gc_init");
 
-       /* set the maximal heap size */
+       /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */
 
-       GC_set_max_heap_size(heapmaxsize);
+       GC_java_finalization = 1;
 
-       /* set the initial heap size */
+       /* Ignore pointers that do not point to the start of an object. */
 
-       heapcurrentsize = GC_get_heap_size();
+       GC_all_interior_pointers = 0;
 
-       if (heapstartsize > heapcurrentsize) {
-               GC_expand_hp(heapstartsize - heapcurrentsize);
-       }
+       /* suppress warnings */
+
+       GC_set_warn_proc(gc_ignore_warnings);
+
+       /* install a GC notifier */
+
+       GC_finalize_on_demand = 1;
+       GC_finalizer_notifier = finalizer_notify;
 
        /* define OOM function */
 
        GC_oom_fn = gc_out_of_memory;
 
-       /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */
+       GC_INIT();
 
-       GC_java_finalization = 1;
+       /* set the maximal heap size */
 
-       /* suppress warnings */
+       GC_set_max_heap_size(heapmaxsize);
 
-       GC_set_warn_proc(gc_ignore_warnings);
+       /* set the initial heap size */
 
-       /* install a GC notifier */
+       heapcurrentsize = GC_get_heap_size();
 
-       GC_finalize_on_demand = 1;
-       GC_finalizer_notifier = finalizer_notify;
+       if (heapstartsize > heapcurrentsize)
+               GC_expand_hp(heapstartsize - heapcurrentsize);
 }
 
 
@@ -113,7 +118,7 @@ static void gc_ignore_warnings(char *msg, GC_word arg)
 }
 
 
-void *heap_alloc_uncollectable(u4 size)
+void *heap_alloc_uncollectable(size_t size)
 {
        void *p;
 
@@ -121,7 +126,7 @@ void *heap_alloc_uncollectable(u4 size)
 
        /* clear allocated memory region */
 
-       MSET(p, 0, u1, bytelength);
+       MSET(p, 0, uint8_t, size);
 
        return p;
 }
@@ -133,7 +138,7 @@ void *heap_alloc_uncollectable(u4 size)
 
 *******************************************************************************/
 
-void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
+void *heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
 {
        void *p;
 #if defined(ENABLE_RT_TIMING)
@@ -154,11 +159,11 @@ void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
                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, size);
+       MSET(p, 0, uint8_t, size);
 
        RT_TIMING_GET_TIME(time_end);
        RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
@@ -182,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();
 }
@@ -200,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();
 }