diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/LuaJIT-1.1.7/src/ljit_hints.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/libraries/LuaJIT-1.1.7/src/ljit_hints.h b/libraries/LuaJIT-1.1.7/src/ljit_hints.h new file mode 100644 index 0000000..23743bc --- /dev/null +++ b/libraries/LuaJIT-1.1.7/src/ljit_hints.h | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | ** Hints for the JIT compiler backend. | ||
3 | ** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifdef STRING_HINTS | ||
7 | #define HH(x, name) #name | ||
8 | #define HH_START(x) static const char *const hints_##x [] = { | ||
9 | #define HH_END(x) NULL } | ||
10 | #else | ||
11 | #define HH(x, name) JIT_##x##_##name | ||
12 | #define HH_START(x) enum { JIT_##x##_NONE, | ||
13 | #define HH_END(x) JIT_##x##_MAX } | ||
14 | |||
15 | /* Macros to access hints. */ | ||
16 | #define JIT_H2NUM(x) ((x) << 16) | ||
17 | |||
18 | #define fhint_get(J, hh) \ | ||
19 | (luaH_getnum(J->comstate, JIT_H2NUM(JIT_FH_##hh))) | ||
20 | #define fhint_isset(J, hh) (!ttisnil(fhint_get(J, hh))) | ||
21 | |||
22 | #define hint_getpc(J, hh, pc) \ | ||
23 | (luaH_getnum(J->comstate, (pc)+JIT_H2NUM(JIT_H_##hh))) | ||
24 | #define hint_get(J, hh) hint_getpc(J, hh, J->nextpc-1) | ||
25 | #define hint_issetpc(J, hh, pc) (!ttisnil(hint_getpc(J, hh, pc))) | ||
26 | #define hint_isset(J, hh) hint_issetpc(J, hh, J->nextpc-1) | ||
27 | |||
28 | #endif | ||
29 | |||
30 | /* Hints for functions. */ | ||
31 | HH_START(FH) | ||
32 | HH(FH, NOCLOSE), /* No luaF_close() needed. */ | ||
33 | HH_END(FH); | ||
34 | |||
35 | /* Hints for individual bytecode instruction. */ | ||
36 | HH_START(H) | ||
37 | HH(H, COMBINE), /* Combine/dead instruction: true/false. */ | ||
38 | HH(H, FOR_STEP_K), /* FORPREP/FORLOOP step is const: step. */ | ||
39 | HH(H, TYPE), /* Type hint: typed object. */ | ||
40 | HH(H, TYPEKEY), /* Type hint for keys: typed object. */ | ||
41 | HH(H, INLINE), /* Inline function call: internal index. */ | ||
42 | HH_END(H); | ||
43 | |||
44 | #undef HH | ||
45 | #undef HH_START | ||
46 | #undef HH_END | ||
47 | |||
48 | |||
49 | /* Avoid multiple inclusion for the following. */ | ||
50 | #ifndef ljit_hints_h | ||
51 | #define ljit_hints_h | ||
52 | |||
53 | /* Index numbers for inlining C functions. */ | ||
54 | /* CHECK: the index numbers must match with jit.opt_lib. */ | ||
55 | |||
56 | #define JIT_IH_LIB(x) ((x) >> 16) | ||
57 | #define JIT_IH_IDX(x) ((x) & 0xffff) | ||
58 | #define JIT_IH_MKIDX(l, f) (((l) << 16) | (f)) | ||
59 | |||
60 | /* Library index numbers. */ | ||
61 | enum { | ||
62 | JIT_IHLIB_INTERNAL, | ||
63 | JIT_IHLIB_BASE, | ||
64 | JIT_IHLIB_COROUTINE, | ||
65 | JIT_IHLIB_STRING, | ||
66 | JIT_IHLIB_TABLE, | ||
67 | JIT_IHLIB_MATH, | ||
68 | JIT_IHLIB__LAST | ||
69 | }; | ||
70 | |||
71 | /* Internal functions. */ | ||
72 | enum { | ||
73 | JIT_IH_INTERNAL_RECURSIVE, /* Recursive call. */ | ||
74 | JIT_IH_INTERNAL__LAST | ||
75 | }; | ||
76 | |||
77 | /* Base library functions. */ | ||
78 | enum { | ||
79 | JIT_IH_BASE_PAIRS, | ||
80 | JIT_IH_BASE_IPAIRS, | ||
81 | JIT_IH_BASE__LAST | ||
82 | }; | ||
83 | |||
84 | /* Coroutine library functions. */ | ||
85 | enum { | ||
86 | JIT_IH_COROUTINE_YIELD, | ||
87 | JIT_IH_COROUTINE_RESUME, | ||
88 | JIT_IH_COROUTINE__LAST | ||
89 | }; | ||
90 | |||
91 | /* String library functions. */ | ||
92 | enum { | ||
93 | JIT_IH_STRING_LEN, | ||
94 | JIT_IH_STRING_SUB, | ||
95 | JIT_IH_STRING_CHAR, | ||
96 | JIT_IH_STRING__LAST | ||
97 | }; | ||
98 | |||
99 | /* Table library functions. */ | ||
100 | enum { | ||
101 | JIT_IH_TABLE_INSERT, | ||
102 | JIT_IH_TABLE_REMOVE, | ||
103 | JIT_IH_TABLE_GETN, | ||
104 | JIT_IH_TABLE__LAST | ||
105 | }; | ||
106 | |||
107 | /* Math library functions. */ | ||
108 | /* CHECK: order must match with function table for jit_inline_math(). */ | ||
109 | enum { | ||
110 | /* 1 arg, 1 result. */ | ||
111 | /* Partially inlined. Call C function from libm: */ | ||
112 | JIT_IH_MATH_LOG, | ||
113 | JIT_IH_MATH_LOG10, | ||
114 | JIT_IH_MATH_EXP, | ||
115 | JIT_IH_MATH_SINH, | ||
116 | JIT_IH_MATH_COSH, | ||
117 | JIT_IH_MATH_TANH, | ||
118 | JIT_IH_MATH_ASIN, | ||
119 | JIT_IH_MATH_ACOS, | ||
120 | JIT_IH_MATH_ATAN, | ||
121 | /* Fully inlined: */ | ||
122 | JIT_IH_MATH_SIN, | ||
123 | JIT_IH_MATH_COS, | ||
124 | JIT_IH_MATH_TAN, | ||
125 | JIT_IH_MATH_CEIL, | ||
126 | JIT_IH_MATH_FLOOR, | ||
127 | JIT_IH_MATH_ABS, | ||
128 | JIT_IH_MATH_SQRT, | ||
129 | /* 2 args, 1 result. */ | ||
130 | JIT_IH_MATH_FMOD, | ||
131 | JIT_IH_MATH_ATAN2, | ||
132 | JIT_IH_MATH__LAST | ||
133 | }; | ||
134 | |||
135 | #define JIT_IH_MATH__21 JIT_IH_MATH_FMOD | ||
136 | |||
137 | #endif | ||