summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-05-23 15:16:20 +0200
committerAndy Wingo <wingo@pobox.com>2013-05-27 07:12:22 +0200
commit27319ffaa90dc5789843d8b80842b9a6d36120e1 (patch)
tree146032af165134a47ccd4caac0832db5a2a26599
parent8dd6bfa7bb786e802be49fb72ff4f526244d341d (diff)
downloadguile-27319ffaa90dc5789843d8b80842b9a6d36120e1.tar.gz
Allow vm_engine caller to pass arguments on the stack.
* libguile/vm-engine.c (vm_engine): Allow the caller to pass arguments on the stack.
-rw-r--r--libguile/vm-engine.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index b7e355d22..77c2e462a 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -356,8 +356,19 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
NEXT;
}
- /* Initial frame */
CACHE_REGISTER ();
+
+ /* Since it's possible to receive the arguments on the stack itself,
+ and indeed the RTL VM invokes us that way, shuffle up the
+ arguments first. */
+ VM_ASSERT (sp + 8 + nargs < stack_limit, vm_error_too_many_args (nargs));
+ {
+ int i;
+ for (i = nargs - 1; i >= 0; i--)
+ sp[9 + i] = argv[i];
+ }
+
+ /* Initial frame */
PUSH (SCM_PACK (fp)); /* dynamic link */
PUSH (SCM_PACK (0)); /* mvra */
PUSH (SCM_PACK (ip)); /* ra */
@@ -371,9 +382,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
PUSH (SCM_PACK (ip)); /* ra */
PUSH (program);
fp = sp + 1;
- VM_ASSERT (sp + nargs < stack_limit, vm_error_too_many_args (nargs));
- while (nargs--)
- PUSH (*argv++);
+ sp += nargs;
PUSH_CONTINUATION_HOOK ();