From f7212ccb97ea39effb9c311b5a7affc8f66d3bf2 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Fri, 1 Sep 2017 09:23:03 +0000 Subject: [PATCH] lj_trace.c: Clear penalty slot after successful trace 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. --- src/lj_trace.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lj_trace.c b/src/lj_trace.c index d52f296b42..591dec712f 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -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: @@ -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; }