diff options
author | Mike Pall <mike> | 2014-06-18 12:36:50 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2014-06-18 12:36:50 +0200 |
commit | 1cb5929c5c0ec3a146410cc4b8edc15040da55ca (patch) | |
tree | a77b792fa4c88abcdad1804acf606f800e51f2b4 /src | |
parent | ccd456af73c7fa98ca0e6fd0fd11c381689f59e7 (diff) | |
download | luajit-1cb5929c5c0ec3a146410cc4b8edc15040da55ca.tar.gz luajit-1cb5929c5c0ec3a146410cc4b8edc15040da55ca.tar.bz2 luajit-1cb5929c5c0ec3a146410cc4b8edc15040da55ca.zip |
Compile debug.getmetatable().
Thanks to Karel Tuma.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib_debug.c | 2 | ||||
-rw-r--r-- | src/lj_ffrecord.c | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/lib_debug.c b/src/lib_debug.c index 97f032f1..9c1a2828 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c | |||
@@ -29,7 +29,7 @@ LJLIB_CF(debug_getregistry) | |||
29 | return 1; | 29 | return 1; |
30 | } | 30 | } |
31 | 31 | ||
32 | LJLIB_CF(debug_getmetatable) | 32 | LJLIB_CF(debug_getmetatable) LJLIB_REC(.) |
33 | { | 33 | { |
34 | lj_lib_checkany(L, 1); | 34 | lj_lib_checkany(L, 1); |
35 | if (!lua_getmetatable(L, 1)) { | 35 | if (!lua_getmetatable(L, 1)) { |
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 8470dd8c..1fff4f48 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c | |||
@@ -1157,6 +1157,28 @@ static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd) | |||
1157 | J->base[0] = TREF_TRUE; | 1157 | J->base[0] = TREF_TRUE; |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | /* -- Debug library fast functions ---------------------------------------- */ | ||
1161 | |||
1162 | static void LJ_FASTCALL recff_debug_getmetatable(jit_State *J, RecordFFData *rd) | ||
1163 | { | ||
1164 | GCtab *mt; | ||
1165 | TRef mtref; | ||
1166 | TRef tr = J->base[0]; | ||
1167 | if (tref_istab(tr)) { | ||
1168 | mt = tabref(tabV(&rd->argv[0])->metatable); | ||
1169 | mtref = emitir(IRT(IR_FLOAD, IRT_TAB), tr, IRFL_TAB_META); | ||
1170 | } else if (tref_isudata(tr)) { | ||
1171 | mt = tabref(udataV(&rd->argv[0])->metatable); | ||
1172 | mtref = emitir(IRT(IR_FLOAD, IRT_TAB), tr, IRFL_UDATA_META); | ||
1173 | } else { | ||
1174 | mt = tabref(basemt_obj(J2G(J), &rd->argv[0])); | ||
1175 | J->base[0] = mt ? lj_ir_ktab(J, mt) : TREF_NIL; | ||
1176 | return; | ||
1177 | } | ||
1178 | emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB)); | ||
1179 | J->base[0] = mt ? mtref : TREF_NIL; | ||
1180 | } | ||
1181 | |||
1160 | /* -- Record calls to fast functions -------------------------------------- */ | 1182 | /* -- Record calls to fast functions -------------------------------------- */ |
1161 | 1183 | ||
1162 | #include "lj_recdef.h" | 1184 | #include "lj_recdef.h" |