cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm);
if (LJ_UNLIKELY(tvisnil(mo))) goto err;
return mmcall(L, cont, mo, o1, o2);
- } else if (itype(o1) == itype(o2)) { /* Never called with two numbers. */
+ } else if (LJ_52 || itype(o1) == itype(o2)) {
+ /* Never called with two numbers. */
if (tvisstr(o1) && tvisstr(o2)) {
int32_t res = lj_str_cmp(strV(o1), strV(o2));
return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1));
ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt;
MMS mm = (op & 2) ? MM_le : MM_lt;
cTValue *mo = lj_meta_lookup(L, o1, mm);
+#if LJ_52
+ if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm))))
+#else
cTValue *mo2 = lj_meta_lookup(L, o2, mm);
- if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) {
+ if (tvisnil(mo) || !lj_obj_equal(mo, mo2))
+#endif
+ {
if (op & 2) { /* MM_le not found: retry with MM_lt. */
cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */
op ^= 3; /* Use LT and flip condition. */
copyTV(J->L, &ix->tabv, &ix->valv);
while (1) {
MMS mm = (op & 2) ? MM_le : MM_lt; /* Try __le + __lt or only __lt. */
+#if LJ_52
+ if (!lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */
+ ix->tab = ix->key;
+ copyTV(J->L, &ix->tabv, &ix->keyv);
+ if (!lj_record_mm_lookup(J, ix, mm)) /* Lookup mm on 2nd operand. */
+ goto nomatch;
+ }
+ rec_mm_callcomp(J, ix, op);
+ return;
+#else
if (lj_record_mm_lookup(J, ix, mm)) { /* Lookup mm on 1st operand. */
cTValue *bv;
TRef mo1 = ix->mobj;
rec_mm_callcomp(J, ix, op);
return;
}
+#endif
nomatch:
- /* First lookup failed. Retry with __lt and swapped operands. */
+ /* Lookup failed. Retry with __lt and swapped operands. */
if (!(op & 2)) break; /* Already at __lt. Interpreter will throw. */
ix->tab = ix->key; ix->key = ix->val; ix->val = ix->tab;
copyTV(J->L, &ix->tabv, &ix->keyv);
ta = IRT_NUM;
} else if (ta == IRT_NUM && tc == IRT_INT) {
rc = emitir(IRTN(IR_CONV), rc, IRCONV_NUM_INT);
+ } else if (LJ_52) {
+ ta = IRT_NIL; /* Force metamethod for different types. */
} else if (!((ta == IRT_FALSE || ta == IRT_TRUE) &&
(tc == IRT_FALSE || tc == IRT_TRUE))) {
break; /* Interpreter will throw for two different types. */