3 inline static cell callstack_object_size(cell size) {
4 return sizeof(callstack) + size;
7 /* This is a little tricky. The iterator may allocate memory, so we
8 keep the callstack in a GC root and use relative offsets */
10 template <typename Iterator, typename Fixup>
11 inline void factor_vm::iterate_callstack_object(callstack* stack_,
14 data_root<callstack> stack(stack_, this);
15 fixnum frame_length = factor::untag_fixnum(stack->length);
16 fixnum frame_offset = 0;
18 while (frame_offset < frame_length) {
19 void* frame_top = stack->frame_top_at(frame_offset);
20 void* addr = *(void**)frame_top;
22 void* fixed_addr = Fixup::translated_code_block_map
23 ? (void*)fixup.translate_code((code_block*)addr)
25 code_block* owner = code->code_block_for_address((cell)fixed_addr);
26 cell frame_size = owner->stack_frame_size_for_address((cell)fixed_addr);
28 iterator(frame_top, frame_size, owner, fixed_addr);
29 frame_offset += frame_size;
33 /* Allocates memory */
34 template <typename Iterator>
35 inline void factor_vm::iterate_callstack_object(callstack* stack,
38 iterate_callstack_object(stack, iterator, none);
41 /* Allocates memory */
42 template <typename Iterator, typename Fixup>
43 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
46 char* frame_top = (char*)ctx->callstack_top;
48 while (frame_top < (char*)ctx->callstack_bottom) {
49 void* addr = *(void**)frame_top;
50 FACTOR_ASSERT(addr != 0);
51 void* fixed_addr = Fixup::translated_code_block_map
52 ? (void*)fixup.translate_code((code_block*)addr)
55 code_block* owner = code->code_block_for_address((cell)fixed_addr);
56 code_block* fixed_owner =
57 Fixup::translated_code_block_map ? owner : fixup.translate_code(owner);
60 fixed_owner->stack_frame_size_for_address((cell)fixed_addr);
62 void* fixed_addr_for_iter =
63 Fixup::translated_code_block_map ? fixed_addr : addr;
65 iterator(frame_top, frame_size, owner, fixed_addr_for_iter);
66 frame_top += frame_size;
70 /* Allocates memory */
71 template <typename Iterator>
72 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) {
74 iterate_callstack(ctx, iterator, none);