Skip to content

Commit

Permalink
Minor update to jit_State bytecode log
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Nov 29, 2017
1 parent 7a4e25b commit 9b2b467
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/lj_jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ typedef struct FoldState {

/* Log entry for a bytecode that was recorded. */
typedef struct BCRecLog {
GCproto *pt;
BCPos pos;
int32_t framedepth;
GCproto *pt; /* Prototype of bytecode function (or NULL). */
BCPos pos; /* Position of bytecode in prototype. */
int32_t framedepth; /* Frame depth when recorded. */
} BCRecLog;

/* JIT compiler state. */
Expand Down Expand Up @@ -348,8 +348,8 @@ typedef struct jit_State {
MSize sizesnapmap; /* Size of temp. snapshot map buffer. */

BCRecLog *bclog; /* Start of of recorded bytecode log. */
BCRecLog *bclognext; /* Next entry in the bytecode log. */
BCRecLog *bcloglast; /* Last entry in the bytecode log. */
uint32_t nbclog; /* Number of logged bytecodes. */
uint32_t maxbclog; /* Max entries in the bytecode log. */

PostProc postproc; /* Required post-processing after execution. */
uint8_t retryrec; /* Retry recording. */
Expand Down
6 changes: 3 additions & 3 deletions src/lj_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,8 @@ void lj_record_ins(jit_State *J)
BCOp op;
TRef ra, rb, rc;

if (J->bclognext < J->bcloglast) {
BCRecLog *log = J->bclognext++;
if (J->nbclog < J->maxbclog) {
BCRecLog *log = &J->bclog[J->nbclog++];
log->pt = J->pt;
log->pos = J->pt ? proto_bcpos(J->pt, J->pc) : -1;
log->framedepth = J->framedepth;
Expand Down Expand Up @@ -2443,7 +2443,7 @@ void lj_record_setup(jit_State *J)
J->bc_min = NULL; /* Means no limit. */
J->bc_extent = ~(MSize)0;

J->bclognext = J->bclog;
J->nbclog = 0;

/* Emit instructions for fixed references. Also triggers initial IR alloc. */
emitir_raw(IRT(IR_BASE, IRT_PGC), J->parent, J->exitno);
Expand Down
5 changes: 3 additions & 2 deletions src/lj_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
J->sizesnapmap = sizeof(SnapEntry)*65536;
J->snapbuf = (SnapShot *)lj_mem_new(L, J->sizesnap);
J->snapmapbuf = (SnapEntry *)lj_mem_new(L, J->sizesnapmap);
J->bclognext = J->bclog = (BCRecLog *)lj_mem_new(L, sizeof(BCRecLog)*65536);
J->bcloglast = J->bclog + 65535;
J->maxbclog = 65536;
J->bclog = (BCRecLog *)lj_mem_new(L, sizeof(BCRecLog)*J->maxbclog);
J->nbclog = 0;
IRIns *irbufmem = (IRIns *)lj_mem_new(L, sizeof(IRIns)*65536);
if (irbufmem == NULL || J->snapbuf == NULL || J->snapmapbuf == NULL)
return NULL;
Expand Down

0 comments on commit 9b2b467

Please sign in to comment.