summaryrefslogtreecommitdiff
path: root/src/lj_trace.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-26 17:01:33 +0100
committerMike Pall <mike>2010-02-26 17:01:33 +0100
commita0fbb05bf0353ac0fede6deec15db5d2d3a9017f (patch)
tree5e4ad50a8ea9bcd1d030ffa736aba46a1d6bb161 /src/lj_trace.c
parent3c6cec0846ae25dc9d0c2495cb02316694725add (diff)
downloadluajit-a0fbb05bf0353ac0fede6deec15db5d2d3a9017f.tar.gz
luajit-a0fbb05bf0353ac0fede6deec15db5d2d3a9017f.tar.bz2
luajit-a0fbb05bf0353ac0fede6deec15db5d2d3a9017f.zip
Make penalty PRNG available for general use by compiler.
Diffstat (limited to '')
-rw-r--r--src/lj_trace.c10
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. */
314static 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. */
322static void blacklist_pc(GCproto *pt, BCIns *pc) 314static 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;