13 extern zone *newspace;
15 extern bool performing_compaction;
16 extern cell collecting_gen;
17 extern bool collecting_aging_again;
19 extern cell last_code_heap_scan;
25 inline static bool collecting_accumulation_gen_p()
27 return ((data->have_aging_p()
28 && collecting_gen == data->aging()
29 && !collecting_aging_again)
30 || collecting_gen == data->tenured());
33 void copy_handle(cell *handle);
35 void garbage_collection(volatile cell gen,
36 bool growing_data_heap_,
37 cell requested_bytes);
39 /* We leave this many bytes free at the top of the nursery so that inline
40 allocation (which does not call GC because of possible roots in volatile
41 registers) does not run out of memory */
42 static const cell allot_buffer_zone = 1024;
44 inline static object *allot_zone(zone *z, cell a)
47 z->here = h + align8(a);
48 object *obj = (object *)h;
54 * It is up to the caller to fill in the object's fields in a meaningful
57 inline static object *allot_object(header header, cell size)
66 if(nursery.size - allot_buffer_zone > size)
68 /* If there is insufficient room, collect the nursery */
69 if(nursery.here + allot_buffer_zone + size > nursery.end)
70 garbage_collection(data->nursery(),false,0);
72 cell h = nursery.here;
73 nursery.here = h + align8(size);
76 /* If the object is bigger than the nursery, allocate it in
80 zone *tenured = &data->generations[data->tenured()];
82 /* If tenured space does not have enough room, collect */
83 if(tenured->here + size > tenured->end)
86 tenured = &data->generations[data->tenured()];
89 /* If it still won't fit, grow the heap */
90 if(tenured->here + size > tenured->end)
92 garbage_collection(data->tenured(),true,size);
93 tenured = &data->generations[data->tenured()];
96 obj = allot_zone(tenured,size);
98 /* Allows initialization code to store old->new pointers
99 without hitting the write barrier in the common case of
100 a nursery allocation */
108 template<typename T> T *allot(cell size)
110 return (T *)allot_object(header(T::type_number),size);
113 void copy_reachable_objects(cell scan, cell *end);
117 void clear_gc_stats();
118 PRIMITIVE(clear_gc_stats);
121 extern bool growing_data_heap;
123 inline static void check_data_pointer(object *pointer)
126 if(!growing_data_heap)
128 assert((cell)pointer >= data->seg->start
129 && (cell)pointer < data->seg->end);
134 inline static void check_tagged_pointer(cell tagged)
137 if(!immediate_p(tagged))
139 object *obj = untag<object>(tagged);
140 check_data_pointer(obj);
146 VM_ASM_API void inline_gc(cell *gc_roots_base, cell gc_roots_size);