diff options
Diffstat (limited to 'src/lj_jit.h')
-rw-r--r-- | src/lj_jit.h | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h index 9b66c565..2d2e833a 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -14,18 +14,16 @@ | |||
14 | 14 | ||
15 | /* CPU-specific JIT engine flags. */ | 15 | /* CPU-specific JIT engine flags. */ |
16 | #if LJ_TARGET_X86ORX64 | 16 | #if LJ_TARGET_X86ORX64 |
17 | #define JIT_F_CMOV 0x00000010 | 17 | #define JIT_F_SSE2 0x00000010 |
18 | #define JIT_F_SSE2 0x00000020 | 18 | #define JIT_F_SSE3 0x00000020 |
19 | #define JIT_F_SSE3 0x00000040 | 19 | #define JIT_F_SSE4_1 0x00000040 |
20 | #define JIT_F_SSE4_1 0x00000080 | 20 | #define JIT_F_PREFER_IMUL 0x00000080 |
21 | #define JIT_F_P4 0x00000100 | 21 | #define JIT_F_LEA_AGU 0x00000100 |
22 | #define JIT_F_PREFER_IMUL 0x00000200 | 22 | #define JIT_F_BMI2 0x00000200 |
23 | #define JIT_F_SPLIT_XMM 0x00000400 | ||
24 | #define JIT_F_LEA_AGU 0x00000800 | ||
25 | 23 | ||
26 | /* Names for the CPU-specific flags. Must match the order above. */ | 24 | /* Names for the CPU-specific flags. Must match the order above. */ |
27 | #define JIT_F_CPU_FIRST JIT_F_CMOV | 25 | #define JIT_F_CPU_FIRST JIT_F_SSE2 |
28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" | 26 | #define JIT_F_CPUSTRING "\4SSE2\4SSE3\6SSE4.1\3AMD\4ATOM\4BMI2" |
29 | #elif LJ_TARGET_ARM | 27 | #elif LJ_TARGET_ARM |
30 | #define JIT_F_ARMV6_ 0x00000010 | 28 | #define JIT_F_ARMV6_ 0x00000010 |
31 | #define JIT_F_ARMV6T2_ 0x00000020 | 29 | #define JIT_F_ARMV6T2_ 0x00000020 |
@@ -100,6 +98,7 @@ | |||
100 | _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ | 98 | _(\012, maxirconst, 500) /* Max. # of IR constants of a trace. */ \ |
101 | _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ | 99 | _(\007, maxside, 100) /* Max. # of side traces of a root trace. */ \ |
102 | _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ | 100 | _(\007, maxsnap, 500) /* Max. # of snapshots for a trace. */ \ |
101 | _(\011, minstitch, 0) /* Min. # of IR ins for a stitched trace. */ \ | ||
103 | \ | 102 | \ |
104 | _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ | 103 | _(\007, hotloop, 56) /* # of iter. to detect a hot loop/call. */ \ |
105 | _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ | 104 | _(\007, hotexit, 10) /* # of taken exits to start a side trace. */ \ |
@@ -205,7 +204,8 @@ typedef enum { | |||
205 | LJ_TRLINK_UPREC, /* Up-recursion. */ | 204 | LJ_TRLINK_UPREC, /* Up-recursion. */ |
206 | LJ_TRLINK_DOWNREC, /* Down-recursion. */ | 205 | LJ_TRLINK_DOWNREC, /* Down-recursion. */ |
207 | LJ_TRLINK_INTERP, /* Fallback to interpreter. */ | 206 | LJ_TRLINK_INTERP, /* Fallback to interpreter. */ |
208 | LJ_TRLINK_RETURN /* Return to interpreter. */ | 207 | LJ_TRLINK_RETURN, /* Return to interpreter. */ |
208 | LJ_TRLINK_STITCH /* Trace stitching. */ | ||
209 | } TraceLink; | 209 | } TraceLink; |
210 | 210 | ||
211 | /* Trace object. */ | 211 | /* Trace object. */ |
@@ -214,6 +214,9 @@ typedef struct GCtrace { | |||
214 | uint8_t topslot; /* Top stack slot already checked to be allocated. */ | 214 | uint8_t topslot; /* Top stack slot already checked to be allocated. */ |
215 | uint8_t linktype; /* Type of link. */ | 215 | uint8_t linktype; /* Type of link. */ |
216 | IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ | 216 | IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ |
217 | #if LJ_GC64 | ||
218 | uint32_t unused_gc64; | ||
219 | #endif | ||
217 | GCRef gclist; | 220 | GCRef gclist; |
218 | IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ | 221 | IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */ |
219 | IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ | 222 | IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ |
@@ -288,6 +291,16 @@ typedef struct ScEvEntry { | |||
288 | uint8_t dir; /* Direction. 1: +, 0: -. */ | 291 | uint8_t dir; /* Direction. 1: +, 0: -. */ |
289 | } ScEvEntry; | 292 | } ScEvEntry; |
290 | 293 | ||
294 | /* Reverse bytecode map (IRRef -> PC). Only for selected instructions. */ | ||
295 | typedef struct RBCHashEntry { | ||
296 | MRef pc; /* Bytecode PC. */ | ||
297 | GCRef pt; /* Prototype. */ | ||
298 | IRRef ref; /* IR reference. */ | ||
299 | } RBCHashEntry; | ||
300 | |||
301 | /* Number of slots in the reverse bytecode hash table. Must be a power of 2. */ | ||
302 | #define RBCHASH_SLOTS 8 | ||
303 | |||
291 | /* 128 bit SIMD constants. */ | 304 | /* 128 bit SIMD constants. */ |
292 | enum { | 305 | enum { |
293 | LJ_KSIMD_ABS, | 306 | LJ_KSIMD_ABS, |
@@ -362,12 +375,14 @@ typedef struct jit_State { | |||
362 | 375 | ||
363 | PostProc postproc; /* Required post-processing after execution. */ | 376 | PostProc postproc; /* Required post-processing after execution. */ |
364 | #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) | 377 | #if LJ_SOFTFP || (LJ_32 && LJ_HASFFI) |
365 | int needsplit; /* Need SPLIT pass. */ | 378 | uint8_t needsplit; /* Need SPLIT pass. */ |
366 | #endif | 379 | #endif |
380 | uint8_t retryrec; /* Retry recording. */ | ||
367 | 381 | ||
368 | GCRef *trace; /* Array of traces. */ | 382 | GCRef *trace; /* Array of traces. */ |
369 | TraceNo freetrace; /* Start of scan for next free trace. */ | 383 | TraceNo freetrace; /* Start of scan for next free trace. */ |
370 | MSize sizetrace; /* Size of trace array. */ | 384 | MSize sizetrace; /* Size of trace array. */ |
385 | TValue *ktracep; /* Pointer to K64Array slot with GCtrace pointer. */ | ||
371 | 386 | ||
372 | IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ | 387 | IRRef1 chain[IR__MAX]; /* IR instruction skip-list chain anchors. */ |
373 | TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ | 388 | TRef slot[LJ_MAX_JSLOTS+LJ_STACK_EXTRA]; /* Stack slot map. */ |
@@ -380,6 +395,10 @@ typedef struct jit_State { | |||
380 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ | 395 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ |
381 | uint32_t prngstate; /* PRNG state. */ | 396 | uint32_t prngstate; /* PRNG state. */ |
382 | 397 | ||
398 | #ifdef LUAJIT_ENABLE_TABLE_BUMP | ||
399 | RBCHashEntry rbchash[RBCHASH_SLOTS]; /* Reverse bytecode map. */ | ||
400 | #endif | ||
401 | |||
383 | BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ | 402 | BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */ |
384 | uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ | 403 | uint32_t bpropslot; /* Round-robin index into bpropcache slots. */ |
385 | 404 | ||
@@ -400,6 +419,12 @@ typedef struct jit_State { | |||
400 | size_t szallmcarea; /* Total size of all allocated mcode areas. */ | 419 | size_t szallmcarea; /* Total size of all allocated mcode areas. */ |
401 | 420 | ||
402 | TValue errinfo; /* Additional info element for trace errors. */ | 421 | TValue errinfo; /* Additional info element for trace errors. */ |
422 | |||
423 | #if LJ_HASPROFILE | ||
424 | GCproto *prev_pt; /* Previous prototype. */ | ||
425 | BCLine prev_line; /* Previous line. */ | ||
426 | int prof_mode; /* Profiling mode: 0, 'f', 'l'. */ | ||
427 | #endif | ||
403 | } | 428 | } |
404 | #if LJ_TARGET_ARM | 429 | #if LJ_TARGET_ARM |
405 | LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ | 430 | LJ_ALIGN(16) /* For DISPATCH-relative addresses in assembler part. */ |