summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2014-05-06 14:31:31 +0200
committerMike Pall <mike>2014-05-06 14:31:31 +0200
commitef82bb014a639142a95b077188c5b18b9cd377e5 (patch)
treeecc4c70e271a22263487cd9b3db476135d0c1540 /src
parent7a39be0ac45d8cd19c13bab38d4dda31ea599760 (diff)
downloadluajit-ef82bb014a639142a95b077188c5b18b9cd377e5.tar.gz
luajit-ef82bb014a639142a95b077188c5b18b9cd377e5.tar.bz2
luajit-ef82bb014a639142a95b077188c5b18b9cd377e5.zip
FFI: Another fix for cdata equality comparisons.
Diffstat (limited to 'src')
-rw-r--r--src/lj_crecord.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c
index 8612f005..69b21f88 100644
--- a/src/lj_crecord.c
+++ b/src/lj_crecord.c
@@ -1317,7 +1317,7 @@ static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm)
1317} 1317}
1318 1318
1319/* Record ctype arithmetic metamethods. */ 1319/* Record ctype arithmetic metamethods. */
1320static TRef crec_arith_meta(jit_State *J, TRef *sp, CTState *cts, 1320static TRef crec_arith_meta(jit_State *J, TRef *sp, CType **s, CTState *cts,
1321 RecordFFData *rd) 1321 RecordFFData *rd)
1322{ 1322{
1323 cTValue *tv = NULL; 1323 cTValue *tv = NULL;
@@ -1342,7 +1342,7 @@ static TRef crec_arith_meta(jit_State *J, TRef *sp, CTState *cts,
1342 return 0; 1342 return 0;
1343 } /* NYI: non-function metamethods. */ 1343 } /* NYI: non-function metamethods. */
1344 } else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */ 1344 } else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */
1345 if (sp[0] && sp[1]) { 1345 if (sp[0] && sp[1] && ctype_isnum(s[0]->info) == ctype_isnum(s[1]->info)) {
1346 /* Assume true comparison. Fixup and emit pending guard later. */ 1346 /* Assume true comparison. Fixup and emit pending guard later. */
1347 lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]); 1347 lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]);
1348 J->postproc = LJ_POST_FIXGUARD; 1348 J->postproc = LJ_POST_FIXGUARD;
@@ -1420,9 +1420,13 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
1420 emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str)); 1420 emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str));
1421 ct = ctype_child(cts, cct); 1421 ct = ctype_child(cts, cct);
1422 tr = lj_ir_kint(J, (int32_t)ofs); 1422 tr = lj_ir_kint(J, (int32_t)ofs);
1423 } /* else: interpreter will throw. */ 1423 } else { /* Interpreter will throw or return false. */
1424 } else { 1424 ct = ctype_get(cts, CTID_P_VOID);
1425 }
1426 } else if (ctype_isptr(ct->info)) {
1425 tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr))); 1427 tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr)));
1428 } else {
1429 ct = ctype_get(cts, CTID_P_VOID);
1426 } 1430 }
1427 } else if (!tref_isnum(tr)) { 1431 } else if (!tref_isnum(tr)) {
1428 tr = 0; 1432 tr = 0;
@@ -1435,7 +1439,7 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
1435 TRef tr; 1439 TRef tr;
1436 if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) && 1440 if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) &&
1437 !(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) && 1441 !(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) &&
1438 !(tr = crec_arith_meta(J, sp, cts, rd))) 1442 !(tr = crec_arith_meta(J, sp, s, cts, rd)))
1439 return; 1443 return;
1440 J->base[0] = tr; 1444 J->base[0] = tr;
1441 /* Fixup cdata comparisons, too. Avoids some cdata escapes. */ 1445 /* Fixup cdata comparisons, too. Avoids some cdata escapes. */