Skip to content

Commit

Permalink
Disable table allocation bump optimization (for now).
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Pall committed Jun 12, 2015
1 parent 26b95a9 commit fe56522
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lj_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ typedef struct jit_State {
uint32_t penaltyslot; /* Round-robin index into penalty slots. */
uint32_t prngstate; /* PRNG state. */

#ifdef LUAJIT_ENABLE_TABLE_BUMP
RBCHashEntry rbchash[RBCHASH_SLOTS]; /* Reverse bytecode map. */
#endif

BPropEntry bpropcache[BPROP_SLOTS]; /* Backpropagation cache slots. */
uint32_t bpropslot; /* Round-robin index into bpropcache slots. */
Expand Down
14 changes: 14 additions & 0 deletions src/lj_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ static void canonicalize_slots(jit_State *J)
/* Stop recording. */
void lj_record_stop(jit_State *J, TraceLink linktype, TraceNo lnk)
{
#ifdef LUAJIT_ENABLE_TABLE_BUMP
if (J->retryrec)
lj_trace_err(J, LJ_TRERR_RETRY);
#endif
lj_trace_end(J);
J->cur.linktype = (uint8_t)linktype;
J->cur.link = (uint16_t)lnk;
Expand Down Expand Up @@ -1129,6 +1131,7 @@ static void rec_mm_comp_cdata(jit_State *J, RecordIndex *ix, int op, MMS mm)

/* -- Indexed access ------------------------------------------------------ */

#ifdef LUAJIT_ENABLE_TABLE_BUMP
/* Bump table allocations in bytecode when they grow during recording. */
static void rec_idx_bump(jit_State *J, RecordIndex *ix)
{
Expand Down Expand Up @@ -1192,6 +1195,7 @@ static void rec_idx_bump(jit_State *J, RecordIndex *ix)
}
}
}
#endif

/* Record bounds-check. */
static void rec_idx_abc(jit_State *J, TRef asizeref, TRef ikey, uint32_t asize)
Expand Down Expand Up @@ -1418,8 +1422,10 @@ TRef lj_record_idx(jit_State *J, RecordIndex *ix)
key = emitir(IRTN(IR_CONV), key, IRCONV_NUM_INT);
xref = emitir(IRT(IR_NEWREF, IRT_P32), 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. */
rec_idx_bump(J, ix);
#endif
}
} else if (!lj_opt_fwd_wasnonnil(J, loadop, tref_ref(xref))) {
/* Cannot derive that the previous value was non-nil, must do checks. */
Expand Down Expand Up @@ -1462,12 +1468,14 @@ static void rec_tsetm(jit_State *J, BCReg ra, BCReg rn, int32_t i)
settabV(J->L, &ix.tabv, t);
ix.tab = getslot(J, ra-1);
ix.idxchain = 0;
#ifdef LUAJIT_ENABLE_TABLE_BUMP
if ((J->flags & JIT_F_OPT_SINK)) {
if (t->asize < i+rn-ra)
lj_tab_reasize(J->L, t, i+rn-ra);
setnilV(&ix.keyv);
rec_idx_bump(J, &ix);
}
#endif
for (; ra < rn; i++, ra++) {
setintV(&ix.keyv, i);
ix.key = lj_ir_kint(J, i);
Expand Down Expand Up @@ -1790,9 +1798,11 @@ static TRef rec_tnew(jit_State *J, uint32_t ah)
TRef tr;
if (asize == 0x7ff) asize = 0x801;
tr = emitir(IRTG(IR_TNEW, IRT_TAB), asize, hbits);
#ifdef LUAJIT_ENABLE_TABLE_BUMP
J->rbchash[(tr & (RBCHASH_SLOTS-1))].ref = tref_ref(tr);
setmref(J->rbchash[(tr & (RBCHASH_SLOTS-1))].pc, J->pc);
setgcref(J->rbchash[(tr & (RBCHASH_SLOTS-1))].pt, obj2gco(J->pt));
#endif
return tr;
}

Expand Down Expand Up @@ -2219,9 +2229,11 @@ void lj_record_ins(jit_State *J)
case BC_TDUP:
rc = emitir(IRTG(IR_TDUP, IRT_TAB),
lj_ir_ktab(J, gco2tab(proto_kgc(J->pt, ~(ptrdiff_t)rc))), 0);
#ifdef LUAJIT_ENABLE_TABLE_BUMP
J->rbchash[(rc & (RBCHASH_SLOTS-1))].ref = tref_ref(rc);
setmref(J->rbchash[(rc & (RBCHASH_SLOTS-1))].pc, pc);
setgcref(J->rbchash[(rc & (RBCHASH_SLOTS-1))].pt, obj2gco(J->pt));
#endif
break;

/* -- Calls and vararg handling ----------------------------------------- */
Expand Down Expand Up @@ -2435,7 +2447,9 @@ void lj_record_setup(jit_State *J)
/* Initialize state related to current trace. */
memset(J->slot, 0, sizeof(J->slot));
memset(J->chain, 0, sizeof(J->chain));
#ifdef LUAJIT_ENABLE_TABLE_BUMP
memset(J->rbchash, 0, sizeof(J->rbchash));
#endif
memset(J->bpropcache, 0, sizeof(J->bpropcache));
J->scev.idx = REF_NIL;
setmref(J->scev.pc, NULL);
Expand Down

0 comments on commit fe56522

Please sign in to comment.