* 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.
/* 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);
#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"
/* 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
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;
}
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
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;
}
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);
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;
enum {
OPT_DebugStackFrameInfo,
OPT_DebugStackTrace,
+ OPT_GCDebugRootSet,
+ OPT_GCStress,
OPT_MaxPermSize,
OPT_PermSize,
OPT_PrintConfig,
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" },
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;
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;