diff options
author | Andy Wingo <wingo@pobox.com> | 2018-07-15 09:50:52 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-07-20 11:42:30 +0200 |
commit | b1705bd0f0181a6496223b26cb5da68fa470ccaa (patch) | |
tree | 709a7ac76ea0d491326ab5464820cc72132c984b /libguile/frames.h | |
parent | e95f15c932650783f34253e396216c66050905f0 (diff) | |
download | guile-b1705bd0f0181a6496223b26cb5da68fa470ccaa.tar.gz |
Prepare for frames having separate virtual and machine return addrs
* libguile/frames.c (scm_frame_return_address): Use
SCM_FRAME_VIRTUAL_RETURN_ADDRESS.
(scm_c_frame_previous): Likewise.
* libguile/frames.h: Update diagram for new names.
(union scm_vm_stack_element): Rename "as_ip" to "as_vcode", and
add "as_mcode" for machine code pointers.
(SCM_FRAME_VIRTUAL_RETURN_ADDRESS)
(SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS): Rename to these, from
SCM_FRAME_RETURN_ADDRESS and SCM_FRAME_SET_RETURN_ADDRESS.
* libguile/vm-engine.c (halt, call, call-label, return-values)
(return-from-interrupt): Adapt to renamings. Make "halt" have frame
size as a parameter.
* libguile/vm.c (scm_i_vm_mark_stack): Adapt to renaming.
(push_interrupt_frame): Take mRA as additional argument. In future we
will set it as frame mRA.
(capture_continuation): Adapt to renaming.
(scm_call_n): Adapt to renaming and make frame size adjustable.
(push_interrupt_frame, reinstate_continuation_x): Make frame size
adjustable.
* module/language/cps/slot-allocation.scm (allocate-slots): Make frame
size adjustable.
* libguile/intrinsics.h (scm_t_thread_mra_intrinsic): New type; use for
push_interrupt_frame.
(scm_t_thread_u8_scm_sp_vra_intrinsic): Rename from the same but was
"ra" instead of "vra", and change type to uint32_t*.
* module/system/vm/disassembler.scm (define-clobber-parser):
Parameterize clobber set for calls by frame size.
Diffstat (limited to 'libguile/frames.h')
-rw-r--r-- | libguile/frames.h | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/libguile/frames.h b/libguile/frames.h index bbc47d009..85e36a5c2 100644 --- a/libguile/frames.h +++ b/libguile/frames.h @@ -39,29 +39,30 @@ Stack frame layout ------------------ - | ... | - +==================+ <- fp + 2 = SCM_FRAME_PREVIOUS_SP (fp) - | Dynamic link | - +------------------+ - | Return address | - +==================+ <- fp - | Local 0 | - +------------------+ - | Local 1 | - +------------------+ - | ... | - +------------------+ - | Local N-1 | - \------------------/ <- sp + | ... | + +==============================+ <- fp + 2 = SCM_FRAME_PREVIOUS_SP (fp) + | Dynamic link | + +------------------------------+ + | Virtual return address (vRA) | + +==============================+ <- fp + | Local 0 | + +------------------------------+ + | Local 1 | + +------------------------------+ + | ... | + +------------------------------+ + | Local N-1 | + \------------------------------/ <- sp The stack grows down. The calling convention is that a caller prepares a stack frame - consisting of the saved FP and the 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 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. After ensuring that the correct number of arguments have been passed, a function will set the stack pointer to point to the last local @@ -90,7 +91,8 @@ union scm_vm_stack_element { uintptr_t as_uint; - uint32_t *as_ip; + uint32_t *as_vcode; + uint8_t *as_mcode; SCM as_scm; double as_f64; uint64_t as_u64; @@ -102,8 +104,8 @@ union scm_vm_stack_element }; #define SCM_FRAME_PREVIOUS_SP(fp) ((fp) + 2) -#define SCM_FRAME_RETURN_ADDRESS(fp) ((fp)[0].as_ip) -#define SCM_FRAME_SET_RETURN_ADDRESS(fp, ra) ((fp)[0].as_ip = (ra)) +#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_SLOT(fp,i) ((fp) - (i) - 1) |