summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
authorMike Pall <mike>2016-05-20 22:41:42 +0200
committerMike Pall <mike>2016-05-20 22:41:42 +0200
commit1931b38da5a9ea075df73a966630308d3988bb96 (patch)
tree3b6d014f6256a78eb2fd270489b8d7dd2183e01e /src/lj_record.c
parent475a6ae33fc4b28d4c1c7a5f663ea933e0ccbdfd (diff)
downloadluajit-1931b38da5a9ea075df73a966630308d3988bb96.tar.gz
luajit-1931b38da5a9ea075df73a966630308d3988bb96.tar.bz2
luajit-1931b38da5a9ea075df73a966630308d3988bb96.zip
LJ_GC64: Introduce IRT_PGC.
Contributed by Peter Cawley.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 568b73aa..f7c53567 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -643,8 +643,8 @@ static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr)
643 GCproto *pt = funcproto(fn); 643 GCproto *pt = funcproto(fn);
644 /* Too many closures created? Probably not a monomorphic function. */ 644 /* Too many closures created? Probably not a monomorphic function. */
645 if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */ 645 if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
646 TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC); 646 TRef trpt = emitir(IRT(IR_FLOAD, IRT_PGC), tr, IRFL_FUNC_PC);
647 emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt))); 647 emitir(IRTG(IR_EQ, IRT_PGC), trpt, lj_ir_kptr(J, proto_bc(pt)));
648 (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */ 648 (void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
649 return tr; 649 return tr;
650 } 650 }
@@ -905,7 +905,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
905 cTValue *mo; 905 cTValue *mo;
906 if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) { 906 if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) {
907 /* Specialize to the C library namespace object. */ 907 /* Specialize to the C library namespace object. */
908 emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv))); 908 emitir(IRTG(IR_EQ, IRT_PGC), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
909 } else { 909 } else {
910 /* Specialize to the type of userdata. */ 910 /* Specialize to the type of userdata. */
911 TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE); 911 TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), ix->tab, IRFL_UDATA_UDTYPE);
@@ -1252,8 +1252,8 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
1252 if ((MSize)k < t->asize) { /* Currently an array key? */ 1252 if ((MSize)k < t->asize) { /* Currently an array key? */
1253 TRef arrayref; 1253 TRef arrayref;
1254 rec_idx_abc(J, asizeref, ikey, t->asize); 1254 rec_idx_abc(J, asizeref, ikey, t->asize);
1255 arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY); 1255 arrayref = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_ARRAY);
1256 return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey); 1256 return emitir(IRT(IR_AREF, IRT_PGC), arrayref, ikey);
1257 } else { /* Currently not in array (may be an array extension)? */ 1257 } else { /* Currently not in array (may be an array extension)? */
1258 emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */ 1258 emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */
1259 if (k == 0 && tref_isk(key)) 1259 if (k == 0 && tref_isk(key))
@@ -1293,13 +1293,13 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
1293 *rbguard = J->guardemit; 1293 *rbguard = J->guardemit;
1294 hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK); 1294 hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
1295 emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask)); 1295 emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
1296 node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE); 1296 node = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_NODE);
1297 kslot = lj_ir_kslot(J, key, hslot / sizeof(Node)); 1297 kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
1298 return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot); 1298 return emitir(IRTG(IR_HREFK, IRT_PGC), node, kslot);
1299 } 1299 }
1300 } 1300 }
1301 /* Fall back to a regular hash lookup. */ 1301 /* Fall back to a regular hash lookup. */
1302 return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key); 1302 return emitir(IRT(IR_HREF, IRT_PGC), ix->tab, key);
1303} 1303}
1304 1304
1305/* Determine whether a key is NOT one of the fast metamethod names. */ 1305/* Determine whether a key is NOT one of the fast metamethod names. */
@@ -1382,7 +1382,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1382 IRType t = itype2irt(oldv); 1382 IRType t = itype2irt(oldv);
1383 TRef res; 1383 TRef res;
1384 if (oldv == niltvg(J2G(J))) { 1384 if (oldv == niltvg(J2G(J))) {
1385 emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1385 emitir(IRTG(IR_EQ, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1386 res = TREF_NIL; 1386 res = TREF_NIL;
1387 } else { 1387 } else {
1388 res = emitir(IRTG(loadop, t), xref, 0); 1388 res = emitir(IRTG(loadop, t), xref, 0);
@@ -1412,7 +1412,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1412 if (hasmm) 1412 if (hasmm)
1413 emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */ 1413 emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */
1414 else if (xrefop == IR_HREF) 1414 else if (xrefop == IR_HREF)
1415 emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32), 1415 emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PGC),
1416 xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1416 xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1417 if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) { 1417 if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) {
1418 lua_assert(hasmm); 1418 lua_assert(hasmm);
@@ -1423,7 +1423,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1423 TRef key = ix->key; 1423 TRef key = ix->key;
1424 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */ 1424 if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
1425 key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT); 1425 key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
1426 xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key); 1426 xref = emitir(IRT(IR_NEWREF, IRT_PGC), ix->tab, key);
1427 keybarrier = 0; /* NEWREF already takes care of the key barrier. */ 1427 keybarrier = 0; /* NEWREF already takes care of the key barrier. */
1428#ifdef LUAJIT_ENABLE_TABLE_BUMP 1428#ifdef LUAJIT_ENABLE_TABLE_BUMP
1429 if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */ 1429 if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */
@@ -1433,7 +1433,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1433 } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) { 1433 } else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
1434 /* Cannot derive that the previous value was non-nil, must do checks. */ 1434 /* Cannot derive that the previous value was non-nil, must do checks. */
1435 if (xrefop == IR_HREF) /* Guard against store to niltv. */ 1435 if (xrefop == IR_HREF) /* Guard against store to niltv. */
1436 emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J)))); 1436 emitir(IRTG(IR_NE, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
1437 if (ix->idxchain) { /* Metamethod lookup required? */ 1437 if (ix->idxchain) { /* Metamethod lookup required? */
1438 /* A check for NULL metatable is cheaper (hoistable) than a load. */ 1438 /* A check for NULL metatable is cheaper (hoistable) than a load. */
1439 if (!mt) { 1439 if (!mt) {
@@ -1455,7 +1455,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
1455 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0); 1455 emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
1456 /* Invalidate neg. metamethod cache for stores with certain string keys. */ 1456 /* Invalidate neg. metamethod cache for stores with certain string keys. */
1457 if (!nommstr(J, ix->key)) { 1457 if (!nommstr(J, ix->key)) {
1458 TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM); 1458 TRef fref = emitir(IRT(IR_FREF, IRT_PGC), ix->tab, IRFL_TAB_NOMM);
1459 emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0)); 1459 emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0));
1460 } 1460 }
1461 J->needsnap = 1; 1461 J->needsnap = 1;
@@ -1541,15 +1541,15 @@ noconstify:
1541 /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ 1541 /* Note: this effectively limits LJ_MAX_UPVAL to 127. */
1542 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff); 1542 uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
1543 if (!uvp->closed) { 1543 if (!uvp->closed) {
1544 uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv)); 1544 uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_PGC), fn, uv));
1545 /* In current stack? */ 1545 /* In current stack? */
1546 if (uvval(uvp) >= tvref(J->L->stack) && 1546 if (uvval(uvp) >= tvref(J->L->stack) &&
1547 uvval(uvp) < tvref(J->L->maxstack)) { 1547 uvval(uvp) < tvref(J->L->maxstack)) {
1548 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot)); 1548 int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
1549 if (slot >= 0) { /* Aliases an SSA slot? */ 1549 if (slot >= 0) { /* Aliases an SSA slot? */
1550 emitir(IRTG(IR_EQ, IRT_P32), 1550 emitir(IRTG(IR_EQ, IRT_PGC),
1551 REF_BASE, 1551 REF_BASE,
1552 emitir(IRT(IR_ADD, IRT_P32), uref, 1552 emitir(IRT(IR_ADD, IRT_PGC), uref,
1553 lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8))); 1553 lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8)));
1554 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */ 1554 slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
1555 if (val == 0) { 1555 if (val == 0) {
@@ -1561,12 +1561,12 @@ noconstify:
1561 } 1561 }
1562 } 1562 }
1563 } 1563 }
1564 emitir(IRTG(IR_UGT, IRT_P32), 1564 emitir(IRTG(IR_UGT, IRT_PGC),
1565 emitir(IRT(IR_SUB, IRT_P32), uref, REF_BASE), 1565 emitir(IRT(IR_SUB, IRT_PGC), uref, REF_BASE),
1566 lj_ir_kint(J, (J->baseslot + J->maxslot) * 8)); 1566 lj_ir_kint(J, (J->baseslot + J->maxslot) * 8));
1567 } else { 1567 } else {
1568 needbarrier = 1; 1568 needbarrier = 1;
1569 uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv)); 1569 uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_PGC), fn, uv));
1570 } 1570 }
1571 if (val == 0) { /* Upvalue load */ 1571 if (val == 0) { /* Upvalue load */
1572 IRType t = itype2irt(uvval(uvp)); 1572 IRType t = itype2irt(uvval(uvp));
@@ -1733,11 +1733,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
1733 else 1733 else
1734 emitir(IRTGI(IR_EQ), fr, 1734 emitir(IRTGI(IR_EQ), fr,
1735 lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1))); 1735 lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
1736 vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); 1736 vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
1737 vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); 1737 vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
1738 for (i = 0; i < nload; i++) { 1738 for (i = 0; i < nload; i++) {
1739 IRType t = itype2irt(&J->L->base[i-1-nvararg]); 1739 IRType t = itype2irt(&J->L->base[i-1-nvararg]);
1740 TRef aref = emitir(IRT(IR_AREF, IRT_P32), 1740 TRef aref = emitir(IRT(IR_AREF, IRT_PGC),
1741 vbase, lj_ir_kint(J, (int32_t)i)); 1741 vbase, lj_ir_kint(J, (int32_t)i));
1742 TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0); 1742 TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
1743 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ 1743 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
@@ -1783,10 +1783,10 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
1783 } 1783 }
1784 if (idx != 0 && idx <= nvararg) { 1784 if (idx != 0 && idx <= nvararg) {
1785 IRType t; 1785 IRType t;
1786 TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr); 1786 TRef aref, vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
1787 vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8)); 1787 vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
1788 t = itype2irt(&J->L->base[idx-2-nvararg]); 1788 t = itype2irt(&J->L->base[idx-2-nvararg]);
1789 aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx); 1789 aref = emitir(IRT(IR_AREF, IRT_PGC), vbase, tridx);
1790 tr = emitir(IRTG(IR_VLOAD, t), aref, 0); 1790 tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
1791 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */ 1791 if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
1792 } 1792 }
@@ -1840,10 +1840,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot)
1840 break; 1840 break;
1841 } 1841 }
1842 xbase = ++trp; 1842 xbase = ++trp;
1843 tr = hdr = emitir(IRT(IR_BUFHDR, IRT_P32), 1843 tr = hdr = emitir(IRT(IR_BUFHDR, IRT_PGC),
1844 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET); 1844 lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
1845 do { 1845 do {
1846 tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, *trp++); 1846 tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, *trp++);
1847 } while (trp <= top); 1847 } while (trp <= top);
1848 tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr); 1848 tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
1849 J->maxslot = (BCReg)(xbase - J->base); 1849 J->maxslot = (BCReg)(xbase - J->base);
@@ -2481,7 +2481,7 @@ void lj_record_setup(jit_State *J)
2481 J->bc_extent = ~(MSize)0; 2481 J->bc_extent = ~(MSize)0;
2482 2482
2483 /* Emit instructions for fixed references. Also triggers initial IR alloc. */ 2483 /* Emit instructions for fixed references. Also triggers initial IR alloc. */
2484 emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno); 2484 emitir_raw(IRT(IR_BASE, IRT_PGC), J->parent, J->exitno);
2485 for (i = 0; i <= 2; i++) { 2485 for (i = 0; i <= 2; i++) {
2486 IRIns *ir = IR(REF_NIL-i); 2486 IRIns *ir = IR(REF_NIL-i);
2487 ir->i = 0; 2487 ir->i = 0;