void mtd_thread_t::run () { mtd_status_t rc; GIANT_LOCK(); bool ok = init_phase0() && init(); GIANT_UNLOCK(); if (!ok) { TWARN ("thread could not initialize"); msg_send (MTD_SHUTDOWN); delete this; return; } become_ready (); do { GIANT_LOCK(); take_svccb (); GIANT_UNLOCK(); rc = msg_recv (); } while (rc == MTD_CONTINUE); cell->status = MTD_SHUTDOWN; msg_send (MTD_SHUTDOWN); return; }
SML_PRIMITIVE NOINLINE void * sml_alloc(unsigned int objsize) { /* objsize = payload_size + bitmap_size */ void *obj; size_t inc = HEAP_ROUND_SIZE(OBJ_HEADER_SIZE + objsize); #ifdef FAIR_COMPARISON if (inc > 4096) { SAVE_FP(); return sml_obj_malloc(inc); } #endif /* FAIR_COMPARISON */ GIANT_LOCK(); obj = sml_heap_from_space.free; if ((size_t)(sml_heap_from_space.limit - (char*)obj) >= inc) { sml_heap_from_space.free += inc; #ifdef GC_STAT sml_heap_alloced(inc); #endif /* GC_STAT */ GIANT_UNLOCK(); } else { SAVE_FP(); obj = slow_alloc(inc); } #ifndef FAIR_COMPARISON OBJ_HEADER(obj) = 0; #endif /* FAIR_COMPARISON */ return obj; }
void sml_heap_gc(void) { GIANT_LOCK(); do_gc(); GIANT_UNLOCK(); #ifndef FAIR_COMPARISON sml_run_finalizer(); #endif /* FAIR_COMPARISON */ }
void sml_heap_gc() { GIANT_LOCK(NULL); STOP_THE_WORLD(); sml_rootset_enum_ptr(trace, MAJOR); sml_malloc_pop_and_mark(trace, MAJOR); sml_check_finalizer(trace, MAJOR); sml_malloc_sweep(MAJOR); RUN_THE_WORLD(); GIANT_UNLOCK(); sml_run_finalizer(NULL); }
SML_PRIMITIVE void * sml_alloc(unsigned int objsize, void *frame_pointer) { /* objsize = payload_size + bitmap_size */ void *obj; size_t inc = HEAP_ROUND_SIZE(OBJ_HEADER_SIZE + objsize); GIANT_LOCK(frame_pointer); HEAP_FAST_ALLOC(obj, inc, (sml_save_frame_pointer(frame_pointer), sml_heap_slow_alloc(inc))); GIANT_UNLOCK(); OBJ_HEADER(obj) = 0; return obj; }