diff options
Diffstat (limited to 'src/lj_dispatch.h')
| -rw-r--r-- | src/lj_dispatch.h | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h index 1104cedc..8492f793 100644 --- a/src/lj_dispatch.h +++ b/src/lj_dispatch.h | |||
| @@ -14,8 +14,24 @@ | |||
| 14 | 14 | ||
| 15 | #if LJ_TARGET_MIPS | 15 | #if LJ_TARGET_MIPS |
| 16 | /* Need our own global offset table for the dreaded MIPS calling conventions. */ | 16 | /* Need our own global offset table for the dreaded MIPS calling conventions. */ |
| 17 | |||
| 18 | #ifndef _LJ_VM_H | ||
| 19 | LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t a, int32_t b); | ||
| 20 | #endif | ||
| 21 | |||
| 22 | #if LJ_SOFTFP | ||
| 23 | #ifndef _LJ_IRCALL_H | ||
| 24 | extern double __adddf3(double a, double b); | ||
| 25 | extern double __subdf3(double a, double b); | ||
| 26 | extern double __muldf3(double a, double b); | ||
| 27 | extern double __divdf3(double a, double b); | ||
| 28 | #endif | ||
| 29 | #define SFGOTDEF(_) _(sqrt) _(__adddf3) _(__subdf3) _(__muldf3) _(__divdf3) | ||
| 30 | #else | ||
| 31 | #define SFGOTDEF(_) | ||
| 32 | #endif | ||
| 17 | #if LJ_HASJIT | 33 | #if LJ_HASJIT |
| 18 | #define JITGOTDEF(_) _(lj_trace_exit) _(lj_trace_hot) | 34 | #define JITGOTDEF(_) _(lj_err_trace) _(lj_trace_exit) _(lj_trace_hot) |
| 19 | #else | 35 | #else |
| 20 | #define JITGOTDEF(_) | 36 | #define JITGOTDEF(_) |
| 21 | #endif | 37 | #endif |
| @@ -28,16 +44,19 @@ | |||
| 28 | #define GOTDEF(_) \ | 44 | #define GOTDEF(_) \ |
| 29 | _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ | 45 | _(floor) _(ceil) _(trunc) _(log) _(log10) _(exp) _(sin) _(cos) _(tan) \ |
| 30 | _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ | 46 | _(asin) _(acos) _(atan) _(sinh) _(cosh) _(tanh) _(frexp) _(modf) _(atan2) \ |
| 31 | _(pow) _(fmod) _(ldexp) \ | 47 | _(pow) _(fmod) _(ldexp) _(lj_vm_modi) \ |
| 32 | _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_err_throw) _(lj_err_run) \ | 48 | _(lj_dispatch_call) _(lj_dispatch_ins) _(lj_dispatch_stitch) \ |
| 49 | _(lj_dispatch_profile) _(lj_err_throw) \ | ||
| 33 | _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ | 50 | _(lj_ffh_coroutine_wrap_err) _(lj_func_closeuv) _(lj_func_newL_gc) \ |
| 34 | _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ | 51 | _(lj_gc_barrieruv) _(lj_gc_step) _(lj_gc_step_fixtop) _(lj_meta_arith) \ |
| 35 | _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ | 52 | _(lj_meta_call) _(lj_meta_cat) _(lj_meta_comp) _(lj_meta_equal) \ |
| 36 | _(lj_meta_for) _(lj_meta_len) _(lj_meta_tget) _(lj_meta_tset) \ | 53 | _(lj_meta_for) _(lj_meta_istype) _(lj_meta_len) _(lj_meta_tget) \ |
| 37 | _(lj_state_growstack) _(lj_str_fromnum) _(lj_str_fromnumber) _(lj_str_new) \ | 54 | _(lj_meta_tset) _(lj_state_growstack) _(lj_strfmt_number) \ |
| 38 | _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) _(lj_tab_new) \ | 55 | _(lj_str_new) _(lj_tab_dup) _(lj_tab_get) _(lj_tab_getinth) _(lj_tab_len) \ |
| 39 | _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ | 56 | _(lj_tab_new) _(lj_tab_newkey) _(lj_tab_next) _(lj_tab_reasize) \ |
| 40 | JITGOTDEF(_) FFIGOTDEF(_) | 57 | _(lj_tab_setinth) _(lj_buf_putstr_reverse) _(lj_buf_putstr_lower) \ |
| 58 | _(lj_buf_putstr_upper) _(lj_buf_tostr) \ | ||
| 59 | JITGOTDEF(_) FFIGOTDEF(_) SFGOTDEF(_) | ||
| 41 | 60 | ||
| 42 | enum { | 61 | enum { |
| 43 | #define GOTENUM(name) LJ_GOT_##name, | 62 | #define GOTENUM(name) LJ_GOT_##name, |
| @@ -60,7 +79,7 @@ typedef uint16_t HotCount; | |||
| 60 | #define HOTCOUNT_CALL 1 | 79 | #define HOTCOUNT_CALL 1 |
| 61 | 80 | ||
| 62 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ | 81 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ |
| 63 | #define GG_NUM_ASMFF 62 | 82 | #define GG_NUM_ASMFF 57 |
| 64 | 83 | ||
| 65 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) | 84 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) |
| 66 | #define GG_LEN_SDISP BC_FUNCF | 85 | #define GG_LEN_SDISP BC_FUNCF |
| @@ -70,7 +89,7 @@ typedef uint16_t HotCount; | |||
| 70 | typedef struct GG_State { | 89 | typedef struct GG_State { |
| 71 | lua_State L; /* Main thread. */ | 90 | lua_State L; /* Main thread. */ |
| 72 | global_State g; /* Global state. */ | 91 | global_State g; /* Global state. */ |
| 73 | #if LJ_TARGET_ARM | 92 | #if LJ_TARGET_ARM && !LJ_TARGET_NX |
| 74 | /* Make g reachable via K12 encoded DISPATCH-relative addressing. */ | 93 | /* Make g reachable via K12 encoded DISPATCH-relative addressing. */ |
| 75 | uint8_t align1[(16-sizeof(global_State))&15]; | 94 | uint8_t align1[(16-sizeof(global_State))&15]; |
| 76 | #endif | 95 | #endif |
| @@ -80,7 +99,7 @@ typedef struct GG_State { | |||
| 80 | #if LJ_HASJIT | 99 | #if LJ_HASJIT |
| 81 | jit_State J; /* JIT state. */ | 100 | jit_State J; /* JIT state. */ |
| 82 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ | 101 | HotCount hotcount[HOTCOUNT_SIZE]; /* Hot counters. */ |
| 83 | #if LJ_TARGET_ARM | 102 | #if LJ_TARGET_ARM && !LJ_TARGET_NX |
| 84 | /* Ditto for J. */ | 103 | /* Ditto for J. */ |
| 85 | uint8_t align2[(16-sizeof(jit_State)-sizeof(HotCount)*HOTCOUNT_SIZE)&15]; | 104 | uint8_t align2[(16-sizeof(jit_State)-sizeof(HotCount)*HOTCOUNT_SIZE)&15]; |
| 86 | #endif | 105 | #endif |
| @@ -96,6 +115,7 @@ typedef struct GG_State { | |||
| 96 | #define J2G(J) (&J2GG(J)->g) | 115 | #define J2G(J) (&J2GG(J)->g) |
| 97 | #define G2J(gl) (&G2GG(gl)->J) | 116 | #define G2J(gl) (&G2GG(gl)->J) |
| 98 | #define L2J(L) (&L2GG(L)->J) | 117 | #define L2J(L) (&L2GG(L)->J) |
| 118 | #define GG_G2J (GG_OFS(J) - GG_OFS(g)) | ||
| 99 | #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) | 119 | #define GG_G2DISP (GG_OFS(dispatch) - GG_OFS(g)) |
| 100 | #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) | 120 | #define GG_DISP2G (GG_OFS(g) - GG_OFS(dispatch)) |
| 101 | #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) | 121 | #define GG_DISP2J (GG_OFS(J) - GG_OFS(dispatch)) |
| @@ -117,7 +137,12 @@ LJ_FUNC void lj_dispatch_update(global_State *g); | |||
| 117 | /* Instruction dispatch callback for hooks or when recording. */ | 137 | /* Instruction dispatch callback for hooks or when recording. */ |
| 118 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); | 138 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc); |
| 119 | LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); | 139 | LJ_FUNCA ASMFunction LJ_FASTCALL lj_dispatch_call(lua_State *L, const BCIns*pc); |
| 120 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_return(lua_State *L, const BCIns *pc); | 140 | #if LJ_HASJIT |
| 141 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_stitch(jit_State *J, const BCIns *pc); | ||
| 142 | #endif | ||
| 143 | #if LJ_HASPROFILE | ||
| 144 | LJ_FUNCA void LJ_FASTCALL lj_dispatch_profile(lua_State *L, const BCIns *pc); | ||
| 145 | #endif | ||
| 121 | 146 | ||
| 122 | #if LJ_HASFFI && !defined(_BUILDVM_H) | 147 | #if LJ_HASFFI && !defined(_BUILDVM_H) |
| 123 | /* Save/restore errno and GetLastError() around hooks, exits and recording. */ | 148 | /* Save/restore errno and GetLastError() around hooks, exits and recording. */ |
