summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-07-15 09:50:52 +0200
committerAndy Wingo <wingo@pobox.com>2018-07-20 11:42:30 +0200
commitb1705bd0f0181a6496223b26cb5da68fa470ccaa (patch)
tree709a7ac76ea0d491326ab5464820cc72132c984b /libguile/vm-engine.c
parente95f15c932650783f34253e396216c66050905f0 (diff)
downloadguile-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/vm-engine.c')
-rw-r--r--libguile/vm-engine.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index e9e1b477e..cf4cab7ff 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -321,13 +321,14 @@ VM_NAME (scm_thread *thread)
*/
VM_DEFINE_OP (0, halt, "halt", OP1 (X32))
{
- /* Boot closure in r0, empty frame in r1/r2, proc in r3, values from r4. */
-
- uint32_t nvals = FRAME_LOCALS_COUNT_FROM (4);
+ size_t frame_size = 2;
+ /* Boot closure, then empty frame, then callee, then values. */
+ size_t first_value = 1 + frame_size + 1;
+ uint32_t nvals = FRAME_LOCALS_COUNT_FROM (first_value);
SCM ret;
if (nvals == 1)
- ret = FP_REF (4);
+ ret = FP_REF (first_value);
else
{
uint32_t n;
@@ -335,10 +336,10 @@ VM_NAME (scm_thread *thread)
VM_ASSERT (nvals <= (UINTPTR_MAX >> 8), abort ());
ret = scm_words ((nvals << 8) | scm_tc7_values, nvals + 1);
for (n = 0; n < nvals; n++)
- SCM_SET_CELL_OBJECT (ret, n+1, FP_REF (4 + n));
+ SCM_SET_CELL_OBJECT (ret, n+1, FP_REF (first_value + n));
}
- VP->ip = SCM_FRAME_RETURN_ADDRESS (VP->fp);
+ VP->ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (VP->fp);
VP->sp = SCM_FRAME_PREVIOUS_SP (VP->fp);
VP->fp = SCM_FRAME_DYNAMIC_LINK (VP->fp);
@@ -371,7 +372,7 @@ VM_NAME (scm_thread *thread)
old_fp = VP->fp;
VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1);
SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp);
- SCM_FRAME_SET_RETURN_ADDRESS (VP->fp, ip + 2);
+ SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS (VP->fp, ip + 2);
RESET_FRAME (nlocals);
@@ -414,7 +415,7 @@ VM_NAME (scm_thread *thread)
old_fp = VP->fp;
VP->fp = SCM_FRAME_SLOT (old_fp, proc - 1);
SCM_FRAME_SET_DYNAMIC_LINK (VP->fp, old_fp);
- SCM_FRAME_SET_RETURN_ADDRESS (VP->fp, ip + 3);
+ SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS (VP->fp, ip + 3);
RESET_FRAME (nlocals);
@@ -576,7 +577,7 @@ VM_NAME (scm_thread *thread)
RESET_FRAME (nlocals);
old_fp = VP->fp;
- ip = SCM_FRAME_RETURN_ADDRESS (VP->fp);
+ ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (VP->fp);
VP->fp = SCM_FRAME_DYNAMIC_LINK (VP->fp);
/* Clear stack frame. */
@@ -2373,7 +2374,7 @@ VM_NAME (scm_thread *thread)
NEXT (1);
SYNC_IP ();
- CALL_INTRINSIC (push_interrupt_frame, (thread));
+ CALL_INTRINSIC (push_interrupt_frame, (thread, 0));
CACHE_SP ();
ip = (uint32_t *) vm_handle_interrupt_code;
APPLY_HOOK ();
@@ -2388,7 +2389,7 @@ VM_NAME (scm_thread *thread)
VM_DEFINE_OP (184, return_from_interrupt, "return-from-interrupt", OP1 (X32))
{
VP->sp = sp = SCM_FRAME_PREVIOUS_SP (VP->fp);
- ip = SCM_FRAME_RETURN_ADDRESS (VP->fp);
+ ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (VP->fp);
VP->fp = SCM_FRAME_DYNAMIC_LINK (VP->fp);
NEXT (0);