VM: possible fix for #1265. the size of the stack frame appears to have been miscalculated in iterate_callstack which this commit fixes.
parent
ee5fd49b9e
commit
d18c48c75b
|
@ -28,6 +28,7 @@ inline void factor_vm::iterate_callstack_object(callstack* stack_,
|
||||||
iterator(frame_top, frame_size, owner, fixed_addr);
|
iterator(frame_top, frame_size, owner, fixed_addr);
|
||||||
frame_offset += frame_size;
|
frame_offset += frame_size;
|
||||||
}
|
}
|
||||||
|
FACTOR_ASSERT(frame_offset == frame_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
|
@ -40,30 +41,31 @@ inline void factor_vm::iterate_callstack_object(callstack* stack,
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
template <typename Iterator, typename Fixup>
|
template <typename Iterator, typename Fixup>
|
||||||
inline void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
|
void factor_vm::iterate_callstack(context* ctx, Iterator& iterator,
|
||||||
Fixup& fixup) {
|
Fixup& fixup) {
|
||||||
|
|
||||||
cell frame_top = ctx->callstack_top;
|
FACTOR_ASSERT(!Fixup::translated_code_block_map);
|
||||||
|
cell top = ctx->callstack_top;
|
||||||
|
|
||||||
while (frame_top < ctx->callstack_bottom) {
|
while (top < ctx->callstack_bottom) {
|
||||||
cell addr = *(cell*)frame_top;
|
cell addr = *(cell*)top;
|
||||||
FACTOR_ASSERT(addr != 0);
|
FACTOR_ASSERT(addr != 0);
|
||||||
cell fixed_addr = Fixup::translated_code_block_map
|
|
||||||
? (cell)fixup.translate_code((code_block*)addr)
|
|
||||||
: addr;
|
|
||||||
|
|
||||||
code_block* owner = code->code_block_for_address(fixed_addr);
|
/* Only the address is valid, if the code heap has been compacted,
|
||||||
code_block* fixed_owner =
|
owner might not point to a real code block. */
|
||||||
Fixup::translated_code_block_map ? owner : fixup.translate_code(owner);
|
code_block* owner = code->code_block_for_address(addr);
|
||||||
|
code_block* fixed_owner = fixup.translate_code(owner);
|
||||||
|
|
||||||
cell frame_size = fixed_owner->stack_frame_size_for_address(fixed_addr);
|
cell delta = addr - (cell)owner - sizeof(code_block);
|
||||||
|
cell natural_frame_size = fixed_owner->stack_frame_size();
|
||||||
|
cell size = LEAF_FRAME_SIZE;
|
||||||
|
if (natural_frame_size > 0 && delta > 0)
|
||||||
|
size = natural_frame_size;
|
||||||
|
|
||||||
cell fixed_addr_for_iter =
|
iterator(top, size, owner, addr);
|
||||||
Fixup::translated_code_block_map ? fixed_addr : addr;
|
top += size;
|
||||||
|
|
||||||
iterator(frame_top, frame_size, owner, fixed_addr_for_iter);
|
|
||||||
frame_top += frame_size;
|
|
||||||
}
|
}
|
||||||
|
FACTOR_ASSERT(top == ctx->callstack_bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocates memory */
|
/* Allocates memory */
|
||||||
|
|
Loading…
Reference in New Issue