mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
add vm-abort-continuation-hook, vm-restore-continuation-hook
* libguile/vm-i-system.c (call_cc, tail_call_cc): Call the new RESTORE_CONTINUATION_HOOK when a continuation is restored. (prompt): Call the new ABORT_CONTINUATION_HOOK when entering the abort handler's continuation. * libguile/vm-engine.h (ABORT_CONTINUATION_HOOK) (RESTORE_CONTINUATION_HOOK): * libguile/vm.h (SCM_VM_ABORT_CONTINUATION_HOOK) (SCM_VM_RESTORE_CONTINUATION_HOOK): * libguile/vm.c: (scm_vm_abort_continuation_hook): New hook, called when entering an abort handler. (scm_vm_restore_continuation_hook): New hook, called after returning to a continuation. * module/system/vm/vm.scm: Add hooks to export list.
This commit is contained in:
parent
c45d4d775d
commit
f312025167
5 changed files with 47 additions and 5 deletions
|
@ -1142,12 +1142,17 @@ VM_DEFINE_INSTRUCTION (64, call_cc, "call/cc", 0, 1, 1)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* otherwise, the vm continuation was reinstated, and
|
||||
scm_i_vm_return_to_continuation pushed on one value. So pull our regs
|
||||
back down from the vp, and march on to the next instruction. */
|
||||
/* Otherwise, the vm continuation was reinstated, and
|
||||
vm_return_to_continuation pushed on one value. We know only one
|
||||
value was returned because we are in value context -- the
|
||||
previous block jumped to vm_call, not vm_mv_call, after all.
|
||||
|
||||
So, pull our regs back down from the vp, and march on to the
|
||||
next instruction. */
|
||||
CACHE_REGISTER ();
|
||||
program = SCM_FRAME_PROGRAM (fp);
|
||||
CACHE_PROGRAM ();
|
||||
RESTORE_CONTINUATION_HOOK ();
|
||||
NEXT;
|
||||
}
|
||||
}
|
||||
|
@ -1177,10 +1182,17 @@ VM_DEFINE_INSTRUCTION (65, tail_call_cc, "tail-call/cc", 0, 1, 1)
|
|||
else
|
||||
{
|
||||
/* Otherwise, cache regs and NEXT, as above. Invoking the continuation
|
||||
does a return from the frame, either to the RA or MVRA. */
|
||||
does a return from the frame, either to the RA or
|
||||
MVRA. */
|
||||
CACHE_REGISTER ();
|
||||
program = SCM_FRAME_PROGRAM (fp);
|
||||
CACHE_PROGRAM ();
|
||||
/* Unfortunately we don't know whether we are at the RA, and thus
|
||||
have one value without an nvalues marker, or we are at the
|
||||
MVRA and thus have multiple values and the nvalues
|
||||
marker. Instead of adding heuristics here, we will let hook
|
||||
client code do that. */
|
||||
RESTORE_CONTINUATION_HOOK ();
|
||||
NEXT;
|
||||
}
|
||||
}
|
||||
|
@ -1505,6 +1517,9 @@ VM_DEFINE_INSTRUCTION (83, prompt, "prompt", 4, 2, 0)
|
|||
CACHE_REGISTER ();
|
||||
program = SCM_FRAME_PROGRAM (fp);
|
||||
CACHE_PROGRAM ();
|
||||
/* The stack contains the values returned to this prompt, along
|
||||
with a number-of-values marker -- like an MV return. */
|
||||
ABORT_CONTINUATION_HOOK ();
|
||||
NEXT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue