diff options
author | Andy Wingo <wingo@pobox.com> | 2018-08-31 11:28:38 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-08-31 11:28:38 +0200 |
commit | cc997293e2f8725d0f3699331930b5490b033226 (patch) | |
tree | 0e2b48c0f3ae3a35e7e12cf77cfbe1a41d733177 | |
parent | def671974c64ace851ac019b5cdff2228284310d (diff) | |
download | guile-cc997293e2f8725d0f3699331930b5490b033226.tar.gz |
JIT threshold controlled by environment variable
* libguile/jit.c (scm_jit_counter_threshold): Make a static variable
instead of a compile-time constant.
(scm_init_jit): Init scm_jit_counter_threshold from
GUILE_JIT_COUNTER_THRESHOLD environment variable. Default is -1
indicating "never JIT".
* libguile/vm-engine.c (instrument-entry, instrument-loop): Adapt to new
variable.
-rw-r--r-- | libguile/jit.c | 6 | ||||
-rw-r--r-- | libguile/jit.h | 3 | ||||
-rw-r--r-- | libguile/vm-engine.c | 4 |
3 files changed, 10 insertions, 3 deletions
diff --git a/libguile/jit.c b/libguile/jit.c index f8b4e7546..76526f524 100644 --- a/libguile/jit.c +++ b/libguile/jit.c @@ -32,6 +32,7 @@ #include "gsubr.h" #include "instructions.h" #include "intrinsics.h" +#include "simpos.h" /* scm_getenv_int */ #include "threads.h" #include "vm-builtins.h" #include "vm-operations.h" @@ -121,6 +122,10 @@ +/* Threshold for when to JIT-compile a function. Set from the + GUILE_JIT_THRESHOLD environment variable. */ +uint32_t scm_jit_counter_threshold = -1; + /* Entry trampoline: saves registers, initializes THREAD and SP registers, and jumps into mcode. */ static void (*enter_mcode) (scm_thread *thread, const uint8_t *mcode); @@ -4465,5 +4470,6 @@ scm_jit_state_free (scm_jit_state *j) void scm_init_jit (void) { + scm_jit_counter_threshold = scm_getenv_int ("GUILE_JIT_COUNTER_THRESHOLD", -1); scm_c_define_gsubr ("%jit-compile", 1, 0, 0, (scm_t_subr) scm_sys_jit_compile); } diff --git a/libguile/jit.h b/libguile/jit.h index ae5c9da21..a1863c2c0 100644 --- a/libguile/jit.h +++ b/libguile/jit.h @@ -48,10 +48,11 @@ enum scm_jit_counter_value { SCM_JIT_COUNTER_ENTRY_INCREMENT = 15, SCM_JIT_COUNTER_LOOP_INCREMENT = 1, - SCM_JIT_COUNTER_THRESHOLD = 50 }; #endif +SCM_INTERNAL uint32_t scm_jit_counter_threshold; + SCM_INTERNAL const uint8_t *scm_jit_compute_mcode (scm_thread *thread, struct scm_jit_function_data *data); SCM_INTERNAL void scm_jit_enter_mcode (scm_thread *thread, diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 58ff53cda..4356159ac 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -471,7 +471,7 @@ VM_NAME (scm_thread *thread) NEXT (0); } - if (data->counter > SCM_JIT_COUNTER_THRESHOLD) + if (data->counter > scm_jit_counter_threshold) { const uint8_t *mcode; @@ -722,7 +722,7 @@ VM_NAME (scm_thread *thread) data = (struct scm_jit_function_data *) (ip + data_offset); - if (data->counter > SCM_JIT_COUNTER_THRESHOLD) + if (data->counter > scm_jit_counter_threshold) { const uint8_t *mcode; |