mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Simplify logic to match gc_sweep
This commit is contained in:
parent
3b7160bf5e
commit
92a0160383
1 changed files with 6 additions and 5 deletions
11
gc.c
11
gc.c
|
@ -541,7 +541,7 @@ size_t gc_convert_heap_page_to_free_list(gc_heap *h, gc_thread_data *thd)
|
||||||
gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd)
|
gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd)
|
||||||
{
|
{
|
||||||
short heap_is_empty;
|
short heap_is_empty;
|
||||||
object p;
|
object p, end;
|
||||||
gc_free_list *q, *r, *s;
|
gc_free_list *q, *r, *s;
|
||||||
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
||||||
gc_heap *orig_heap_ptr = h;
|
gc_heap *orig_heap_ptr = h;
|
||||||
|
@ -567,14 +567,15 @@ gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd)
|
||||||
size_t remaining = h->size - (h->size % h->block_size); // - h->block_size; // Remove first one??
|
size_t remaining = h->size - (h->size % h->block_size); // - h->block_size; // Remove first one??
|
||||||
char *data_end = h->data + remaining;
|
char *data_end = h->data + remaining;
|
||||||
heap_is_empty = 1; // Base case is an empty heap
|
heap_is_empty = 1; // Base case is an empty heap
|
||||||
|
end = (object)data_end;
|
||||||
|
p = h->data;
|
||||||
q = h->free_list;
|
q = h->free_list;
|
||||||
while (remaining) {
|
while (p < end) {
|
||||||
p = data_end - remaining;
|
|
||||||
// find preceding/succeeding free list pointers for p
|
// find preceding/succeeding free list pointers for p
|
||||||
for (r = (q?q->next:NULL); r && ((char *)r < (char *)p); q = r, r = r->next) ;
|
for (r = (q?q->next:NULL); r && ((char *)r < (char *)p); q = r, r = r->next) ;
|
||||||
if ((char *)q == (char *)p || (char *)r == (char *)p) { // this is a free block, skip it
|
if ((char *)q == (char *)p || (char *)r == (char *)p) { // this is a free block, skip it
|
||||||
//printf("Sweep skip free block %p remaining=%lu\n", p, remaining);
|
//printf("Sweep skip free block %p remaining=%lu\n", p, remaining);
|
||||||
remaining -= h->block_size;
|
p = (object) (((char *)p) + h->block_size);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if GC_SAFETY_CHECKS
|
#if GC_SAFETY_CHECKS
|
||||||
|
@ -648,7 +649,7 @@ gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd)
|
||||||
}
|
}
|
||||||
//next->next = (gc_free_list *)(((char *) next) + h->block_size);
|
//next->next = (gc_free_list *)(((char *) next) + h->block_size);
|
||||||
//next = next->next;
|
//next = next->next;
|
||||||
remaining -= h->block_size;
|
p = (object) (((char *)p) + h->block_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Free the heap page if possible.
|
// Free the heap page if possible.
|
||||||
|
|
Loading…
Add table
Reference in a new issue