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