diff options
author | Andy Wingo <wingo@pobox.com> | 2010-02-22 21:53:24 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-02-22 21:54:06 +0100 |
commit | 2d026f04cc581915f62b1f2f3be2f27026ee383e (patch) | |
tree | 582b9ebf67aa95937142a3c4f1d5505938788c38 /libguile/vm.c | |
parent | f828ab4f30b974c0f839fb6df9590c16907b7a0a (diff) | |
download | guile-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/vm.c')
-rw-r--r-- | libguile/vm.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libguile/vm.c b/libguile/vm.c index 7433a11e3..831200fdf 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -206,15 +206,25 @@ static void vm_abort (SCM vm, size_t n) { size_t i; - SCM tag, *argv; + ssize_t tail_len; + SCM tag, tail, *argv; + /* FIXME: VM_ENABLE_STACK_NULLING */ + tail = *(SCM_VM_DATA (vm)->sp--); + /* NULLSTACK (1) */ + tail_len = scm_ilength (tail); + if (tail_len < 0) + abort (); tag = SCM_VM_DATA (vm)->sp[-n]; - argv = alloca (n * sizeof (SCM)); + argv = alloca ((n + tail_len) * sizeof (SCM)); for (i = 0; i < n; i++) argv[i] = SCM_VM_DATA (vm)->sp[-(n-1-i)]; + for (; i < n + tail_len; i++, tail = scm_cdr (tail)) + argv[i] = scm_car (tail); + /* NULLSTACK (n + 1) */ SCM_VM_DATA (vm)->sp -= n + 1; - scm_c_abort (vm, tag, n, argv); + scm_c_abort (vm, tag, n + tail_len, argv); } @@ -386,6 +396,7 @@ make_vm (void) vp->trace_level = 0; for (i = 0; i < SCM_VM_NUM_HOOKS; i++) vp->hooks[i] = SCM_BOOL_F; + vp->cookie = 0; return scm_cell (scm_tc7_vm, (scm_t_bits)vp); } #undef FUNC_NAME |