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

add a multiple values return address to stack frames

* libguile/frames.c (frame-mv-return-address): New accessor.

* libguile/frames.h: Update frame diagram.
  (SCM_FRAME_UPPER_ADDRESS): Update for data area
  growing by one pointer.
  (SCM_FRAME_MV_RETURN_ADDRESS): New macro.

* libguile/vm-engine.h (NEW_FRAME): Update for frame getting bigger by a
  pointer. In a normal NEW_FRAME, set the MV return address to NULL, to
  indicate that this continuation does not accept multiple values.

* libguile/vm-i-system.c (tail-call): Update frame replacement code to
  understand the MV return address.
  (return): Make room for the MVRA.
This commit is contained in:
Andy Wingo 2008-09-13 19:15:20 +02:00
parent 28106f547d
commit da320011a3
4 changed files with 27 additions and 8 deletions

View file

@ -571,13 +571,14 @@ VM_DEFINE_INSTRUCTION (tail_call, "tail-call", 1, -1, 1)
{
SCM *data, *tail_args, *dl;
int i;
scm_byte_t *ra;
scm_byte_t *ra, *mvra;
EXIT_HOOK ();
/* save registers */
tail_args = stack_base + 2;
ra = SCM_FRAME_RETURN_ADDRESS (fp);
mvra = SCM_FRAME_MV_RETURN_ADDRESS (fp);
dl = SCM_FRAME_DYNAMIC_LINK (fp);
/* switch programs */
@ -590,7 +591,7 @@ VM_DEFINE_INSTRUCTION (tail_call, "tail-call", 1, -1, 1)
sure we have space for the locals now */
data = SCM_FRAME_DATA_ADDRESS (fp);
ip = bp->base;
stack_base = data + 3;
stack_base = data + 4;
sp = stack_base;
CHECK_OVERFLOW ();
@ -608,7 +609,8 @@ VM_DEFINE_INSTRUCTION (tail_call, "tail-call", 1, -1, 1)
CONS (external, SCM_UNDEFINED, external);
/* Set frame data */
data[3] = (SCM)ra;
data[4] = (SCM)ra;
data[3] = (SCM)mvra;
data[2] = (SCM)dl;
data[1] = SCM_BOOL_F;
data[0] = external;
@ -731,13 +733,13 @@ VM_DEFINE_INSTRUCTION (return, "return", 0, 0, 1)
#ifdef THE_GOVERNMENT_IS_AFTER_ME
if (sp != stack_base)
abort ();
if (stack_base != data + 3)
if (stack_base != data + 4)
abort ();
#endif
/* Restore registers */
sp = SCM_FRAME_LOWER_ADDRESS (fp);
ip = SCM_FRAME_BYTE_CAST (data[3]);
ip = SCM_FRAME_BYTE_CAST (data[4]);
fp = SCM_FRAME_STACK_CAST (data[2]);
stack_base = SCM_FRAME_UPPER_ADDRESS (fp) - 1;