Remove unused code

This commit is contained in:
Justin Ethier 2018-07-31 22:54:39 -04:00
parent 7631607d87
commit ebc3247aa7
2 changed files with 14 additions and 14 deletions

26
gc.c
View file

@ -363,7 +363,7 @@ gc_heap *gc_heap_create(int heap_type, size_t size, size_t max_size,
h->max_size = max_size; h->max_size = max_size;
h->data = (char *)gc_heap_align(sizeof(h->data) + (uintptr_t) & (h->data)); h->data = (char *)gc_heap_align(sizeof(h->data) + (uintptr_t) & (h->data));
h->next = NULL; h->next = NULL;
h->num_children = 1; //h->num_children = 1;
h->num_unswept_children = 0; h->num_unswept_children = 0;
free = h->free_list = (gc_free_list *) h->data; free = h->free_list = (gc_free_list *) h->data;
next = (gc_free_list *) (((char *)free) + gc_heap_align(gc_free_chunk_size)); next = (gc_free_list *) (((char *)free) + gc_heap_align(gc_free_chunk_size));
@ -962,8 +962,8 @@ int gc_grow_heap(gc_heap * h, int heap_type, size_t size, size_t chunk_size, gc_
while (h_last->next) { while (h_last->next) {
h_last = h_last->next; h_last = h_last->next;
} }
} else if (heap_type == HEAP_SM || heap_type == HEAP_64) { // } else if (heap_type == HEAP_SM || heap_type == HEAP_64) {
new_size = gc_heap_align(64 * 4096); // Completely insane(?), match linux page size // new_size = gc_heap_align(64 * 4096); // Completely insane(?), match linux page size
} else { } else {
// Grow heap gradually using fibonnaci sequence. // Grow heap gradually using fibonnaci sequence.
size_t prev_size = GROW_HEAP_BY_SIZE; size_t prev_size = GROW_HEAP_BY_SIZE;
@ -1128,7 +1128,7 @@ void *gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, int heap_type, size_t siz
} }
//thd->cached_heap_free_sizes[heap_type] -= prev_free_size; //thd->cached_heap_free_sizes[heap_type] -= prev_free_size;
thd->cached_heap_total_sizes[heap_type] -= h_size; thd->cached_heap_total_sizes[heap_type] -= h_size;
h_passed->num_children--; //h_passed->num_children--;
continue; continue;
} }
} }
@ -1175,10 +1175,10 @@ void *gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, int heap_type, size_t siz
void *gc_try_alloc_fixed_size(gc_heap * h, int heap_type, size_t size, char *obj, gc_thread_data * thd) void *gc_try_alloc_fixed_size(gc_heap * h, int heap_type, size_t size, char *obj, gc_thread_data * thd)
{ {
void *result; void *result;
gc_heap *h_passed = h; //gc_heap *h_passed = h;
h = h->next_free; //h = h->next_free;
for (; h; h = h->next) { // All heaps //for (; h; h = h->next) { // All heaps
if (h->free_list) { if (h->free_list) {
result = h->free_list; result = h->free_list;
h->free_list = h->free_list->next; h->free_list = h->free_list->next;
@ -1200,11 +1200,11 @@ void *gc_try_alloc_fixed_size(gc_heap * h, int heap_type, size_t size, char *obj
gc_copy_obj(result, obj, thd); gc_copy_obj(result, obj, thd);
//ck_pr_sub_ptr(&(thd->cached_heap_free_sizes[heap_type]), size); //ck_pr_sub_ptr(&(thd->cached_heap_free_sizes[heap_type]), size);
h_passed->next_free = h; //h_passed->next_free = h;
h->free_size -= size; h->free_size -= size;
return result; return result;
} }
} //}
return NULL; return NULL;
} }
@ -1243,7 +1243,7 @@ void *gc_try_alloc_slow_fixed_size(gc_heap *h_passed, gc_heap *h, int heap_type,
} }
//thd->cached_heap_free_sizes[heap_type] -= prev_free_size; //thd->cached_heap_free_sizes[heap_type] -= prev_free_size;
thd->cached_heap_total_sizes[heap_type] -= h_size; thd->cached_heap_total_sizes[heap_type] -= h_size;
h_passed->num_children--; //h_passed->num_children--;
continue; continue;
} }
} }
@ -1376,8 +1376,8 @@ fprintf(stderr, "slow alloc of %p\n", result);
if (result) { if (result) {
// Check if we need to start a major collection // Check if we need to start a major collection
if (heap_type != HEAP_HUGE && if (heap_type != HEAP_HUGE &&
((try_alloc == &gc_try_alloc_fixed_size && // Fixed-size object heap (//(try_alloc == &gc_try_alloc_fixed_size && // Fixed-size object heap
h_passed->num_unswept_children < (GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT * 128)) || // h_passed->num_unswept_children < (GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT * 128)) ||
h_passed->num_unswept_children < GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT)) { h_passed->num_unswept_children < GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT)) {
gc_start_major_collection(thd); gc_start_major_collection(thd);
} }
@ -1388,7 +1388,7 @@ fprintf(stderr, "slow alloc of %p\n", result);
/* of which are asynchronous. So... no choice but to grow the heap. */ /* of which are asynchronous. So... no choice but to grow the heap. */
gc_grow_heap(h, heap_type, size, 0, thd); gc_grow_heap(h, heap_type, size, 0, thd);
*heap_grown = 1; *heap_grown = 1;
h_passed->num_children++; //h_passed->num_children++;
// TODO: would be nice if gc_grow_heap returns new page (maybe it does) then we can start from there // TODO: would be nice if gc_grow_heap returns new page (maybe it does) then we can start from there
// otherwise will be a bit of a bottleneck since with lazy sweeping there is no guarantee we are at // otherwise will be a bit of a bottleneck since with lazy sweeping there is no guarantee we are at
// the end of the heap anymore // the end of the heap anymore

View file

@ -219,7 +219,7 @@ struct gc_heap_t {
// //
gc_free_list *free_list; gc_free_list *free_list;
gc_heap *next; // TBD, linked list is not very efficient, but easy to work with as a start gc_heap *next; // TBD, linked list is not very efficient, but easy to work with as a start
int num_children; //int num_children;
int num_unswept_children; int num_unswept_children;
char *data; char *data;
}; };