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 = frame_return_address(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,
45 if (ctx->callstack_top == ctx->callstack_bottom)
48 char* frame_top = (char*)ctx->callstack_top;
50 while (frame_top < (char*)ctx->callstack_bottom) {
51 void* addr = frame_return_address((void*)frame_top);
52 FACTOR_ASSERT(addr != 0);
53 void* fixed_addr = Fixup::translated_code_block_map
54 ? (void*)fixup.translate_code((code_block*)addr)
57 code_block* owner = code->code_block_for_address((cell)fixed_addr);
58 code_block* fixed_owner =
59 Fixup::translated_code_block_map ? owner : fixup.translate_code(owner);
62 fixed_owner->stack_frame_size_for_address((cell)fixed_addr);
64 void* fixed_addr_for_iter =
65 Fixup::translated_code_block_map ? fixed_addr : addr;
67 iterator(frame_top, frame_size, owner, fixed_addr_for_iter);
68 frame_top += frame_size;
72 /* Allocates memory */
73 template <typename Iterator>
74 inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator) {
76 iterate_callstack(ctx, iterator, none);