diff options
author | Mike Pall <mike> | 2024-09-29 16:03:37 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2024-09-29 16:03:37 +0200 |
commit | 5141cbc20c43921778ff36be541c15888bee8ee3 (patch) | |
tree | 76e60a8f1dee3b2efdf5ea5d2ef70491aa45b5c1 /src | |
parent | c63a1607068a7698c8d26bde84a0f3ca0a5cfd03 (diff) | |
download | luajit-5141cbc20c43921778ff36be541c15888bee8ee3.tar.gz luajit-5141cbc20c43921778ff36be541c15888bee8ee3.tar.bz2 luajit-5141cbc20c43921778ff36be541c15888bee8ee3.zip |
Fix compiliation of getmetatable() for UDTYPE_IO_FILE.
Reported by Sergey Bronnikov. #1279
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_record.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index 207327b3..af12e256 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -821,6 +821,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) | |||
821 | } else if (tref_isudata(ix->tab)) { | 821 | } else if (tref_isudata(ix->tab)) { |
822 | int udtype = udataV(&ix->tabv)->udtype; | 822 | int udtype = udataV(&ix->tabv)->udtype; |
823 | mt = tabref(udataV(&ix->tabv)->metatable); | 823 | mt = tabref(udataV(&ix->tabv)->metatable); |
824 | mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); | ||
824 | /* The metatables of special userdata objects are treated as immutable. */ | 825 | /* The metatables of special userdata objects are treated as immutable. */ |
825 | if (udtype != UDTYPE_USERDATA) { | 826 | if (udtype != UDTYPE_USERDATA) { |
826 | cTValue *mo; | 827 | cTValue *mo; |
@@ -834,6 +835,8 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) | |||
834 | } | 835 | } |
835 | immutable_mt: | 836 | immutable_mt: |
836 | mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); | 837 | mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm)); |
838 | ix->mt = mix.tab; | ||
839 | ix->mtv = mt; | ||
837 | if (!mo || tvisnil(mo)) | 840 | if (!mo || tvisnil(mo)) |
838 | return 0; /* No metamethod. */ | 841 | return 0; /* No metamethod. */ |
839 | /* Treat metamethod or index table as immutable, too. */ | 842 | /* Treat metamethod or index table as immutable, too. */ |
@@ -841,11 +844,8 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm) | |||
841 | lj_trace_err(J, LJ_TRERR_BADTYPE); | 844 | lj_trace_err(J, LJ_TRERR_BADTYPE); |
842 | copyTV(J->L, &ix->mobjv, mo); | 845 | copyTV(J->L, &ix->mobjv, mo); |
843 | ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); | 846 | ix->mobj = lj_ir_kgc(J, gcV(mo), tvisfunc(mo) ? IRT_FUNC : IRT_TAB); |
844 | ix->mtv = mt; | ||
845 | ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */ | ||
846 | return 1; /* Got metamethod or index table. */ | 847 | return 1; /* Got metamethod or index table. */ |
847 | } | 848 | } |
848 | mix.tab = emitir(IRT(IR_FLOAD, IRT_TAB), ix->tab, IRFL_UDATA_META); | ||
849 | } else { | 849 | } else { |
850 | /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ | 850 | /* Specialize to base metatable. Must flush mcode in lua_setmetatable(). */ |
851 | mt = tabref(basemt_obj(J2G(J), &ix->tabv)); | 851 | mt = tabref(basemt_obj(J2G(J), &ix->tabv)); |