From cc30168878972652ddde4489351b76dc53f20142 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 19 Feb 2020 16:53:44 +0100 Subject: [PATCH] Fix bug restoring a JIT continuation from the interpreter * libguile/vm.c (push_interrupt_frame, compose_continuation): In places where we push on synthetic frames before possibly going back to mcode, make sure that the return mcode will trampoline back to the interpreter. Fixes compose-continuation from the interpreter to partial continuations with mcode. --- libguile/vm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libguile/vm.c b/libguile/vm.c index ab6a6295e..b20c6eb5f 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -1051,6 +1051,11 @@ push_interrupt_frame (scm_thread *thread, uint8_t *mra) size_t old_frame_size = frame_locals_count (thread); SCM proc = scm_i_async_pop (thread); +#if ENABLE_JIT + if (!mra) + mra = scm_jit_return_to_interpreter_trampoline; +#endif + /* Reserve space for frame and callee. */ alloc_frame (thread, old_frame_size + frame_overhead + 1); @@ -1191,6 +1196,12 @@ compose_continuation (scm_thread *thread, SCM cont) if (SCM_UNLIKELY (! SCM_VM_CONT_REWINDABLE_P (cont))) scm_wrong_type_arg_msg (NULL, 0, cont, "resumable continuation"); +#if ENABLE_JIT + if (!SCM_FRAME_MACHINE_RETURN_ADDRESS (vp->fp)) + SCM_FRAME_SET_MACHINE_RETURN_ADDRESS + (vp->fp, scm_jit_return_to_interpreter_trampoline); +#endif + nargs = frame_locals_count (thread) - 1; args = alloca (nargs * sizeof (*args)); memcpy (args, vp->sp, nargs * sizeof (*args));