[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/27: return-values opcode resets the frame
From: |
Andy Wingo |
Subject: |
[Guile-commits] 06/27: return-values opcode resets the frame |
Date: |
Wed, 11 Nov 2015 11:39:08 +0000 |
wingo pushed a commit to branch master
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] 27/27: Bump bytecode version, (continued)
- [Guile-commits] 27/27: Bump bytecode version, Andy Wingo, 2015/11/11
- [Guile-commits] 04/27: Run CSE to clean up after closure conversion, Andy Wingo, 2015/11/11
- [Guile-commits] 01/27: Bootstrap build doesn't have to expand CPS optimizations, Andy Wingo, 2015/11/11
- [Guile-commits] 05/27: Fix slot-allocation to make 'return' not need to alloc-frame, Andy Wingo, 2015/11/11
- [Guile-commits] 07/27: Don't emit redundant reset-frame before return, Andy Wingo, 2015/11/11
- [Guile-commits] 11/27: Remove use of return in disassembler.scm, Andy Wingo, 2015/11/11
- [Guile-commits] 10/27: rtl.test uses return-values, Andy Wingo, 2015/11/11
- [Guile-commits] 13/27: Treat tail $values as generating lazy allocations, Andy Wingo, 2015/11/11
- [Guile-commits] 14/27: VM support for raw slots, Andy Wingo, 2015/11/11
- [Guile-commits] 15/27: Reflection support for unboxed f64 slots, Andy Wingo, 2015/11/11
- [Guile-commits] 06/27: return-values opcode resets the frame,
Andy Wingo <=
- [Guile-commits] 20/27: Scalar replacement for f64->scm, Andy Wingo, 2015/11/11
- [Guile-commits] 21/27: Add fadd, fsub, fmul, fdiv instructions, Andy Wingo, 2015/11/11
- [Guile-commits] 23/27: Fix slot representation computation for fadd, fmul, etc, Andy Wingo, 2015/11/11
- [Guile-commits] 19/27: bv-{f32, f64}-{ref, set!} operate on raw f64 values, Andy Wingo, 2015/11/11
- [Guile-commits] 25/27: Better f64 unboxing for loop vars that might flow to $ktail, Andy Wingo, 2015/11/11
- [Guile-commits] 17/27: Add VM ops to pack and unpack raw f64 values., Andy Wingo, 2015/11/11
- [Guile-commits] 03/27: CSE can run on first-order CPS, Andy Wingo, 2015/11/11
- [Guile-commits] 16/27: Stack slots can hold a double, Andy Wingo, 2015/11/11
- [Guile-commits] 12/27: Remove return opcode, Andy Wingo, 2015/11/11
- [Guile-commits] 09/27: Always emit return-values, Andy Wingo, 2015/11/11