Added debug statements

This commit is contained in:
Justin Ethier 2015-11-25 23:46:50 -05:00
parent 6ad6f6e254
commit ff1fc10a90
3 changed files with 12 additions and 11 deletions

20
gc.c
View file

@ -354,11 +354,13 @@ if (is_value_type(result)) {
return 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; tag_type t;
if (is_value_type(obj)) { 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); exit(1);
//return gc_heap_align(1); //return gc_heap_align(1);
} }
@ -486,7 +488,7 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr)
//#endif //#endif
continue; 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); //fprintf(stdout, "check object %p, size = %d\n", p, size);
//#if GC_DEBUG_CONCISE_PRINTFS //#if GC_DEBUG_CONCISE_PRINTFS
@ -507,12 +509,10 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr)
//#endif //#endif
if (mark(p) == gc_color_clear) { if (mark(p) == gc_color_clear) {
#if GC_DEBUG_PRINTFS //#if GC_DEBUG_PRINTFS
fprintf(stdout, "sweep: object is not marked %p\n", p); //fprintf(stdout, "sweep: object is not marked %p\n", p);
//fprintf(stdout, "sweep is freeing obj: %p ", p); fprintf(stdout, "sweep is freeing obj: %p with tag %d\n", p, type_of(p));
//Cyc_display(p, stdout); //#endif
//fprintf(stdout, "\n");
#endif
mark(p) = gc_color_blue; // Needed? mark(p) = gc_color_blue; // Needed?
// free p // free p
sum_freed += size; sum_freed += size;
@ -800,7 +800,7 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value)
//printf("\n"); //printf("\n");
gc_mark_gray(thd, old_obj); gc_mark_gray(thd, old_obj);
// TODO: need this too??? // TODO: need this too???
gc_stack_mark_gray(thd, value); //gc_stack_mark_gray(thd, value);
} else if (stage == STAGE_TRACING) { } else if (stage == STAGE_TRACING) {
//printf("DEBUG - GC async tracing marking heap obj %p ", old_obj); //printf("DEBUG - GC async tracing marking heap obj %p ", old_obj);
//Cyc_display(old_obj, stdout); //Cyc_display(old_obj, stdout);

View file

@ -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); 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_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); 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); gc_heap *gc_heap_last(gc_heap *h);
size_t gc_heap_total_size(gc_heap *h); size_t gc_heap_total_size(gc_heap *h);
//size_t gc_collect(gc_heap *h, size_t *sum_freed); //size_t gc_collect(gc_heap *h, size_t *sum_freed);

View file

@ -2742,6 +2742,7 @@ void GC(void *data, closure cont, object *args, int num_args)
// Cooperate with the collector thread // Cooperate with the collector thread
gc_mut_cooperate((gc_thread_data *)data); gc_mut_cooperate((gc_thread_data *)data);
printf("done with minor GC\n");
// Let it all go, Neo... // Let it all go, Neo...
longjmp(*(((gc_thread_data *)data)->jmp_start), 1); longjmp(*(((gc_thread_data *)data)->jmp_start), 1);
} }