Skip to content

Commit

Permalink
lj_trace.c: Clear penalty slot after successful trace
Browse files Browse the repository at this point in the history
Clear the penalty slot associated with a bytecode after it is traced
successfully.

This prevents penalties from accumulating for bytecodes that are
traced frequently, such as branchy subroutines that are called from
many different root traces and will need to record a side-trace for
each.

Especially intended to handle the special case when applications are
generating code at runtime that creates a "fairly large" number of
root traces and that need correspondingly many side-traces to be
recorded without prematurely and unproductively blacklisting things.
  • Loading branch information
lukego committed Sep 8, 2017
1 parent d400946 commit f7212cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lj_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ static void trace_stop(jit_State *J)
TraceNo traceno = J->cur.traceno;
GCtrace *T = J->curfinal;
lua_State *L;
int i;

switch (op) {
case BC_FORL:
Expand Down Expand Up @@ -444,6 +445,11 @@ static void trace_stop(jit_State *J)
J->postproc = LJ_POST_NONE;
trace_save(J, T);

/* Clear any penalty after successful recording. */
for (i = 0; i < PENALTY_SLOTS; i++)
if (mref(J->penalty[i].pc, const BCIns) == pc)
J->penalty[i].val = PENALTY_MIN;

L = J->L;
}

Expand Down

0 comments on commit f7212cc

Please sign in to comment.