diff options
author | Andy Wingo <wingo@pobox.com> | 2019-06-20 14:02:05 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-06-20 14:02:05 +0200 |
commit | 89e28df1c9069dcb65188fe7b3973c333d87d7e2 (patch) | |
tree | 5cfd7790f030b82ed39425b420bed0bb3123ab8e /libguile/jit.c | |
parent | 33aecf48b057f6f3abd65bea7c4b7a0d9aadf980 (diff) | |
download | guile-89e28df1c9069dcb65188fe7b3973c333d87d7e2.tar.gz |
Add an inlined jit fast-path for allocate-words/immediate
* libguile/intrinsics.c (allocate_words_with_freelist)
(scm_bootstrap_intrinsics):
* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): New intrinsic.
* libguile/jit.c (compile_allocate_words_immediate): Add fast-path.
A marginal improvement.
Diffstat (limited to 'libguile/jit.c')
-rw-r--r-- | libguile/jit.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/libguile/jit.c b/libguile/jit.c index 77222342a..700b1a468 100644 --- a/libguile/jit.c +++ b/libguile/jit.c @@ -32,6 +32,7 @@ #include "frames.h" #include "gsubr.h" +#include "gc-inline.h" #include "instructions.h" #include "intrinsics.h" #include "simpos.h" /* scm_getenv_int */ @@ -2056,14 +2057,41 @@ compile_allocate_words (scm_jit_state *j, uint16_t dst, uint16_t nwords) static void compile_allocate_words_immediate (scm_jit_state *j, uint16_t dst, uint16_t nwords) { - jit_gpr_t t = T0; + size_t bytes = nwords * sizeof(SCM); + size_t idx = scm_inline_gc_bytes_to_freelist_index (bytes); - emit_store_current_ip (j, t); - emit_call_2 (j, scm_vm_intrinsics.allocate_words, thread_operand (), - jit_operand_imm (JIT_OPERAND_ABI_WORD, nwords)); - emit_retval (j, t); - emit_reload_sp (j); - emit_sp_set_scm (j, dst, t); + if (SCM_UNLIKELY (idx >= SCM_INLINE_GC_FREELIST_COUNT)) + { + jit_gpr_t t = T0; + emit_store_current_ip (j, t); + emit_call_1 (j, GC_malloc, jit_operand_imm (JIT_OPERAND_ABI_WORD, bytes)); + emit_retval (j, t); + emit_reload_sp (j); + emit_sp_set_scm (j, dst, t); + } + else + { + jit_gpr_t res = T0; + ptrdiff_t offset = offsetof(struct scm_thread, freelists); + offset += idx * sizeof(void*); + emit_ldxi (j, res, THREAD, offset); + jit_reloc_t fast = jit_bnei (j->jit, res, 0); + emit_store_current_ip (j, res); + emit_call_2 (j, scm_vm_intrinsics.allocate_words_with_freelist, + thread_operand (), + jit_operand_imm (JIT_OPERAND_ABI_WORD, idx)); + emit_retval (j, res); + emit_reload_sp (j); + jit_reloc_t done = jit_jmp (j->jit); + + jit_patch_here (j->jit, fast); + jit_gpr_t new_freelist = T1; + emit_ldr (j, new_freelist, res); + jit_stxi (j->jit, offset, THREAD, new_freelist); + + jit_patch_here (j->jit, done); + emit_sp_set_scm (j, dst, res); + } } static void |