mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Fix compiliation of getmetatable() for UDTYPE_IO_FILE.
Reported by Sergey Bronnikov. #1279
This commit is contained in:
parent
c63a160706
commit
5141cbc20c
@ -821,6 +821,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
|||||||
} else if (tref_isudata(ix->tab)) {
|
} else if (tref_isudata(ix->tab)) {
|
||||||
int udtype = udataV(&ix->tabv)->udtype;
|
int udtype = udataV(&ix->tabv)->udtype;
|
||||||
mt = tabref(udataV(&ix->tabv)->metatable);
|
mt = tabref(udataV(&ix->tabv)->metatable);
|
||||||
|
mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META);
|
||||||
/* The metatables of special userdata objects are treated as immutable. */
|
/* The metatables of special userdata objects are treated as immutable. */
|
||||||
if (udtype != UDTYPE_USERDATA) {
|
if (udtype != UDTYPE_USERDATA) {
|
||||||
cTValue *mo;
|
cTValue *mo;
|
||||||
@ -834,6 +835,8 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
|||||||
}
|
}
|
||||||
immutable_mt:
|
immutable_mt:
|
||||||
mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm));
|
mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm));
|
||||||
|
ix->mt = mix.tab;
|
||||||
|
ix->mtv = mt;
|
||||||
if (!mo || tvisnil(mo))
|
if (!mo || tvisnil(mo))
|
||||||
return 0; /* No metamethod. */
|
return 0; /* No metamethod. */
|
||||||
/* Treat metamethod or index table as immutable, too. */
|
/* Treat metamethod or index table as immutable, too. */
|
||||||
@ -841,11 +844,8 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
|||||||
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
lj_trace_err(J, LJ_TRERR_BADTYPE);
|
||||||
copyTV(J->L, &ix->mobjv, mo);
|
copyTV(J->L, &ix->mobjv, mo);
|
||||||
ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB);
|
ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB);
|
||||||
ix->mtv = mt;
|
|
||||||
ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */
|
|
||||||
return 1; /* Got metamethod or index table. */
|
return 1; /* Got metamethod or index table. */
|
||||||
}
|
}
|
||||||
mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META);
|
|
||||||
} else {
|
} else {
|
||||||
/* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */
|
/* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */
|
||||||
mt = tabref(basemt_obj(J2G(J), &ix->tabv));
|
mt = tabref(basemt_obj(J2G(J), &ix->tabv));
|
||||||
|
Loading…
Reference in New Issue
Block a user