mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +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
|
@ -121,7 +121,7 @@ compile_compose_continuation (scm_jit_state *j, uint32_t a)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
compile_call_cc (scm_jit_state *j)
|
compile_capture_continuation (scm_jit_state *j, uint32_t dst)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,6 @@ VM_NAME (scm_thread *thread)
|
||||||
SCM_FRAME_SET_MACHINE_RETURN_ADDRESS (new_fp, 0);
|
SCM_FRAME_SET_MACHINE_RETURN_ADDRESS (new_fp, 0);
|
||||||
VP->fp = new_fp;
|
VP->fp = new_fp;
|
||||||
|
|
||||||
SYNC_IP ();
|
|
||||||
RESET_FRAME (nlocals);
|
RESET_FRAME (nlocals);
|
||||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
||||||
CACHE_SP ();
|
CACHE_SP ();
|
||||||
|
@ -429,7 +428,6 @@ VM_NAME (scm_thread *thread)
|
||||||
*/
|
*/
|
||||||
VM_DEFINE_OP (3, tail_call, "tail-call", OP1 (X32))
|
VM_DEFINE_OP (3, tail_call, "tail-call", OP1 (X32))
|
||||||
{
|
{
|
||||||
SYNC_IP ();
|
|
||||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
||||||
CACHE_SP ();
|
CACHE_SP ();
|
||||||
NEXT (0);
|
NEXT (0);
|
||||||
|
@ -726,28 +724,21 @@ VM_NAME (scm_thread *thread)
|
||||||
NEXT (2);
|
NEXT (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call/cc _:24
|
/* capture-continuation dst:24
|
||||||
*
|
*
|
||||||
* Capture the current continuation, and tail-apply the procedure in
|
* Capture the current continuation. This instruction is part of the
|
||||||
* local slot 1 to it. This instruction is part of the implementation
|
* implementation of `call/cc', and is not generated by the compiler.
|
||||||
* 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 ();
|
SYNC_IP ();
|
||||||
cont = CALL_INTRINSIC (capture_continuation, (thread));
|
SP_SET (dst, CALL_INTRINSIC (capture_continuation, (thread)));
|
||||||
|
|
||||||
RESET_FRAME (2);
|
NEXT (1);
|
||||||
|
|
||||||
SP_SET (1, SP_REF (0));
|
|
||||||
SP_SET (0, cont);
|
|
||||||
|
|
||||||
ip = CALL_INTRINSIC (get_callee_vcode, (thread));
|
|
||||||
CACHE_SP ();
|
|
||||||
|
|
||||||
NEXT (0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* abort _:24
|
/* abort _:24
|
||||||
|
|
|
@ -338,7 +338,9 @@ static const uint32_t vm_builtin_call_with_values_code[] = {
|
||||||
|
|
||||||
static const uint32_t vm_builtin_call_with_current_continuation_code[] = {
|
static const uint32_t vm_builtin_call_with_current_continuation_code[] = {
|
||||||
SCM_PACK_OP_24 (assert_nargs_ee, 2),
|
SCM_PACK_OP_24 (assert_nargs_ee, 2),
|
||||||
SCM_PACK_OP_24 (call_cc, 0)
|
SCM_PACK_OP_12_12 (mov, 1, 0),
|
||||||
|
SCM_PACK_OP_24 (capture_continuation, 0),
|
||||||
|
SCM_PACK_OP_24 (tail_call, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32_t vm_handle_interrupt_code[] = {
|
static const uint32_t vm_handle_interrupt_code[] = {
|
||||||
|
@ -1332,6 +1334,8 @@ get_callee_vcode (scm_thread *thread)
|
||||||
return SCM_PROGRAM_CODE (proc);
|
return SCM_PROGRAM_CODE (proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vp->ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (vp->fp);
|
||||||
|
|
||||||
scm_error (scm_arg_type_key, NULL, "Wrong type to apply: ~S",
|
scm_error (scm_arg_type_key, NULL, "Wrong type to apply: ~S",
|
||||||
scm_list_1 (proc), scm_list_1 (proc));
|
scm_list_1 (proc), scm_list_1 (proc));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue