* src/mm/cacao-gc/rootset.c (rootset_readout): Ignore threads in state new.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 5 Sep 2007 11:35:55 +0000 (13:35 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 5 Sep 2007 11:35:55 +0000 (13:35 +0200)
* src/mm/cacao-gc/heap.c (heap_alloc): Wrap reference befor returning.
(heap_alloc_intern): Respect stress-test option flag.

* src/mm/cacao-gc/gc.c (gc_collect): Respect debug rootset option flag.

* src/vmcore/options.h [ENABLE_GC_CACAO] (opt_GCDebugRootSet): Added.
[ENABLE_GC_CACAO] (opt_GCStress): Likewise.

* src/vmcore/options.c (options_xx) [ENABLE_GC_CACAO]: Parse above two options.

src/mm/cacao-gc/gc.c
src/mm/cacao-gc/heap.c
src/mm/cacao-gc/rootset.c
src/vmcore/options.c
src/vmcore/options.h

index d262bcf778164021861647eaa6631c68ca38dc45..0ad4b59180caa040b3c8afea4f17689dab1361c2 100644 (file)
@@ -242,7 +242,12 @@ void gc_collect(s4 level)
 
        /* find the global and local rootsets */
        rs = rootset_readout();
-       GC_LOG( rootset_print(rs); );
+
+#if !defined(NDEBUG)
+       /* print the rootsets if debugging is enabled */
+       if (opt_GCDebugRootSet)
+               rootset_print(rs);
+#endif
 
        RT_TIMING_GET_TIME(time_rootset);
 
index c4f9dbac1dd6db27979c89091337d49bc7068a5f..425b0dfc38286eb353155446e7d76fcdbde2be9d 100644 (file)
 #include "region.h"
 #include "mm/memory.h"
 #include "native/include/java_lang_String.h"
+#include "native/llni.h"
 #include "toolbox/logging.h"
 #include "vm/global.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
+#include "vmcore/options.h"
 #include "vmcore/rt-timing.h"
 
 
@@ -248,9 +250,9 @@ static java_object_t *heap_alloc_intern(u4 bytelength, regioninfo_t *region, boo
        /* lock the region */
        LOCK_MONITOR_ENTER(region);
 
-#if 0
+#if !defined(NDEBUG)
        /* heavy stress test */
-       if (collect)
+       if (opt_GCStress && collect)
                gc_collect(0);
 #endif
 
@@ -260,7 +262,15 @@ static java_object_t *heap_alloc_intern(u4 bytelength, regioninfo_t *region, boo
 
                if (collect) {
                        gc_collect(0);
+#if 0
                        GC_ASSERT(region->free >= bytelength);
+#else
+                       if (region->free < bytelength) {
+                               dolog("GC: OOM OOM OOM OOM OOM OOM OOM OOM OOM OOM");
+                               exceptions_throw_outofmemoryerror();
+                               return NULL;
+                       }
+#endif
                } else
                        return NULL;
        }
@@ -293,6 +303,7 @@ static java_object_t *heap_alloc_intern(u4 bytelength, regioninfo_t *region, boo
 void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
 {
        java_object_t *p;
+       java_handle_t *h;
 #if defined(ENABLE_RT_TIMING)
        struct timespec time_start, time_end;
 #endif
@@ -317,10 +328,12 @@ void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect)
                final_register(p, finalizer);
        }
 
+       h = LLNI_WRAP(p);
+
        RT_TIMING_GET_TIME(time_end);
        RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC);
 
-       return p;
+       return h;
 }
 
 
index ad75f7b9f9c9c4a41824d10ee562e43c22884b48..edcd892ce0c09adc91d6b3e46788cd769d76aa8b 100644 (file)
@@ -338,6 +338,11 @@ rootset_t *rootset_readout()
        rs = rs_top;
 #if defined(ENABLE_THREADS)
        for (thread = threads_list_first(); thread != NULL; thread = threads_list_next(thread)) {
+
+               /* ignore threads which are in state NEW */
+               if (thread->state == THREAD_STATE_NEW)
+                       continue;
+
                rs->next = rootset_create();
                rs->next = rootset_from_thread(thread, rs->next);
 
index 1817c97bc613871ddfcabe9d423d6ad9baaa2759..cf2bbec5cb58d65b1e186e9f1f4f04bb09b0e8e4 100644 (file)
@@ -177,6 +177,10 @@ const char *opt_filter_show_method = 0;
 
 int32_t  opt_DebugStackFrameInfo       = 0;
 int32_t  opt_DebugStackTrace           = 0;
+#if defined(ENABLE_GC_CACAO)
+int32_t  opt_GCDebugRootSet            = 0;
+int32_t  opt_GCStress                  = 0;
+#endif
 int32_t  opt_MaxPermSize               = 0;
 int32_t  opt_PermSize                  = 0;
 int      opt_PrintConfig               = 0;
@@ -201,6 +205,8 @@ enum {
 enum {
        OPT_DebugStackFrameInfo,
        OPT_DebugStackTrace,
+       OPT_GCDebugRootSet,
+       OPT_GCStress,
        OPT_MaxPermSize,
        OPT_PermSize,
        OPT_PrintConfig,
@@ -219,6 +225,10 @@ enum {
 option_t options_XX[] = {
        { "DebugStackFrameInfo",       OPT_DebugStackFrameInfo,       OPT_TYPE_BOOLEAN, "TODO" },
        { "DebugStackTrace",           OPT_DebugStackTrace,           OPT_TYPE_BOOLEAN, "debug stacktrace creation" },
+#if defined(ENABLE_GC_CACAO)
+       { "GCDebugRootSet",            OPT_GCDebugRootSet,            OPT_TYPE_BOOLEAN, "GC: print root-set at collection" },
+       { "GCStress",                  OPT_GCStress,                  OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" },
+#endif
        { "MaxPermSize",               OPT_MaxPermSize,               OPT_TYPE_VALUE,   "not implemented" },
        { "PermSize",                  OPT_PermSize,                  OPT_TYPE_VALUE,   "not implemented" },
        { "PrintConfig",               OPT_PrintConfig,               OPT_TYPE_BOOLEAN, "print VM configuration" },
@@ -479,6 +489,16 @@ void options_xx(const char *name)
                opt_DebugStackTrace = enable;
                break;
 
+#if defined(ENABLE_GC_CACAO)
+       case OPT_GCDebugRootSet:
+               opt_GCDebugRootSet = enable;
+               break;
+
+       case OPT_GCStress:
+               opt_GCStress = enable;
+               break;
+#endif
+
        case OPT_MaxPermSize:
                /* currently ignored */
                break;
index 6e9b7b4a99c6686268ddb7de09c99f0809c311a5..83b1c5cb1a7f37c1fd22bacbe028f8778bc11ecb 100644 (file)
@@ -192,6 +192,10 @@ extern const char *opt_filter_show_method;
 
 extern int32_t  opt_DebugStackFrameInfo;
 extern int32_t  opt_DebugStackTrace;
+#if defined(ENABLE_GC_CACAO)
+extern int32_t  opt_GCDebugRootSet;
+extern int32_t  opt_GCStress;
+#endif
 extern int32_t  opt_MaxPermSize;
 extern int32_t  opt_PermSize;
 extern int      opt_PrintConfig;