[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/07: More JIT debugging
From: |
Andy Wingo |
Subject: |
[Guile-commits] 03/07: More JIT debugging |
Date: |
Sun, 2 Sep 2018 03:24:25 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 79be7028e4961c7d45ba0c0661cec8ab16cc3978
Author: Andy Wingo <address@hidden>
Date: Fri Aug 31 15:48:49 2018 +0200
More JIT debugging
* libguile/jit.c (compile1): Add debug for when instructions are first
compiled. Will be removed when all is working.
(compute_mcode): Add debugging about what code is compiled.
(scm_sys_jit_compile): Remove per-instruction output.
(scm_jit_compute_mcode): Actually compile JIT code. Use
GUILE_JIT_COUNTER_THRESHOLD to control when JIT happens.
---
libguile/jit.c | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/libguile/jit.c b/libguile/jit.c
index 76526f5..1c76285 100644
--- a/libguile/jit.c
+++ b/libguile/jit.c
@@ -123,7 +123,7 @@
/* Threshold for when to JIT-compile a function. Set from the
- GUILE_JIT_THRESHOLD environment variable. */
+ GUILE_JIT_COUNTER_THRESHOLD environment variable. */
uint32_t scm_jit_counter_threshold = -1;
/* Entry trampoline: saves registers, initializes THREAD and SP
@@ -4220,11 +4220,28 @@ compile_f64_set (scm_jit_state *j, uint8_t ptr, uint8_t
idx, uint8_t v)
comp (j, a, b, c, d, e); \
}
+static uint8_t first_seen[256];
+
static void
compile1 (scm_jit_state *j)
{
uint8_t opcode = j->ip[0] & 0xff;
+ if (!first_seen[opcode])
+ {
+ const char *n;
+ switch (opcode)
+ {
+#define NAME(code, cname, name, arity) case code: n = name; break;
+ FOR_EACH_VM_OPERATION(NAME)
+#undef NAME
+ default:
+ UNREACHABLE ();
+ }
+ first_seen[opcode] = 1;
+ fprintf (stderr, "Instruction first seen at vcode %p: %s\n", j->ip, n);
+ }
+
j->next_ip = j->ip + op_lengths[opcode];
switch (opcode)
@@ -4396,6 +4413,8 @@ compute_mcode (scm_thread *thread, struct
scm_jit_function_data *data)
j->jit = jit_new_state ();
+ fprintf (stderr, "vcode: start=%p,+%zu\n", j->start, j->end - j->start);
+
compile (j);
data->mcode = jit_emit ();
@@ -4431,7 +4450,6 @@ scm_sys_jit_compile (SCM fn)
fprintf (stderr, "compiling function at %p\n", code);
data = (struct scm_jit_function_data *) (code + (int32_t)code[1]);
- fprintf (stderr, "data %p start=%d, end=%d\n", data, data->start, data->end);
compute_mcode (SCM_I_CURRENT_THREAD, data);
@@ -4441,11 +4459,15 @@ scm_sys_jit_compile (SCM fn)
const uint8_t *
scm_jit_compute_mcode (scm_thread *thread, struct scm_jit_function_data *data)
{
- uint8_t *mcode_start = data->mcode;
const uint32_t *vcode_start = (const uint32_t *) (((char *)data) +
data->start);
- if (mcode_start && vcode_start == thread->vm.ip)
- return mcode_start;
+ if (vcode_start == thread->vm.ip)
+ {
+ if (!data->mcode)
+ compute_mcode (thread, data);
+
+ return data->mcode;
+ }
return NULL;
}
@@ -4453,8 +4475,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");
}
void
- [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 <=
- [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