diff --git a/moo/lib/gc.c b/moo/lib/gc.c index fea148b..50527de 100644 --- a/moo/lib/gc.c +++ b/moo/lib/gc.c @@ -846,20 +846,19 @@ static MOO_INLINE void gc_mark_root (moo_t* moo) moo_oow_t i, gcfin_count; moo_evtcb_t* cb; - if (moo->active_context) + if (moo->processor && moo->processor->active) { MOO_ASSERT (moo, (moo_oop_t)moo->processor != moo->_nil); MOO_ASSERT (moo, (moo_oop_t)moo->processor->active != moo->_nil); - + /* commit the stack pointer to the active process because - * gc utilizes the stack pointer of a process object when marking */ - + * gc needs the correct stack pointer for a process object */ moo->processor->active->sp = MOO_SMOOI_TO_OOP(moo->sp); + } #if 0 - moo->active_context->ip = MOO_SMOOI_TO_OOP(moo->ip); /* not needed but do it */ + if (moo->active_context) moo->active_context->ip = MOO_SMOOI_TO_OOP(moo->ip); /* no need to commit the instruction pointer */ #endif - } gc_mark (moo, moo->_nil); gc_mark (moo, moo->_true); diff --git a/moo/lib/obj.c b/moo/lib/obj.c index 6377eaf..281ea96 100644 --- a/moo/lib/obj.c +++ b/moo/lib/obj.c @@ -34,7 +34,8 @@ void* moo_allocbytes (moo_t* moo, moo_oow_t size) #endif #if defined(MOO_BUILD_DEBUG) - if ((moo->option.trait & MOO_TRAIT_DEBUG_GC) && !(moo->option.trait & MOO_TRAIT_NOGC)) moo_gc (moo); + /* DEBUG_GC is set but NOGC is not set */ + if ((moo->option.trait & (MOO_TRAIT_DEBUG_GC | MOO_TRAIT_NOGC)) == MOO_TRAIT_DEBUG_GC) moo_gc (moo); #endif #if defined(MOO_ENABLE_GC_MARK_SWEEP)