diff options
author | Mike Pall <mike> | 2024-01-22 19:06:36 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2024-01-22 19:06:36 +0100 |
commit | 4b90f6c4d7420139c135435e1580acb52ea18436 (patch) | |
tree | 1c3543b6baa4f8b30a33e8a624b60edc6feb0206 /src/lib_jit.c | |
parent | c525bcb9024510cad9e170e12b6209aedb330f83 (diff) | |
download | luajit-4b90f6c4d7420139c135435e1580acb52ea18436.tar.gz luajit-4b90f6c4d7420139c135435e1580acb52ea18436.tar.bz2 luajit-4b90f6c4d7420139c135435e1580acb52ea18436.zip |
Add cross-32/64 bit and deterministic bytecode generation.
Contributed by Peter Cawley. #993 #1008
Diffstat (limited to 'src/lib_jit.c')
-rw-r--r-- | src/lib_jit.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index c0294927..b83c865a 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -161,24 +161,6 @@ LJLIB_PUSH(top-2) LJLIB_SET(version) | |||
161 | 161 | ||
162 | /* -- Reflection API for Lua functions ------------------------------------ */ | 162 | /* -- Reflection API for Lua functions ------------------------------------ */ |
163 | 163 | ||
164 | /* Return prototype of first argument (Lua function or prototype object) */ | ||
165 | static GCproto *check_Lproto(lua_State *L, int nolua) | ||
166 | { | ||
167 | TValue *o = L->base; | ||
168 | if (L->top > o) { | ||
169 | if (tvisproto(o)) { | ||
170 | return protoV(o); | ||
171 | } else if (tvisfunc(o)) { | ||
172 | if (isluafunc(funcV(o))) | ||
173 | return funcproto(funcV(o)); | ||
174 | else if (nolua) | ||
175 | return NULL; | ||
176 | } | ||
177 | } | ||
178 | lj_err_argt(L, 1, LUA_TFUNCTION); | ||
179 | return NULL; /* unreachable */ | ||
180 | } | ||
181 | |||
182 | static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) | 164 | static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) |
183 | { | 165 | { |
184 | setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); | 166 | setintV(lj_tab_setstr(L, t, lj_str_newz(L, name)), val); |
@@ -187,7 +169,7 @@ static void setintfield(lua_State *L, GCtab *t, const char *name, int32_t val) | |||
187 | /* local info = jit.util.funcinfo(func [,pc]) */ | 169 | /* local info = jit.util.funcinfo(func [,pc]) */ |
188 | LJLIB_CF(jit_util_funcinfo) | 170 | LJLIB_CF(jit_util_funcinfo) |
189 | { | 171 | { |
190 | GCproto *pt = check_Lproto(L, 1); | 172 | GCproto *pt = lj_lib_checkLproto(L, 1, 1); |
191 | if (pt) { | 173 | if (pt) { |
192 | BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); | 174 | BCPos pc = (BCPos)lj_lib_optint(L, 2, 0); |
193 | GCtab *t; | 175 | GCtab *t; |
@@ -229,7 +211,7 @@ LJLIB_CF(jit_util_funcinfo) | |||
229 | /* local ins, m = jit.util.funcbc(func, pc) */ | 211 | /* local ins, m = jit.util.funcbc(func, pc) */ |
230 | LJLIB_CF(jit_util_funcbc) | 212 | LJLIB_CF(jit_util_funcbc) |
231 | { | 213 | { |
232 | GCproto *pt = check_Lproto(L, 0); | 214 | GCproto *pt = lj_lib_checkLproto(L, 1, 0); |
233 | BCPos pc = (BCPos)lj_lib_checkint(L, 2); | 215 | BCPos pc = (BCPos)lj_lib_checkint(L, 2); |
234 | if (pc < pt->sizebc) { | 216 | if (pc < pt->sizebc) { |
235 | BCIns ins = proto_bc(pt)[pc]; | 217 | BCIns ins = proto_bc(pt)[pc]; |
@@ -246,7 +228,7 @@ LJLIB_CF(jit_util_funcbc) | |||
246 | /* local k = jit.util.funck(func, idx) */ | 228 | /* local k = jit.util.funck(func, idx) */ |
247 | LJLIB_CF(jit_util_funck) | 229 | LJLIB_CF(jit_util_funck) |
248 | { | 230 | { |
249 | GCproto *pt = check_Lproto(L, 0); | 231 | GCproto *pt = lj_lib_checkLproto(L, 1, 0); |
250 | ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); | 232 | ptrdiff_t idx = (ptrdiff_t)lj_lib_checkint(L, 2); |
251 | if (idx >= 0) { | 233 | if (idx >= 0) { |
252 | if (idx < (ptrdiff_t)pt->sizekn) { | 234 | if (idx < (ptrdiff_t)pt->sizekn) { |
@@ -266,7 +248,7 @@ LJLIB_CF(jit_util_funck) | |||
266 | /* local name = jit.util.funcuvname(func, idx) */ | 248 | /* local name = jit.util.funcuvname(func, idx) */ |
267 | LJLIB_CF(jit_util_funcuvname) | 249 | LJLIB_CF(jit_util_funcuvname) |
268 | { | 250 | { |
269 | GCproto *pt = check_Lproto(L, 0); | 251 | GCproto *pt = lj_lib_checkLproto(L, 1, 0); |
270 | uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); | 252 | uint32_t idx = (uint32_t)lj_lib_checkint(L, 2); |
271 | if (idx < pt->sizeuv) { | 253 | if (idx < pt->sizeuv) { |
272 | setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); | 254 | setstrV(L, L->top-1, lj_str_newz(L, lj_debug_uvname(pt, idx))); |