From 7a45137ca2d1360d63d12304e8aa8dd3c6001129 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 23 Oct 2015 19:48:55 -0400 Subject: [PATCH] Added debug statements --- gc.c | 5 ++++- runtime.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 24e18b62..b15d5c07 100644 --- a/gc.c +++ b/gc.c @@ -225,7 +225,9 @@ fprintf(stdout, "sweep heap %p, size = %d\n", h, h->size); if ((char *)r == (char *)p) { // this is a free block, skip it p = (object) (((char *)p) + r->size); -fprintf(stdout, "skip free block %p size = %d\n", p, r->size); +#if GC_DEBUG_PRINTFS + fprintf(stdout, "skip free block %p size = %d\n", p, r->size); +#endif continue; } size = gc_heap_align(gc_allocated_bytes(p)); @@ -308,6 +310,7 @@ void gc_thr_grow_move_buffer(gc_thread_data *d) } d->moveBuf = realloc(d->moveBuf, d->moveBufLen * sizeof(void *)); + printf("grew moveBuffer, len = %d\n", d->moveBufLen); } void gc_thr_add_to_move_buffer(gc_thread_data *d, int *alloci, object obj) diff --git a/runtime.c b/runtime.c index bf376f2f..662cc26b 100644 --- a/runtime.c +++ b/runtime.c @@ -2708,8 +2708,11 @@ void GC(cont, args, num_args) closure cont; object *args; int num_args; scani++; } +//fprintf(stdout, "DEBUG done minor GC, alloci = %d\n", alloci); + // Check if we need to do a major GC if (heap_grown) { + time_t majorStart = time(NULL); size_t freed = 0, max_freed = 0; fprintf(stdout, "DEBUG, starting major mark/sweep GC\n"); // JAE DEBUG gc_mark(Cyc_heap, cont); @@ -2717,7 +2720,7 @@ fprintf(stdout, "DEBUG, starting major mark/sweep GC\n"); // JAE DEBUG gc_mark(Cyc_heap, args[i]); } max_freed = gc_collect(Cyc_heap, &freed); -printf("done, freed = %d, max_freed = %d\n", freed, max_freed); +printf("done, freed = %d, max_freed = %d, elapsed = %ld\n", freed, max_freed, time(NULL) - majorStart); //JAE_DEBUG++; //if (JAE_DEBUG == 2) exit(1); // JAE DEBUG }