Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 431 lines (372 sloc) 12.128 kb
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
1 namespace factor
2 {
3
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
4 /* Size of the object pointed to by an untagged pointer */
5 template<typename Fixup>
6 cell object::size(Fixup fixup) const
7 {
8 if(free_p()) return ((free_heap_block *)this)->size();
9
10 switch(type())
11 {
12 case ARRAY_TYPE:
13 return align(array_size((array*)this),data_alignment);
14 case BIGNUM_TYPE:
15 return align(array_size((bignum*)this),data_alignment);
16 case BYTE_ARRAY_TYPE:
17 return align(array_size((byte_array*)this),data_alignment);
18 case STRING_TYPE:
19 return align(string_size(string_capacity((string*)this)),data_alignment);
20 case TUPLE_TYPE:
21 {
22 tuple_layout *layout = (tuple_layout *)fixup.translate_data(untag<object>(((tuple *)this)->layout));
23 return align(tuple_size(layout),data_alignment);
24 }
25 case QUOTATION_TYPE:
26 return align(sizeof(quotation),data_alignment);
27 case WORD_TYPE:
28 return align(sizeof(word),data_alignment);
29 case FLOAT_TYPE:
30 return align(sizeof(boxed_float),data_alignment);
31 case DLL_TYPE:
32 return align(sizeof(dll),data_alignment);
33 case ALIEN_TYPE:
34 return align(sizeof(alien),data_alignment);
35 case WRAPPER_TYPE:
36 return align(sizeof(wrapper),data_alignment);
37 case CALLSTACK_TYPE:
38 return align(callstack_object_size(untag_fixnum(((callstack *)this)->length)),data_alignment);
39 default:
40 critical_error("Invalid header in size",(cell)this);
41 return 0; /* can't happen */
42 }
43 }
44
45 inline cell object::size() const
46 {
47 return size(no_fixup());
48 }
49
50 /* The number of cells from the start of the object which should be scanned by
51 the GC. Some types have a binary payload at the end (string, word, DLL) which
52 we ignore. */
53 template<typename Fixup>
54 cell object::binary_payload_start(Fixup fixup) const
55 {
56 if(free_p()) return 0;
57
58 switch(type())
59 {
60 /* these objects do not refer to other objects at all */
61 case FLOAT_TYPE:
62 case BYTE_ARRAY_TYPE:
63 case BIGNUM_TYPE:
64 case CALLSTACK_TYPE:
65 return 0;
66 /* these objects have some binary data at the end */
67 case WORD_TYPE:
5b43301 @jckarter vm: strip out call-counting profiler
jckarter authored
68 return sizeof(word) - sizeof(cell);
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
69 case ALIEN_TYPE:
70 return sizeof(cell) * 3;
71 case DLL_TYPE:
72 return sizeof(cell) * 2;
73 case QUOTATION_TYPE:
5b43301 @jckarter vm: strip out call-counting profiler
jckarter authored
74 return sizeof(quotation) - sizeof(cell);
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
75 case STRING_TYPE:
76 return sizeof(string);
77 /* everything else consists entirely of pointers */
78 case ARRAY_TYPE:
79 return array_size<array>(array_capacity((array*)this));
80 case TUPLE_TYPE:
81 {
82 tuple_layout *layout = (tuple_layout *)fixup.translate_data(untag<object>(((tuple *)this)->layout));
83 return tuple_size(layout);
84 }
85 case WRAPPER_TYPE:
86 return sizeof(wrapper);
87 default:
88 critical_error("Invalid header in binary_payload_start",(cell)this);
89 return 0; /* can't happen */
90 }
91 }
92
93 inline cell object::binary_payload_start() const
94 {
95 return binary_payload_start(no_fixup());
96 }
97
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
98 /* Slot visitors iterate over the slots of an object, applying a functor to
99 each one that is a non-immediate slot. The pointer is untagged first. The
100 functor returns a new untagged object pointer. The return value may or may not equal the old one,
101 however the new pointer receives the same tag before being stored back to the
102 original location.
103
104 Slots storing immediate values are left unchanged and the visitor does inspect
105 them.
106
107 This is used by GC's copying, sweep and compact phases, and the implementation
108 of the become primitive.
109
110 Iteration is driven by visit_*() methods. Some of them define GC roots:
111 - visit_roots()
112 - visit_contexts() */
113
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
114 template<typename Fixup> struct slot_visitor {
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
115 factor_vm *parent;
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
116 Fixup fixup;
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
117
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
118 explicit slot_visitor<Fixup>(factor_vm *parent_, Fixup fixup_) :
119 parent(parent_), fixup(fixup_) {}
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
120
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
121 cell visit_pointer(cell pointer);
122 void visit_handle(cell *handle);
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
123 void visit_object_array(cell *start, cell *end);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
124 void visit_slots(object *ptr, cell payload_start);
125 void visit_slots(object *ptr);
126 void visit_stack_elements(segment *region, cell *top);
127 void visit_data_roots();
128 void visit_bignum_roots();
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
129 void visit_callback_roots();
912b126 Split literal table into literal and parameter tables, literal table is ...
Slava Pestov authored
130 void visit_literal_table_roots();
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
131 void visit_roots();
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
132 void visit_callstack_object(callstack *stack);
133 void visit_callstack(context *ctx);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
134 void visit_contexts();
3789e75 vm: compaction now updates the needs_fixup set
Slava Pestov authored
135 void visit_code_block_objects(code_block *compiled);
136 void visit_embedded_literals(code_block *compiled);
2a64c3e @jckarter vm: sample code block owners instead of blocks
jckarter authored
137 void visit_sample_callstacks();
b0f6dbd @jckarter vm: sample thread object rather than raw context
jckarter authored
138 void visit_sample_threads();
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
139 };
858f20e vm: fix crash in profiler
Slava Pestov authored
140
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
141 template<typename Fixup>
142 cell slot_visitor<Fixup>::visit_pointer(cell pointer)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
143 {
144 if(immediate_p(pointer)) return pointer;
c434201 vm: eliminating literal table work in progress
Slava Pestov authored
145
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
146 object *untagged = fixup.fixup_data(untag<object>(pointer));
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
147 return RETAG(untagged,TAG(pointer));
148 }
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
149
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
150 template<typename Fixup>
151 void slot_visitor<Fixup>::visit_handle(cell *handle)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
152 {
153 *handle = visit_pointer(*handle);
154 }
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
155
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
156 template<typename Fixup>
157 void slot_visitor<Fixup>::visit_object_array(cell *start, cell *end)
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
158 {
159 while(start < end) visit_handle(start++);
160 }
161
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
162 template<typename Fixup>
163 void slot_visitor<Fixup>::visit_slots(object *ptr, cell payload_start)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
164 {
165 cell *slot = (cell *)ptr;
166 cell *end = (cell *)((cell)ptr + payload_start);
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
167
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
168 if(slot != end)
f5a6a34 vm: got data heap compaction working
Slava Pestov authored
169 {
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
170 slot++;
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
171 visit_object_array(slot,end);
f5a6a34 vm: got data heap compaction working
Slava Pestov authored
172 }
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
173 }
f5a6a34 vm: got data heap compaction working
Slava Pestov authored
174
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
175 template<typename Fixup>
176 void slot_visitor<Fixup>::visit_slots(object *obj)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
177 {
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
178 if(obj->type() == CALLSTACK_TYPE)
179 visit_callstack_object((callstack *)obj);
180 else
181 visit_slots(obj,obj->binary_payload_start(fixup));
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
182 }
183
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
184 template<typename Fixup>
185 void slot_visitor<Fixup>::visit_stack_elements(segment *region, cell *top)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
186 {
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
187 visit_object_array((cell *)region->start,top + 1);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
188 }
189
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
190 template<typename Fixup>
191 void slot_visitor<Fixup>::visit_data_roots()
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
192 {
193 std::vector<data_root_range>::const_iterator iter = parent->data_roots.begin();
194 std::vector<data_root_range>::const_iterator end = parent->data_roots.end();
195
196 for(; iter < end; iter++)
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
197 visit_object_array(iter->start,iter->start + iter->len);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
198 }
199
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
200 template<typename Fixup>
201 void slot_visitor<Fixup>::visit_bignum_roots()
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
202 {
203 std::vector<cell>::const_iterator iter = parent->bignum_roots.begin();
204 std::vector<cell>::const_iterator end = parent->bignum_roots.end();
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
205
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
206 for(; iter < end; iter++)
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
207 {
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
208 cell *handle = (cell *)(*iter);
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
209
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
210 if(*handle)
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
211 *handle = (cell)fixup.fixup_data(*(object **)handle);
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
212 }
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
213 }
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
214
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
215 template<typename Fixup>
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
216 struct callback_slot_visitor {
217 callback_heap *callbacks;
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
218 slot_visitor<Fixup> *visitor;
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
219
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
220 explicit callback_slot_visitor(callback_heap *callbacks_, slot_visitor<Fixup> *visitor_) :
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
221 callbacks(callbacks_), visitor(visitor_) {}
222
223 void operator()(code_block *stub)
224 {
225 visitor->visit_handle(&stub->owner);
226 }
227 };
228
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
229 template<typename Fixup>
230 void slot_visitor<Fixup>::visit_callback_roots()
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
231 {
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
232 callback_slot_visitor<Fixup> callback_visitor(parent->callbacks,this);
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
233 parent->callbacks->each_callback(callback_visitor);
234 }
235
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
236 template<typename Fixup>
237 void slot_visitor<Fixup>::visit_literal_table_roots()
912b126 Split literal table into literal and parameter tables, literal table is ...
Slava Pestov authored
238 {
239 std::map<code_block *, cell> *uninitialized_blocks = &parent->code->uninitialized_blocks;
240 std::map<code_block *, cell>::const_iterator iter = uninitialized_blocks->begin();
241 std::map<code_block *, cell>::const_iterator end = uninitialized_blocks->end();
242
243 std::map<code_block *, cell> new_uninitialized_blocks;
244 for(; iter != end; iter++)
245 {
246 new_uninitialized_blocks.insert(std::make_pair(
247 iter->first,
248 visit_pointer(iter->second)));
249 }
250
251 parent->code->uninitialized_blocks = new_uninitialized_blocks;
252 }
253
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
254 template<typename Fixup>
2a64c3e @jckarter vm: sample code block owners instead of blocks
jckarter authored
255 void slot_visitor<Fixup>::visit_sample_callstacks()
256 {
257 for (std::vector<cell>::iterator iter = parent->sample_callstacks.begin();
258 iter != parent->sample_callstacks.end();
259 ++iter)
260 {
261 visit_handle(&*iter);
262 }
263 }
264
265 template<typename Fixup>
b0f6dbd @jckarter vm: sample thread object rather than raw context
jckarter authored
266 void slot_visitor<Fixup>::visit_sample_threads()
267 {
268 for (std::vector<profiling_sample>::iterator iter = parent->samples.begin();
269 iter != parent->samples.end();
270 ++iter)
271 {
272 visit_handle(&iter->thread);
273 }
274 }
275
276 template<typename Fixup>
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
277 void slot_visitor<Fixup>::visit_roots()
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
278 {
279 visit_handle(&parent->true_object);
280 visit_handle(&parent->bignum_zero);
281 visit_handle(&parent->bignum_pos_one);
282 visit_handle(&parent->bignum_neg_one);
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
283
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
284 visit_data_roots();
285 visit_bignum_roots();
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
286 visit_callback_roots();
912b126 Split literal table into literal and parameter tables, literal table is ...
Slava Pestov authored
287 visit_literal_table_roots();
2a64c3e @jckarter vm: sample code block owners instead of blocks
jckarter authored
288 visit_sample_callstacks();
b0f6dbd @jckarter vm: sample thread object rather than raw context
jckarter authored
289 visit_sample_threads();
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
290
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
291 visit_object_array(parent->special_objects,parent->special_objects + special_object_count);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
292 }
293
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
294 template<typename Fixup>
295 struct call_frame_slot_visitor {
296 factor_vm *parent;
297 slot_visitor<Fixup> *visitor;
298
299 explicit call_frame_slot_visitor(factor_vm *parent_, slot_visitor<Fixup> *visitor_) :
300 parent(parent_), visitor(visitor_) {}
301
302 /*
00967b4 @jckarter vm: iterate_callstack_reversed in slot_visitor
jckarter authored
303 frame top -> [return address]
304 [spill area]
305 ...
306 [entry_point]
307 [size]
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
308 */
841600f @jckarter vm: stage code block map fixup properly for GC
jckarter authored
309 void operator()(void *frame_top, cell frame_size, code_block *owner, void *addr)
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
310 {
00967b4 @jckarter vm: iterate_callstack_reversed in slot_visitor
jckarter authored
311 cell return_address = owner->offset(addr);
5e39764 vm: have to be extra careful when messing with return addresses
Slava Pestov authored
312
841600f @jckarter vm: stage code block map fixup properly for GC
jckarter authored
313 code_block *compiled = Fixup::translated_code_block_map
314 ? owner
315 : visitor->fixup.translate_code(owner);
316 gc_info *info = compiled->block_gc_info();
5e39764 vm: have to be extra careful when messing with return addresses
Slava Pestov authored
317
841600f @jckarter vm: stage code block map fixup properly for GC
jckarter authored
318 FACTOR_ASSERT(return_address < compiled->size());
f34fd74 Fix win64 compile error
Slava Pestov authored
319 cell callsite = info->return_address_index(return_address);
9e1ff0c vm: fix 64-bit regression
Slava Pestov authored
320 if(callsite == (cell)-1)
5e39764 vm: have to be extra careful when messing with return addresses
Slava Pestov authored
321 return;
322
fb4de47 Add GC maps to ##box, ##box-long-long, ##alien-invoke, ##alien-indirect ...
Slava Pestov authored
323 #ifdef DEBUG_GC_MAPS
841600f @jckarter vm: stage code block map fixup properly for GC
jckarter authored
324 std::cout << "call frame code block " << compiled << " with offset " << return_address << std::endl;
fb4de47 Add GC maps to ##box, ##box-long-long, ##alien-invoke, ##alien-indirect ...
Slava Pestov authored
325 #endif
00967b4 @jckarter vm: iterate_callstack_reversed in slot_visitor
jckarter authored
326 cell *stack_pointer = (cell *)frame_top;
4877d32 compiler: preliminary implementation of tracking derived pointers in GC ...
Slava Pestov authored
327 u8 *bitmap = info->gc_info_bitmap();
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
328
4877d32 compiler: preliminary implementation of tracking derived pointers in GC ...
Slava Pestov authored
329 /* Subtract old value of base pointer from every derived pointer. */
330 for(cell spill_slot = 0; spill_slot < info->derived_root_count; spill_slot++)
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
331 {
9e1ff0c vm: fix 64-bit regression
Slava Pestov authored
332 u32 base_pointer = info->lookup_base_pointer(callsite, spill_slot);
333 if(base_pointer != (u32)-1)
fb4de47 Add GC maps to ##box, ##box-long-long, ##alien-invoke, ##alien-indirect ...
Slava Pestov authored
334 {
335 #ifdef DEBUG_GC_MAPS
4877d32 compiler: preliminary implementation of tracking derived pointers in GC ...
Slava Pestov authored
336 std::cout << "visiting derived root " << spill_slot
337 << " with base pointer " << base_pointer
338 << std::endl;
339 #endif
340 stack_pointer[spill_slot] -= stack_pointer[base_pointer];
341 }
342 }
343
344 /* Update all GC roots, including base pointers. */
345 cell callsite_gc_roots = info->callsite_gc_roots(callsite);
346
347 for(cell spill_slot = 0; spill_slot < info->gc_root_count; spill_slot++)
348 {
349 if(bitmap_p(bitmap,callsite_gc_roots + spill_slot))
350 {
351 #ifdef DEBUG_GC_MAPS
352 std::cout << "visiting GC root " << spill_slot << std::endl;
fb4de47 Add GC maps to ##box, ##box-long-long, ##alien-invoke, ##alien-indirect ...
Slava Pestov authored
353 #endif
a8e2017 vm: fix another compile warning on 32-bit Windows
Slava Pestov authored
354 visitor->visit_handle(stack_pointer + spill_slot);
fb4de47 Add GC maps to ##box, ##box-long-long, ##alien-invoke, ##alien-indirect ...
Slava Pestov authored
355 }
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
356 }
4877d32 compiler: preliminary implementation of tracking derived pointers in GC ...
Slava Pestov authored
357
358 /* Add the base pointers to obtain new derived pointer values. */
359 for(cell spill_slot = 0; spill_slot < info->derived_root_count; spill_slot++)
360 {
9e1ff0c vm: fix 64-bit regression
Slava Pestov authored
361 u32 base_pointer = info->lookup_base_pointer(callsite, spill_slot);
362 if(base_pointer != (u32)-1)
4877d32 compiler: preliminary implementation of tracking derived pointers in GC ...
Slava Pestov authored
363 stack_pointer[spill_slot] += stack_pointer[base_pointer];
364 }
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
365 }
366 };
367
368 template<typename Fixup>
369 void slot_visitor<Fixup>::visit_callstack_object(callstack *stack)
370 {
371 call_frame_slot_visitor<Fixup> call_frame_visitor(parent,this);
9df2c10 @jckarter vm: remove _reversed from callstack iterator names
jckarter authored
372 parent->iterate_callstack_object(stack,call_frame_visitor,fixup);
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
373 }
374
375 template<typename Fixup>
376 void slot_visitor<Fixup>::visit_callstack(context *ctx)
377 {
378 call_frame_slot_visitor<Fixup> call_frame_visitor(parent,this);
9df2c10 @jckarter vm: remove _reversed from callstack iterator names
jckarter authored
379 parent->iterate_callstack(ctx,call_frame_visitor,fixup);
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
380 }
381
382 template<typename Fixup>
383 void slot_visitor<Fixup>::visit_contexts()
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
384 {
adeb6fb vm: actually use context callstacks when running code
Slava Pestov authored
385 std::set<context *>::const_iterator begin = parent->active_contexts.begin();
386 std::set<context *>::const_iterator end = parent->active_contexts.end();
387 while(begin != end)
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
388 {
adeb6fb vm: actually use context callstacks when running code
Slava Pestov authored
389 context *ctx = *begin;
390
391 visit_stack_elements(ctx->datastack_seg,(cell *)ctx->datastack);
392 visit_stack_elements(ctx->retainstack_seg,(cell *)ctx->retainstack);
af573bd Add context-specific special object table, generalizing catchstack_save ...
Slava Pestov authored
393 visit_object_array(ctx->context_objects,ctx->context_objects + context_object_count);
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
394 visit_callstack(ctx);
adeb6fb vm: actually use context callstacks when running code
Slava Pestov authored
395 begin++;
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
396 }
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
397 }
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
398
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
399 template<typename Fixup>
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
400 struct literal_references_visitor {
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
401 slot_visitor<Fixup> *visitor;
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
402
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
403 explicit literal_references_visitor(slot_visitor<Fixup> *visitor_) : visitor(visitor_) {}
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
404
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
405 void operator()(instruction_operand op)
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
406 {
31a260b vm: big overhaul of non-optimizing compiler
Slava Pestov authored
407 if(op.rel_type() == RT_LITERAL)
3d33547 vm: new image relocation that doesn't use literal table
Slava Pestov authored
408 op.store_value(visitor->visit_pointer(op.load_value()));
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
409 }
410 };
411
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
412 template<typename Fixup>
413 void slot_visitor<Fixup>::visit_code_block_objects(code_block *compiled)
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
414 {
415 visit_handle(&compiled->owner);
912b126 Split literal table into literal and parameter tables, literal table is ...
Slava Pestov authored
416 visit_handle(&compiled->parameters);
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
417 visit_handle(&compiled->relocation);
3789e75 vm: compaction now updates the needs_fixup set
Slava Pestov authored
418 }
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
419
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
420 template<typename Fixup>
421 void slot_visitor<Fixup>::visit_embedded_literals(code_block *compiled)
3789e75 vm: compaction now updates the needs_fixup set
Slava Pestov authored
422 {
912b126 Split literal table into literal and parameter tables, literal table is ...
Slava Pestov authored
423 if(!parent->code->uninitialized_p(compiled))
bfa5340 vm: mark sweep now traces code block references; rename embedded_pointer...
Slava Pestov authored
424 {
a08295d GC maps for more compact inline GC checks
Slava Pestov authored
425 literal_references_visitor<Fixup> visitor(this);
ca7bca6 Big cleanup of literal table and relocation-related code
Slava Pestov authored
426 compiled->each_instruction_operand(visitor);
bfa5340 vm: mark sweep now traces code block references; rename embedded_pointer...
Slava Pestov authored
427 }
e66b867 vm: minor GC traces embedded pointers
Slava Pestov authored
428 }
429
eefcc0f vm: factor out code that visits object slots and code heap blocks into s...
Slava Pestov authored
430 }
Something went wrong with that request. Please try again.