aboutsummaryrefslogtreecommitdiff
path: root/src/lj_meta.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_meta.c')
-rw-r--r--src/lj_meta.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lj_meta.c b/src/lj_meta.c
index de2b4068..ab5d1b54 100644
--- a/src/lj_meta.c
+++ b/src/lj_meta.c
@@ -386,7 +386,8 @@ TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op)
386 cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm); 386 cTValue *mo = lj_meta_lookup(L, tviscdata(o1) ? o1 : o2, mm);
387 if (LJ_UNLIKELY(tvisnil(mo))) goto err; 387 if (LJ_UNLIKELY(tvisnil(mo))) goto err;
388 return mmcall(L, cont, mo, o1, o2); 388 return mmcall(L, cont, mo, o1, o2);
389 } else if (itype(o1) == itype(o2)) { /* Never called with two numbers. */ 389 } else if (LJ_52 || itype(o1) == itype(o2)) {
390 /* Never called with two numbers. */
390 if (tvisstr(o1) && tvisstr(o2)) { 391 if (tvisstr(o1) && tvisstr(o2)) {
391 int32_t res = lj_str_cmp(strV(o1), strV(o2)); 392 int32_t res = lj_str_cmp(strV(o1), strV(o2));
392 return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1)); 393 return (TValue *)(intptr_t)(((op&2) ? res <= 0 : res < 0) ^ (op&1));
@@ -396,8 +397,13 @@ TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op)
396 ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt; 397 ASMFunction cont = (op & 1) ? lj_cont_condf : lj_cont_condt;
397 MMS mm = (op & 2) ? MM_le : MM_lt; 398 MMS mm = (op & 2) ? MM_le : MM_lt;
398 cTValue *mo = lj_meta_lookup(L, o1, mm); 399 cTValue *mo = lj_meta_lookup(L, o1, mm);
400#if LJ_52
401 if (tvisnil(mo) && tvisnil((mo = lj_meta_lookup(L, o2, mm))))
402#else
399 cTValue *mo2 = lj_meta_lookup(L, o2, mm); 403 cTValue *mo2 = lj_meta_lookup(L, o2, mm);
400 if (tvisnil(mo) || !lj_obj_equal(mo, mo2)) { 404 if (tvisnil(mo) || !lj_obj_equal(mo, mo2))
405#endif
406 {
401 if (op & 2) { /* MM_le not found: retry with MM_lt. */ 407 if (op & 2) { /* MM_le not found: retry with MM_lt. */
402 cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */ 408 cTValue *ot = o1; o1 = o2; o2 = ot; /* Swap operands. */
403 op ^= 3; /* Use LT and flip condition. */ 409 op ^= 3; /* Use LT and flip condition. */