diff options
Diffstat (limited to 'rts/sm/NonMoving.c')
-rw-r--r-- | rts/sm/NonMoving.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c index 6bccf7f100..24464a43f9 100644 --- a/rts/sm/NonMoving.c +++ b/rts/sm/NonMoving.c @@ -291,6 +291,11 @@ static struct NonmovingAllocator *alloc_nonmoving_allocator(uint32_t n_caps) return alloc; } +static void free_nonmoving_allocator(struct NonmovingAllocator *alloc) +{ + stgFree(alloc); +} + void nonmovingInit(void) { if (! RtsFlags.GcFlags.useNonmoving) return; @@ -305,7 +310,8 @@ void nonmovingInit(void) nonmovingMarkInitUpdRemSet(); } -void nonmovingExit(void) +// Stop any nonmoving collection in preparation for RTS shutdown. +void nonmovingStop(void) { if (! RtsFlags.GcFlags.useNonmoving) return; #if defined(THREADED_RTS) @@ -315,14 +321,24 @@ void nonmovingExit(void) ACQUIRE_LOCK(&concurrent_coll_finished_lock); waitCondition(&concurrent_coll_finished, &concurrent_coll_finished_lock); } +#endif +} +void nonmovingExit(void) +{ + if (! RtsFlags.GcFlags.useNonmoving) return; + + // First make sure collector is stopped before we tear things down. + nonmovingStop(); + +#if defined(THREADED_RTS) closeMutex(&concurrent_coll_finished_lock); closeCondition(&concurrent_coll_finished); closeMutex(&nonmoving_collection_mutex); #endif for (unsigned int i = 0; i < NONMOVING_ALLOCA_CNT; i++) { - stgFree(nonmovingHeap.allocators[i]); + free_nonmoving_allocator(nonmovingHeap.allocators[i]); } } |