1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

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.
This commit is contained in:
Andy Wingo 2018-07-15 09:50:52 +02:00
parent e95f15c932
commit b1705bd0f0
8 changed files with 70 additions and 62 deletions

View file

@ -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);