1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 20:30:28 +02:00

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.
This commit is contained in:
Andy Wingo 2010-02-22 21:53:24 +01:00
parent f828ab4f30
commit 2d026f04cc
12 changed files with 71 additions and 50 deletions

View file

@ -1464,7 +1464,7 @@ VM_DEFINE_INSTRUCTION (83, prompt, "prompt", 4, 2, 0)
/* Push the prompt onto the dynamic stack. The setjmp itself has to be local
to this procedure. */
/* FIXME: do more error checking */
prompt = scm_c_make_prompt (vm, k, escape_only_p);
prompt = scm_c_make_prompt (vm, k, escape_only_p, vm_cookie);
scm_i_set_dynwinds (scm_cons (prompt, scm_i_dynwinds ()));
if (SCM_PROMPT_SETJMP (prompt))
{
@ -1509,7 +1509,7 @@ VM_DEFINE_INSTRUCTION (86, abort, "abort", 1, -1, -1)
{
unsigned n = FETCH ();
SYNC_REGISTER ();
if (sp - n - 1 <= SCM_FRAME_UPPER_ADDRESS (fp))
if (sp - n - 2 <= SCM_FRAME_UPPER_ADDRESS (fp))
goto vm_error_stack_underflow;
vm_abort (vm, n);
/* vm_abort should not return */