summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-11-08 20:39:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-11-08 20:39:38 -0800
commit6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce (patch)
treec3de299b609d808c28c6a378515f8f448c2d4d84
parente9bf49f0e7b1fe2160c5f965cd51049edc0b5e35 (diff)
downloadtxr-6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce.tar.gz
txr-6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce.tar.bz2
txr-6ac6c3657dc0dbf3c961a96f1f85d2a570ccc8ce.zip
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.
-rw-r--r--gc.c7
1 files changed, 7 insertions, 0 deletions
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;
}