diff --git a/gc.c b/gc.c index 9bc27d3b..21df6578 100644 --- a/gc.c +++ b/gc.c @@ -184,6 +184,7 @@ gc_heap *gc_heap_create(int heap_type, size_t size, size_t max_size, h = malloc(padded_size); // TODO: mmap? if (!h) return NULL; + h->type = heap_type; h->size = size; //h->free_size = size; cached_heap_total_sizes[heap_type] += size; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 85477af9..ce038101 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -142,8 +142,16 @@ struct gc_thread_data_t { /* GC data structures */ -typedef enum { HEAP_SM = 0, HEAP_MED, HEAP_REST -} cached_heap_type; +/** + * Group heap pages by type, to attempt to limit fragmentation + * and improve performance. + */ +typedef enum { + HEAP_SM = 0 // 32 byte objects (min gc_heap_align) + , HEAP_MED // 64 byte objects (twice the min) + , HEAP_HUGE // Huge objects, 1 per page + , HEAP_REST // Everything else +} gc_heap_type; typedef struct gc_free_list_t gc_free_list; struct gc_free_list_t { @@ -153,6 +161,7 @@ struct gc_free_list_t { typedef struct gc_heap_t gc_heap; struct gc_heap_t { + gc_heap_type type; unsigned int size; unsigned int chunk_size; // 0 for any size, other and heap will only alloc chunks of that size unsigned int max_size;