LJ_GC64: Introduce IRT_PGC.
Contributed by Peter Cawley.
This commit is contained in:
@@ -643,8 +643,8 @@ static TRef rec_call_specialize(jit_State *J, GCfunc *fn, TRef tr)
|
||||
GCproto *pt = funcproto(fn);
|
||||
/* Too many closures created? Probably not a monomorphic function. */
|
||||
if (pt->flags >= PROTO_CLC_POLY) { /* Specialize to prototype instead. */
|
||||
TRef trpt = emitir(IRT(IR_FLOAD, IRT_P32), tr, IRFL_FUNC_PC);
|
||||
emitir(IRTG(IR_EQ, IRT_P32), trpt, lj_ir_kptr(J, proto_bc(pt)));
|
||||
TRef trpt = emitir(IRT(IR_FLOAD, IRT_PGC), tr, IRFL_FUNC_PC);
|
||||
emitir(IRTG(IR_EQ, IRT_PGC), trpt, lj_ir_kptr(J, proto_bc(pt)));
|
||||
(void)lj_ir_kgc(J, obj2gco(pt), IRT_PROTO); /* Prevent GC of proto. */
|
||||
return tr;
|
||||
}
|
||||
@@ -905,7 +905,7 @@ int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm)
|
||||
cTValue *mo;
|
||||
if (LJ_HASFFI && udtype == UDTYPE_FFI_CLIB) {
|
||||
/* Specialize to the C library namespace object. */
|
||||
emitir(IRTG(IR_EQ, IRT_P32), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
|
||||
emitir(IRTG(IR_EQ, IRT_PGC), ix->tab, lj_ir_kptr(J, udataV(&ix->tabv)));
|
||||
} else {
|
||||
/* Specialize to the type of userdata. */
|
||||
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,
|
||||
if ((MSize)k < t->asize) { /* Currently an array key? */
|
||||
TRef arrayref;
|
||||
rec_idx_abc(J, asizeref, ikey, t->asize);
|
||||
arrayref = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_ARRAY);
|
||||
return emitir(IRT(IR_AREF, IRT_P32), arrayref, ikey);
|
||||
arrayref = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_ARRAY);
|
||||
return emitir(IRT(IR_AREF, IRT_PGC), arrayref, ikey);
|
||||
} else { /* Currently not in array (may be an array extension)? */
|
||||
emitir(IRTGI(IR_ULE), asizeref, ikey); /* Inv. bounds check. */
|
||||
if (k == 0 && tref_isk(key))
|
||||
@@ -1293,13 +1293,13 @@ static TRef rec_idx_key(jit_State *J, RecordIndex *ix, IRRef *rbref,
|
||||
*rbguard = J->guardemit;
|
||||
hm = emitir(IRTI(IR_FLOAD), ix->tab, IRFL_TAB_HMASK);
|
||||
emitir(IRTGI(IR_EQ), hm, lj_ir_kint(J, (int32_t)t->hmask));
|
||||
node = emitir(IRT(IR_FLOAD, IRT_P32), ix->tab, IRFL_TAB_NODE);
|
||||
node = emitir(IRT(IR_FLOAD, IRT_PGC), ix->tab, IRFL_TAB_NODE);
|
||||
kslot = lj_ir_kslot(J, key, hslot / sizeof(Node));
|
||||
return emitir(IRTG(IR_HREFK, IRT_P32), node, kslot);
|
||||
return emitir(IRTG(IR_HREFK, IRT_PGC), node, kslot);
|
||||
}
|
||||
}
|
||||
/* Fall back to a regular hash lookup. */
|
||||
return emitir(IRT(IR_HREF, IRT_P32), ix->tab, key);
|
||||
return emitir(IRT(IR_HREF, IRT_PGC), ix->tab, key);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
IRType t = itype2irt(oldv);
|
||||
TRef res;
|
||||
if (oldv == niltvg(J2G(J))) {
|
||||
emitir(IRTG(IR_EQ, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||
emitir(IRTG(IR_EQ, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||
res = TREF_NIL;
|
||||
} else {
|
||||
res = emitir(IRTG(loadop, t), xref, 0);
|
||||
@@ -1412,7 +1412,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
||||
if (hasmm)
|
||||
emitir(IRTG(loadop, IRT_NIL), xref, 0); /* Guard for nil value. */
|
||||
else if (xrefop == IR_HREF)
|
||||
emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_P32),
|
||||
emitir(IRTG(oldv == niltvg(J2G(J)) ? IR_EQ : IR_NE, IRT_PGC),
|
||||
xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||
if (ix->idxchain && lj_record_mm_lookup(J, ix, MM_newindex)) {
|
||||
lua_assert(hasmm);
|
||||
@@ -1423,7 +1423,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
||||
TRef key = ix->key;
|
||||
if (tref_isinteger(key)) /* NEWREF needs a TValue as a key. */
|
||||
key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
|
||||
xref = emitir(IRT(IR_NEWREF, IRT_P32), ix->tab, key);
|
||||
xref = emitir(IRT(IR_NEWREF, IRT_PGC), ix->tab, key);
|
||||
keybarrier = 0; /* NEWREF already takes care of the key barrier. */
|
||||
#ifdef LUAJIT_ENABLE_TABLE_BUMP
|
||||
if ((J->flags & JIT_F_OPT_SINK)) /* Avoid a separate flag. */
|
||||
@@ -1433,7 +1433,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
||||
} else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
|
||||
/* Cannot derive that the previous value was non-nil, must do checks. */
|
||||
if (xrefop == IR_HREF) /* Guard against store to niltv. */
|
||||
emitir(IRTG(IR_NE, IRT_P32), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||
emitir(IRTG(IR_NE, IRT_PGC), xref, lj_ir_kkptr(J, niltvg(J2G(J))));
|
||||
if (ix->idxchain) { /* Metamethod lookup required? */
|
||||
/* A check for NULL metatable is cheaper (hoistable) than a load. */
|
||||
if (!mt) {
|
||||
@@ -1455,7 +1455,7 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
|
||||
emitir(IRT(IR_TBAR, IRT_NIL), ix->tab, 0);
|
||||
/* Invalidate neg. metamethod cache for stores with certain string keys. */
|
||||
if (!nommstr(J, ix->key)) {
|
||||
TRef fref = emitir(IRT(IR_FREF, IRT_P32), ix->tab, IRFL_TAB_NOMM);
|
||||
TRef fref = emitir(IRT(IR_FREF, IRT_PGC), ix->tab, IRFL_TAB_NOMM);
|
||||
emitir(IRT(IR_FSTORE, IRT_U8), fref, lj_ir_kint(J, 0));
|
||||
}
|
||||
J->needsnap = 1;
|
||||
@@ -1541,15 +1541,15 @@ noconstify:
|
||||
/* Note: this effectively limits LJ_MAX_UPVAL to 127. */
|
||||
uv = (uv << 8) | (hashrot(uvp->dhash, uvp->dhash + HASH_BIAS) & 0xff);
|
||||
if (!uvp->closed) {
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_P32), fn, uv));
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFO, IRT_PGC), fn, uv));
|
||||
/* In current stack? */
|
||||
if (uvval(uvp) >= tvref(J->L->stack) &&
|
||||
uvval(uvp) < tvref(J->L->maxstack)) {
|
||||
int32_t slot = (int32_t)(uvval(uvp) - (J->L->base - J->baseslot));
|
||||
if (slot >= 0) { /* Aliases an SSA slot? */
|
||||
emitir(IRTG(IR_EQ, IRT_P32),
|
||||
emitir(IRTG(IR_EQ, IRT_PGC),
|
||||
REF_BASE,
|
||||
emitir(IRT(IR_ADD, IRT_P32), uref,
|
||||
emitir(IRT(IR_ADD, IRT_PGC), uref,
|
||||
lj_ir_kint(J, (slot - 1 - LJ_FR2) * -8)));
|
||||
slot -= (int32_t)J->baseslot; /* Note: slot number may be negative! */
|
||||
if (val == 0) {
|
||||
@@ -1561,12 +1561,12 @@ noconstify:
|
||||
}
|
||||
}
|
||||
}
|
||||
emitir(IRTG(IR_UGT, IRT_P32),
|
||||
emitir(IRT(IR_SUB, IRT_P32), uref, REF_BASE),
|
||||
emitir(IRTG(IR_UGT, IRT_PGC),
|
||||
emitir(IRT(IR_SUB, IRT_PGC), uref, REF_BASE),
|
||||
lj_ir_kint(J, (J->baseslot + J->maxslot) * 8));
|
||||
} else {
|
||||
needbarrier = 1;
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_P32), fn, uv));
|
||||
uref = tref_ref(emitir(IRTG(IR_UREFC, IRT_PGC), fn, uv));
|
||||
}
|
||||
if (val == 0) { /* Upvalue load */
|
||||
IRType t = itype2irt(uvval(uvp));
|
||||
@@ -1733,11 +1733,11 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
|
||||
else
|
||||
emitir(IRTGI(IR_EQ), fr,
|
||||
lj_ir_kint(J, (int32_t)frame_ftsz(J->L->base-1)));
|
||||
vbase = emitir(IRTI(IR_SUB), REF_BASE, fr);
|
||||
vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8));
|
||||
vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
|
||||
vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
|
||||
for (i = 0; i < nload; i++) {
|
||||
IRType t = itype2irt(&J->L->base[i-1-nvararg]);
|
||||
TRef aref = emitir(IRT(IR_AREF, IRT_P32),
|
||||
TRef aref = emitir(IRT(IR_AREF, IRT_PGC),
|
||||
vbase, lj_ir_kint(J, (int32_t)i));
|
||||
TRef tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
||||
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)
|
||||
}
|
||||
if (idx != 0 && idx <= nvararg) {
|
||||
IRType t;
|
||||
TRef aref, vbase = emitir(IRTI(IR_SUB), REF_BASE, fr);
|
||||
vbase = emitir(IRT(IR_ADD, IRT_P32), vbase, lj_ir_kint(J, frofs-8));
|
||||
TRef aref, vbase = emitir(IRT(IR_SUB, IRT_IGC), REF_BASE, fr);
|
||||
vbase = emitir(IRT(IR_ADD, IRT_PGC), vbase, lj_ir_kint(J, frofs-8));
|
||||
t = itype2irt(&J->L->base[idx-2-nvararg]);
|
||||
aref = emitir(IRT(IR_AREF, IRT_P32), vbase, tridx);
|
||||
aref = emitir(IRT(IR_AREF, IRT_PGC), vbase, tridx);
|
||||
tr = emitir(IRTG(IR_VLOAD, t), aref, 0);
|
||||
if (irtype_ispri(t)) tr = TREF_PRI(t); /* Canonicalize primitives. */
|
||||
}
|
||||
@@ -1840,10 +1840,10 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot)
|
||||
break;
|
||||
}
|
||||
xbase = ++trp;
|
||||
tr = hdr = emitir(IRT(IR_BUFHDR, IRT_P32),
|
||||
tr = hdr = emitir(IRT(IR_BUFHDR, IRT_PGC),
|
||||
lj_ir_kptr(J, &J2G(J)->tmpbuf), IRBUFHDR_RESET);
|
||||
do {
|
||||
tr = emitir(IRT(IR_BUFPUT, IRT_P32), tr, *trp++);
|
||||
tr = emitir(IRT(IR_BUFPUT, IRT_PGC), tr, *trp++);
|
||||
} while (trp <= top);
|
||||
tr = emitir(IRT(IR_BUFSTR, IRT_STR), tr, hdr);
|
||||
J->maxslot = (BCReg)(xbase - J->base);
|
||||
@@ -2481,7 +2481,7 @@ void lj_record_setup(jit_State *J)
|
||||
J->bc_extent = ~(MSize)0;
|
||||
|
||||
/* Emit instructions for fixed references. Also triggers initial IR alloc. */
|
||||
emitir_raw(IRT(IR_BASE, IRT_P32), J->parent, J->exitno);
|
||||
emitir_raw(IRT(IR_BASE, IRT_PGC), J->parent, J->exitno);
|
||||
for (i = 0; i <= 2; i++) {
|
||||
IRIns *ir = IR(REF_NIL-i);
|
||||
ir->i = 0;
|
||||
|
||||
Reference in New Issue
Block a user