1 /*
2 ** Common definitions for the JIT compiler.
3 ** Copyright (C) 2005-2021 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 
14 /* General JIT engine flags. 4 bits. */
15 #define JIT_F_ON		0x00000001
16 
17 /* CPU-specific JIT engine flags. 12 bits. Flags and strings must match. */
18 #define JIT_F_CPU		0x00000010
19 
20 #if LJ_TARGET_X86ORX64
21 
22 #define JIT_F_SSE3		(JIT_F_CPU << 0)
23 #define JIT_F_SSE4_1		(JIT_F_CPU << 1)
24 #define JIT_F_BMI2		(JIT_F_CPU << 2)
25 #define JIT_F_SSE4_2		(JIT_F_CPU << 3)
26 
27 
28 #define JIT_F_CPUSTRING		"\4SSE3\6SSE4.1\4BMI2"
29 
30 #elif LJ_TARGET_ARM
31 
32 #define JIT_F_ARMV6_		(JIT_F_CPU << 0)
33 #define JIT_F_ARMV6T2_		(JIT_F_CPU << 1)
34 #define JIT_F_ARMV7		(JIT_F_CPU << 2)
35 #define JIT_F_ARMV8		(JIT_F_CPU << 3)
36 #define JIT_F_VFPV2		(JIT_F_CPU << 4)
37 #define JIT_F_VFPV3		(JIT_F_CPU << 5)
38 
39 #define JIT_F_ARMV6		(JIT_F_ARMV6_|JIT_F_ARMV6T2_|JIT_F_ARMV7|JIT_F_ARMV8)
40 #define JIT_F_ARMV6T2		(JIT_F_ARMV6T2_|JIT_F_ARMV7|JIT_F_ARMV8)
41 #define JIT_F_VFP		(JIT_F_VFPV2|JIT_F_VFPV3)
42 
43 #define JIT_F_CPUSTRING		"\5ARMv6\7ARMv6T2\5ARMv7\5ARMv8\5VFPv2\5VFPv3"
44 
45 #elif LJ_TARGET_PPC
46 
47 #define JIT_F_SQRT		(JIT_F_CPU << 0)
48 #define JIT_F_ROUND		(JIT_F_CPU << 1)
49 
50 #define JIT_F_CPUSTRING		"\4SQRT\5ROUND"
51 
52 #elif LJ_TARGET_MIPS
53 
54 #define JIT_F_MIPSXXR2		(JIT_F_CPU << 0)
55 
56 #if LJ_TARGET_MIPS32
57 #if LJ_TARGET_MIPSR6
58 #define JIT_F_CPUSTRING		"\010MIPS32R6"
59 #else
60 #define JIT_F_CPUSTRING		"\010MIPS32R2"
61 #endif
62 #else
63 #if LJ_TARGET_MIPSR6
64 #define JIT_F_CPUSTRING		"\010MIPS64R6"
65 #else
66 #define JIT_F_CPUSTRING		"\010MIPS64R2"
67 #endif
68 #endif
69 
70 #else
71 
72 #define JIT_F_CPUSTRING		""
73 
74 #endif
75 
76 /* Optimization flags. 12 bits. */
77 #define JIT_F_OPT		0x00010000
78 #define JIT_F_OPT_MASK		0x0fff0000
79 
80 #define JIT_F_OPT_FOLD		(JIT_F_OPT << 0)
81 #define JIT_F_OPT_CSE		(JIT_F_OPT << 1)
82 #define JIT_F_OPT_DCE		(JIT_F_OPT << 2)
83 #define JIT_F_OPT_FWD		(JIT_F_OPT << 3)
84 #define JIT_F_OPT_DSE		(JIT_F_OPT << 4)
85 #define JIT_F_OPT_NARROW	(JIT_F_OPT << 5)
86 #define JIT_F_OPT_LOOP		(JIT_F_OPT << 6)
87 #define JIT_F_OPT_ABC		(JIT_F_OPT << 7)
88 #define JIT_F_OPT_SINK		(JIT_F_OPT << 8)
89 #define JIT_F_OPT_FUSE		(JIT_F_OPT << 9)
90 
91 /* Optimizations names for -O. Must match the order above. */
92 #define JIT_F_OPTSTRING	\
93   "\4fold\3cse\3dce\3fwd\3dse\6narrow\4loop\3abc\4sink\4fuse"
94 
95 /* Optimization levels set a fixed combination of flags. */
96 #define JIT_F_OPT_0	0
97 #define JIT_F_OPT_1	(JIT_F_OPT_FOLD|JIT_F_OPT_CSE|JIT_F_OPT_DCE)
98 #define JIT_F_OPT_2	(JIT_F_OPT_1|JIT_F_OPT_NARROW|JIT_F_OPT_LOOP)
99 #define JIT_F_OPT_3	(JIT_F_OPT_2|\
100   JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_SINK|JIT_F_OPT_FUSE)
101 #define JIT_F_OPT_DEFAULT	JIT_F_OPT_3
102 
103 /* -- JIT engine parameters ----------------------------------------------- */
104 
105 #if LJ_TARGET_WINDOWS || LJ_64
106 /* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */
107 #define JIT_P_sizemcode_DEFAULT		64
108 #else
109 /* Could go as low as 4K, but the mmap() overhead would be rather high. */
110 #define JIT_P_sizemcode_DEFAULT		32
111 #endif
112 
113 /* Optimization parameters and their defaults. Length is a char in octal! */
114 #define JIT_PARAMDEF(_) \
115   _(\010, maxtrace,	8000)	/* Max. # of traces in cache. */ \
116   _(\011, maxrecord,	16000)	/* Max. # of recorded IR instructions. */ \
117   _(\012, maxirconst,	500)	/* Max. # of IR constants of a trace. */ \
118   _(\007, maxside,	100)	/* Max. # of side traces of a root trace. */ \
119   _(\007, maxsnap,	500)	/* Max. # of snapshots for a trace. */ \
120   _(\011, minstitch,	3)	/* Min. # of IR ins for a stitched trace. */ \
121   \
122   _(\007, hotloop,	56)	/* # of iter. to detect a hot loop/call. */ \
123   _(\007, hotexit,	10)	/* # of taken exits to start a side trace. */ \
124   _(\007, tryside,	4)	/* # of attempts to compile a side trace. */ \
125   \
126   _(\012, instunroll,	4)	/* Max. unroll for instable loops. */ \
127   _(\012, loopunroll,	15)	/* Max. unroll for loop ops in side traces. */ \
128   _(\012, callunroll,	3)	/* Max. unroll for recursive calls. */ \
129   _(\011, recunroll,	2)	/* Min. unroll for true recursion. */ \
130   \
131   /* Size of each machine code area (in KBytes). */ \
132   _(\011, sizemcode,	JIT_P_sizemcode_DEFAULT) \
133   /* Max. total size of all machine code areas (in KBytes). */ \
134   _(\010, maxmcode,	40960) \
135   /* End of list. */
136 
137 enum {
138 #define JIT_PARAMENUM(len, name, value)	JIT_P_##name,
139 JIT_PARAMDEF(JIT_PARAMENUM)
140 #undef JIT_PARAMENUM
141   JIT_P__MAX
142 };
143 
144 #define JIT_PARAMSTR(len, name, value)	#len #name
145 #define JIT_P_STRING	JIT_PARAMDEF(JIT_PARAMSTR)
146 
147 /* -- JIT engine data structures ------------------------------------------ */
148 
149 /* Trace compiler state. */
150 typedef enum {
151   LJ_TRACE_IDLE,	/* Trace compiler idle. */
152   LJ_TRACE_ACTIVE = 0x10,
153   LJ_TRACE_RECORD,	/* Bytecode recording active. */
154   LJ_TRACE_RECORD_1ST,	/* Record 1st instruction, too. */
155   LJ_TRACE_START,	/* New trace started. */
156   LJ_TRACE_END,		/* End of trace. */
157   LJ_TRACE_ASM,		/* Assemble trace. */
158   LJ_TRACE_ERR		/* Trace aborted with error. */
159 } TraceState;
160 
161 /* Post-processing action. */
162 typedef enum {
163   LJ_POST_NONE,		/* No action. */
164   LJ_POST_FIXCOMP,	/* Fixup comparison and emit pending guard. */
165   LJ_POST_FIXGUARD,	/* Fixup and emit pending guard. */
166   LJ_POST_FIXGUARDSNAP,	/* Fixup and emit pending guard and snapshot. */
167   LJ_POST_FIXBOOL,	/* Fixup boolean result. */
168   LJ_POST_FIXCONST,	/* Fixup constant results. */
169   LJ_POST_FFRETRY	/* Suppress recording of retried fast functions. */
170 } PostProc;
171 
172 /* Machine code type. */
173 #if LJ_TARGET_X86ORX64
174 typedef uint8_t MCode;
175 #else
176 typedef uint32_t MCode;
177 #endif
178 
179 /* Linked list of MCode areas. */
180 typedef struct MCLink {
181   MCode *next;		/* Next area. */
182   size_t size;		/* Size of current area. */
183 } MCLink;
184 
185 /* Stack snapshot header. */
186 typedef struct SnapShot {
187   uint32_t mapofs;	/* Offset into snapshot map. */
188   IRRef1 ref;		/* First IR ref for this snapshot. */
189   uint16_t mcofs;	/* Offset into machine code in MCode units. */
190   uint8_t nslots;	/* Number of valid slots. */
191   uint8_t topslot;	/* Maximum frame extent. */
192   uint8_t nent;		/* Number of compressed entries. */
193   uint8_t count;	/* Count of taken exits for this snapshot. */
194 } SnapShot;
195 
196 #define SNAPCOUNT_DONE	255	/* Already compiled and linked a side trace. */
197 
198 /* Compressed snapshot entry. */
199 typedef uint32_t SnapEntry;
200 
201 #define SNAP_FRAME		0x010000	/* Frame slot. */
202 #define SNAP_CONT		0x020000	/* Continuation slot. */
203 #define SNAP_NORESTORE		0x040000	/* No need to restore slot. */
204 #define SNAP_SOFTFPNUM		0x080000	/* Soft-float number. */
205 #define SNAP_KEYINDEX		0x100000	/* Traversal key index. */
206 LJ_STATIC_ASSERT(SNAP_FRAME == TREF_FRAME);
207 LJ_STATIC_ASSERT(SNAP_CONT == TREF_CONT);
208 LJ_STATIC_ASSERT(SNAP_KEYINDEX == TREF_KEYINDEX);
209 
210 #define SNAP(slot, flags, ref)	(((SnapEntry)(slot) << 24) + (flags) + (ref))
211 #define SNAP_TR(slot, tr) \
212   (((SnapEntry)(slot) << 24) + \
213    ((tr) & (TREF_KEYINDEX|TREF_CONT|TREF_FRAME|TREF_REFMASK)))
214 #if !LJ_FR2
215 #define SNAP_MKPC(pc)		((SnapEntry)u32ptr(pc))
216 #endif
217 #define SNAP_MKFTSZ(ftsz)	((SnapEntry)(ftsz))
218 #define snap_ref(sn)		((sn) & 0xffff)
219 #define snap_slot(sn)		((BCReg)((sn) >> 24))
220 #define snap_isframe(sn)	((sn) & SNAP_FRAME)
221 #define snap_setref(sn, ref)	(((sn) & (0xffff0000&~SNAP_NORESTORE)) | (ref))
222 
snap_pc(SnapEntry * sn)223 static LJ_AINLINE const BCIns *snap_pc(SnapEntry *sn)
224 {
225 #if LJ_FR2
226   uint64_t pcbase;
227   memcpy(&pcbase, sn, sizeof(uint64_t));
228   return (const BCIns *)(pcbase >> 8);
229 #else
230   return (const BCIns *)(uintptr_t)*sn;
231 #endif
232 }
233 
234 /* Snapshot and exit numbers. */
235 typedef uint32_t SnapNo;
236 typedef uint32_t ExitNo;
237 
238 /* Trace number. */
239 typedef uint32_t TraceNo;	/* Used to pass around trace numbers. */
240 typedef uint16_t TraceNo1;	/* Stored trace number. */
241 
242 /* Type of link. ORDER LJ_TRLINK */
243 typedef enum {
244   LJ_TRLINK_NONE,		/* Incomplete trace. No link, yet. */
245   LJ_TRLINK_ROOT,		/* Link to other root trace. */
246   LJ_TRLINK_LOOP,		/* Loop to same trace. */
247   LJ_TRLINK_TAILREC,		/* Tail-recursion. */
248   LJ_TRLINK_UPREC,		/* Up-recursion. */
249   LJ_TRLINK_DOWNREC,		/* Down-recursion. */
250   LJ_TRLINK_INTERP,		/* Fallback to interpreter. */
251   LJ_TRLINK_RETURN,		/* Return to interpreter. */
252   LJ_TRLINK_STITCH		/* Trace stitching. */
253 } TraceLink;
254 
255 /* Trace object. */
256 typedef struct GCtrace {
257   GCHeader;
258   uint16_t nsnap;	/* Number of snapshots. */
259   IRRef nins;		/* Next IR instruction. Biased with REF_BIAS. */
260 #if LJ_GC64
261   uint32_t unused_gc64;
262 #endif
263   GCRef gclist;
264   IRIns *ir;		/* IR instructions/constants. Biased with REF_BIAS. */
265   IRRef nk;		/* Lowest IR constant. Biased with REF_BIAS. */
266   uint32_t nsnapmap;	/* Number of snapshot map elements. */
267   SnapShot *snap;	/* Snapshot array. */
268   SnapEntry *snapmap;	/* Snapshot map. */
269   GCRef startpt;	/* Starting prototype. */
270   MRef startpc;		/* Bytecode PC of starting instruction. */
271   BCIns startins;	/* Original bytecode of starting instruction. */
272   MSize szmcode;	/* Size of machine code. */
273   MCode *mcode;		/* Start of machine code. */
274   MSize mcloop;		/* Offset of loop start in machine code. */
275   uint16_t nchild;	/* Number of child traces (root trace only). */
276   uint16_t spadjust;	/* Stack pointer adjustment (offset in bytes). */
277   TraceNo1 traceno;	/* Trace number. */
278   TraceNo1 link;	/* Linked trace (or self for loops). */
279   TraceNo1 root;	/* Root trace of side trace (or 0 for root traces). */
280   TraceNo1 nextroot;	/* Next root trace for same prototype. */
281   TraceNo1 nextside;	/* Next side trace of same root trace. */
282   uint8_t sinktags;	/* Trace has SINK tags. */
283   uint8_t topslot;	/* Top stack slot already checked to be allocated. */
284   uint8_t linktype;	/* Type of link. */
285   uint8_t unused1;
286 #ifdef LUAJIT_USE_GDBJIT
287   void *gdbjit_entry;	/* GDB JIT entry. */
288 #endif
289 } GCtrace;
290 
291 #define gco2trace(o)	check_exp((o)->gch.gct == ~LJ_TTRACE, (GCtrace *)(o))
292 #define traceref(J, n) \
293   check_exp((n)>0 && (MSize)(n)<J->sizetrace, (GCtrace *)gcref(J->trace[(n)]))
294 
295 LJ_STATIC_ASSERT(offsetof(GChead, gclist) == offsetof(GCtrace, gclist));
296 
snap_nextofs(GCtrace * T,SnapShot * snap)297 static LJ_AINLINE MSize snap_nextofs(GCtrace *T, SnapShot *snap)
298 {
299   if (snap+1 == &T->snap[T->nsnap])
300     return T->nsnapmap;
301   else
302     return (snap+1)->mapofs;
303 }
304 
305 /* Round-robin penalty cache for bytecodes leading to aborted traces. */
306 typedef struct HotPenalty {
307   MRef pc;		/* Starting bytecode PC. */
308   uint16_t val;		/* Penalty value, i.e. hotcount start. */
309   uint16_t reason;	/* Abort reason (really TraceErr). */
310 } HotPenalty;
311 
312 #define PENALTY_SLOTS	64	/* Penalty cache slot. Must be a power of 2. */
313 #define PENALTY_MIN	(36*2)	/* Minimum penalty value. */
314 #define PENALTY_MAX	60000	/* Maximum penalty value. */
315 #define PENALTY_RNDBITS	4	/* # of random bits to add to penalty value. */
316 
317 /* Round-robin backpropagation cache for narrowing conversions. */
318 typedef struct BPropEntry {
319   IRRef1 key;		/* Key: original reference. */
320   IRRef1 val;		/* Value: reference after conversion. */
321   IRRef mode;		/* Mode for this entry (currently IRCONV_*). */
322 } BPropEntry;
323 
324 /* Number of slots for the backpropagation cache. Must be a power of 2. */
325 #define BPROP_SLOTS	16
326 
327 /* Scalar evolution analysis cache. */
328 typedef struct ScEvEntry {
329   MRef pc;		/* Bytecode PC of FORI. */
330   IRRef1 idx;		/* Index reference. */
331   IRRef1 start;		/* Constant start reference. */
332   IRRef1 stop;		/* Constant stop reference. */
333   IRRef1 step;		/* Constant step reference. */
334   IRType1 t;		/* Scalar type. */
335   uint8_t dir;		/* Direction. 1: +, 0: -. */
336 } ScEvEntry;
337 
338 /* Reverse bytecode map (IRRef -> PC). Only for selected instructions. */
339 typedef struct RBCHashEntry {
340   MRef pc;		/* Bytecode PC. */
341   GCRef pt;		/* Prototype. */
342   IRRef ref;		/* IR reference. */
343 } RBCHashEntry;
344 
345 /* Number of slots in the reverse bytecode hash table. Must be a power of 2. */
346 #define RBCHASH_SLOTS	8
347 
348 /* 128 bit SIMD constants. */
349 enum {
350   LJ_KSIMD_ABS,
351   LJ_KSIMD_NEG,
352   LJ_KSIMD__MAX
353 };
354 
355 enum {
356 #if LJ_TARGET_X86ORX64
357   LJ_K64_TOBIT,		/* 2^52 + 2^51 */
358   LJ_K64_2P64,		/* 2^64 */
359   LJ_K64_M2P64,		/* -2^64 */
360 #if LJ_32
361   LJ_K64_M2P64_31,	/* -2^64 or -2^31 */
362 #else
363   LJ_K64_M2P64_31 = LJ_K64_M2P64,
364 #endif
365 #endif
366 #if LJ_TARGET_MIPS
367   LJ_K64_2P31,		/* 2^31 */
368 #if LJ_64
369   LJ_K64_2P63,		/* 2^63 */
370   LJ_K64_M2P64,		/* -2^64 */
371 #endif
372 #endif
373   LJ_K64__MAX,
374 };
375 
376 enum {
377 #if LJ_TARGET_X86ORX64
378   LJ_K32_M2P64_31,	/* -2^64 or -2^31 */
379 #endif
380 #if LJ_TARGET_PPC
381   LJ_K32_2P52_2P31,	/* 2^52 + 2^31 */
382   LJ_K32_2P52,		/* 2^52 */
383 #endif
384 #if LJ_TARGET_PPC || LJ_TARGET_MIPS
385   LJ_K32_2P31,		/* 2^31 */
386 #endif
387 #if LJ_TARGET_MIPS64
388   LJ_K32_2P63,		/* 2^63 */
389   LJ_K32_M2P64,		/* -2^64 */
390 #endif
391   LJ_K32__MAX
392 };
393 
394 /* Get 16 byte aligned pointer to SIMD constant. */
395 #define LJ_KSIMD(J, n) \
396   ((TValue *)(((intptr_t)&J->ksimd[2*(n)] + 15) & ~(intptr_t)15))
397 
398 /* Set/reset flag to activate the SPLIT pass for the current trace. */
399 #if LJ_SOFTFP32 || (LJ_32 && LJ_HASFFI)
400 #define lj_needsplit(J)		(J->needsplit = 1)
401 #define lj_resetsplit(J)	(J->needsplit = 0)
402 #else
403 #define lj_needsplit(J)		UNUSED(J)
404 #define lj_resetsplit(J)	UNUSED(J)
405 #endif
406 
407 /* Fold state is used to fold instructions on-the-fly. */
408 typedef struct FoldState {
409   IRIns ins;		/* Currently emitted instruction. */
410   IRIns left[2];	/* Instruction referenced by left operand. */
411   IRIns right[2];	/* Instruction referenced by right operand. */
412 } FoldState;
413 
414 /* JIT compiler state. */
415 typedef struct jit_State {
416   GCtrace cur;		/* Current trace. */
417   GCtrace *curfinal;	/* Final address of current trace (set during asm). */
418 
419   lua_State *L;		/* Current Lua state. */
420   const BCIns *pc;	/* Current PC. */
421   GCfunc *fn;		/* Current function. */
422   GCproto *pt;		/* Current prototype. */
423   TRef *base;		/* Current frame base, points into J->slots. */
424 
425   uint32_t flags;	/* JIT engine flags. */
426   BCReg maxslot;	/* Relative to baseslot. */
427   BCReg baseslot;	/* Current frame base, offset into J->slots. */
428 
429   uint8_t mergesnap;	/* Allowed to merge with next snapshot. */
430   uint8_t needsnap;	/* Need snapshot before recording next bytecode. */
431   IRType1 guardemit;	/* Accumulated IRT_GUARD for emitted instructions. */
432   uint8_t bcskip;	/* Number of bytecode instructions to skip. */
433 
434   FoldState fold;	/* Fold state. */
435 
436   const BCIns *bc_min;	/* Start of allowed bytecode range for root trace. */
437   MSize bc_extent;	/* Extent of the range. */
438 
439   TraceState state;	/* Trace compiler state. */
440 
441   int32_t instunroll;	/* Unroll counter for instable loops. */
442   int32_t loopunroll;	/* Unroll counter for loop ops in side traces. */
443   int32_t tailcalled;	/* Number of successive tailcalls. */
444   int32_t framedepth;	/* Current frame depth. */
445   int32_t retdepth;	/* Return frame depth (count of RETF). */
446 
447   uint32_t k32[LJ_K32__MAX];  /* Common 4 byte constants used by backends. */
448   TValue ksimd[LJ_KSIMD__MAX*2+1];  /* 16 byte aligned SIMD constants. */
449   TValue k64[LJ_K64__MAX];  /* Common 8 byte constants. */
450 
451   IRIns *irbuf;		/* Temp. IR instruction buffer. Biased with REF_BIAS. */
452   IRRef irtoplim;	/* Upper limit of instuction buffer (biased). */
453   IRRef irbotlim;	/* Lower limit of instuction buffer (biased). */
454   IRRef loopref;	/* Last loop reference or ref of final LOOP (or 0). */
455 
456   MSize sizesnap;	/* Size of temp. snapshot buffer. */
457   SnapShot *snapbuf;	/* Temp. snapshot buffer. */
458   SnapEntry *snapmapbuf;  /* Temp. snapshot map buffer. */
459   MSize sizesnapmap;	/* Size of temp. snapshot map buffer. */
460 
461   PostProc postproc;	/* Required post-processing after execution. */
462 #if LJ_SOFTFP32 || (LJ_32 && LJ_HASFFI)
463   uint8_t needsplit;	/* Need SPLIT pass. */
464 #endif
465   uint8_t retryrec;	/* Retry recording. */
466 
467   GCRef *trace;		/* Array of traces. */
468   TraceNo freetrace;	/* Start of scan for next free trace. */
469   MSize sizetrace;	/* Size of trace array. */
470   IRRef1 ktrace;	/* Reference to KGC with GCtrace. */
471 
472   IRRef1 chain[IR__MAX];  /* IR instruction skip-list chain anchors. */
473   TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA];  /* Stack slot map. */
474 
475   int32_t param[JIT_P__MAX];  /* JIT engine parameters. */
476 
477   MCode *exitstubgroup[LJ_MAX_EXITSTUBGR];  /* Exit stub group addresses. */
478 
479   HotPenalty penalty[PENALTY_SLOTS];  /* Penalty slots. */
480   uint32_t penaltyslot;	/* Round-robin index into penalty slots. */
481 
482 #ifdef LUAJIT_ENABLE_TABLE_BUMP
483   RBCHashEntry rbchash[RBCHASH_SLOTS];  /* Reverse bytecode map. */
484 #endif
485 
486   BPropEntry bpropcache[BPROP_SLOTS];  /* Backpropagation cache slots. */
487   uint32_t bpropslot;	/* Round-robin index into bpropcache slots. */
488 
489   ScEvEntry scev;	/* Scalar evolution analysis cache slots. */
490 
491   const BCIns *startpc;	/* Bytecode PC of starting instruction. */
492   TraceNo parent;	/* Parent of current side trace (0 for root traces). */
493   ExitNo exitno;	/* Exit number in parent of current side trace. */
494   int exitcode;		/* Exit code from unwound trace. */
495 
496   BCIns *patchpc;	/* PC for pending re-patch. */
497   BCIns patchins;	/* Instruction for pending re-patch. */
498 
499   int mcprot;		/* Protection of current mcode area. */
500   MCode *mcarea;	/* Base of current mcode area. */
501   MCode *mctop;		/* Top of current mcode area. */
502   MCode *mcbot;		/* Bottom of current mcode area. */
503   size_t szmcarea;	/* Size of current mcode area. */
504   size_t szallmcarea;	/* Total size of all allocated mcode areas. */
505 
506   TValue errinfo;	/* Additional info element for trace errors. */
507 
508 #if LJ_HASPROFILE
509   GCproto *prev_pt;	/* Previous prototype. */
510   BCLine prev_line;	/* Previous line. */
511   int prof_mode;	/* Profiling mode: 0, 'f', 'l'. */
512 #endif
513   PRNGState prng;	/* PRNG state for the JIT compiler, defaults to prng in
514 			   global_State. */
515 } jit_State;
516 
517 #ifdef LUA_USE_ASSERT
518 #define lj_assertJ(c, ...)	lj_assertG_(J2G(J), (c), __VA_ARGS__)
519 #else
520 #define lj_assertJ(c, ...)	((void)J)
521 #endif
522 
523 #endif
524