mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
FFI: Treat cdata metatable+methods as immutable in trace recorder.
This commit is contained in:
parent
d4d95ee2da
commit
2a917a9d83
@ -667,6 +667,19 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
||||
ix->mt = TREF_NIL;
|
||||
return 0; /* No metamethod. */
|
||||
}
|
||||
#if LJ_HASFFI
|
||||
/* The cdata metatable is treated as immutable. */
|
||||
if (tref_iscdata(ix->tab)) {
|
||||
cTValue *mo = lj_tab_getstr(mt, mmname_str(J2G(J), mm));
|
||||
if (!mo || tvisnil(mo))
|
||||
return 0; /* No metamethod. */
|
||||
setfuncV(J->L, &ix->mobjv, funcV(mo));
|
||||
ix->mobj = lj_ir_kfunc(J, funcV(mo)); /* Immutable metamethod. */
|
||||
ix->mtv = mt;
|
||||
ix->mt = TREF_NIL; /* Dummy value for comparison semantics. */
|
||||
return 1; /* Got cdata metamethod. */
|
||||
}
|
||||
#endif
|
||||
ix->mt = mix.tab = lj_ir_ktab(J, mt);
|
||||
goto nocheck;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user