mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 23:50:19 +02:00
Change call/cc inst to capture-continuation
* libguile/jit.c (compile_capture_continuation): Rename from call_cc now that the call is elsewhere. * libguile/vm-engine.c (call, tail-call): Remove needless SYNC_IP before get-callee-vcode; the intrinsic can sync the ip if needed from the frame. (capture-continuation): Rename from call/cc, and leave the call itself to tail-call. * libguile/vm.c (vm_builtin_call_with_current_continuation_code): Update to put the continuation in a local and then tail call. (get_callee_vcode): Sync vp->ip if we error.
This commit is contained in:
parent
926b72f5ac
commit
c3ff72cb81
3 changed files with 15 additions and 20 deletions
|
@ -379,7 +379,6 @@ VM_NAME (scm_thread *thread)
|
|||
SCM_FRAME_SET_MACHINE_RETURN_ADDRESS (new_fp, 0);
|
||||
VP->fp = new_fp;
|
||||
|
||||
SYNC_IP ();
|
||||
RESET_FRAME (nlocals);
|
||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
||||
CACHE_SP ();
|
||||
|
@ -429,7 +428,6 @@ VM_NAME (scm_thread *thread)
|
|||
*/
|
||||
VM_DEFINE_OP (3, tail_call, "tail-call", OP1 (X32))
|
||||
{
|
||||
SYNC_IP ();
|
||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
||||
CACHE_SP ();
|
||||
NEXT (0);
|
||||
|
@ -726,28 +724,21 @@ VM_NAME (scm_thread *thread)
|
|||
NEXT (2);
|
||||
}
|
||||
|
||||
/* call/cc _:24
|
||||
/* capture-continuation dst:24
|
||||
*
|
||||
* Capture the current continuation, and tail-apply the procedure in
|
||||
* local slot 1 to it. This instruction is part of the implementation
|
||||
* of `call/cc', and is not generated by the compiler.
|
||||
* Capture the current continuation. This instruction is part of the
|
||||
* implementation of `call/cc', and is not generated by the compiler.
|
||||
*/
|
||||
VM_DEFINE_OP (15, call_cc, "call/cc", OP1 (X32))
|
||||
VM_DEFINE_OP (15, capture_continuation, "capture-continuation", DOP1 (X8_S24))
|
||||
{
|
||||
SCM cont;
|
||||
uint32_t dst;
|
||||
|
||||
UNPACK_24 (op, dst);
|
||||
|
||||
SYNC_IP ();
|
||||
cont = CALL_INTRINSIC (capture_continuation, (thread));
|
||||
SP_SET (dst, CALL_INTRINSIC (capture_continuation, (thread)));
|
||||
|
||||
RESET_FRAME (2);
|
||||
|
||||
SP_SET (1, SP_REF (0));
|
||||
SP_SET (0, cont);
|
||||
|
||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
||||
CACHE_SP ();
|
||||
|
||||
NEXT (0);
|
||||
NEXT (1);
|
||||
}
|
||||
|
||||
/* abort _:24
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue