summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--gc.c13
2 files changed, 21 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 141e4dda..e60a7636 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-12-03 Kaz Kylheku <kkylheku@gmail.com>
+ * gc.c (heap_min_bound, heap_max_bound): New static globals.
+ (more): Update heap_min_bound and heap_max_bound.
+ (in_heap): Do early rejection tests on the pointer. If it's
+ not aligned, or it's completely outside of the bounding
+ box of the heap area, short circuit to false.
+
+2009-12-03 Kaz Kylheku <kkylheku@gmail.com>
+
Version 027.
Code cleanup.
diff --git a/gc.c b/gc.c
index 0582bf0c..1a48ab2f 100644
--- a/gc.c
+++ b/gc.c
@@ -63,6 +63,7 @@ static val **top = prot_stack;
static val free_list, *free_tail = &free_list;
static heap_t *heap_list;
+static val heap_min_bound, heap_max_bound;
int gc_enabled = 1;
@@ -115,6 +116,12 @@ static void more(void)
assert (free_list == 0);
+ if (end > heap_max_bound)
+ heap_max_bound = end;
+
+ if (block < heap_min_bound)
+ heap_min_bound = block;
+
while (block < end) {
block->t.next = free_list;
block->t.type = (type_t) FREE;
@@ -277,6 +284,12 @@ static int in_heap(val ptr)
{
heap_t *heap;
+ if (!is_ptr(ptr))
+ return 0;
+
+ if (ptr < heap_min_bound || ptr >= heap_max_bound)
+ return 0;
+
for (heap = heap_list; heap != 0; heap = heap->next) {
if (ptr >= heap->block && ptr < heap->block + HEAP_SIZE)
if (((char *) ptr - (char *) heap->block) % sizeof (obj_t) == 0)