diff options
Diffstat (limited to 'src/lj_jit.h')
-rw-r--r-- | src/lj_jit.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h index f0472282..ff3492bf 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -278,7 +278,7 @@ typedef struct jit_State { | |||
278 | 278 | ||
279 | HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ | 279 | HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ |
280 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ | 280 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ |
281 | uint32_t prngstate; /* PRNG state for penalty randomization. */ | 281 | uint32_t prngstate; /* PRNG state. */ |
282 | 282 | ||
283 | BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ | 283 | BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ |
284 | uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ | 284 | uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ |
@@ -297,6 +297,14 @@ typedef struct jit_State { | |||
297 | int mcprot; /* Protection of current mcode area. */ | 297 | int mcprot; /* Protection of current mcode area. */ |
298 | } jit_State; | 298 | } jit_State; |
299 | 299 | ||
300 | /* Trivial PRNG e.g. used for penalty randomization. */ | ||
301 | static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) | ||
302 | { | ||
303 | /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ | ||
304 | J->prngstate = J->prngstate * 1103515245 + 12345; | ||
305 | return J->prngstate >> (32-bits); | ||
306 | } | ||
307 | |||
300 | /* Exit stubs. */ | 308 | /* Exit stubs. */ |
301 | #if LJ_TARGET_X86ORX64 | 309 | #if LJ_TARGET_X86ORX64 |
302 | /* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ | 310 | /* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ |