mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 21:59:16 +02:00
WIP
This commit is contained in:
parent
3ff33cbcb8
commit
6274eb2652
1 changed files with 15 additions and 8 deletions
21
gc.c
21
gc.c
|
@ -660,6 +660,8 @@ gc_heap *gc_sweep_fixed_size(gc_heap * h, int heap_type, gc_thread_data *thd)
|
||||||
// h->data_end = h->data + h->remaining;
|
// h->data_end = h->data + h->remaining;
|
||||||
// h->free_list = NULL; // No free lists with bump&pop
|
// h->free_list = NULL; // No free lists with bump&pop
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
(thd->heap->heap[heap_type])->num_unswept_children--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
||||||
|
@ -1117,7 +1119,6 @@ void *gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, int heap_type, size_t siz
|
||||||
// prev_free_size = h_size; // Full size was cached
|
// prev_free_size = h_size; // Full size was cached
|
||||||
//}
|
//}
|
||||||
gc_heap *keep = gc_sweep(h, heap_type, thd); // Clean up garbage objects
|
gc_heap *keep = gc_sweep(h, heap_type, thd); // Clean up garbage objects
|
||||||
h_passed->num_unswept_children--;
|
|
||||||
if (!keep) {
|
if (!keep) {
|
||||||
// Heap marked for deletion, remove it and keep searching
|
// Heap marked for deletion, remove it and keep searching
|
||||||
gc_heap *freed = gc_heap_free(h, h_prev);
|
gc_heap *freed = gc_heap_free(h, h_prev);
|
||||||
|
@ -1130,6 +1131,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--;
|
||||||
|
h_passed->num_unswept_children--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1232,7 +1234,6 @@ void *gc_try_alloc_slow_fixed_size(gc_heap *h_passed, gc_heap *h, int heap_type,
|
||||||
} else if (h->is_unswept == 1 && !gc_is_heap_empty(h)) {
|
} else if (h->is_unswept == 1 && !gc_is_heap_empty(h)) {
|
||||||
unsigned int h_size = h->size;
|
unsigned int h_size = h->size;
|
||||||
gc_heap *keep = gc_sweep_fixed_size(h, heap_type, thd); // Clean up garbage objects
|
gc_heap *keep = gc_sweep_fixed_size(h, heap_type, thd); // Clean up garbage objects
|
||||||
h_passed->num_unswept_children--;
|
|
||||||
if (!keep) {
|
if (!keep) {
|
||||||
// Heap marked for deletion, remove it and keep searching
|
// Heap marked for deletion, remove it and keep searching
|
||||||
gc_heap *freed = gc_heap_free(h, h_prev);
|
gc_heap *freed = gc_heap_free(h, h_prev);
|
||||||
|
@ -1245,6 +1246,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--;
|
||||||
|
h_passed->num_unswept_children--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1381,7 +1383,7 @@ fprintf(stderr, "slow alloc of %p\n", result);
|
||||||
// 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_num_unswept_heaps(h_passed) < GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT)){
|
// gc_num_unswept_heaps(h_passed) < GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT)){
|
||||||
printf("major collection h->num_unswept = %d, computed = %d\n", h_passed->num_unswept_children, gc_num_unswept_heaps(h_passed));
|
printf("major collection heap_type = %d h->num_unswept = %d, computed = %d\n", heap_type, h_passed->num_unswept_children, gc_num_unswept_heaps(h_passed));
|
||||||
gc_start_major_collection(thd);
|
gc_start_major_collection(thd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1699,10 +1701,13 @@ gc_heap *gc_sweep(gc_heap * h, int heap_type, gc_thread_data *thd)
|
||||||
// remaining without them.
|
// remaining without them.
|
||||||
//
|
//
|
||||||
// Experimenting with only freeing huge heaps
|
// Experimenting with only freeing huge heaps
|
||||||
if (gc_is_heap_empty(h) &&
|
if (gc_is_heap_empty(h)) {
|
||||||
(h->type == HEAP_HUGE || (h->ttl--) <= 0)) {
|
if (h->type == HEAP_HUGE || (h->ttl--) <= 0) {
|
||||||
rv = NULL; // Let caller know heap needs to be freed
|
rv = NULL; // Let caller know heap needs to be freed
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
(thd->heap->heap[heap_type])->num_unswept_children--;
|
||||||
|
}
|
||||||
|
|
||||||
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
#if GC_DEBUG_SHOW_SWEEP_DIAG
|
||||||
fprintf(stderr, "\nAfter sweep -------------------------\n");
|
fprintf(stderr, "\nAfter sweep -------------------------\n");
|
||||||
|
@ -1963,6 +1968,8 @@ fprintf(stdout, "done tracing, cooperator is clearing full bits\n");
|
||||||
// thd->cached_heap_free_sizes[heap_type], thd->cached_heap_total_sizes[heap_type]);
|
// thd->cached_heap_free_sizes[heap_type], thd->cached_heap_total_sizes[heap_type]);
|
||||||
//}
|
//}
|
||||||
//h_tmp->free_size = h_tmp->size;
|
//h_tmp->free_size = h_tmp->size;
|
||||||
|
} else if (gc_is_heap_empty(h_tmp)) {
|
||||||
|
unswept++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h_head->num_unswept_children = unswept;
|
h_head->num_unswept_children = unswept;
|
||||||
|
@ -2029,7 +2036,7 @@ fprintf(stdout, "done tracing, cooperator is clearing full bits\n");
|
||||||
thd->cached_heap_free_sizes[HEAP_96] = gc_heap_free_size(thd->heap->heap[HEAP_96]) ;
|
thd->cached_heap_free_sizes[HEAP_96] = gc_heap_free_size(thd->heap->heap[HEAP_96]) ;
|
||||||
thd->cached_heap_free_sizes[HEAP_REST] = gc_heap_free_size(thd->heap->heap[HEAP_REST]);
|
thd->cached_heap_free_sizes[HEAP_REST] = gc_heap_free_size(thd->heap->heap[HEAP_REST]);
|
||||||
|
|
||||||
#if GC_DEBUG_VERBOSE
|
//#if GC_DEBUG_VERBOSE
|
||||||
fprintf(stderr, "heap %d free %zu total %zu\n", HEAP_SM, thd->cached_heap_free_sizes[HEAP_SM], thd->cached_heap_total_sizes[HEAP_SM]);
|
fprintf(stderr, "heap %d free %zu total %zu\n", HEAP_SM, thd->cached_heap_free_sizes[HEAP_SM], thd->cached_heap_total_sizes[HEAP_SM]);
|
||||||
if (thd->cached_heap_free_sizes[HEAP_SM] > thd->cached_heap_total_sizes[HEAP_SM]) {
|
if (thd->cached_heap_free_sizes[HEAP_SM] > thd->cached_heap_total_sizes[HEAP_SM]) {
|
||||||
fprintf(stderr, "gc_mut_cooperate - Invalid cached heap sizes, free=%zu total=%zu\n",
|
fprintf(stderr, "gc_mut_cooperate - Invalid cached heap sizes, free=%zu total=%zu\n",
|
||||||
|
@ -2054,7 +2061,7 @@ fprintf(stdout, "done tracing, cooperator is clearing full bits\n");
|
||||||
thd->cached_heap_free_sizes[HEAP_REST], thd->cached_heap_total_sizes[HEAP_REST]);
|
thd->cached_heap_free_sizes[HEAP_REST], thd->cached_heap_total_sizes[HEAP_REST]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
// Initiate collection cycle if free space is too low.
|
// Initiate collection cycle if free space is too low.
|
||||||
// Threshold is intentially low because we have to go through an
|
// Threshold is intentially low because we have to go through an
|
||||||
|
|
Loading…
Add table
Reference in a new issue