young_heap_t * create_nursery( int gen_no, gc_t *gc, /* the owning GC */ nursery_info_t *info, /* creation parameters */ word *globals /* the globals array (not in heap) */ ) { int size_bytes = info->size_bytes; young_data_t *data; young_heap_t *heap; heap = allocate_nursery( gen_no, gc ); data = heap->data; assert( size_bytes >= GC_LARGE_OBJECT_LIMIT + MAX_STACK_FRAME ); size_bytes = roundup_page( size_bytes ); data->globals = globals; data->heapsize = size_bytes; again2: data->heapbot = (word*)gclib_alloc_heap( size_bytes, data->gen_no ); if (data->heapbot == 0) { memfail( MF_HEAP, "young-heap: Could not allocate heap data area." ); goto again2; } data->heaplim = data->heapbot + bytes2words(size_bytes); /* Setup heap pointers needed by RTS */ globals[ G_EBOT ] = (word)(data->heapbot); globals[ G_ETOP ] = (word)(data->heapbot); globals[ G_ELIM ] = (word)(data->heaplim); /* Must be set up before stack can be initialized */ globals[ G_STKP ] = globals[ G_ELIM ]; globals[ G_STKUFLOW ] = 0; heap->maximum = DATA(heap)->heapsize; heap->allocated = 0; return heap; }
word *los_allocate( los_t *los, int nbytes, int gen_no ) { word *w; int size; assert( 0 <= gen_no && gen_no < los->generations && nbytes > 0 ); size = roundup_page( nbytes + sizeof(word)*HEADER_WORDS ); w = gclib_alloc_heap( size, gen_no ); gclib_add_attribute( w, size, MB_LARGE_OBJECT ); w += HEADER_WORDS; set_size( w, size ); insert_at_end( w, los->object_lists[ gen_no ] ); supremely_annoyingmsg( "{LOS} Allocating large object size %d at 0x%p", size, w ); return w; }