Skip to content

Commit

Permalink
lj_jit.h: Save 'parent' and 'exitno' fields in GCtrace
Browse files Browse the repository at this point in the history
For debugging purposes it is very useful to be able to refer to the
origin of a trace (parent/exit) and so this change stores that
information persistently in GCtrace instead of only ephemerally in
jit_State.

These fields are now duplicated in jit_State (valid while recording)
and GCtrace (valid after recording.) This duplication could be avoided
by putting them only in GCtrace and accessing them via J->cur but this
would be a more noisy change since the existing fields are accessed
from many places including DynASM macros.
  • Loading branch information
lukego committed Jul 28, 2017
1 parent 5708b06 commit 4aaa844
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lj_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ typedef struct GCtrace {
TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */
TraceNo1 nextroot; /* Next root trace for same prototype. */
TraceNo1 nextside; /* Next side trace of same root trace. */
TraceNo1 parent; /* Parent of this trace (or 0 for root traces). */
ExitNo exitno; /* Exit number in parent (valid for side-traces only). */
uint8_t sinktags; /* Trace has SINK tags. */
uint8_t unused1;
} GCtrace;
Expand Down
2 changes: 2 additions & 0 deletions src/lj_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ static void trace_save(jit_State *J, GCtrace *T)
size_t szins = (J->cur.nins-J->cur.nk)*sizeof(IRIns);
char *p = (char *)T + sztr;
memcpy(T, &J->cur, sizeof(GCtrace));
T->parent = J->parent;
T->exitno = J->exitno;
setgcrefr(T->nextgc, J2G(J)->gc.root);
setgcrefp(J2G(J)->gc.root, T);
newwhite(J2G(J), T);
Expand Down

0 comments on commit 4aaa844

Please sign in to comment.