mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 17:27:33 +02:00
Cleanup
This commit is contained in:
parent
5a7be4f864
commit
93eff719a7
1 changed files with 16 additions and 21 deletions
37
gc.c
37
gc.c
|
@ -234,6 +234,13 @@ gc_heap *gc_heap_free(gc_heap *page, gc_heap *prev_page)
|
||||||
return prev_page;
|
return prev_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gc_is_heap_empty(gc_heap *h)
|
||||||
|
{
|
||||||
|
// TODO: this function does not work yet!!
|
||||||
|
if (h == NULL || h->free_list == NULL) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print heap usage information.
|
* Print heap usage information.
|
||||||
* Before calling this function the current thread must have the heap lock
|
* Before calling this function the current thread must have the heap lock
|
||||||
|
@ -256,12 +263,9 @@ void gc_print_stats(gc_heap * h)
|
||||||
if (f->size > free_max)
|
if (f->size > free_max)
|
||||||
free_max = f->size;
|
free_max = f->size;
|
||||||
}
|
}
|
||||||
//if (free == 0){
|
if (free == 0){ // No free chunks
|
||||||
// // Page is completely unused
|
free_min = 0;
|
||||||
// free = h->size;
|
}
|
||||||
// free_chunks = 1;
|
|
||||||
// free_min = free_max = h->size;
|
|
||||||
//}
|
|
||||||
heap_is_empty = gc_is_heap_empty(h);
|
heap_is_empty = gc_is_heap_empty(h);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Heap page size=%u, is empty=%d, used=%u, free=%u, free chunks=%u, min=%u, max=%u\n",
|
"Heap page size=%u, is empty=%d, used=%u, free=%u, free chunks=%u, min=%u, max=%u\n",
|
||||||
|
@ -269,15 +273,6 @@ void gc_print_stats(gc_heap * h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int gc_is_heap_empty(gc_heap *h)
|
|
||||||
{
|
|
||||||
return (h && (h->free_list == NULL) ||
|
|
||||||
(h->free_list->next &&
|
|
||||||
// TODO: think this case is busted, need to debug
|
|
||||||
h->free_list->next->next == NULL &&
|
|
||||||
h->free_list->next->size == h->size));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy given object into given heap object
|
// Copy given object into given heap object
|
||||||
char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd)
|
char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd)
|
||||||
{
|
{
|
||||||
|
@ -661,9 +656,9 @@ size_t gc_sweep(gc_heap * h, int heap_type, size_t * sum_freed_ptr)
|
||||||
pthread_mutex_lock(&heap_lock);
|
pthread_mutex_lock(&heap_lock);
|
||||||
|
|
||||||
// DEBUGGING:
|
// DEBUGGING:
|
||||||
fprintf(stderr, "\nBefore sweep -------------------------\n");
|
//fprintf(stderr, "\nBefore sweep -------------------------\n");
|
||||||
fprintf(stderr, "Heap %d diagnostics:\n", heap_type);
|
//fprintf(stderr, "Heap %d diagnostics:\n", heap_type);
|
||||||
gc_print_stats(orig_heap_ptr);
|
//gc_print_stats(orig_heap_ptr);
|
||||||
|
|
||||||
for (; h; prev_h = h, h = h->next) { // All heaps
|
for (; h; prev_h = h, h = h->next) { // All heaps
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
|
@ -775,9 +770,9 @@ gc_print_stats(orig_heap_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUGGING:
|
// DEBUGGING:
|
||||||
fprintf(stderr, "\nAfter sweep -------------------------\n");
|
//fprintf(stderr, "\nAfter sweep -------------------------\n");
|
||||||
fprintf(stderr, "Heap %d diagnostics:\n", heap_type);
|
//fprintf(stderr, "Heap %d diagnostics:\n", heap_type);
|
||||||
gc_print_stats(orig_heap_ptr);
|
//gc_print_stats(orig_heap_ptr);
|
||||||
|
|
||||||
pthread_mutex_unlock(&heap_lock);
|
pthread_mutex_unlock(&heap_lock);
|
||||||
if (sum_freed_ptr)
|
if (sum_freed_ptr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue