15
15
* This file contains the functions:
16
16
* ptr_t GC_build_flXXX(h, old_fl)
17
* void GC_new_hblk(size)
19
19
/* Boehm, May 19, 1994 2:09 pm PDT */
25
25
#ifndef SMALL_CONFIG
27
* Build a free list for size 1 objects inside hblk h. Set the last link to
27
* Build a free list for size 2 (words) cleared objects inside hblk h.
28
* Set the last link to
28
29
* be ofl. Return a pointer tpo the first free list entry.
30
ptr_t GC_build_fl1(h, ofl)
34
register word * p = h -> hb_body;
35
register word * lim = (word *)(h + 1);
42
for (; p < lim; p += 4) {
51
/* The same for size 2 cleared objects */
52
ptr_t GC_build_fl_clear2(h, ofl)
56
register word * p = h -> hb_body;
57
register word * lim = (word *)(h + 1);
31
ptr_t GC_build_fl_clear2(struct hblk *h, ptr_t ofl)
33
word * p = (word *)(h -> hb_body);
34
word * lim = (word *)(h + 1);
70
47
return((ptr_t)(p-2));
73
/* The same for size 3 cleared objects */
74
ptr_t GC_build_fl_clear3(h, ofl)
78
register word * p = h -> hb_body;
79
register word * lim = (word *)(h + 1) - 2;
85
for (; p < lim; p += 3) {
93
50
/* The same for size 4 cleared objects */
94
ptr_t GC_build_fl_clear4(h, ofl)
51
ptr_t GC_build_fl_clear4(struct hblk *h, ptr_t ofl)
98
register word * p = h -> hb_body;
99
register word * lim = (word *)(h + 1);
53
word * p = (word *)(h -> hb_body);
54
word * lim = (word *)(h + 1);
115
70
/* The same for size 2 uncleared objects */
116
ptr_t GC_build_fl2(h, ofl)
71
ptr_t GC_build_fl2(struct hblk *h, ptr_t ofl)
120
register word * p = h -> hb_body;
121
register word * lim = (word *)(h + 1);
73
word * p = (word *)(h -> hb_body);
74
word * lim = (word *)(h + 1);
133
86
/* The same for size 4 uncleared objects */
134
ptr_t GC_build_fl4(h, ofl)
87
ptr_t GC_build_fl4(struct hblk *h, ptr_t ofl)
138
register word * p = h -> hb_body;
139
register word * lim = (word *)(h + 1);
89
word * p = (word *)(h -> hb_body);
90
word * lim = (word *)(h + 1);
158
109
/* This could be called without the main GC lock, if we ensure that */
159
110
/* there is no concurrent collection which might reclaim objects that */
160
111
/* we have not yet allocated. */
161
ptr_t GC_build_fl(h, sz, clear, list)
112
ptr_t GC_build_fl(struct hblk *h, size_t sz, GC_bool clear, ptr_t list)
168
115
word *last_object; /* points to last object in new hblk */
179
126
/* the difference is less significant. */
180
127
# ifndef SMALL_CONFIG
182
case 1: return GC_build_fl1(h, list);
183
129
case 2: if (clear) {
184
130
return GC_build_fl_clear2(h, list);
186
132
return GC_build_fl2(h, list);
189
return GC_build_fl_clear3(h, list);
191
/* It's messy to do better than the default here. */
194
134
case 4: if (clear) {
195
135
return GC_build_fl_clear4(h, list);
205
145
if (clear) BZERO(h, HBLKSIZE);
207
147
/* Add objects to free list */
208
p = &(h -> hb_body[sz]); /* second object in *h */
209
prev = &(h -> hb_body[0]); /* One object behind p */
148
p = (word *)(h -> hb_body) + sz; /* second object in *h */
149
prev = (word *)(h -> hb_body); /* One object behind p */
210
150
last_object = (word *)((char *)h + HBLKSIZE);
211
151
last_object -= sz;
212
152
/* Last place for last object to start */
228
168
return ((ptr_t)p);
232
* Allocate a new heapblock for small objects of size n.
173
* Allocate a new heapblock for small objects of size gran granules.
233
174
* Add all of the heapblock's objects to the free list for objects
235
176
* Set all mark bits if objects are uncollectable.
236
177
* Will fail to do anything if we are out of memory.
238
void GC_new_hblk(sz, kind)
179
void GC_new_hblk(size_t gran, int kind)
242
register struct hblk *h; /* the new heap block */
243
register GC_bool clear = GC_obj_kinds[kind].ok_init;
181
struct hblk *h; /* the new heap block */
182
GC_bool clear = GC_obj_kinds[kind].ok_init;
246
if ((sizeof (struct hblk)) > HBLKSIZE) {
247
ABORT("HBLK SZ inconsistency");
184
/* Ignore gcc "no effect" warning on the following: */
185
GC_STATIC_ASSERT((sizeof (struct hblk)) == HBLKSIZE);
250
187
if (GC_debugging_started) clear = TRUE;
252
189
/* Allocate a new heap block */
253
h = GC_allochblk(sz, kind, 0);
190
h = GC_allochblk(GRANULES_TO_BYTES(gran), kind, 0);
254
191
if (h == 0) return;
256
193
/* Mark all objects if appropriate. */
257
194
if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
259
196
/* Build the free list */
260
GC_obj_kinds[kind].ok_freelist[sz] =
261
GC_build_fl(h, sz, clear, GC_obj_kinds[kind].ok_freelist[sz]);
197
GC_obj_kinds[kind].ok_freelist[gran] =
198
GC_build_fl(h, GRANULES_TO_WORDS(gran), clear,
199
GC_obj_kinds[kind].ok_freelist[gran]);