[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/21: return-values opcode resets the frame
From: |
Andy Wingo |
Subject: |
[Guile-commits] 07/21: return-values opcode resets the frame |
Date: |
Wed, 28 Oct 2015 22:31:16 +0000 |
wingo pushed a commit to branch wip-2.1.2
in repository guile.
commit 7aee3c74f5f31c6f386c75506f43b42c786a41b4
Author: Andy Wingo <address@hidden>
Date: Wed Oct 28 10:47:18 2015 +0000
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.
---
doc/ref/vm.texi | 7 ++++---
libguile/vm-engine.c | 12 +++++++++---
module/language/cps/compile-bytecode.scm | 4 ++--
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/doc/ref/vm.texi b/doc/ref/vm.texi
index e44f211..420671a 100644
--- a/doc/ref/vm.texi
+++ b/doc/ref/vm.texi
@@ -763,12 +763,13 @@ has run, the values can be copied down via @code{mov}, or
used in place.
Return a value.
@end deftypefn
address@hidden Instruction {} return-values x24:@var{_}
address@hidden Instruction {} return-values c24:@var{nlocals}
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,
we expect that the values have already been shuffled down to a
-contiguous array starting at slot 1. We also expect the frame has
-already been reset.
+contiguous array starting at slot 1. If @var{nlocals} is nonzero, reset
+the frame to hold that number of locals. Note that a frame reset to 1
+local returns 0 values.
@end deftypefn
@deftypefn Instruction {} call/cc x24:@var{_}
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index d5f6857..45faa14 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -747,20 +747,26 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
RETURN_ONE_VALUE (SP_REF (src));
}
- /* return-values _:24
+ /* return-values nlocals:24
*
* Return a number of values from a call frame. This opcode
* corresponds to an application of `values' in tail position. As
* with tail calls, we expect that the values have already been
* 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;
+ scm_t_uint32 nlocals;
VM_HANDLE_INTERRUPTS;
+ UNPACK_24 (op, nlocals);
+ if (nlocals)
+ RESET_FRAME (nlocals);
+
old_fp = vp->fp;
ip = SCM_FRAME_RETURN_ADDRESS (vp->fp);
vp->fp = SCM_FRAME_DYNAMIC_LINK (vp->fp);
diff --git a/module/language/cps/compile-bytecode.scm
b/module/language/cps/compile-bytecode.scm
index 86c9d30..838fd4d 100644
--- a/module/language/cps/compile-bytecode.scm
+++ b/module/language/cps/compile-bytecode.scm
@@ -124,7 +124,7 @@
(emit-tail-call-label asm (1+ (length args)) k))
(($ $values ())
(emit-reset-frame asm 1)
- (emit-return-values asm))
+ (emit-return-values asm 1))
(($ $values (arg))
(if (maybe-slot arg)
(emit-return asm (from-sp (slot arg)))
@@ -138,7 +138,7 @@
((src . dst) (emit-mov asm (from-sp dst) (from-sp src))))
(lookup-parallel-moves label allocation))
(emit-reset-frame asm (1+ (length args)))
- (emit-return-values asm))
+ (emit-return-values asm (1+ (length args))))
(($ $primcall 'return (arg))
(emit-return asm (from-sp (slot arg))))))
- [Guile-commits] branch wip-2.1.2 created (now b5b6721), Andy Wingo, 2015/10/28
- [Guile-commits] 01/21: Release v2.1.1, Andy Wingo, 2015/10/28
- [Guile-commits] 02/21: Bootstrap build doesn't have to expand CPS optimizations, Andy Wingo, 2015/10/28
- [Guile-commits] 05/21: Run CSE to clean up after closure conversion, Andy Wingo, 2015/10/28
- [Guile-commits] 03/21: Revert "Bootstrap build doesn't have to expand CPS optimizations", Andy Wingo, 2015/10/28
- [Guile-commits] 06/21: Fix slot-allocation to make 'return' not need to alloc-frame, Andy Wingo, 2015/10/28
- [Guile-commits] 08/21: Don't emit redundant reset-frame before return, Andy Wingo, 2015/10/28
- [Guile-commits] 07/21: return-values opcode resets the frame,
Andy Wingo <=
- [Guile-commits] 11/21: rtl.test uses return-values, Andy Wingo, 2015/10/28
- [Guile-commits] 10/21: Always emit return-values, Andy Wingo, 2015/10/28
- [Guile-commits] 12/21: Remove use of return in disassembler.scm, Andy Wingo, 2015/10/28
- [Guile-commits] 04/21: CSE can run on first-order CPS, Andy Wingo, 2015/10/28
- [Guile-commits] 09/21: Replace return primcalls with $values, Andy Wingo, 2015/10/28
- [Guile-commits] 13/21: Remove return opcode, Andy Wingo, 2015/10/28
- [Guile-commits] 14/21: Treat tail $values as generating lazy allocations, Andy Wingo, 2015/10/28
- [Guile-commits] 17/21: Stack slots can hold a double, Andy Wingo, 2015/10/28
- [Guile-commits] 18/21: Add VM ops to pack and unpack raw f64 values., Andy Wingo, 2015/10/28
- [Guile-commits] 21/21: Scalar replacement for f64->scm, Andy Wingo, 2015/10/28