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 */
9 template <typename Iterator, typename Fixup>
10 inline void factor_vm::iterate_callstack_object(callstack* stack_,
13 data_root<callstack> stack(stack_, this);
14 fixnum frame_length = factor::untag_fixnum(stack->length);
15 fixnum frame_offset = 0;
17 while (frame_offset < frame_length) {
18 void* frame_top = stack->frame_top_at(frame_offset);
19 void* addr = frame_return_address(frame_top);
21 void* fixed_addr = Fixup::translated_code_block_map
22 ? (void*)fixup.translate_code((code_block*)addr)
24 code_block* owner = code->code_block_for_address((cell)fixed_addr);
25 cell frame_size = owner->stack_frame_size_for_address((cell)fixed_addr);
27 iterator(frame_top, frame_size, owner, fixed_addr);
28 frame_offset += frame_size;
32 template <typename Iterator>
33 inline void factor_vm::iterate_callstack_object(callstack* stack,
36 iterate_callstack_object(stack, iterator, none);
39 template <typename Iterator, typename Fixup>
40 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
42 if (ctx->callstack_top == ctx->callstack_bottom)
45 char* frame_top = (char*)ctx->callstack_top;
47 while (frame_top < (char*)ctx->callstack_bottom) {
48 void* addr = frame_return_address((void*)frame_top);
49 FACTOR_ASSERT(addr != 0);
50 void* fixed_addr = Fixup::translated_code_block_map
51 ? (void*)fixup.translate_code((code_block*)addr)
54 code_block* owner = code->code_block_for_address((cell)fixed_addr);
55 code_block* fixed_owner =
56 Fixup::translated_code_block_map ? owner : fixup.translate_code(owner);
59 fixed_owner->stack_frame_size_for_address((cell)fixed_addr);
61 void* fixed_addr_for_iter =
62 Fixup::translated_code_block_map ? fixed_addr : addr;
64 iterator(frame_top, frame_size, owner, fixed_addr_for_iter);
65 frame_top += frame_size;
69 template <typename Iterator>
70 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) {
72 iterate_callstack(ctx, iterator, none);