[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/07: Add ability to stop JIT after N compilations.
From: |
Andy Wingo |
Subject: |
[Guile-commits] 06/07: Add ability to stop JIT after N compilations. |
Date: |
Sun, 2 Sep 2018 03:24:25 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 1f42a6042ef48bc2dd3fe69bf5cd1a4d2c13f3e2
Author: Andy Wingo <address@hidden>
Date: Sat Sep 1 11:28:59 2018 +0200
Add ability to stop JIT after N compilations.
* libguile/jit.c (jit_stop_after, jit_pause_when_stopping): New locals.
(scm_jit_compute_mcode): Add ability to stop after N compilations.
(scm_jit_enter_mcode): Comment out printfs for the time being.
(scm_init_jit): Init locals from environment variables.
---
libguile/jit.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/libguile/jit.c b/libguile/jit.c
index fffd71d..76bb6bb 100644
--- a/libguile/jit.c
+++ b/libguile/jit.c
@@ -126,6 +126,14 @@
GUILE_JIT_COUNTER_THRESHOLD environment variable. */
uint32_t scm_jit_counter_threshold = -1;
+/* If positive, stop JIT compilation after the Nth compilation. Useful
+ for hunting down bugs. */
+static int jit_stop_after = -1;
+
+/* If nonzero, pause when stopping JIT compilation after the Nth
+ compilation. For debugging. */
+static int jit_pause_when_stopping = 0;
+
/* Entry trampoline: saves registers, initializes THREAD and SP
registers, and jumps into mcode. */
static void (*enter_mcode) (scm_thread *thread, const uint8_t *mcode);
@@ -4463,7 +4471,21 @@ scm_jit_compute_mcode (scm_thread *thread, struct
scm_jit_function_data *data)
if (vcode_start == thread->vm.ip)
{
if (!data->mcode)
- compute_mcode (thread, data);
+ {
+ compute_mcode (thread, data);
+
+ if (--jit_stop_after == 0)
+ {
+ scm_jit_counter_threshold = -1;
+ fprintf (stderr, "stopping automatic JIT compilation, as
requested\n");
+ if (jit_pause_when_stopping)
+ {
+ fprintf (stderr, "sleeping for 30s; to debug:\n");
+ fprintf (stderr, " gdb -p %d\n\n", getpid ());
+ sleep (30);
+ }
+ }
+ }
return data->mcode;
}
@@ -4474,9 +4496,9 @@ scm_jit_compute_mcode (scm_thread *thread, struct
scm_jit_function_data *data)
void
scm_jit_enter_mcode (scm_thread *thread, const uint8_t *mcode)
{
- fprintf (stderr, "entering mcode: %p\n", mcode);
+ // fprintf (stderr, "entering mcode: %p\n", mcode);
enter_mcode (thread, mcode);
- fprintf (stderr, "exited mcode\n");
+ // fprintf (stderr, "exited mcode\n");
}
void
@@ -4493,5 +4515,7 @@ void
scm_init_jit (void)
{
scm_jit_counter_threshold = scm_getenv_int ("GUILE_JIT_COUNTER_THRESHOLD",
-1);
+ jit_stop_after = scm_getenv_int ("GUILE_JIT_STOP_AFTER", -1);
+ jit_pause_when_stopping = scm_getenv_int ("GUILE_JIT_PAUSE_WHEN_STOPPING",
0);
scm_c_define_gsubr ("%jit-compile", 1, 0, 0, (scm_t_subr)
scm_sys_jit_compile);
}
- [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 <=
- [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, 2018/09/02
- [Guile-commits] 01/07: Minor optimization in compile_alloc_frame, Andy Wingo, 2018/09/02