Author: chromatic Date: Thu Jan 3 02:25:35 2008 New Revision: 24478 Modified: trunk/src/gc/dod.c trunk/src/inter_create.c trunk/src/pmc/scheduler.pmc
Log: [GC] During global destruction of the Parrot interpreter, mark the parent thread as suspended for GC. When it collects all PMCs, this allows the PMC freer that it's safe to free all shared PMCs. Without this, they go away without having their destroy vtable entries invoked. With this, Memcheck says of "Hello, world!": All heap blocks were freed -- no leaks are possible. Yippee. Modified: trunk/src/gc/dod.c ============================================================================== --- trunk/src/gc/dod.c (original) +++ trunk/src/gc/dod.c Thu Jan 3 02:25:35 2008 @@ -311,7 +311,6 @@ if (interp->scheduler) pobject_lives(interp, (PObj *)interp->scheduler); - /* s. packfile.c */ mark_const_subs(interp); @@ -1108,8 +1107,7 @@ * the live bits are cleared */ if (flags & DOD_finish_FLAG) { - /* XXX */ - Parrot_dod_clear_live_bits(interp); + clear_live_bits(interp->arena_base->pmc_pool); clear_live_bits(interp->arena_base->constant_pmc_pool); Parrot_dod_sweep(interp, interp->arena_base->pmc_pool); Modified: trunk/src/inter_create.c ============================================================================== --- trunk/src/inter_create.c (original) +++ trunk/src/inter_create.c Thu Jan 3 02:25:35 2008 @@ -341,6 +341,9 @@ /* Destroys all PMCs, even constants and the ParrotIO objects for * std{in, out, err}, so don't be verbose about DOD'ing. */ + if (interp->thread_data) + interp->thread_data->state |= THREAD_STATE_SUSPENDED_GC; + Parrot_do_dod_run(interp, DOD_finish_FLAG); #if STM_PROFILE Modified: trunk/src/pmc/scheduler.pmc ============================================================================== --- trunk/src/pmc/scheduler.pmc (original) +++ trunk/src/pmc/scheduler.pmc Thu Jan 3 02:25:35 2008 @@ -51,7 +51,6 @@ core_struct->interp = INTERP; COND_INIT(core_struct->condition); MUTEX_INIT(core_struct->lock); - } /* @@ -242,7 +241,7 @@ Parrot_Scheduler * const core_struct = PARROT_SCHEDULER(SELF); COND_DESTROY(core_struct->condition); MUTEX_DESTROY(core_struct->lock); - mem_sys_free(PMC_data(SELF)); + mem_sys_free(core_struct); } /*