cleanup of gchdr'ed objects in moo_fini()

This commit is contained in:
hyunghwan.chung 2020-10-23 16:55:11 +00:00
parent 2ce8c35e0f
commit 023d147e14
2 changed files with 21 additions and 2 deletions

View File

@ -205,6 +205,9 @@ static MOO_INLINE void vm_cleanup (moo_t* moo)
*/
moo_deregallfinalizables (moo);
/* final garbage collection */
moo_gc (moo);
MOO_DEBUG0 (moo, "VM cleaned up\n");
}
@ -688,8 +691,7 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
proc->sp = MOO_SMOOI_TO_OOP(-1); /* invalidate the process stack */
MOO_STORE_OOP (moo, (moo_oop_t*)&proc->current_context, (moo_oop_t)proc->initial_context); /* not needed but just in case */
/* a runnable or running process must not be chanined to the
* process list of a semaphore */
/* a runnable or running process must not be chanined to the process list of a semaphore */
MOO_ASSERT (moo, (moo_oop_t)proc->sem == moo->_nil);
if (nrp == proc)
@ -5146,6 +5148,7 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo)
"%zd suspended process(es) found - check your program\n",
MOO_OOP_TO_SMOOI(moo->processor->suspended.count));
}
return 0;
}

View File

@ -250,8 +250,24 @@ void moo_fini (moo_t* moo)
* the heap may not exist */
if (moo->heap) moo_killheap (moo, moo->heap);
#if defined(MOO_ENABLE_GC_MARK_SWEEP)
if (moo->gch)
{
moo_gchdr_t* next;
do
{
next = moo->gch->next;
moo_freemem (moo, moo->gch);
moo->gch = next;
}
while (moo->gch);
}
#endif
moo_finidbgi (moo);
for (i = 0; i < MOO_COUNTOF(moo->sbuf); i++)
{
if (moo->sbuf[i].ptr)