mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
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.
This commit is contained in:
parent
def671974c
commit
cc997293e2
3 changed files with 10 additions and 3 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "gsubr.h"
|
#include "gsubr.h"
|
||||||
#include "instructions.h"
|
#include "instructions.h"
|
||||||
#include "intrinsics.h"
|
#include "intrinsics.h"
|
||||||
|
#include "simpos.h" /* scm_getenv_int */
|
||||||
#include "threads.h"
|
#include "threads.h"
|
||||||
#include "vm-builtins.h"
|
#include "vm-builtins.h"
|
||||||
#include "vm-operations.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
|
/* Entry trampoline: saves registers, initializes THREAD and SP
|
||||||
registers, and jumps into mcode. */
|
registers, and jumps into mcode. */
|
||||||
static void (*enter_mcode) (scm_thread *thread, const uint8_t *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
|
void
|
||||||
scm_init_jit (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);
|
scm_c_define_gsubr ("%jit-compile", 1, 0, 0, (scm_t_subr) scm_sys_jit_compile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,11 @@ enum scm_jit_counter_value
|
||||||
{
|
{
|
||||||
SCM_JIT_COUNTER_ENTRY_INCREMENT = 15,
|
SCM_JIT_COUNTER_ENTRY_INCREMENT = 15,
|
||||||
SCM_JIT_COUNTER_LOOP_INCREMENT = 1,
|
SCM_JIT_COUNTER_LOOP_INCREMENT = 1,
|
||||||
SCM_JIT_COUNTER_THRESHOLD = 50
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SCM_INTERNAL uint32_t scm_jit_counter_threshold;
|
||||||
|
|
||||||
SCM_INTERNAL const uint8_t *scm_jit_compute_mcode (scm_thread *thread,
|
SCM_INTERNAL const uint8_t *scm_jit_compute_mcode (scm_thread *thread,
|
||||||
struct scm_jit_function_data *data);
|
struct scm_jit_function_data *data);
|
||||||
SCM_INTERNAL void scm_jit_enter_mcode (scm_thread *thread,
|
SCM_INTERNAL void scm_jit_enter_mcode (scm_thread *thread,
|
||||||
|
|
|
@ -471,7 +471,7 @@ VM_NAME (scm_thread *thread)
|
||||||
NEXT (0);
|
NEXT (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->counter > SCM_JIT_COUNTER_THRESHOLD)
|
if (data->counter > scm_jit_counter_threshold)
|
||||||
{
|
{
|
||||||
const uint8_t *mcode;
|
const uint8_t *mcode;
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ VM_NAME (scm_thread *thread)
|
||||||
|
|
||||||
data = (struct scm_jit_function_data *) (ip + data_offset);
|
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;
|
const uint8_t *mcode;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue