From 6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 8 Nov 2019 20:39:38 -0800 Subject: gc: recalculate heap bounding box when sweeping. Since sweep can delete heaps now, it's possible that the bounding box may be tightened. Since we are iterating over all heaps, we can just recalculate it. * gc.c (sweep): Recalculate the heap boundaries using local variables, taking care to exclude any heap that is being deleted. Then update the globals. --- gc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gc.c b/gc.c index 8e84af01..b136143a 100644 --- a/gc.c +++ b/gc.c @@ -608,6 +608,7 @@ static int_ptr_t sweep(void) { int_ptr_t free_count = 0; heap_t **pph; + val hminb = nil, hmaxb = nil; #if HAVE_VALGRIND const int vg_dbg = opt_vg_debug; #endif @@ -683,10 +684,16 @@ static int_ptr_t sweep(void) } #endif } else { + if (!hmaxb || end > hmaxb) + hmaxb = end; + if (!hminb || heap->block < hminb) + hminb = heap->block; pph = &(*pph)->next; } } + heap_min_bound = hminb; + heap_max_bound = hmaxb; return free_count; } -- cgit v1.2.3