diff options
author | Andy Wingo <wingo@pobox.com> | 2018-08-31 15:48:49 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-08-31 15:50:46 +0200 |
commit | 79be7028e4961c7d45ba0c0661cec8ab16cc3978 (patch) | |
tree | ba7d8d4072b618109b358bc4b66796f212d0de38 | |
parent | cc997293e2f8725d0f3699331930b5490b033226 (diff) | |
download | guile-79be7028e4961c7d45ba0c0661cec8ab16cc3978.tar.gz |
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.
-rw-r--r-- | libguile/jit.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/libguile/jit.c b/libguile/jit.c index 76526f524..1c76285b2 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 |