From: Leandro Lucarella Date: Mon, 23 Aug 2010 00:38:50 +0000 (-0300) Subject: Move sweeping phase to a separate function X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/commitdiff_plain/0b6f418d7a9f1b8b2bf9330232e45f92d67005a0?hp=d8944d1a3011a7b9b2ffcebf41fdb5d6d3b03467 Move sweeping phase to a separate function --- diff --git a/rt/gc/cdgc/gc.d b/rt/gc/cdgc/gc.d index 0084481..46c43ad 100644 --- a/rt/gc/cdgc/gc.d +++ b/rt/gc/cdgc/gc.d @@ -921,13 +921,22 @@ size_t fullcollect(void *stackTop) thread_resumeAll(); gc.stats.world_started(); + return sweep(); +} + + +/** + * + */ +size_t sweep() +{ // Free up everything not marked - debug(COLLECT_PRINTF) printf("\tfree'ing\n"); + debug(COLLECT_PRINTF) printf("\tsweep\n"); size_t freedpages = 0; size_t freed = 0; - for (n = 0; n < gc.pools.length; n++) + for (size_t n = 0; n < gc.pools.length; n++) { - pool = gc.pools[n]; + Pool* pool = gc.pools[n]; pool.clear_cache(); uint* bbase = pool.mark.base(); size_t pn; @@ -1039,9 +1048,9 @@ version(none) // BUG: doesn't work because freebits() must also be cleared // Free complete pages, rebuild free list debug(COLLECT_PRINTF) printf("\tfree complete pages\n"); size_t recoveredpages = 0; - for (n = 0; n < gc.pools.length; n++) + for (size_t n = 0; n < gc.pools.length; n++) { - pool = gc.pools[n]; + Pool* pool = gc.pools[n]; for (size_t pn = 0; pn < pool.npages; pn++) { Bins bin = cast(Bins)pool.pagetable[pn];