mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
Compile debug.getmetatable().
Thanks to Karel Tuma.
This commit is contained in:
parent
ccd456af73
commit
1cb5929c5c
@ -29,7 +29,7 @@ LJLIB_CF(debug_getregistry)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LJLIB_CF(debug_getmetatable)
|
LJLIB_CF(debug_getmetatable) LJLIB_REC(.)
|
||||||
{
|
{
|
||||||
lj_lib_checkany(L, 1);
|
lj_lib_checkany(L, 1);
|
||||||
if (!lua_getmetatable(L, 1)) {
|
if (!lua_getmetatable(L, 1)) {
|
||||||
|
@ -1157,6 +1157,28 @@ static void LJ_FASTCALL recff_io_flush(jit_State *J, RecordFFData *rd)
|
|||||||
J->base[0] = TREF_TRUE;
|
J->base[0] = TREF_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -- Debug library fast functions ---------------------------------------- */
|
||||||
|
|
||||||
|
static void LJ_FASTCALL recff_debug_getmetatable(jit_State *J, RecordFFData *rd)
|
||||||
|
{
|
||||||
|
GCtab *mt;
|
||||||
|
TRef mtref;
|
||||||
|
TRef tr = J->base[0];
|
||||||
|
if (tref_istab(tr)) {
|
||||||
|
mt = tabref(tabV(&rd->argv[0])->metatable);
|
||||||
|
mtref = emitir(IRT(IR_FLOAD, IRT_TAB), tr, IRFL_TAB_META);
|
||||||
|
} else if (tref_isudata(tr)) {
|
||||||
|
mt = tabref(udataV(&rd->argv[0])->metatable);
|
||||||
|
mtref = emitir(IRT(IR_FLOAD, IRT_TAB), tr, IRFL_UDATA_META);
|
||||||
|
} else {
|
||||||
|
mt = tabref(basemt_obj(J2G(J), &rd->argv[0]));
|
||||||
|
J->base[0] = mt ? lj_ir_ktab(J, mt) : TREF_NIL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emitir(IRTG(mt ? IR_NE : IR_EQ, IRT_TAB), mtref, lj_ir_knull(J, IRT_TAB));
|
||||||
|
J->base[0] = mt ? mtref : TREF_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
/* -- Record calls to fast functions -------------------------------------- */
|
/* -- Record calls to fast functions -------------------------------------- */
|
||||||
|
|
||||||
#include "lj_recdef.h"
|
#include "lj_recdef.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user