diff --git a/libguile/continuations.c b/libguile/continuations.c index 467ae4ea9..5380a5eeb 100644 --- a/libguile/continuations.c +++ b/libguile/continuations.c @@ -167,7 +167,7 @@ restore_auxiliary_stack (scm_thread *thread, scm_t_contregs *continuation) } SCM -scm_i_make_continuation (jmp_buf *registers, scm_thread *thread, SCM vm_cont) +scm_i_make_continuation (scm_thread *thread, SCM vm_cont) { SCM cont; scm_t_contregs *continuation; @@ -187,7 +187,7 @@ scm_i_make_continuation (jmp_buf *registers, scm_thread *thread, SCM vm_cont) #endif continuation->offset = continuation->stack - src; memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size); - memcpy (continuation->jmpbuf, registers, sizeof (*registers)); + memcpy (continuation->jmpbuf, thread->vm.registers, sizeof (jmp_buf)); continuation->vm_cont = vm_cont; capture_auxiliary_stack (thread, continuation); diff --git a/libguile/continuations.h b/libguile/continuations.h index 94a791db1..8893eef07 100644 --- a/libguile/continuations.h +++ b/libguile/continuations.h @@ -67,9 +67,7 @@ typedef struct -SCM_INTERNAL SCM scm_i_make_continuation (jmp_buf *registers, - scm_thread *thread, - SCM vm_cont); +SCM_INTERNAL SCM scm_i_make_continuation (scm_thread *thread, SCM vm_cont); SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont) SCM_NORETURN; SCM_INTERNAL int scm_i_continuation_to_frame (SCM cont, diff --git a/libguile/intrinsics.c b/libguile/intrinsics.c index 42b66107c..75cf2f05e 100644 --- a/libguile/intrinsics.c +++ b/libguile/intrinsics.c @@ -348,7 +348,7 @@ current_module (scm_thread *thread) } static void -push_prompt (scm_thread *thread, jmp_buf *registers, uint8_t escape_only_p, +push_prompt (scm_thread *thread, uint8_t escape_only_p, SCM tag, const union scm_vm_stack_element *sp, void *ra) { struct scm_vm *vp = &thread->vm; @@ -357,7 +357,7 @@ push_prompt (scm_thread *thread, jmp_buf *registers, uint8_t escape_only_p, flags = escape_only_p ? SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY : 0; scm_dynstack_push_prompt (&thread->dynstack, flags, tag, vp->stack_top - vp->fp, vp->stack_top - sp, - ra, registers); + ra, thread->vm.registers); } void diff --git a/libguile/intrinsics.h b/libguile/intrinsics.h index c44f83243..3c35749fc 100644 --- a/libguile/intrinsics.h +++ b/libguile/intrinsics.h @@ -54,20 +54,17 @@ typedef void (*scm_t_thread_u32_u32_scm_u8_u8_intrinsic) (scm_thread*, uint32_t, typedef SCM (*scm_t_scm_from_scm_scm_scmp_sp_intrinsic) (SCM, SCM, SCM*, const union scm_vm_stack_element*); typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_thread*, SCM) SCM_NORETURN; -typedef SCM (*scm_t_scm_from_thread_regs_intrinsic) (scm_thread*, jmp_buf*); -typedef void (*scm_t_thread_regs_scm_intrinsic) (scm_thread*, jmp_buf*, SCM); typedef int (*scm_t_int_from_scm_intrinsic) (SCM); -typedef void (*scm_t_thread_regs_intrinsic) (scm_thread*, jmp_buf*); typedef void (*scm_t_scm_scm_noreturn_intrinsic) (SCM, SCM) SCM_NORETURN; typedef void (*scm_t_noreturn_intrinsic) (void) SCM_NORETURN; typedef void (*scm_t_scm_noreturn_intrinsic) (SCM) SCM_NORETURN; typedef void (*scm_t_u32_noreturn_intrinsic) (uint32_t) SCM_NORETURN; typedef SCM (*scm_t_scm_from_thread_u64_intrinsic) (scm_thread*, uint64_t); typedef SCM (*scm_t_scm_from_thread_intrinsic) (scm_thread*); -typedef void (*scm_t_thread_regs_u8_scm_sp_ra_intrinsic) (scm_thread*, jmp_buf*, - uint8_t, SCM, - const union scm_vm_stack_element*, - void*); +typedef void (*scm_t_thread_u8_scm_sp_ra_intrinsic) (scm_thread*, + uint8_t, SCM, + const union scm_vm_stack_element*, + void*); #define SCM_FOR_ALL_VM_INTRINSICS(M) \ M(scm_from_scm_scm, add, "add", ADD) \ @@ -119,10 +116,10 @@ typedef void (*scm_t_thread_regs_u8_scm_sp_ra_intrinsic) (scm_thread*, jmp_buf*, M(thread, push_interrupt_frame, "push-interrupt-frame", PUSH_INTERRUPT_FRAME) \ M(scm_from_scm_scm_scmp_sp, foreign_call, "foreign-call", FOREIGN_CALL) \ M(thread_scm_noreturn, reinstate_continuation_x, "reinstate-continuation!", REINSTATE_CONTINUATION_X) \ - M(scm_from_thread_regs, capture_continuation, "capture-continuation", CAPTURE_CONTINUATION) \ - M(thread_regs_scm, compose_continuation, "compose-continuation", COMPOSE_CONTINUATION) \ + M(scm_from_thread, capture_continuation, "capture-continuation", CAPTURE_CONTINUATION) \ + M(thread_scm, compose_continuation, "compose-continuation", COMPOSE_CONTINUATION) \ M(int_from_scm, rest_arg_length, "rest-arg-length", REST_ARG_LENGTH) \ - M(thread_regs, abort_to_prompt, "abort-to-prompt", ABORT_TO_PROMPT) \ + M(thread, abort_to_prompt, "abort-to-prompt", ABORT_TO_PROMPT) \ M(scm_scm_noreturn, throw_, "throw", THROW) \ M(scm_scm_noreturn, throw_with_value, "throw/value", THROW_WITH_VALUE) \ M(scm_scm_noreturn, throw_with_value_and_data, "throw/value+data", THROW_WITH_VALUE_AND_DATA) \ @@ -133,7 +130,7 @@ typedef void (*scm_t_thread_regs_u8_scm_sp_ra_intrinsic) (scm_thread*, jmp_buf*, M(thread, apply_non_program, "apply-non-program", APPLY_NON_PROGRAM) \ M(scm_from_thread_u64, allocate_words, "allocate-words", ALLOCATE_WORDS) \ M(scm_from_thread, current_module, "current-module", CURRENT_MODULE) \ - M(thread_regs_u8_scm_sp_ra, push_prompt, "push-prompt", PUSH_PROMPT) \ + M(thread_u8_scm_sp_ra, push_prompt, "push-prompt", PUSH_PROMPT) \ /* Add new intrinsics here; also update scm_bootstrap_intrinsics. */ enum scm_vm_intrinsic diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 9ad2e7d72..2409af98d 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -272,7 +272,7 @@ ((uintptr_t) (ptr) % alignof_type (type) == 0) static SCM -VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) +VM_NAME (scm_thread *thread, int resume) { /* Instruction pointer: A pointer to the opcode that is currently running. */ @@ -714,7 +714,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) vmcont = SCM_PROGRAM_FREE_VARIABLE_REF (FP_REF (0), cont_idx); SYNC_IP (); - CALL_INTRINSIC (compose_continuation, (thread, registers, vmcont)); + CALL_INTRINSIC (compose_continuation, (thread, vmcont)); CACHE_REGISTER (); NEXT (0); } @@ -777,7 +777,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) SCM cont; SYNC_IP (); - cont = CALL_INTRINSIC (capture_continuation, (thread, registers)); + cont = CALL_INTRINSIC (capture_continuation, (thread)); RESET_FRAME (2); @@ -810,7 +810,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) it continues with the next instruction. */ ip++; SYNC_IP (); - CALL_INTRINSIC (abort_to_prompt, (thread, registers)); + CALL_INTRINSIC (abort_to_prompt, (thread)); /* If abort_to_prompt returned, that means there were no intervening C frames to jump over, so we just continue @@ -1676,9 +1676,8 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume) /* Push the prompt onto the dynamic stack. */ SYNC_IP (); - CALL_INTRINSIC (push_prompt, - (thread, registers, escape_only_p, - SP_REF (tag), FP_SLOT (proc_slot), ip + offset)); + CALL_INTRINSIC (push_prompt, (thread, escape_only_p, SP_REF (tag), + FP_SLOT (proc_slot), ip + offset)); NEXT (3); } diff --git a/libguile/vm.c b/libguile/vm.c index 442bd72c3..ef423b0db 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -464,8 +464,7 @@ scm_i_call_with_current_continuation (SCM proc) #undef VM_USE_HOOKS #undef VM_NAME -typedef SCM (*scm_t_vm_engine) (scm_thread *current_thread, - jmp_buf *registers, int resume); +typedef SCM (*scm_t_vm_engine) (scm_thread *current_thread, int resume); static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] = { vm_regular_engine, vm_debug_engine }; @@ -1102,7 +1101,7 @@ reinstate_continuation_x (scm_thread *thread, SCM cont) } static SCM -capture_continuation (scm_thread *thread, jmp_buf *registers) +capture_continuation (scm_thread *thread) { struct scm_vm *vp = &thread->vm; SCM vm_cont = @@ -1112,7 +1111,7 @@ capture_continuation (scm_thread *thread, jmp_buf *registers) SCM_FRAME_RETURN_ADDRESS (vp->fp), scm_dynstack_capture_all (&thread->dynstack), 0); - return scm_i_make_continuation (registers, thread, vm_cont); + return scm_i_make_continuation (thread, vm_cont); } struct compose_continuation_data @@ -1139,7 +1138,7 @@ compose_continuation_inner (void *data_ptr) } static void -compose_continuation (scm_thread *thread, jmp_buf *registers, SCM cont) +compose_continuation (scm_thread *thread, SCM cont) { struct scm_vm *vp = &thread->vm; size_t nargs; @@ -1185,7 +1184,7 @@ compose_continuation (scm_thread *thread, jmp_buf *registers, SCM cont) if (SCM_DYNSTACK_TAG_TYPE (tag) == SCM_DYNSTACK_TYPE_PROMPT) scm_dynstack_wind_prompt (&thread->dynstack, walk, old_fp_offset, - registers); + thread->vm.registers); else scm_dynstack_wind_1 (&thread->dynstack, walk); } @@ -1257,7 +1256,7 @@ scm_i_vm_abort (SCM *tag_and_argv, size_t n) } static void -abort_to_prompt (scm_thread *thread, jmp_buf *current_registers) +abort_to_prompt (scm_thread *thread) { struct scm_vm *vp = &thread->vm; scm_t_dynstack *dynstack = &thread->dynstack; @@ -1292,7 +1291,7 @@ abort_to_prompt (scm_thread *thread, jmp_buf *current_registers) captured = scm_dynstack_capture (dynstack, SCM_DYNSTACK_NEXT (prompt)); cont = capture_delimited_continuation (vp, fp, sp, ip, registers, captured, - current_registers); + thread->vm.registers); } /* Unwind. */ @@ -1316,7 +1315,7 @@ abort_to_prompt (scm_thread *thread, jmp_buf *current_registers) /* If there are intervening C frames, then jump over them, making a nonlocal exit. Otherwise fall through and let the VM pick up where it left off. */ - if (current_registers != registers) + if (thread->vm.registers != registers) longjmp (*registers, 1); } @@ -1423,7 +1422,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs) } thread->vm.registers = ®isters; - ret = vm_engines[vp->engine](thread, ®isters, resume); + ret = vm_engines[vp->engine](thread, resume); thread->vm.registers = prev_registers; return ret;