summaryrefslogtreecommitdiff
path: root/src/lj_snap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_snap.c')
-rw-r--r--src/lj_snap.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lj_snap.c b/src/lj_snap.c
index e2a49ae3..c2aff3db 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -32,7 +32,7 @@
32*/ 32*/
33 33
34/* Add all modified slots to the snapshot. */ 34/* Add all modified slots to the snapshot. */
35static void snapshot_slots(jit_State *J, IRRef2 *map, BCReg nslots) 35static MSize snapshot_slots(jit_State *J, SnapEntry *map, BCReg nslots)
36{ 36{
37 BCReg s; 37 BCReg s;
38 for (s = 0; s < nslots; s++) { 38 for (s = 0; s < nslots; s++) {
@@ -42,12 +42,13 @@ static void snapshot_slots(jit_State *J, IRRef2 *map, BCReg nslots)
42 if (ir->o == IR_SLOAD && ir->op1 == s && !(ir->op2 & IRSLOAD_INHERIT)) 42 if (ir->o == IR_SLOAD && ir->op1 == s && !(ir->op2 & IRSLOAD_INHERIT))
43 ref = 0; 43 ref = 0;
44 } 44 }
45 map[s] = (IRRef2)ref; 45 map[s] = (SnapEntry)ref;
46 } 46 }
47 return nslots;
47} 48}
48 49
49/* Add frame links at the end of the snapshot. */ 50/* Add frame links at the end of the snapshot. */
50static MSize snapshot_framelinks(jit_State *J, IRRef2 *map) 51static MSize snapshot_framelinks(jit_State *J, SnapEntry *map)
51{ 52{
52 cTValue *frame = J->L->base - 1; 53 cTValue *frame = J->L->base - 1;
53 cTValue *lim = J->L->base - J->baseslot; 54 cTValue *lim = J->L->base - J->baseslot;
@@ -76,7 +77,7 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap)
76{ 77{
77 BCReg nslots = J->baseslot + J->maxslot; 78 BCReg nslots = J->baseslot + J->maxslot;
78 MSize nsm, nframelinks; 79 MSize nsm, nframelinks;
79 IRRef2 *p; 80 SnapEntry *p;
80 /* Conservative estimate. Continuation frames need 2 slots. */ 81 /* Conservative estimate. Continuation frames need 2 slots. */
81 nsm = nsnapmap + nslots + (uint32_t)J->framedepth*2+1; 82 nsm = nsnapmap + nslots + (uint32_t)J->framedepth*2+1;
82 if (LJ_UNLIKELY(nsm > J->sizesnapmap)) { /* Need to grow snapshot map? */ 83 if (LJ_UNLIKELY(nsm > J->sizesnapmap)) { /* Need to grow snapshot map? */
@@ -84,13 +85,13 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap)
84 nsm = 2*J->sizesnapmap; 85 nsm = 2*J->sizesnapmap;
85 else if (nsm < 64) 86 else if (nsm < 64)
86 nsm = 64; 87 nsm = 64;
87 J->snapmapbuf = (IRRef2 *)lj_mem_realloc(J->L, J->snapmapbuf, 88 J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf,
88 J->sizesnapmap*sizeof(IRRef2), nsm*sizeof(IRRef2)); 89 J->sizesnapmap*sizeof(SnapEntry), nsm*sizeof(SnapEntry));
89 J->cur.snapmap = J->snapmapbuf; 90 J->cur.snapmap = J->snapmapbuf;
90 J->sizesnapmap = nsm; 91 J->sizesnapmap = nsm;
91 } 92 }
92 p = &J->cur.snapmap[nsnapmap]; 93 p = &J->cur.snapmap[nsnapmap];
93 snapshot_slots(J, p, nslots); 94 nslots = snapshot_slots(J, p, nslots);
94 nframelinks = snapshot_framelinks(J, p + nslots); 95 nframelinks = snapshot_framelinks(J, p + nslots);
95 J->cur.nsnapmap = (uint16_t)(nsnapmap + nslots + nframelinks); 96 J->cur.nsnapmap = (uint16_t)(nsnapmap + nslots + nframelinks);
96 snap->mapofs = (uint16_t)nsnapmap; 97 snap->mapofs = (uint16_t)nsnapmap;
@@ -130,8 +131,8 @@ void lj_snap_shrink(jit_State *J)
130{ 131{
131 BCReg nslots = J->baseslot + J->maxslot; 132 BCReg nslots = J->baseslot + J->maxslot;
132 SnapShot *snap = &J->cur.snap[J->cur.nsnap-1]; 133 SnapShot *snap = &J->cur.snap[J->cur.nsnap-1];
133 IRRef2 *oflinks = &J->cur.snapmap[snap->mapofs + snap->nslots]; 134 SnapEntry *oflinks = &J->cur.snapmap[snap->mapofs + snap->nslots];
134 IRRef2 *nflinks = &J->cur.snapmap[snap->mapofs + nslots]; 135 SnapEntry *nflinks = &J->cur.snapmap[snap->mapofs + nslots];
135 uint32_t s, nframelinks = snap->nframelinks; 136 uint32_t s, nframelinks = snap->nframelinks;
136 lua_assert(nslots < snap->nslots); 137 lua_assert(nslots < snap->nslots);
137 snap->nslots = (uint8_t)nslots; 138 snap->nslots = (uint8_t)nslots;
@@ -171,7 +172,7 @@ void lj_snap_regspmap(uint16_t *rsmap, Trace *T, SnapNo snapno)
171{ 172{
172 SnapShot *snap = &T->snap[snapno]; 173 SnapShot *snap = &T->snap[snapno];
173 BCReg s, nslots = snap->nslots; 174 BCReg s, nslots = snap->nslots;
174 IRRef2 *map = &T->snapmap[snap->mapofs]; 175 SnapEntry *map = &T->snapmap[snap->mapofs];
175 BloomFilter rfilt = snap_renamefilter(T, snapno); 176 BloomFilter rfilt = snap_renamefilter(T, snapno);
176 for (s = 0; s < nslots; s++) { 177 for (s = 0; s < nslots; s++) {
177 IRRef ref = snap_ref(map[s]); 178 IRRef ref = snap_ref(map[s]);
@@ -193,8 +194,8 @@ void lj_snap_restore(jit_State *J, void *exptr)
193 Trace *T = J->trace[J->parent]; 194 Trace *T = J->trace[J->parent];
194 SnapShot *snap = &T->snap[snapno]; 195 SnapShot *snap = &T->snap[snapno];
195 BCReg s, nslots = snap->nslots; 196 BCReg s, nslots = snap->nslots;
196 IRRef2 *map = &T->snapmap[snap->mapofs]; 197 SnapEntry *map = &T->snapmap[snap->mapofs];
197 IRRef2 *flinks = map + nslots + snap->nframelinks; 198 SnapEntry *flinks = map + nslots + snap->nframelinks;
198 TValue *o, *newbase, *ntop; 199 TValue *o, *newbase, *ntop;
199 BloomFilter rfilt = snap_renamefilter(T, snapno); 200 BloomFilter rfilt = snap_renamefilter(T, snapno);
200 lua_State *L = J->L; 201 lua_State *L = J->L;