summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-10-18 19:21:44 +0200
committerAndy Wingo <wingo@pobox.com>2008-10-18 19:21:44 +0200
commit5e390de62f2355866e9bdad8b7aea4ac4080bdcd (patch)
tree9e4013d205e018aaf839e5a269a4355802720618 /libguile
parentb3b45ac15ef508623dd9031f3c7e69dff7949801 (diff)
downloadguile-5e390de62f2355866e9bdad8b7aea4ac4080bdcd.tar.gz
fix bug in self-tail-recursion with "external" variables; other sundries
* gdbinit (pp, inst): New commands. * libguile/vm-engine.c (vm_error_not_a_pair): New error case. * libguile/vm-i-scheme.c (VM_VALIDATE_CONS): New macro -- use this instead of SCM_VALIDATE_* because SCM_VALIDATE will exit nonlocally before we have a chance to sync the regs. (car, cdr, set-car, set-cdr): Use VM_VALIDATE_CONS. * libguile/vm-i-system.c (goto/args): Bugfix: when doing a self-tail-recursion, allocate fresh externals. Fixes use of match.go. * module/system/vm/assemble.scm (dump-object!): Add some checks that we aren't dumping out values that the VM can't handle. * module/system/vm/disasm.scm (disassemble-externals): Fix rotten call to `print-info'. * oop/goops/dispatch.scm: Add a FIXME. * testsuite/Makefile.am (vm_test_files): * testsuite/t-closure4.scm (extract-symbols): New test, distilled with much effort out of match.scm. * ice-9/Makefile.am (NOCOMP_SOURCES): Re-enable compilation of match.scm. Yay!
Diffstat (limited to 'libguile')
-rw-r--r--libguile/vm-engine.c6
-rw-r--r--libguile/vm-i-scheme.c14
-rw-r--r--libguile/vm-i-system.c8
3 files changed, 23 insertions, 5 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 3956a389d..84af98c07 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -180,6 +180,12 @@ vm_run (SCM vm, SCM program, SCM args)
err_msg = scm_from_locale_string ("VM: Attempt to unroll an improper list: tail is ~A");
goto vm_error;
+ vm_error_not_a_pair:
+ SYNC_ALL ();
+ scm_wrong_type_arg_msg (FUNC_NAME, 1, err_args, "pair");
+ /* shouldn't get here */
+ goto vm_error;
+
vm_error_no_values:
err_msg = scm_from_locale_string ("VM: 0-valued return");
err_args = SCM_EOL;
diff --git a/libguile/vm-i-scheme.c b/libguile/vm-i-scheme.c
index ee724d633..d4dac80d3 100644
--- a/libguile/vm-i-scheme.c
+++ b/libguile/vm-i-scheme.c
@@ -134,24 +134,30 @@ VM_DEFINE_FUNCTION (cons, "cons", 2)
RETURN (x);
}
+#define VM_VALIDATE_CONS(x) \
+ if (SCM_UNLIKELY (!scm_is_pair (x))) \
+ { err_args = x; \
+ goto vm_error_not_a_pair; \
+ }
+
VM_DEFINE_FUNCTION (car, "car", 1)
{
ARGS1 (x);
- SCM_VALIDATE_CONS (1, x);
+ VM_VALIDATE_CONS (x);
RETURN (SCM_CAR (x));
}
VM_DEFINE_FUNCTION (cdr, "cdr", 1)
{
ARGS1 (x);
- SCM_VALIDATE_CONS (1, x);
+ VM_VALIDATE_CONS (x);
RETURN (SCM_CDR (x));
}
VM_DEFINE_FUNCTION (set_car, "set-car!", 2)
{
ARGS2 (x, y);
- SCM_VALIDATE_CONS (1, x);
+ VM_VALIDATE_CONS (x);
SCM_SETCAR (x, y);
RETURN (SCM_UNSPECIFIED);
}
@@ -159,7 +165,7 @@ VM_DEFINE_FUNCTION (set_car, "set-car!", 2)
VM_DEFINE_FUNCTION (set_cdr, "set-cdr!", 2)
{
ARGS2 (x, y);
- SCM_VALIDATE_CONS (1, x);
+ VM_VALIDATE_CONS (x);
SCM_SETCDR (x, y);
RETURN (SCM_UNSPECIFIED);
}
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index fbb94c89a..2da2d4249 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -621,7 +621,13 @@ VM_DEFINE_INSTRUCTION (goto_args, "goto/args", 1, -1, 1)
/* Drop the first argument and the program itself. */
sp -= 2;
- NULLSTACK (bp->nargs + 1)
+ NULLSTACK (bp->nargs + 1);
+
+ /* Freshen the externals */
+ external = bp->external;
+ for (i = 0; i < bp->nexts; i++)
+ CONS (external, SCM_UNDEFINED, external);
+ SCM_FRAME_DATA_ADDRESS (fp)[0] = external;
/* Call itself */
ip = bp->base;