Fix callstack relocation

release
Slava 2007-09-22 18:56:27 -04:00
parent 05e66a0659
commit 64e3e0c0d6
4 changed files with 18 additions and 7 deletions

Binary file not shown.

View File

@ -173,6 +173,8 @@ void fixup_alien(F_ALIEN *d)
d->expired = T;
}
F_FIXNUM delta;
void fixup_stack_frame(F_STACK_FRAME *frame)
{
code_fixup(&frame->xt);
@ -185,13 +187,22 @@ void fixup_stack_frame(F_STACK_FRAME *frame)
}
#ifdef CALLSTACK_UP_P
printf("%x %x\n",frame->xt,*(CELL *)(frame->next + 1));
code_fixup((CELL *)(frame->next + 1));
F_STACK_FRAME *next = REBASE_FRAME_SUCCESSOR(frame,delta);
code_fixup((XT *)(next + 1));
#else
code_fixup(&frame->return_address);
#endif
}
void fixup_callstack_object(F_CALLSTACK *stack)
{
CELL top = (CELL)(stack + 1);
CELL bottom = top + untag_fixnum_fast(stack->length);
delta = (bottom - stack->bottom);
iterate_callstack_object(stack,fixup_stack_frame);
}
/* Initialize an object in a newly-loaded image */
void relocate_object(CELL relocating)
{
@ -212,9 +223,7 @@ void relocate_object(CELL relocating)
fixup_alien((F_ALIEN *)relocating);
break;
case CALLSTACK_TYPE:
iterate_callstack_object(
(F_CALLSTACK *)relocating,
fixup_stack_frame);
fixup_callstack_object((F_CALLSTACK *)relocating);
break;
}
}

View File

@ -111,7 +111,7 @@ void iterate_callstack(CELL top, CELL bottom, CELL base, CALLSTACK_ITER iterator
while(ITERATING_P)
{
F_STACK_FRAME *next = (F_STACK_FRAME *)((CELL)FRAME_SUCCESSOR(frame) + delta);
F_STACK_FRAME *next = REBASE_FRAME_SUCCESSOR(frame,delta);
iterator(frame);
frame = next;
}
@ -344,7 +344,7 @@ static F_FIXNUM delta;
void adjust_stack_frame(F_STACK_FRAME *frame)
{
FRAME_SUCCESSOR(frame) = (F_STACK_FRAME *)((CELL)FRAME_SUCCESSOR(frame) + delta);
FRAME_SUCCESSOR(frame) = REBASE_FRAME_SUCCESSOR(frame,delta);
}
void adjust_callstack(F_CALLSTACK *stack, CELL bottom)

View File

@ -56,6 +56,8 @@ void init_stacks(CELL ds_size, CELL rs_size);
#define FIRST_STACK_FRAME(stack) (F_STACK_FRAME *)((stack) + 1)
#define REBASE_FRAME_SUCCESSOR(frame,delta) (F_STACK_FRAME *)((CELL)FRAME_SUCCESSOR(frame) + delta)
typedef void (*CALLSTACK_ITER)(F_STACK_FRAME *frame);
void iterate_callstack(CELL top, CELL bottom, CELL base, CALLSTACK_ITER iterator);