diff options
Diffstat (limited to 'src/lj_dispatch.h')
-rw-r--r-- | src/lj_dispatch.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h index bbbfa0be..865ee790 100644 --- a/src/lj_dispatch.h +++ b/src/lj_dispatch.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #define _LJ_DISPATCH_H | 7 | #define _LJ_DISPATCH_H |
8 | 8 | ||
9 | #include "lj_obj.h" | 9 | #include "lj_obj.h" |
10 | #include "lj_bc.h" | ||
10 | #if LJ_HASJIT | 11 | #if LJ_HASJIT |
11 | #include "lj_jit.h" | 12 | #include "lj_jit.h" |
12 | #endif | 13 | #endif |
@@ -21,6 +22,13 @@ typedef uint16_t HotCount; | |||
21 | #define HOTCOUNT_MIN_PENALTY 103 | 22 | #define HOTCOUNT_MIN_PENALTY 103 |
22 | #define HOTCOUNT_MAX_PENALTY 60000 | 23 | #define HOTCOUNT_MAX_PENALTY 60000 |
23 | 24 | ||
25 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ | ||
26 | #define GG_NUM_ASMFF 62 | ||
27 | |||
28 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) | ||
29 | #define GG_LEN_SDISP BC_FUNCC | ||
30 | #define GG_LEN_DISP (GG_LEN_DDISP + GG_LEN_SDISP) | ||
31 | |||
24 | /* Global state, main thread and extra fields are allocated together. */ | 32 | /* Global state, main thread and extra fields are allocated together. */ |
25 | typedef struct GG_State { | 33 | typedef struct GG_State { |
26 | lua_State L; /* Main thread. */ | 34 | lua_State L; /* Main thread. */ |
@@ -29,22 +37,22 @@ typedef struct GG_State { | |||
29 | jit_State J; /* JIT state. */ | 37 | jit_State J; /* JIT state. */ |
30 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ | 38 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ |
31 | #endif | 39 | #endif |
32 | /* Instruction dispatch tables follow. */ | 40 | ASMFunction dispatch[GG_LEN_DISP]; /* Instruction dispatch tables. */ |
41 | BCIns bcff[GG_NUM_ASMFF]; /* Bytecode for ASM fast functions. */ | ||
33 | } GG_State; | 42 | } GG_State; |
34 | 43 | ||
35 | #define GG_OFS(field) ((int)offsetof(GG_State, field)) | 44 | #define GG_OFS(field) ((int)offsetof(GG_State, field)) |
36 | #define GG_OFS_DISP ((int)sizeof(GG_State)) | ||
37 | #define GG2DISP(gg) ((ASMFunction *)((char *)(gg) + GG_OFS_DISP)) | ||
38 | #define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) | 45 | #define G2GG(gl) ((GG_State *)((char *)(gl) - GG_OFS(g))) |
39 | #define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) | 46 | #define J2GG(j) ((GG_State *)((char *)(j) - GG_OFS(J))) |
40 | #define L2GG(L) (G2GG(G(L))) | 47 | #define L2GG(L) (G2GG(G(L))) |
41 | #define J2G(J) (&J2GG(J)->g) | 48 | #define J2G(J) (&J2GG(J)->g) |
42 | #define G2J(gl) (&G2GG(gl)->J) | 49 | #define G2J(gl) (&G2GG(gl)->J) |
43 | #define L2J(L) (&L2GG(L)->J) | 50 | #define L2J(L) (&L2GG(L)->J) |
44 | #define GG_G2DISP (GG_OFS_DISP - GG_OFS(g)) | 51 | #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) |
45 | #define GG_DISP2G (GG_OFS(g) - GG_OFS_DISP) | 52 | #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) |
46 | #define GG_DISP2J (GG_OFS(J) - GG_OFS_DISP) | 53 | #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) |
47 | #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS_DISP) | 54 | #define GG_DISP2HOT (GG_OFS(hotcount) - GG_OFS(dispatch)) |
55 | #define GG_DISP2STATIC (GG_LEN_DDISP*(int)sizeof(ASMFunction)) | ||
48 | 56 | ||
49 | #define hotcount_get(gg, pc) \ | 57 | #define hotcount_get(gg, pc) \ |
50 | (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] | 58 | (gg)->hotcount[(u32ptr(pc)>>2) & (HOTCOUNT_SIZE-1)] |