Fix recording of getmetatable() for non-tables.

This commit is contained in:
Mike Pall 2010-03-09 17:49:13 +01:00
parent 6e6034e809
commit f49649d005

View File

@ -660,9 +660,11 @@ static int rec_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
} 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));
if (mt == NULL) if (mt == NULL) {
ix->mt = TREF_NIL;
return 0; /* No metamethod. */ return 0; /* No metamethod. */
mix.tab = lj_ir_ktab(J, mt); }
ix->mt = mix.tab = lj_ir_ktab(J, mt);
goto nocheck; goto nocheck;
} }
ix->mt = mt ? mix.tab : TREF_NIL; ix->mt = mt ? mix.tab : TREF_NIL;
@ -1160,7 +1162,7 @@ static void LJ_FASTCALL recff_type(jit_State *J, RecordFFData *rd)
static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd) static void LJ_FASTCALL recff_getmetatable(jit_State *J, RecordFFData *rd)
{ {
TRef tr = J->base[0]; TRef tr = J->base[0];
if (tref_istab(tr)) { if (tr) {
RecordIndex ix; RecordIndex ix;
ix.tab = tr; ix.tab = tr;
copyTV(J->L, &ix.tabv, &rd->argv[0]); copyTV(J->L, &ix.tabv, &rd->argv[0]);