diff options
author | Andy Wingo <wingo@pobox.com> | 2018-08-29 17:54:19 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-08-29 17:54:19 +0200 |
commit | 24d09b16b60c6c8f0dee8e3cd69de0e677601ee7 (patch) | |
tree | 2a0303169124b87d1115c4ce04574568f7114b27 | |
parent | c03e2bbbb411267041f5fbba62c9a8f967a2c3fc (diff) | |
download | guile-24d09b16b60c6c8f0dee8e3cd69de0e677601ee7.tar.gz |
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.
-rw-r--r-- | libguile/jit.c | 13 | ||||
-rw-r--r-- | libguile/vm-engine.c | 21 |
2 files changed, 19 insertions, 15 deletions
diff --git a/libguile/jit.c b/libguile/jit.c index c9328d2d6..867ee7f2d 100644 --- a/libguile/jit.c +++ b/libguile/jit.c @@ -4425,14 +4425,11 @@ scm_sys_jit_compile (SCM fn) const uint8_t * scm_jit_compute_mcode (scm_thread *thread, struct scm_jit_function_data *data) { - const uint32_t *start = (const uint32_t *) (((char *)data) + data->start); - - /* Until the JIT is tested, don't automatically JIT-compile code. - Just return whatever code is already there. If we decide to buy - later, replace with something that wires up a call to - "compute_mcode". */ - if (start == thread->vm.ip) - return data->mcode; + uint8_t *mcode_start = data->mcode; + const uint32_t *vcode_start = (const uint32_t *) (((char *)data) + data->start); + + if (mcode_start && vcode_start == thread->vm.ip) + return mcode_start; return NULL; } diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index c8db813a6..58ff53cda 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -565,18 +565,25 @@ VM_NAME (scm_thread *thread) { union scm_vm_stack_element *old_fp; size_t frame_size = 3; + uint8_t *mcode; RETURN_HOOK (); old_fp = VP->fp; - ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (VP->fp); - VP->fp = SCM_FRAME_DYNAMIC_LINK (VP->fp); - - /* Clear stack frame. */ - while (frame_size--) - old_fp[frame_size].as_scm = SCM_BOOL_F; + VP->fp = SCM_FRAME_DYNAMIC_LINK (old_fp); - NEXT (0); + mcode = SCM_FRAME_MACHINE_RETURN_ADDRESS (old_fp); + if (mcode) + { + scm_jit_enter_mcode (thread, mcode); + CACHE_REGISTER (); + NEXT (0); + } + else + { + ip = SCM_FRAME_VIRTUAL_RETURN_ADDRESS (old_fp); + NEXT (0); + } } |