mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Added heap merge functions
This commit is contained in:
parent
8b530989ee
commit
e30ff16b3d
2 changed files with 30 additions and 5 deletions
33
gc.c
33
gc.c
|
@ -1684,11 +1684,11 @@ void gc_thread_data_free(gc_thread_data * thd)
|
|||
{
|
||||
if (thd) {
|
||||
//
|
||||
!!
|
||||
TODO: (not necessarily here, but somewhere need to roll heap pages into
|
||||
another thread data. need to include cached heap sizes/total, too.
|
||||
then free cached heap vars here.
|
||||
!!
|
||||
// !!
|
||||
// TODO: (not necessarily here, but somewhere need to roll heap pages into
|
||||
// another thread data. need to include cached heap sizes/total, too.
|
||||
// then free cached heap vars here.
|
||||
// !!
|
||||
//
|
||||
if (pthread_mutex_destroy(&thd->lock) != 0) {
|
||||
// TODO: can only destroy the lock if it is unlocked. need to make sure we
|
||||
|
@ -1714,6 +1714,29 @@ void gc_thread_data_free(gc_thread_data * thd)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge one heap into another. Assumes appropriate locks are already held.
|
||||
*/
|
||||
void gc_heap_merge(gc_heap *hdest, gc_heap *hsrc)
|
||||
{
|
||||
gc_heap *last = gc_heap_last(hdest);
|
||||
last->next = hsrc;
|
||||
}
|
||||
|
||||
void gc_heap_merge_all(gc_heap_root *dest, gc_heap_root *src)
|
||||
{
|
||||
gc_heap *hdest, *hsrc;
|
||||
int heap_type;
|
||||
|
||||
for (heap_type = 0; heap_type < NUM_HEAP_TYPES; heap_type++) {
|
||||
hdest = dest->heap[heap_type];
|
||||
hsrc = src->heap[heap_type];
|
||||
if (hdest && hsrc) {
|
||||
gc_heap_merge(hdest, hsrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called explicitly from a mutator thread to let the collector know
|
||||
* it (may) block for an unknown period of time.
|
||||
|
|
|
@ -662,6 +662,8 @@ void gc_remove_mutator(gc_thread_data * thd);
|
|||
gc_heap *gc_heap_create(int heap_type, size_t size, size_t max_size,
|
||||
size_t chunk_size, gc_thread_data *thd);
|
||||
gc_heap *gc_heap_free(gc_heap *page, gc_heap *prev_page);
|
||||
void gc_heap_merge(gc_heap *hdest, gc_heap *hsrc);
|
||||
void gc_heap_merge_all(gc_heap_root *dest, gc_heap_root *src);
|
||||
void gc_print_stats(gc_heap * h);
|
||||
int gc_grow_heap(gc_heap * h, int heap_type, size_t size, size_t chunk_size, gc_thread_data *thd);
|
||||
char *gc_copy_obj(object hp, char *obj, gc_thread_data * thd);
|
||||
|
|
Loading…
Add table
Reference in a new issue