diff options
Diffstat (limited to 'src/lj_trace.c')
-rw-r--r-- | src/lj_trace.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/lj_trace.c b/src/lj_trace.c index e476122c..0b55f717 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
@@ -310,14 +310,6 @@ void lj_trace_freestate(global_State *g) | |||
310 | 310 | ||
311 | /* -- Penalties and blacklisting ------------------------------------------ */ | 311 | /* -- Penalties and blacklisting ------------------------------------------ */ |
312 | 312 | ||
313 | /* Trivial PRNG for randomization of penalties. */ | ||
314 | static uint32_t penalty_prng(jit_State *J, int bits) | ||
315 | { | ||
316 | /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ | ||
317 | J->prngstate = J->prngstate * 1103515245 + 12345; | ||
318 | return J->prngstate >> (32-bits); | ||
319 | } | ||
320 | |||
321 | /* Blacklist a bytecode instruction. */ | 313 | /* Blacklist a bytecode instruction. */ |
322 | static void blacklist_pc(GCproto *pt, BCIns *pc) | 314 | static void blacklist_pc(GCproto *pt, BCIns *pc) |
323 | { | 315 | { |
@@ -333,7 +325,7 @@ static void penalty_pc(jit_State *J, GCproto *pt, BCIns *pc, TraceError e) | |||
333 | if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ | 325 | if (mref(J->penalty[i].pc, const BCIns) == pc) { /* Cache slot found? */ |
334 | /* First try to bump its hotcount several times. */ | 326 | /* First try to bump its hotcount several times. */ |
335 | val = ((uint32_t)J->penalty[i].val << 1) + | 327 | val = ((uint32_t)J->penalty[i].val << 1) + |
336 | penalty_prng(J, PENALTY_RNDBITS); | 328 | LJ_PRNG_BITS(J, PENALTY_RNDBITS); |
337 | if (val > PENALTY_MAX) { | 329 | if (val > PENALTY_MAX) { |
338 | blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ | 330 | blacklist_pc(pt, pc); /* Blacklist it, if that didn't help. */ |
339 | return; | 331 | return; |