mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
return-values opcode resets the frame
* libguile/vm-engine.c (return-values): Change to also reset the frame, if nlocals is nonzero. * doc/ref/vm.texi (Procedure Call and Return Instructions): Updated docs. * module/language/cps/compile-bytecode.scm (compile-function): Adapt to call emit-return-values with the right number of arguments.
This commit is contained in:
parent
34f3fb78e0
commit
7aee3c74f5
3 changed files with 15 additions and 8 deletions
|
@ -763,12 +763,13 @@ has run, the values can be copied down via @code{mov}, or used in place.
|
||||||
Return a value.
|
Return a value.
|
||||||
@end deftypefn
|
@end deftypefn
|
||||||
|
|
||||||
@deftypefn Instruction {} return-values x24:@var{_}
|
@deftypefn Instruction {} return-values c24:@var{nlocals}
|
||||||
Return a number of values from a call frame. This opcode corresponds to
|
Return a number of values from a call frame. This opcode corresponds to
|
||||||
an application of @code{values} in tail position. As with tail calls,
|
an application of @code{values} in tail position. As with tail calls,
|
||||||
we expect that the values have already been shuffled down to a
|
we expect that the values have already been shuffled down to a
|
||||||
contiguous array starting at slot 1. We also expect the frame has
|
contiguous array starting at slot 1. If @var{nlocals} is nonzero, reset
|
||||||
already been reset.
|
the frame to hold that number of locals. Note that a frame reset to 1
|
||||||
|
local returns 0 values.
|
||||||
@end deftypefn
|
@end deftypefn
|
||||||
|
|
||||||
@deftypefn Instruction {} call/cc x24:@var{_}
|
@deftypefn Instruction {} call/cc x24:@var{_}
|
||||||
|
|
|
@ -747,20 +747,26 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
RETURN_ONE_VALUE (SP_REF (src));
|
RETURN_ONE_VALUE (SP_REF (src));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return-values _:24
|
/* return-values nlocals:24
|
||||||
*
|
*
|
||||||
* Return a number of values from a call frame. This opcode
|
* Return a number of values from a call frame. This opcode
|
||||||
* corresponds to an application of `values' in tail position. As
|
* corresponds to an application of `values' in tail position. As
|
||||||
* with tail calls, we expect that the values have already been
|
* with tail calls, we expect that the values have already been
|
||||||
* shuffled down to a contiguous array starting at slot 1.
|
* shuffled down to a contiguous array starting at slot 1.
|
||||||
* We also expect the frame has already been reset.
|
* If NLOCALS is not zero, we also reset the frame to hold NLOCALS
|
||||||
|
* values.
|
||||||
*/
|
*/
|
||||||
VM_DEFINE_OP (9, return_values, "return-values", OP1 (X32))
|
VM_DEFINE_OP (9, return_values, "return-values", OP1 (X8_C24))
|
||||||
{
|
{
|
||||||
union scm_vm_stack_element *old_fp;
|
union scm_vm_stack_element *old_fp;
|
||||||
|
scm_t_uint32 nlocals;
|
||||||
|
|
||||||
VM_HANDLE_INTERRUPTS;
|
VM_HANDLE_INTERRUPTS;
|
||||||
|
|
||||||
|
UNPACK_24 (op, nlocals);
|
||||||
|
if (nlocals)
|
||||||
|
RESET_FRAME (nlocals);
|
||||||
|
|
||||||
old_fp = vp->fp;
|
old_fp = vp->fp;
|
||||||
ip = SCM_FRAME_RETURN_ADDRESS (vp->fp);
|
ip = SCM_FRAME_RETURN_ADDRESS (vp->fp);
|
||||||
vp->fp = SCM_FRAME_DYNAMIC_LINK (vp->fp);
|
vp->fp = SCM_FRAME_DYNAMIC_LINK (vp->fp);
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
(emit-tail-call-label asm (1+ (length args)) k))
|
(emit-tail-call-label asm (1+ (length args)) k))
|
||||||
(($ $values ())
|
(($ $values ())
|
||||||
(emit-reset-frame asm 1)
|
(emit-reset-frame asm 1)
|
||||||
(emit-return-values asm))
|
(emit-return-values asm 1))
|
||||||
(($ $values (arg))
|
(($ $values (arg))
|
||||||
(if (maybe-slot arg)
|
(if (maybe-slot arg)
|
||||||
(emit-return asm (from-sp (slot arg)))
|
(emit-return asm (from-sp (slot arg)))
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
((src . dst) (emit-mov asm (from-sp dst) (from-sp src))))
|
((src . dst) (emit-mov asm (from-sp dst) (from-sp src))))
|
||||||
(lookup-parallel-moves label allocation))
|
(lookup-parallel-moves label allocation))
|
||||||
(emit-reset-frame asm (1+ (length args)))
|
(emit-reset-frame asm (1+ (length args)))
|
||||||
(emit-return-values asm))
|
(emit-return-values asm (1+ (length args))))
|
||||||
(($ $primcall 'return (arg))
|
(($ $primcall 'return (arg))
|
||||||
(emit-return asm (from-sp (slot arg))))))
|
(emit-return asm (from-sp (slot arg))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue