1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-21 20:20:24 +02:00

Maybe enter JIT when returning from interpreted functions

* libguile/jit.c (scm_jit_compute_mcode): Minor optimization.
* libguile/vm-engine.c (return-values): Maybe return to JIT code.
This commit is contained in:
Andy Wingo 2018-08-29 17:54:19 +02:00
parent c03e2bbbb4
commit 24d09b16b6
2 changed files with 18 additions and 14 deletions

View file

@ -4425,14 +4425,11 @@ scm_sys_jit_compile (SCM fn)
const uint8_t * const uint8_t *
scm_jit_compute_mcode (scm_thread *thread, struct scm_jit_function_data *data) scm_jit_compute_mcode (scm_thread *thread, struct scm_jit_function_data *data)
{ {
const uint32_t *start = (const uint32_t *) (((char *)data) + data->start); uint8_t *mcode_start = data->mcode;
const uint32_t *vcode_start = (const uint32_t *) (((char *)data) + data->start);
/* Until the JIT is tested, don't automatically JIT-compile code. if (mcode_start && vcode_start == thread->vm.ip)
Just return whatever code is already there. If we decide to buy return mcode_start;
later, replace with something that wires up a call to
"compute_mcode". */
if (start == thread->vm.ip)
return data->mcode;
return NULL; return NULL;
} }

View file

@ -565,18 +565,25 @@ VM_NAME (scm_thread *thread)
{ {
union scm_vm_stack_element *old_fp; union scm_vm_stack_element *old_fp;
size_t frame_size = 3; size_t frame_size = 3;
uint8_t *mcode;
RETURN_HOOK (); RETURN_HOOK ();
old_fp = VP->fp; old_fp = VP->fp;
ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (VP->fp); VP->fp = SCM_FRAME_DYNAMIC_LINK (old_fp);
VP->fp = SCM_FRAME_DYNAMIC_LINK (VP->fp);
/* Clear stack frame. */ mcode = SCM_FRAME_MACHINE_RETURN_ADDRESS (old_fp);
while (frame_size--) if (mcode)
old_fp[frame_size].as_scm = SCM_BOOL_F; {
scm_jit_enter_mcode (thread, mcode);
NEXT (0); CACHE_REGISTER ();
NEXT (0);
}
else
{
ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (old_fp);
NEXT (0);
}
} }