summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 3e5d3c89..2d92987e 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -812,6 +812,23 @@ static void rec_mm_comp(jit_State *J, RecordIndex *ix, int op)
812 } 812 }
813} 813}
814 814
815#if LJ_HASFFI
816/* Setup call to cdata comparison metamethod. */
817static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm)
818{
819 if (tref_iscdata(ix->val)) {
820 ix->tab = ix->val;
821 copyTV(J->L, &ix->tabv, &ix->valv);
822 } else {
823 lua_assert(tref_iscdata(ix->key));
824 ix->tab = ix->key;
825 copyTV(J->L, &ix->tabv, &ix->keyv);
826 }
827 lj_record_mm_lookup(J, ix, mm);
828 rec_mm_callcomp(J, ix, op);
829}
830#endif
831
815/* -- Indexed access ------------------------------------------------------ */ 832/* -- Indexed access ------------------------------------------------------ */
816 833
817/* Record bounds-check. */ 834/* Record bounds-check. */
@@ -1410,6 +1427,12 @@ void lj_record_ins(jit_State *J)
1410 /* -- Comparison ops ---------------------------------------------------- */ 1427 /* -- Comparison ops ---------------------------------------------------- */
1411 1428
1412 case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT: 1429 case BC_ISLT: case BC_ISGE: case BC_ISLE: case BC_ISGT:
1430#if LJ_HASFFI
1431 if (tref_iscdata(ra) || tref_iscdata(rc)) {
1432 rec_mm_comp_cdata(J, &ix, op, ((int)op & 2) ? MM_le : MM_lt);
1433 break;
1434 }
1435#endif
1413 /* Emit nothing for two numeric or string consts. */ 1436 /* Emit nothing for two numeric or string consts. */
1414 if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) { 1437 if (!(tref_isk2(ra,rc) && tref_isnumber_str(ra) && tref_isnumber_str(rc))) {
1415 IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra); 1438 IRType ta = tref_isinteger(ra) ? IRT_INT : tref_type(ra);
@@ -1452,6 +1475,12 @@ void lj_record_ins(jit_State *J)
1452 case BC_ISEQS: case BC_ISNES: 1475 case BC_ISEQS: case BC_ISNES:
1453 case BC_ISEQN: case BC_ISNEN: 1476 case BC_ISEQN: case BC_ISNEN:
1454 case BC_ISEQP: case BC_ISNEP: 1477 case BC_ISEQP: case BC_ISNEP:
1478#if LJ_HASFFI
1479 if (tref_iscdata(ra) || tref_iscdata(rc)) {
1480 rec_mm_comp_cdata(J, &ix, op, MM_eq);
1481 break;
1482 }
1483#endif
1455 /* Emit nothing for two non-table, non-udata consts. */ 1484 /* Emit nothing for two non-table, non-udata consts. */
1456 if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) { 1485 if (!(tref_isk2(ra, rc) && !(tref_istab(ra) || tref_isudata(ra)))) {
1457 int diff; 1486 int diff;