1 /* Set by the -securegc command line argument */
4 /* generational copying GC divides memory into zones */
6 /* allocation pointer is 'here'; its offset is hardcoded in the
27 CELL
*allot_markers_end
;
36 F_DATA_HEAP
*data_heap
;
38 /* the 0th generation is where new objects are allocated. */
40 #define HAVE_NURSERY_P (data_heap->gen_count>1)
41 /* where objects hang around */
42 #define AGING (data_heap->gen_count-2)
43 #define HAVE_AGING_P (data_heap->gen_count>2)
44 /* the oldest generation */
45 #define TENURED (data_heap->gen_count-1)
47 #define MIN_GEN_COUNT 1
48 #define MAX_GEN_COUNT 3
50 /* new objects are allocated here */
51 DLLEXPORT F_ZONE nursery
;
53 INLINE
bool in_zone(F_ZONE
*z
, CELL pointer
)
55 return pointer
>= z
->start
&& pointer
< z
->end
;
58 CELL
init_zone(F_ZONE
*z
, CELL size
, CELL base
);
60 void init_card_decks(void);
62 F_DATA_HEAP
*grow_data_heap(F_DATA_HEAP
*data_heap
, CELL requested_bytes
);
64 void dealloc_data_heap(F_DATA_HEAP
*data_heap
);
66 void clear_cards(CELL from
, CELL to
);
67 void clear_decks(CELL from
, CELL to
);
68 void clear_allot_markers(CELL from
, CELL to
);
69 void reset_generation(CELL i
);
70 void reset_generations(CELL from
, CELL to
);
72 void set_data_heap(F_DATA_HEAP
*data_heap_
);
74 void init_data_heap(CELL gens
,
80 /* set up guard pages to check for under/overflow.
81 size must be a multiple of the page size */
82 F_SEGMENT
*alloc_segment(CELL size
);
83 void dealloc_segment(F_SEGMENT
*block
);
85 CELL
untagged_object_size(CELL pointer
);
86 CELL
unaligned_object_size(CELL pointer
);
87 CELL
object_size(CELL pointer
);
88 CELL
binary_payload_start(CELL pointer
);
90 void begin_scan(void);
91 CELL
next_object(void);
93 void primitive_data_room(void);
94 void primitive_size(void);
96 void primitive_begin_scan(void);
97 void primitive_next_object(void);
98 void primitive_end_scan(void);
100 /* A heap walk allows useful things to be done, like finding all
101 references to an object for debugging purposes. */
104 /* GC is off during heap walking */
107 INLINE
bool in_data_heap_p(CELL ptr
)
109 return (ptr
>= data_heap
->segment
->start
110 && ptr
<= data_heap
->segment
->end
);
113 INLINE
void *allot_zone(F_ZONE
*z
, CELL a
)
116 z
->here
= h
+ align8(a
);
120 CELL
find_all_words(void);
122 /* Every object has a regular representation in the runtime, which makes GC
123 much simpler. Every slot of the object until binary_payload_start is a pointer
124 to some other object. */
125 INLINE
void do_slots(CELL obj
, void (* iter
)(CELL
*))
128 CELL payload_start
= binary_payload_start(obj
);
129 CELL end
= obj
+ payload_start
;