mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
Reporting time spec in GC when SEXP_USE_DEBUG_GC > 0.
This commit is contained in:
parent
6db194171e
commit
d1c71adb40
1 changed files with 14 additions and 5 deletions
19
gc.c
19
gc.c
|
@ -390,7 +390,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
size = sexp_heap_align(sexp_allocated_bytes(ctx, p));
|
size = sexp_heap_align(sexp_allocated_bytes(ctx, p));
|
||||||
#if SEXP_USE_DEBUG_GC
|
#if SEXP_USE_DEBUG_GC > 1
|
||||||
if (!sexp_valid_object_p(ctx, p))
|
if (!sexp_valid_object_p(ctx, p))
|
||||||
fprintf(stderr, SEXP_BANNER("%p sweep: invalid object at %p"), ctx, p);
|
fprintf(stderr, SEXP_BANNER("%p sweep: invalid object at %p"), ctx, p);
|
||||||
if ((char*)q + q->size > (char*)p)
|
if ((char*)q + q->size > (char*)p)
|
||||||
|
@ -455,17 +455,26 @@ void sexp_mark_global_symbols(sexp ctx) {
|
||||||
|
|
||||||
sexp sexp_gc (sexp ctx, size_t *sum_freed) {
|
sexp sexp_gc (sexp ctx, size_t *sum_freed) {
|
||||||
sexp res, finalized SEXP_NO_WARN_UNUSED;
|
sexp res, finalized SEXP_NO_WARN_UNUSED;
|
||||||
|
#if SEXP_USE_DEBUG_GC
|
||||||
|
struct rusage start, end;
|
||||||
|
getrusage(RUSAGE_SELF, &start);
|
||||||
sexp_debug_printf("%p (heap: %p size: %lu)", ctx, sexp_context_heap(ctx),
|
sexp_debug_printf("%p (heap: %p size: %lu)", ctx, sexp_context_heap(ctx),
|
||||||
sexp_heap_total_size(sexp_context_heap(ctx)));
|
sexp_heap_total_size(sexp_context_heap(ctx)));
|
||||||
|
#endif
|
||||||
sexp_mark_global_symbols(ctx);
|
sexp_mark_global_symbols(ctx);
|
||||||
sexp_mark(ctx, ctx);
|
sexp_mark(ctx, ctx);
|
||||||
sexp_conservative_mark(ctx);
|
sexp_conservative_mark(ctx);
|
||||||
sexp_reset_weak_references(ctx);
|
sexp_reset_weak_references(ctx);
|
||||||
finalized = sexp_finalize(ctx);
|
finalized = sexp_finalize(ctx);
|
||||||
res = sexp_sweep(ctx, sum_freed);
|
res = sexp_sweep(ctx, sum_freed);
|
||||||
sexp_debug_printf("%p (freed: %lu max_freed: %lu finalized: %lu)", ctx,
|
#if SEXP_USE_DEBUG_GC
|
||||||
(sum_freed ? *sum_freed : 0), sexp_unbox_fixnum(res),
|
getrusage(RUSAGE_SELF, &end);
|
||||||
sexp_unbox_fixnum(finalized));
|
sexp_debug_printf("%p (freed: %lu max_freed: %lu finalized: %lu time: %luus)",
|
||||||
|
ctx, (sum_freed ? *sum_freed : 0), sexp_unbox_fixnum(res),
|
||||||
|
sexp_unbox_fixnum(finalized),
|
||||||
|
(end.ru_utime.tv_sec - start.ru_utime.tv_sec) * 1000000 +
|
||||||
|
end.ru_utime.tv_usec - start.ru_utime.tv_usec);
|
||||||
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,7 +529,7 @@ void* sexp_try_alloc (sexp ctx, size_t size) {
|
||||||
#endif
|
#endif
|
||||||
for (ls1=h->free_list, ls2=ls1->next; ls2; ls1=ls2, ls2=ls2->next) {
|
for (ls1=h->free_list, ls2=ls1->next; ls2; ls1=ls2, ls2=ls2->next) {
|
||||||
if (ls2->size >= size) {
|
if (ls2->size >= size) {
|
||||||
#if SEXP_USE_DEBUG_GC
|
#if SEXP_USE_DEBUG_GC > 1
|
||||||
ls3 = (sexp_free_list) sexp_heap_end(h);
|
ls3 = (sexp_free_list) sexp_heap_end(h);
|
||||||
if (ls2 >= ls3)
|
if (ls2 >= ls3)
|
||||||
fprintf(stderr, "alloced %lu bytes past end of heap: %p (%lu) >= %p"
|
fprintf(stderr, "alloced %lu bytes past end of heap: %p (%lu) >= %p"
|
||||||
|
|
Loading…
Add table
Reference in a new issue