summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--lib.c24
2 files changed, 23 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b744a5a..39a7a296 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-03-27 Kaz Kylheku <kaz@kylheku.com>
+
+ Fix generational GC regression caused by fixes
+ in in 2014-03-12, when prof was introduced.
+ The attempt to fix a bug made things worse.
+
+ * lib.c (adjust_bounds): New static function.
+ (chk_malloc, chk_calloc, chk_realloc): Replace existing logic with
+ call to adjust_bounds.
+ (chk_malloc_gc_more): Bugfix: add missing call to adjust_bounds.
+
2014-03-26 Kaz Kylheku <kaz@kylheku.com>
* genvim.txr: Update for WLL's and QLL's.
diff --git a/lib.c b/lib.c
index edeb8737..a493d875 100644
--- a/lib.c
+++ b/lib.c
@@ -1296,6 +1296,14 @@ static mem_t *malloc_low_bound, *malloc_high_bound;
alloc_bytes_t malloc_bytes;
+static void adjust_bounds(mem_t *ptr, size_t size)
+{
+ if (ptr < malloc_low_bound)
+ malloc_low_bound = ptr;
+ else if (ptr + size > malloc_high_bound)
+ malloc_high_bound = ptr + size;
+}
+
mem_t *chk_malloc(size_t size)
{
mem_t *ptr = (mem_t *) malloc(size);
@@ -1304,10 +1312,7 @@ mem_t *chk_malloc(size_t size)
if (size && ptr == 0)
ptr = (mem_t *) oom_realloc(0, size);
- if (ptr < malloc_low_bound)
- malloc_low_bound = ptr;
- else if (ptr + size > malloc_high_bound)
- malloc_high_bound = ptr + size;
+ adjust_bounds(ptr, size);
malloc_bytes += size;
return ptr;
}
@@ -1318,6 +1323,7 @@ mem_t *chk_malloc_gc_more(size_t size)
assert (!async_sig_enabled);
if (size && ptr == 0)
ptr = (mem_t *) oom_realloc(0, size);
+ adjust_bounds(ptr, size);
return ptr;
}
@@ -1332,10 +1338,7 @@ mem_t *chk_calloc(size_t n, size_t size)
ptr = (mem_t *) oom_realloc(0, total);
memset(ptr, 0, total);
}
- if (ptr < malloc_low_bound)
- malloc_low_bound = ptr;
- else if (ptr + size > malloc_high_bound)
- malloc_high_bound = ptr + total;
+ adjust_bounds(ptr, size);
malloc_bytes += total;
return ptr;
}
@@ -1348,10 +1351,7 @@ mem_t *chk_realloc(mem_t *old, size_t size)
if (size != 0 && newptr == 0)
newptr = oom_realloc(old, size);
- if (newptr < malloc_low_bound)
- malloc_low_bound = newptr;
- else if (newptr + size > malloc_high_bound)
- malloc_high_bound = newptr + size;
+ adjust_bounds(newptr, size);
malloc_bytes += size;
return newptr;
}