mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
Better debugging in jit.c
* libguile/jit.c (emit_direct_tail_call): Assert self-tail call has mcode. (opcodes_seen, bitvector_ref, bitvector_set, compile1): Make the opcodes_seen set more compact, and log all instruction emissions at level 3. (compute_mcode): Don't overwrite mcode if compilation fails.
This commit is contained in:
parent
74eafacff0
commit
18e9366142
1 changed files with 36 additions and 9 deletions
|
@ -819,7 +819,9 @@ emit_direct_tail_call (scm_jit_state *j, const uint32_t *vcode)
|
||||||
|
|
||||||
if (vcode == j->start)
|
if (vcode == j->start)
|
||||||
{
|
{
|
||||||
jit_jmpi (j->jit, j->labels[inline_label_offset (0)]);
|
uint8_t *mcode = j->labels[inline_label_offset (0)];
|
||||||
|
ASSERT (mcode);
|
||||||
|
jit_jmpi (j->jit, mcode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5359,14 +5361,28 @@ compile_s64_to_f64_slow (scm_jit_state *j, uint16_t dst, uint16_t src)
|
||||||
comp (j, a, b, c, d, e); \
|
comp (j, a, b, c, d, e); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t first_seen[256];
|
static uintptr_t opcodes_seen[256 / (SCM_SIZEOF_UINTPTR_T * 8)];
|
||||||
|
|
||||||
|
static uintptr_t
|
||||||
|
bitvector_ref (const uintptr_t *bv, size_t n)
|
||||||
|
{
|
||||||
|
uintptr_t word = bv[n / (SCM_SIZEOF_UINTPTR_T * 8)];
|
||||||
|
return word & (((uintptr_t) 1) << (n & (SCM_SIZEOF_UINTPTR_T * 8 - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bitvector_set (uintptr_t *bv, size_t n)
|
||||||
|
{
|
||||||
|
uintptr_t *word_loc = &bv[n / (SCM_SIZEOF_UINTPTR_T * 8)];
|
||||||
|
*word_loc |= ((uintptr_t) 1) << (n & (SCM_SIZEOF_UINTPTR_T * 8 - 1));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
compile1 (scm_jit_state *j)
|
compile1 (scm_jit_state *j)
|
||||||
{
|
{
|
||||||
uint8_t opcode = j->ip[0] & 0xff;
|
uint8_t opcode = j->ip[0] & 0xff;
|
||||||
|
|
||||||
if (!first_seen[opcode])
|
if (jit_log_level >= LOG_LEVEL_DEBUG)
|
||||||
{
|
{
|
||||||
const char *n;
|
const char *n;
|
||||||
switch (opcode)
|
switch (opcode)
|
||||||
|
@ -5377,8 +5393,14 @@ compile1 (scm_jit_state *j)
|
||||||
default:
|
default:
|
||||||
UNREACHABLE ();
|
UNREACHABLE ();
|
||||||
}
|
}
|
||||||
first_seen[opcode] = 1;
|
|
||||||
DEBUG ("Instruction first seen at vcode %p: %s\n", j->ip, n);
|
if (!bitvector_ref (opcodes_seen, opcode))
|
||||||
|
{
|
||||||
|
bitvector_set (opcodes_seen, opcode);
|
||||||
|
DEBUG ("Instruction first seen at vcode %p: %s\n", j->ip, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG ("Instruction at vcode %p: %s\n", j->ip, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
j->next_ip = j->ip + op_lengths[opcode];
|
j->next_ip = j->ip + op_lengths[opcode];
|
||||||
|
@ -5646,11 +5668,16 @@ compute_mcode (scm_thread *thread, uint32_t *entry_ip,
|
||||||
|
|
||||||
analyze (j);
|
analyze (j);
|
||||||
|
|
||||||
data->mcode = emit_code (j, compile);
|
uint8_t *mcode = emit_code (j, compile);
|
||||||
if (data->mcode)
|
if (mcode)
|
||||||
entry_mcode = j->labels[inline_label_offset (j->entry - j->start)];
|
{
|
||||||
|
entry_mcode = j->labels[inline_label_offset (j->entry - j->start)];
|
||||||
|
data->mcode = mcode;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
entry_mcode = NULL;
|
{
|
||||||
|
entry_mcode = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free (j->op_attrs);
|
free (j->op_attrs);
|
||||||
j->op_attrs = NULL;
|
j->op_attrs = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue