diff options
author | Andy Wingo <wingo@pobox.com> | 2018-07-16 15:42:05 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-07-20 11:42:30 +0200 |
commit | 043432fd573648fe8591672aca7e2438b71e6774 (patch) | |
tree | 15e0f687c0bb1283b3fa066ed4ef23404e757a23 /libguile/frames.h | |
parent | b1705bd0f0181a6496223b26cb5da68fa470ccaa (diff) | |
download | guile-043432fd573648fe8591672aca7e2438b71e6774.tar.gz |
Reserve frame word for machine return address
* libguile/frames.h: Add machine return address to diagram.
(SCM_FRAME_MACHINE_RETURN_ADDRESS):
(SCM_FRAME_SET_MACHINE_RETURN_ADDRESS): New macros.
(SCM_FRAME_PREVIOUS_SP):
(SCM_FRAME_DYNAMIC_LINK):
(SCM_FRAME_SET_DYNAMIC_LINK): Adapt for new frame size.
* libguile/vm-engine.c (halt): Set frame size to 3.
(call, call-label): Set mRA to 0.
* libguile/vm.c (push_interrupt_frame, reinstate_continuation_x):
(scm_call_n): Set frame size to 3. In push_interrupt_frame, init the
mRA of the frame.
(vm_builtin_call_with_values_code, vm_handle_interrupt_code): Allocate
larger frames.
* module/language/cps/slot-allocation.scm (allocate-slots): Frame size
is 3.
* module/system/vm/disassembler.scm (define-clobber-parser): Bump frame
size.
Diffstat (limited to 'libguile/frames.h')
-rw-r--r-- | libguile/frames.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/libguile/frames.h b/libguile/frames.h index 85e36a5c2..99c5dff84 100644 --- a/libguile/frames.h +++ b/libguile/frames.h @@ -44,6 +44,8 @@ | Dynamic link | +------------------------------+ | Virtual return address (vRA) | + +------------------------------+ + | Machine return address (mRA) | +==============================+ <- fp | Local 0 | +------------------------------+ @@ -57,12 +59,12 @@ The stack grows down. The calling convention is that a caller prepares a stack frame - consisting of the saved FP and the saved virtual return address, - followed by the procedure and then the arguments to the call, in - order. Thus in the beginning of a call, the procedure being called - is in slot 0, the first argument is in slot 1, and the SP points to - the last argument. The number of arguments, including the procedure, - is thus FP - SP. + consisting of the saved FP, the saved virtual return addres, and the + saved machine return address of the calling function, followed by the + procedure and then the arguments to the call, in order. Thus in the + beginning of a call, the procedure being called is in slot 0, the + first argument is in slot 1, and the SP points to the last argument. + The number of arguments, including the procedure, is thus FP - SP. After ensuring that the correct number of arguments have been passed, a function will set the stack pointer to point to the last local @@ -103,11 +105,13 @@ union scm_vm_stack_element scm_t_bits as_bits; }; -#define SCM_FRAME_PREVIOUS_SP(fp) ((fp) + 2) -#define SCM_FRAME_VIRTUAL_RETURN_ADDRESS(fp) ((fp)[0].as_vcode) -#define SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS(fp, ra) ((fp)[0].as_vcode = (ra)) -#define SCM_FRAME_DYNAMIC_LINK(fp) ((fp) + (fp)[1].as_uint) -#define SCM_FRAME_SET_DYNAMIC_LINK(fp, dl) ((fp)[1].as_uint = ((dl) - (fp))) +#define SCM_FRAME_PREVIOUS_SP(fp) ((fp) + 3) +#define SCM_FRAME_MACHINE_RETURN_ADDRESS(fp) ((fp)[0].as_mcode) +#define SCM_FRAME_SET_MACHINE_RETURN_ADDRESS(fp, ra) ((fp)[0].as_mcode = (ra)) +#define SCM_FRAME_VIRTUAL_RETURN_ADDRESS(fp) ((fp)[1].as_vcode) +#define SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS(fp, ra) ((fp)[1].as_vcode = (ra)) +#define SCM_FRAME_DYNAMIC_LINK(fp) ((fp) + (fp)[2].as_uint) +#define SCM_FRAME_SET_DYNAMIC_LINK(fp, dl) ((fp)[2].as_uint = ((dl) - (fp))) #define SCM_FRAME_SLOT(fp,i) ((fp) - (i) - 1) #define SCM_FRAME_LOCAL(fp,i) (SCM_FRAME_SLOT (fp, i)->as_scm) #define SCM_FRAME_NUM_LOCALS(fp, sp) ((fp) - (sp)) |