summaryrefslogtreecommitdiff
path: root/libguile/control.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-02-22 21:53:24 +0100
committerAndy Wingo <wingo@pobox.com>2010-02-22 21:54:06 +0100
commit2d026f04cc581915f62b1f2f3be2f27026ee383e (patch)
tree582b9ebf67aa95937142a3c4f1d5505938788c38 /libguile/control.c
parentf828ab4f30b974c0f839fb6df9590c16907b7a0a (diff)
downloadguile-2d026f04cc581915f62b1f2f3be2f27026ee383e.tar.gz
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h: * libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie. Continuations will be rewindable only if the abort has the same cookie as the prompt. (scm_at_abort): Redefine from scm_abort, and instead of taking rest args, take the abort values as a list directly. Also, don't allow rewinding, because we won't support rewinding the C stack with delimited continuations. * libguile/eval.c (eval): Adapt to scm_c_make_prompt change. * libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value corresponding to this VM invocation. * libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt. (abort): Take an additional tail arg. * libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for the @abort case, or the (apply abort ...) case. (make_vm): Initialize the cookie to 0. * libguile/vm.h (struct scm_vm): Add cookie. * module/ice-9/boot-9.scm (abort): Define here as a trampoline to @abort. Needed to make sure that a call to abort dispatches to a VM opcode, so the cookie will be the same. * module/language/tree-il.scm (<tree-il>): Add a "tail" field to <abort>, for the (apply abort ...) case, or (@abort tag args). Should be #<const ()> in the normal case. Add support throughout. * module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail support here too. * module/language/tree-il/compile-glil.scm (flatten): Compile the tail argument appropriately. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix @abort and abort cases to pass the tail arg to make-abort.
Diffstat (limited to 'libguile/control.c')
-rw-r--r--libguile/control.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/libguile/control.c b/libguile/control.c
index a243be037..371ec2d20 100644
--- a/libguile/control.c
+++ b/libguile/control.c
@@ -27,7 +27,8 @@
SCM
-scm_c_make_prompt (SCM vm, SCM k, scm_t_uint8 escape_only_p)
+scm_c_make_prompt (SCM vm, SCM k, scm_t_uint8 escape_only_p,
+ scm_t_int64 vm_cookie)
{
scm_t_bits tag;
SCM ret;
@@ -42,6 +43,7 @@ scm_c_make_prompt (SCM vm, SCM k, scm_t_uint8 escape_only_p)
regs->fp = SCM_VM_DATA (vm)->fp;
regs->sp = SCM_VM_DATA (vm)->sp;
regs->ip = SCM_VM_DATA (vm)->ip;
+ regs->cookie = vm_cookie;
SCM_SET_CELL_OBJECT (ret, 1, k);
SCM_SET_CELL_WORD (ret, 2, (scm_t_bits)regs);
@@ -109,9 +111,9 @@ scm_c_abort (SCM vm, SCM tag, size_t n, SCM *argv)
abort ();
}
-SCM_DEFINE (scm_abort, "abort", 1, 0, 1, (SCM tag, SCM args),
+SCM_DEFINE (scm_at_abort, "@abort", 2, 0, 0, (SCM tag, SCM args),
"Abort to the nearest prompt with tag @var{tag}.")
-#define FUNC_NAME s_scm_abort
+#define FUNC_NAME s_scm_at_abort
{
SCM *argv;
size_t i, n;
@@ -123,23 +125,11 @@ SCM_DEFINE (scm_abort, "abort", 1, 0, 1, (SCM tag, SCM args),
scm_c_abort (scm_the_vm (), tag, n, argv);
- /* Oh, what, you're still here? The abort must have been reinstated. OK, pull
- args back from the stack, and keep going... */
-
- {
- SCM vals = SCM_EOL;
- struct scm_vm *vp = SCM_VM_DATA (scm_the_vm ());
- n = scm_to_size_t (vp->sp[0]);
- for (i = 0; i < n; i++)
- vals = scm_cons (vp->sp[-(i + 1)], vals);
- /* The continuation call did reset the VM's registers, but then these values
- were pushed on; so we need to pop them ourselves. */
- vp->sp -= n + 1;
- /* FIXME NULLSTACK */
-
- return (scm_is_pair (vals) && scm_is_null (scm_cdr (vals)))
- ? scm_car (vals) : scm_values (vals);
- }
+ /* Oh, what, you're still here? The abort must have been reinstated. Actually,
+ that's quite impossible, given that we're already in C-land here, so...
+ abort! */
+
+ abort ();
}
#undef FUNC_NAME