From ff1fc10a90057dcd63e7aa8951c9e672b67efbc7 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 25 Nov 2015 23:46:50 -0500 Subject: [PATCH] Added debug statements --- gc.c | 20 ++++++++++---------- include/cyclone/types.h | 2 +- runtime.c | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gc.c b/gc.c index 9a34e7bd..906e7d13 100644 --- a/gc.c +++ b/gc.c @@ -354,11 +354,13 @@ if (is_value_type(result)) { return result; } -size_t gc_allocated_bytes(object obj) +size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r) { tag_type t; if (is_value_type(obj)) { - fprintf(stdout, "gc_allocated_bytes - passed value type %p\n", obj); + fprintf(stdout, + "gc_allocated_bytes - passed value type %p q=[%p, %d] r=[%p, %d]\n", + obj, q, q->size, r, r->size); exit(1); //return gc_heap_align(1); } @@ -486,7 +488,7 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr) //#endif continue; } - size = gc_heap_align(gc_allocated_bytes(p)); + size = gc_heap_align(gc_allocated_bytes(p, q, r)); //fprintf(stdout, "check object %p, size = %d\n", p, size); //#if GC_DEBUG_CONCISE_PRINTFS @@ -507,12 +509,10 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr) //#endif if (mark(p) == gc_color_clear) { -#if GC_DEBUG_PRINTFS - fprintf(stdout, "sweep: object is not marked %p\n", p); - //fprintf(stdout, "sweep is freeing obj: %p ", p); - //Cyc_display(p, stdout); - //fprintf(stdout, "\n"); -#endif +//#if GC_DEBUG_PRINTFS + //fprintf(stdout, "sweep: object is not marked %p\n", p); + fprintf(stdout, "sweep is freeing obj: %p with tag %d\n", p, type_of(p)); +//#endif mark(p) = gc_color_blue; // Needed? // free p sum_freed += size; @@ -800,7 +800,7 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value) //printf("\n"); gc_mark_gray(thd, old_obj); // TODO: need this too??? - gc_stack_mark_gray(thd, value); + //gc_stack_mark_gray(thd, value); } else if (stage == STAGE_TRACING) { //printf("DEBUG - GC async tracing marking heap obj %p ", old_obj); //Cyc_display(old_obj, stdout); diff --git a/include/cyclone/types.h b/include/cyclone/types.h index fe0cfc26..38388f3b 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -146,7 +146,7 @@ int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size); char *gc_copy_obj(object hp, char *obj, gc_thread_data *thd); void *gc_try_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd); void *gc_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd, int *heap_grown); -size_t gc_allocated_bytes(object obj); +size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r); gc_heap *gc_heap_last(gc_heap *h); size_t gc_heap_total_size(gc_heap *h); //size_t gc_collect(gc_heap *h, size_t *sum_freed); diff --git a/runtime.c b/runtime.c index 0d33c4d9..da652d1e 100644 --- a/runtime.c +++ b/runtime.c @@ -2742,6 +2742,7 @@ void GC(void *data, closure cont, object *args, int num_args) // Cooperate with the collector thread gc_mut_cooperate((gc_thread_data *)data); +printf("done with minor GC\n"); // Let it all go, Neo... longjmp(*(((gc_thread_data *)data)->jmp_start), 1); }