mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-14 00:17:33 +02:00
Adding optional padding on heap objects for debugging.
This commit is contained in:
parent
9deba4dbf1
commit
776fc91be4
2 changed files with 8 additions and 4 deletions
8
gc.c
8
gc.c
|
@ -98,7 +98,7 @@ sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x) {
|
|||
if (!sexp_pointerp(x) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx)))
|
||||
return sexp_heap_align(1);
|
||||
t = sexp_object_type(ctx, x);
|
||||
res = sexp_type_size_of_object(t, x);
|
||||
res = sexp_type_size_of_object(t, x) + SEXP_GC_PAD;
|
||||
#if SEXP_USE_DEBUG_GC
|
||||
if (res == 0) {
|
||||
fprintf(stderr, SEXP_BANNER("%p zero-size object: %p"), ctx, x);
|
||||
|
@ -537,7 +537,7 @@ void* sexp_alloc (sexp ctx, size_t size) {
|
|||
void *res;
|
||||
size_t max_freed, sum_freed, total_size;
|
||||
sexp_heap h = sexp_context_heap(ctx);
|
||||
size = sexp_heap_align(size);
|
||||
size = sexp_heap_align(size) + SEXP_GC_PAD;
|
||||
res = sexp_try_alloc(ctx, size);
|
||||
if (! res) {
|
||||
max_freed = sexp_unbox_fixnum(sexp_gc(ctx, &sum_freed));
|
||||
|
@ -649,7 +649,7 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
|
|||
sexp_dl_handle(p) = NULL;
|
||||
#endif
|
||||
}
|
||||
p = (sexp) (((char*)p)+sexp_heap_align(sexp_type_size_of_object(t, p)));
|
||||
p = (sexp) (((char*)p)+sexp_heap_align(sexp_type_size_of_object(t, p))+SEXP_GC_PAD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -688,7 +688,7 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
|
|||
}
|
||||
}
|
||||
t = types[sexp_pointer_tag(p)];
|
||||
p = (sexp) (((char*)p)+sexp_heap_align(sexp_type_size_of_object(t, p)));
|
||||
p = (sexp) (((char*)p)+sexp_heap_align(sexp_type_size_of_object(t, p)+SEXP_GC_PAD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,6 +388,10 @@
|
|||
#define SEXP_USE_HEADER_MAGIC 0
|
||||
#endif
|
||||
|
||||
#ifndef SEXP_GC_PAD
|
||||
#define SEXP_GC_PAD 0
|
||||
#endif
|
||||
|
||||
#ifndef SEXP_USE_SAFE_ACCESSORS
|
||||
#define SEXP_USE_SAFE_ACCESSORS 0
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue