#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 "vm/vm.hpp"
+#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;
}