summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2019-06-06 16:20:20 +0200
committerAndy Wingo <wingo@pobox.com>2019-06-06 16:36:32 +0200
commit9fd978ed7eebe32ceff7762eb87bba5d56a0743c (patch)
treee2b7e28c42924c1c5aced9f56cdbdec525c5146c /libguile/vm-engine.c
parent12d6e4317657e4334306b1345a09a11b0e256fa3 (diff)
downloadguile-9fd978ed7eebe32ceff7762eb87bba5d56a0743c.tar.gz
Add bind-optionals instruction
* doc/ref/vm.texi (Function Prologue Instructions): Document new instruction. * libguile/jit.c (compile_bind_optionals): New compiler. * libguile/vm-engine.c (VM_NAME): New interpreter. * module/system/vm/assembler.scm (opt-prelude): Emit bind-optionals as appropriate. * module/system/vm/disassembler.scm (define-stack-effect-parser) (code-annotation): Handle bind-optionals.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r--libguile/vm-engine.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 062dc00bd..a2e4be57a 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -3231,7 +3231,28 @@ VM_NAME (scm_thread *thread)
VM_DEFINE_OP (153, f64_set, "f64-set!", OP1 (X8_S8_S8_S8))
PTR_SET (double, F64);
- VM_DEFINE_OP (154, unused_154, NULL, NOP)
+ /* bind-optionals nargs:24
+ *
+ * Expand the current frame to have NARGS locals, filling in any fresh
+ * values with SCM_UNDEFINED.
+ */
+ VM_DEFINE_OP (154, bind_optionals, "bind-optionals", DOP1 (X8_F24))
+ {
+ uint32_t nlocals, nargs;
+
+ UNPACK_24 (op, nlocals);
+ nargs = FRAME_LOCALS_COUNT ();
+
+ if (nargs < nlocals)
+ {
+ ALLOC_FRAME (nlocals);
+ while (nargs < nlocals)
+ FP_SET (nargs++, SCM_UNDEFINED);
+ }
+
+ NEXT (1);
+ }
+
VM_DEFINE_OP (155, unused_155, NULL, NOP)
VM_DEFINE_OP (156, unused_156, NULL, NOP)
VM_DEFINE_OP (157, unused_157, NULL, NOP)