diff options
Diffstat (limited to 'src/lj_jit.h')
-rw-r--r-- | src/lj_jit.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/lj_jit.h b/src/lj_jit.h index cced4813..22f1d581 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -27,7 +27,8 @@ | |||
27 | #define JIT_F_CPU_FIRST JIT_F_CMOV | 27 | #define JIT_F_CPU_FIRST JIT_F_CMOV |
28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" | 28 | #define JIT_F_CPUSTRING "\4CMOV\4SSE2\4SSE3\6SSE4.1\2P4\3AMD\2K8\4ATOM" |
29 | #else | 29 | #else |
30 | #error "Missing CPU-specific JIT engine flags" | 30 | #define JIT_F_CPU_FIRST 0 |
31 | #define JIT_F_CPUSTRING "" | ||
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | /* Optimization flags. */ | 34 | /* Optimization flags. */ |
@@ -118,7 +119,11 @@ typedef enum { | |||
118 | } PostProc; | 119 | } PostProc; |
119 | 120 | ||
120 | /* Machine code type. */ | 121 | /* Machine code type. */ |
122 | #if LJ_TARGET_X86ORX64 | ||
121 | typedef uint8_t MCode; | 123 | typedef uint8_t MCode; |
124 | #else | ||
125 | typedef uint32_t MCode; | ||
126 | #endif | ||
122 | 127 | ||
123 | /* Stack snapshot header. */ | 128 | /* Stack snapshot header. */ |
124 | typedef struct SnapShot { | 129 | typedef struct SnapShot { |
@@ -252,6 +257,13 @@ enum { | |||
252 | #define lj_resetsplit(J) UNUSED(J) | 257 | #define lj_resetsplit(J) UNUSED(J) |
253 | #endif | 258 | #endif |
254 | 259 | ||
260 | /* Exit stubs. */ | ||
261 | #if LJ_TARGET_X86ORX64 | ||
262 | /* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ | ||
263 | #define EXITSTUB_SPACING (2+2) | ||
264 | #define EXITSTUBS_PER_GROUP 32 | ||
265 | #endif | ||
266 | |||
255 | /* Fold state is used to fold instructions on-the-fly. */ | 267 | /* Fold state is used to fold instructions on-the-fly. */ |
256 | typedef struct FoldState { | 268 | typedef struct FoldState { |
257 | IRIns ins; /* Currently emitted instruction. */ | 269 | IRIns ins; /* Currently emitted instruction. */ |
@@ -318,7 +330,9 @@ typedef struct jit_State { | |||
318 | 330 | ||
319 | int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ | 331 | int32_t param[JIT_P__MAX]; /* JIT engine parameters. */ |
320 | 332 | ||
333 | #if LJ_TARGET_X86ORX64 | ||
321 | MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ | 334 | MCode *exitstubgroup[LJ_MAX_EXITSTUBGR]; /* Exit stub group addresses. */ |
335 | #endif | ||
322 | 336 | ||
323 | HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ | 337 | HotPenalty penalty[PENALTY_SLOTS]; /* Penalty slots. */ |
324 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ | 338 | uint32_t penaltyslot; /* Round-robin index into penalty slots. */ |
@@ -344,7 +358,7 @@ typedef struct jit_State { | |||
344 | size_t szallmcarea; /* Total size of all allocated mcode areas. */ | 358 | size_t szallmcarea; /* Total size of all allocated mcode areas. */ |
345 | 359 | ||
346 | TValue errinfo; /* Additional info element for trace errors. */ | 360 | TValue errinfo; /* Additional info element for trace errors. */ |
347 | } jit_State; | 361 | } LJ_ALIGN(16) jit_State; |
348 | 362 | ||
349 | /* Trivial PRNG e.g. used for penalty randomization. */ | 363 | /* Trivial PRNG e.g. used for penalty randomization. */ |
350 | static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) | 364 | static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) |
@@ -354,21 +368,14 @@ static LJ_AINLINE uint32_t LJ_PRNG_BITS(jit_State *J, int bits) | |||
354 | return J->prngstate >> (32-bits); | 368 | return J->prngstate >> (32-bits); |
355 | } | 369 | } |
356 | 370 | ||
357 | /* Exit stubs. */ | 371 | #ifdef EXITSTUBS_PER_GROUP |
358 | #if LJ_TARGET_X86ORX64 | ||
359 | /* Limited by the range of a short fwd jump (127): (2+2)*(32-1)-2 = 122. */ | ||
360 | #define EXITSTUB_SPACING (2+2) | ||
361 | #define EXITSTUBS_PER_GROUP 32 | ||
362 | #else | ||
363 | #error "Missing CPU-specific exit stub definitions" | ||
364 | #endif | ||
365 | |||
366 | /* Return the address of an exit stub. */ | 372 | /* Return the address of an exit stub. */ |
367 | static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) | 373 | static LJ_AINLINE MCode *exitstub_addr(jit_State *J, ExitNo exitno) |
368 | { | 374 | { |
369 | lua_assert(J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] != NULL); | 375 | lua_assert(J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] != NULL); |
370 | return J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] + | 376 | return (MCode *)((char *)J->exitstubgroup[exitno / EXITSTUBS_PER_GROUP] + |
371 | EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP); | 377 | EXITSTUB_SPACING*(exitno % EXITSTUBS_PER_GROUP)); |
372 | } | 378 | } |
379 | #endif | ||
373 | 380 | ||
374 | #endif | 381 | #endif |