diff options
author | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
commit | 6523585c66c04cea54df50013df8886b589847d8 (patch) | |
tree | 0b22aee7064166d88595eda260ca2d17c0773da5 /libraries/luajit-2.0/src/lj_jit.h | |
parent | Update the EFL to what I'm actually using, coz I'm using some stuff not yet r... (diff) | |
download | SledjHamr-6523585c66c04cea54df50013df8886b589847d8.zip SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.gz SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.bz2 SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.xz |
Add luaproc and LuaJIT libraries.
Two versions of LuaJIT, the stable release, and the dev version. Try the dev version first, until ih fails badly.
Diffstat (limited to '')
-rw-r--r-- | libraries/luajit-2.0/src/lj_jit.h | 394 |
1 files changed, 394 insertions, 0 deletions
diff --git a/libraries/luajit-2.0/src/lj_jit.h b/libraries/luajit-2.0/src/lj_jit.h new file mode 100644 index 0000000..8a4c04c --- /dev/null +++ b/libraries/luajit-2.0/src/lj_jit.h | |||
@@ -0,0 +1,394 @@ | |||
1 | /* | ||
2 | ** Common definitions for the JIT compiler. | ||
3 | ** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_JIT_H | ||
7 | #define _LJ_JIT_H | ||
8 | |||
9 | #include "lj_obj.h" | ||
10 | #include "lj_ir.h" | ||
11 | |||
12 | /* JIT engine flags. */ | ||
13 | #define JIT_F_ON 0x00000001 | ||
14 | |||
15 | /* CPU-specific JIT engine flags. */ | ||
16 | #if LJ_TARGET_X86ORX64 | ||
17 | #define JIT_F_CMOV 0x00000010 | ||
18 | #define JIT_F_SSE2 0x00000020 | ||
19 | #define JIT_F_SSE3 0x00000040 | ||
20 | #define JIT_F_SSE4_1 0x00000080 | ||
21 | #define JIT_F_P4 0x00000100 | ||
22 | #define JIT_F_PREFER_IMUL 0x00000200 | ||
23 | #define JIT_F_SPLIT_XMM 0x00000400 | ||
24 | #define JIT_F_LEA_AGU 0x00000800 | ||
25 | |||
26 | /* Names for the CPU-specific flags. Must match the order above. */ | ||
27 | #define JIT_F_CPU_FIRST JIT_F_CMOV | ||
28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" | ||
29 | #elif LJ_TARGET_ARM | ||
30 | #define JIT_F_ARMV6 0x00000010 | ||
31 | #define JIT_F_ARMV6T2 0x00000020 | ||
32 | #define JIT_F_ARMV7 0x00000040 | ||
33 | |||
34 | /* Names for the CPU-specific flags. Must match the order above. */ | ||
35 | #define JIT_F_CPU_FIRST JIT_F_ARMV6 | ||
36 | #define JIT_F_CPUSTRING "\5ARMv6\7ARMv6T2\5ARMv7" | ||
37 | #else | ||
38 | #define JIT_F_CPU_FIRST 0 | ||
39 | #define JIT_F_CPUSTRING "" | ||
40 | #endif | ||
41 | |||
42 | /* Optimization flags. */ | ||
43 | #define JIT_F_OPT_MASK 0x0fff0000 | ||
44 | |||
45 | #define JIT_F_OPT_FOLD 0x00010000 | ||
46 | #define JIT_F_OPT_CSE 0x00020000 | ||
47 | #define JIT_F_OPT_DCE 0x00040000 | ||
48 | #define JIT_F_OPT_FWD 0x00080000 | ||
49 | #define JIT_F_OPT_DSE 0x00100000 | ||
50 | #define JIT_F_OPT_NARROW 0x00200000 | ||
51 | #define JIT_F_OPT_LOOP 0x00400000 | ||
52 | #define JIT_F_OPT_ABC 0x00800000 | ||
53 | #define JIT_F_OPT_FUSE 0x01000000 | ||
54 | |||
55 | /* Optimizations names for -O. Must match the order above. */ | ||
56 | #define JIT_F_OPT_FIRST JIT_F_OPT_FOLD | ||
57 | #define JIT_F_OPTSTRING \ | ||
58 | "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4fuse" | ||
59 | |||
60 | /* Optimization levels set a fixed combination of flags. */ | ||
61 | #define JIT_F_OPT_0 0 | ||
62 | #define JIT_F_OPT_1 (JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE) | ||
63 | #define JIT_F_OPT_2 (JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP) | ||
64 | #define JIT_F_OPT_3 \ | ||
65 | (JIT_F_OPT_2|JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_FUSE) | ||
66 | #define JIT_F_OPT_DEFAULT JIT_F_OPT_3 | ||
67 | |||
68 | #if LJ_TARGET_WINDOWS || LJ_64 | ||
69 | /* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */ | ||
70 | #define JIT_P_sizemcode_DEFAULT 64 | ||
71 | #else | ||
72 | /* Could go as low as 4K, but the mmap() overhead would be rather high. */ | ||
73 | #define JIT_P_sizemcode_DEFAULT 32 | ||
74 | #endif | ||
75 | |||
76 | /* Optimization parameters and their defaults. Length is a char in octal! */ | ||
77 | #define JIT_PARAMDEF(_) \ | ||
78 | _(\010, maxtrace, 1000) /* Max. # of traces in cache. */ \ | ||
79 | _(\011, maxrecord, 4000) /* Max. # of recorded IR instructions. */ \ | ||
80 | _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ | ||
81 | _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ | ||
82 | _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ | ||
83 | \ | ||
84 | _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ | ||
85 | _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ | ||
86 | _(\007, tryside, 4) /* # of attempts to compile a side trace. */ \ | ||
87 | \ | ||
88 | _(\012, instunroll, 4) /* Max. unroll for instable loops. */ \ | ||
89 | _(\012, loopunroll, 15) /* Max. unroll for loop ops in side traces. */ \ | ||
90 | _(\012, callunroll, 3) /* Max. unroll for recursive calls. */ \ | ||
91 | _(\011, recunroll, 2) /* Min. unroll for true recursion. */ \ | ||
92 | \ | ||
93 | /* Size of each machine code area (in KBytes). */ \ | ||
94 | _(\011, sizemcode, JIT_P_sizemcode_DEFAULT) \ | ||
95 | /* Max. total size of all machine code areas (in KBytes). */ \ | ||
96 | _(\010, maxmcode, 512) \ | ||
97 | /* End of list. */ | ||
98 | |||
99 | enum { | ||
100 | #define JIT_PARAMENUM(len, name, value) JIT_P_##name, | ||
101 | JIT_PARAMDEF(JIT_PARAMENUM) | ||
102 | #undef JIT_PARAMENUM | ||
103 | JIT_P__MAX | ||
104 | }; | ||
105 | |||
106 | #define JIT_PARAMSTR(len, name, value) #len #name | ||
107 | #define JIT_P_STRING JIT_PARAMDEF(JIT_PARAMSTR) | ||
108 | |||
109 | /* Trace compiler state. */ | ||
110 | typedef enum { | ||
111 | LJ_TRACE_IDLE, /* Trace compiler idle. */ | ||
112 | LJ_TRACE_ACTIVE = 0x10, | ||
113 | LJ_TRACE_RECORD, /* Bytecode recording active. */ | ||
114 | LJ_TRACE_START, /* New trace started. */ | ||
115 | LJ_TRACE_END, /* End of trace. */ | ||
116 | LJ_TRACE_ASM, /* Assemble trace. */ | ||
117 | LJ_TRACE_ERR /* Trace aborted with error. */ | ||
118 | } TraceState; | ||
119 | |||
120 | /* Post-processing action. */ | ||
121 | typedef enum { | ||
122 | LJ_POST_NONE, /* No action. */ | ||
123 | LJ_POST_FIXCOMP, /* Fixup comparison and emit pending guard. */ | ||
124 | LJ_POST_FIXGUARD, /* Fixup and emit pending guard. */ | ||
125 | LJ_POST_FIXGUARDSNAP, /* Fixup and emit pending guard and snapshot. */ | ||
126 | LJ_POST_FIXBOOL, /* Fixup boolean result. */ | ||
127 | LJ_POST_FFRETRY /* Suppress recording of retried fast functions. */ | ||
128 | } PostProc; | ||
129 | |||
130 | /* Machine code type. */ | ||
131 | #if LJ_TARGET_X86ORX64 | ||
132 | typedef uint8_t MCode; | ||
133 | #else | ||
134 | typedef uint32_t MCode; | ||
135 | #endif | ||
136 | |||
137 | /* Stack snapshot header. */ | ||
138 | typedef struct SnapShot { | ||
139 | uint16_t mapofs; /* Offset into snapshot map. */ | ||
140 | IRRef1 ref; /* First IR ref for this snapshot. */ | ||
141 | uint8_t nslots; /* Number of valid slots. */ | ||
142 | uint8_t topslot; /* Maximum frame extent. */ | ||
143 | uint8_t nent; /* Number of compressed entries. */ | ||
144 | uint8_t count; /* Count of taken exits for this snapshot. */ | ||
145 | } SnapShot; | ||
146 | |||
147 | #define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ | ||
148 | |||
149 | /* Compressed snapshot entry. */ | ||
150 | typedef uint32_t SnapEntry; | ||
151 | |||
152 | #define SNAP_FRAME 0x010000 /* Frame slot. */ | ||
153 | #define SNAP_CONT 0x020000 /* Continuation slot. */ | ||
154 | #define SNAP_NORESTORE 0x040000 /* No need to restore slot. */ | ||
155 | #define SNAP_SOFTFPNUM 0x080000 /* Soft-float number. */ | ||
156 | LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME); | ||
157 | LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT); | ||
158 | |||
159 | #define SNAP(slot, flags, ref) (((SnapEntry)(slot) << 24) + (flags) + (ref)) | ||
160 | #define SNAP_TR(slot, tr) \ | ||
161 | (((SnapEntry)(slot) << 24) + ((tr) & (TREF_CONT|TREF_FRAME|TREF_REFMASK))) | ||
162 | #define SNAP_MKPC(pc) ((SnapEntry)u32ptr(pc)) | ||
163 | #define SNAP_MKFTSZ(ftsz) ((SnapEntry)(ftsz)) | ||
164 | #define snap_ref(sn) ((sn) & 0xffff) | ||
165 | #define snap_slot(sn) ((BCReg)((sn) >> 24)) | ||
166 | #define snap_isframe(sn) ((sn) & SNAP_FRAME) | ||
167 | #define snap_pc(sn) ((const BCIns *)(uintptr_t)(sn)) | ||
168 | #define snap_setref(sn, ref) (((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref)) | ||
169 | |||
170 | /* Snapshot and exit numbers. */ | ||
171 | typedef uint32_t SnapNo; | ||
172 | typedef uint32_t ExitNo; | ||
173 | |||
174 | /* Trace number. */ | ||
175 | typedef uint32_t TraceNo; /* Used to pass around trace numbers. */ | ||
176 | typedef uint16_t TraceNo1; /* Stored trace number. */ | ||
177 | |||
178 | /* Type of link. ORDER LJ_TRLINK */ | ||
179 | typedef enum { | ||
180 | LJ_TRLINK_NONE, /* Incomplete trace. No link, yet. */ | ||
181 | LJ_TRLINK_ROOT, /* Link to other root trace. */ | ||
182 | LJ_TRLINK_LOOP, /* Loop to same trace. */ | ||
183 | LJ_TRLINK_TAILREC, /* Tail-recursion. */ | ||
184 | LJ_TRLINK_UPREC, /* Up-recursion. */ | ||
185 | LJ_TRLINK_DOWNREC, /* Down-recursion. */ | ||
186 | LJ_TRLINK_INTERP, /* Fallback to interpreter. */ | ||
187 | LJ_TRLINK_RETURN /* Return to interpreter. */ | ||
188 | } TraceLink; | ||
189 | |||
190 | /* Trace object. */ | ||
191 | typedef struct GCtrace { | ||
192 | GCHeader; | ||
193 | uint8_t topslot; /* Top stack slot already checked to be allocated. */ | ||
194 | uint8_t linktype; /* Type of link. */ | ||
195 | IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ | ||
196 | GCRef gclist; | ||
197 | IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ | ||
198 | IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ | ||
199 | uint16_t nsnap; /* Number of snapshots. */ | ||
200 | uint16_t nsnapmap; /* Number of snapshot map elements. */ | ||
201 | SnapShot *snap; /* Snapshot array. */ | ||
202 | SnapEntry *snapmap; /* Snapshot map. */ | ||
203 | GCRef startpt; /* Starting prototype. */ | ||
204 | MRef startpc; /* Bytecode PC of starting instruction. */ | ||
205 | BCIns startins; /* Original bytecode of starting instruction. */ | ||
206 | MSize szmcode; /* Size of machine code. */ | ||
207 | MCode *mcode; /* Start of machine code. */ | ||
208 | MSize mcloop; /* Offset of loop start in machine code. */ | ||
209 | uint16_t nchild; /* Number of child traces (root trace only). */ | ||
210 | uint16_t spadjust; /* Stack pointer adjustment (offset in bytes). */ | ||
211 | TraceNo1 traceno; /* Trace number. */ | ||
212 | TraceNo1 link; /* Linked trace (or self for loops). */ | ||
213 | TraceNo1 root; /* Root trace of side trace (or 0 for root traces). */ | ||
214 | TraceNo1 nextroot; /* Next root trace for same prototype. */ | ||
215 | TraceNo1 nextside; /* Next side trace of same root trace. */ | ||
216 | uint16_t unused2; | ||
217 | #ifdef LUAJIT_USE_GDBJIT | ||
218 | void *gdbjit_entry; /* GDB JIT entry. */ | ||
219 | #endif | ||
220 | } GCtrace; | ||
221 | |||
222 | #define gco2trace(o) check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o)) | ||
223 | #define traceref(J, n) \ | ||
224 | check_exp((n)>0 && (MSize)(n)<J->sizetrace, (GCtrace *)gcref(J->trace[(n)])) | ||
225 | |||
226 | LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist)); | ||
227 | |||
228 | static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap) | ||
229 | { | ||
230 | if (snap+1 == &T->snap[T->nsnap]) | ||
231 | return T->nsnapmap; | ||
232 | else | ||
233 | return (snap+1)->mapofs; | ||
234 | } | ||
235 | |||
236 | /* Round-robin penalty cache for bytecodes leading to aborted traces. */ | ||
237 | typedef struct HotPenalty { | ||
238 | MRef pc; /* Starting bytecode PC. */ | ||
239 | uint16_t val; /* Penalty value, i.e. hotcount start. */ | ||
240 | uint16_t reason; /* Abort reason (really TraceErr). */ | ||
241 | } HotPenalty; | ||
242 | |||
243 | #define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ | ||
244 | #define PENALTY_MIN (36*2) /* Minimum penalty value. */ | ||
245 | #define PENALTY_MAX 60000 /* Maximum penalty value. */ | ||
246 | #define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ | ||
247 | |||
248 | /* Round-robin backpropagation cache for narrowing conversions. */ | ||
249 | typedef struct BPropEntry { | ||
250 | IRRef1 key; /* Key: original reference. */ | ||
251 | IRRef1 val; /* Value: reference after conversion. */ | ||
252 | IRRef mode; /* Mode for this entry (currently IRCONV_*). */ | ||
253 | } BPropEntry; | ||
254 | |||
255 | /* Number of slots for the backpropagation cache. Must be a power of 2. */ | ||
256 | #define BPROP_SLOTS 16 | ||
257 | |||
258 | /* Scalar evolution analysis cache. */ | ||
259 | typedef struct ScEvEntry { | ||
260 | IRRef1 idx; /* Index reference. */ | ||
261 | IRRef1 start; /* Constant start reference. */ | ||
262 | IRRef1 stop; /* Constant stop reference. */ | ||
263 | IRRef1 step; /* Constant step reference. */ | ||
264 | IRType1 t; /* Scalar type. */ | ||
265 | uint8_t dir; /* Direction. 1: +, 0: -. */ | ||
266 | } ScEvEntry; | ||
267 | |||
268 | /* 128 bit SIMD constants. */ | ||
269 | enum { | ||
270 | LJ_KSIMD_ABS, | ||
271 | LJ_KSIMD_NEG, | ||
272 | LJ_KSIMD__MAX | ||
273 | }; | ||
274 | |||
275 | /* Get 16 byte aligned pointer to SIMD constant. */ | ||
276 | #define LJ_KSIMD(J, n) \ | ||
277 | ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15)) | ||
278 | |||
279 | /* Set/reset flag to activate the SPLIT pass for the current trace. */ | ||
280 | #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) | ||
281 | #define lj_needsplit(J) (J->needsplit = 1) | ||
282 | #define lj_resetsplit(J) (J->needsplit = 0) | ||
283 | #else | ||
284 | #define lj_needsplit(J) UNUSED(J) | ||
285 | #define lj_resetsplit(J) UNUSED(J) | ||
286 | #endif | ||
287 | |||
288 | /* Fold state is used to fold instructions on-the-fly. */ | ||
289 | typedef struct FoldState { | ||
290 | IRIns ins; /* Currently emitted instruction. */ | ||
291 | IRIns left; /* Instruction referenced by left operand. */ | ||
292 | IRIns right; /* Instruction referenced by right operand. */ | ||
293 | } FoldState; | ||
294 | |||
295 | /* JIT compiler state. */ | ||
296 | typedef struct jit_State { | ||
297 | GCtrace cur; /* Current trace. */ | ||
298 | |||
299 | lua_State *L; /* Current Lua state. */ | ||
300 | const BCIns *pc; /* Current PC. */ | ||
301 | GCfunc *fn; /* Current function. */ | ||
302 | GCproto *pt; /* Current prototype. */ | ||
303 | TRef *base; /* Current frame base, points into J->slots. */ | ||
304 | |||
305 | uint32_t flags; /* JIT engine flags. */ | ||
306 | BCReg maxslot; /* Relative to baseslot. */ | ||
307 | BCReg baseslot; /* Current frame base, offset into J->slots. */ | ||
308 | |||
309 | uint8_t mergesnap; /* Allowed to merge with next snapshot. */ | ||
310 | uint8_t needsnap; /* Need snapshot before recording next bytecode. */ | ||
311 | IRType1 guardemit; /* Accumulated IRT_GUARD for emitted instructions. */ | ||
312 | uint8_t bcskip; /* Number of bytecode instructions to skip. */ | ||
313 | |||
314 | FoldState fold; /* Fold state. */ | ||
315 | |||
316 | const BCIns *bc_min; /* Start of allowed bytecode range for root trace. */ | ||
317 | MSize bc_extent; /* Extent of the range. */ | ||
318 | |||
319 | TraceState state; /* Trace compiler state. */ | ||
320 | |||
321 | int32_t instunroll; /* Unroll counter for instable loops. */ | ||
322 | int32_t loopunroll; /* Unroll counter for loop ops in side traces. */ | ||
323 | int32_t tailcalled; /* Number of successive tailcalls. */ | ||
324 | int32_t framedepth; /* Current frame depth. */ | ||
325 | int32_t retdepth; /* Return frame depth (count of RETF). */ | ||
326 | |||
327 | MRef k64; /* Pointer to chained array of 64 bit constants. */ | ||
328 | TValue ksimd[LJ_KSIMD__MAX*2+1]; /* 16 byte aligned SIMD constants. */ | ||
329 | |||
330 | IRIns *irbuf; /* Temp. IR instruction buffer. Biased with REF_BIAS. */ | ||
331 | IRRef irtoplim; /* Upper limit of instuction buffer (biased). */ | ||
332 | IRRef irbotlim; /* Lower limit of instuction buffer (biased). */ | ||
333 | IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ | ||
334 | |||
335 | MSize sizesnap; /* Size of temp. snapshot buffer. */ | ||
336 | SnapShot *snapbuf; /* Temp. snapshot buffer. */ | ||
337 | SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */ | ||
338 | MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ | ||
339 | |||
340 | PostProc postproc; /* Required post-processing after execution. */ | ||
341 | #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) | ||
342 | int needsplit; /* Need SPLIT pass. */ | ||
343 | #endif | ||
344 | |||
345 | GCRef *trace; /* Array of traces. */ | ||
346 | TraceNo freetrace; /* Start of scan for next free trace. */ | ||
347 | MSize sizetrace; /* Size of trace array. */ | ||
348 | |||
349 | IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ | ||
350 | TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ | ||
351 | |||
352 | int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ | ||
353 | |||
354 | MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ | ||
355 | |||
356 | HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ | ||
357 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ | ||
358 | uint32_t prngstate; /* PRNG state. */ | ||
359 | |||
360 | BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ | ||
361 | uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ | ||
362 | |||
363 | ScEvEntry scev; /* Scalar evolution analysis cache slots. */ | ||
364 | |||
365 | const BCIns *startpc; /* Bytecode PC of starting instruction. */ | ||
366 | TraceNo parent; /* Parent of current side trace (0 for root traces). */ | ||
367 | ExitNo exitno; /* Exit number in parent of current side trace. */ | ||
368 | |||
369 | BCIns *patchpc; /* PC for pending re-patch. */ | ||
370 | BCIns patchins; /* Instruction for pending re-patch. */ | ||
371 | |||
372 | int mcprot; /* Protection of current mcode area. */ | ||
373 | MCode *mcarea; /* Base of current mcode area. */ | ||
374 | MCode *mctop; /* Top of current mcode area. */ | ||
375 | MCode *mcbot; /* Bottom of current mcode area. */ | ||
376 | size_t szmcarea; /* Size of current mcode area. */ | ||
377 | size_t szallmcarea; /* Total size of all allocated mcode areas. */ | ||
378 | |||
379 | TValue errinfo; /* Additional info element for trace errors. */ | ||
380 | } | ||
381 | #if LJ_TARGET_ARM | ||
382 | LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ | ||
383 | #endif | ||
384 | jit_State; | ||
385 | |||
386 | /* Trivial PRNG e.g. used for penalty randomization. */ | ||
387 | static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) | ||
388 | { | ||
389 | /* Yes, this LCG is very weak, but that doesn't matter for our use case. */ | ||
390 | J->prngstate = J->prngstate * 1103515245 + 12345; | ||
391 | return J->prngstate >> (32-bits); | ||
392 | } | ||
393 | |||
394 | #endif | ||