[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 02/07: JIT threshold controlled by environment variable
From: |
Andy Wingo |
Subject: |
[Guile-commits] 02/07: JIT threshold controlled by environment variable |
Date: |
Sun, 2 Sep 2018 03:24:25 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit cc997293e2f8725d0f3699331930b5490b033226
Author: Andy Wingo <address@hidden>
Date: Fri Aug 31 11:28:38 2018 +0200
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.
---
libguile/jit.c | 6 ++++++
libguile/jit.h | 3 ++-
libguile/vm-engine.c | 4 ++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libguile/jit.c b/libguile/jit.c
index f8b4e75..76526f5 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 ae5c9da..a1863c2 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 58ff53c..4356159 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;
- [Guile-commits] branch lightning updated (dac4344 -> 449ef7d), Andy Wingo, 2018/09/02
- [Guile-commits] 07/07: Prevent Lightning from stompling our registers, Andy Wingo, 2018/09/02
- [Guile-commits] 06/07: Add ability to stop JIT after N compilations., Andy Wingo, 2018/09/02
- [Guile-commits] 05/07: Minor 32-bit untag-fixnum optimization, Andy Wingo, 2018/09/02
- [Guile-commits] 04/07: Fix compilation of compile_eq, Andy Wingo, 2018/09/02
- [Guile-commits] 03/07: More JIT debugging, Andy Wingo, 2018/09/02
- [Guile-commits] 02/07: JIT threshold controlled by environment variable,
Andy Wingo <=
- [Guile-commits] 01/07: Minor optimization in compile_alloc_frame, Andy Wingo, 2018/09/02