aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib_jit.c2
-rw-r--r--src/lj_asm.c10
-rw-r--r--src/lj_jit.h10
-rw-r--r--src/lj_opt_dce.c2
-rw-r--r--src/lj_opt_loop.c10
-rw-r--r--src/lj_record.c2
-rw-r--r--src/lj_snap.c25
-rw-r--r--src/lj_trace.c8
8 files changed, 36 insertions, 33 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c
index d849ded4..aa421613 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -331,7 +331,7 @@ LJLIB_CF(jit_util_tracesnap)
331 SnapNo sn = (SnapNo)lj_lib_checkint(L, 2); 331 SnapNo sn = (SnapNo)lj_lib_checkint(L, 2);
332 if (T && sn < T->nsnap) { 332 if (T && sn < T->nsnap) {
333 SnapShot *snap = &T->snap[sn]; 333 SnapShot *snap = &T->snap[sn];
334 IRRef2 *map = &T->snapmap[snap->mapofs]; 334 SnapEntry *map = &T->snapmap[snap->mapofs];
335 BCReg s, nslots = snap->nslots; 335 BCReg s, nslots = snap->nslots;
336 GCtab *t; 336 GCtab *t;
337 lua_createtable(L, nslots ? (int)nslots : 1, 0); 337 lua_createtable(L, nslots ? (int)nslots : 1, 0);
diff --git a/src/lj_asm.c b/src/lj_asm.c
index eeb6aeb4..a8cb3dd0 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -925,7 +925,7 @@ static int asm_snap_canremat(ASMState *as)
925static void asm_snap_alloc(ASMState *as) 925static void asm_snap_alloc(ASMState *as)
926{ 926{
927 SnapShot *snap = &as->T->snap[as->snapno]; 927 SnapShot *snap = &as->T->snap[as->snapno];
928 IRRef2 *map = &as->T->snapmap[snap->mapofs]; 928 SnapEntry *map = &as->T->snapmap[snap->mapofs];
929 BCReg s, nslots = snap->nslots; 929 BCReg s, nslots = snap->nslots;
930 for (s = 0; s < nslots; s++) { 930 for (s = 0; s < nslots; s++) {
931 IRRef ref = snap_ref(map[s]); 931 IRRef ref = snap_ref(map[s]);
@@ -959,7 +959,7 @@ static void asm_snap_alloc(ASMState *as)
959static int asm_snap_checkrename(ASMState *as, IRRef ren) 959static int asm_snap_checkrename(ASMState *as, IRRef ren)
960{ 960{
961 SnapShot *snap = &as->T->snap[as->snapno]; 961 SnapShot *snap = &as->T->snap[as->snapno];
962 IRRef2 *map = &as->T->snapmap[snap->mapofs]; 962 SnapEntry *map = &as->T->snapmap[snap->mapofs];
963 BCReg s, nslots = snap->nslots; 963 BCReg s, nslots = snap->nslots;
964 for (s = 0; s < nslots; s++) { 964 for (s = 0; s < nslots; s++) {
965 IRRef ref = snap_ref(map[s]); 965 IRRef ref = snap_ref(map[s]);
@@ -2463,7 +2463,7 @@ static void asm_gc_sync(ASMState *as, SnapShot *snap, Reg base)
2463 ** only. This avoids register allocation state unification. 2463 ** only. This avoids register allocation state unification.
2464 */ 2464 */
2465 RegSet allow = rset_exclude(RSET_SCRATCH & RSET_GPR, base); 2465 RegSet allow = rset_exclude(RSET_SCRATCH & RSET_GPR, base);
2466 IRRef2 *map = &as->T->snapmap[snap->mapofs]; 2466 SnapEntry *map = &as->T->snapmap[snap->mapofs];
2467 BCReg s, nslots = snap->nslots; 2467 BCReg s, nslots = snap->nslots;
2468 for (s = 0; s < nslots; s++) { 2468 for (s = 0; s < nslots; s++) {
2469 IRRef ref = snap_ref(map[s]); 2469 IRRef ref = snap_ref(map[s]);
@@ -2965,8 +2965,8 @@ static void asm_tail_sync(ASMState *as)
2965{ 2965{
2966 SnapShot *snap = &as->T->snap[as->T->nsnap-1]; /* Last snapshot. */ 2966 SnapShot *snap = &as->T->snap[as->T->nsnap-1]; /* Last snapshot. */
2967 BCReg s, nslots = snap->nslots; 2967 BCReg s, nslots = snap->nslots;
2968 IRRef2 *map = &as->T->snapmap[snap->mapofs]; 2968 SnapEntry *map = &as->T->snapmap[snap->mapofs];
2969 IRRef2 *flinks = map + nslots + snap->nframelinks; 2969 SnapEntry *flinks = map + nslots + snap->nframelinks;
2970 BCReg newbase = 0; 2970 BCReg newbase = 0;
2971 BCReg secondbase = ~(BCReg)0; 2971 BCReg secondbase = ~(BCReg)0;
2972 BCReg topslot = 0; 2972 BCReg topslot = 0;
diff --git a/src/lj_jit.h b/src/lj_jit.h
index c783922c..36e60113 100644
--- a/src/lj_jit.h
+++ b/src/lj_jit.h
@@ -119,8 +119,10 @@ typedef struct SnapShot {
119} SnapShot; 119} SnapShot;
120 120
121#define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */ 121#define SNAPCOUNT_DONE 255 /* Already compiled and linked a side trace. */
122#define snap_ref(sn) ((IRRef)(IRRef1)(sn)) 122
123#define snap_ridsp(sn) ((sn) >> 16) 123/* Snapshot entry. */
124typedef uint32_t SnapEntry;
125#define snap_ref(sn) ((sn) & 0xffff)
124 126
125/* Snapshot and exit numbers. */ 127/* Snapshot and exit numbers. */
126typedef uint32_t SnapNo; 128typedef uint32_t SnapNo;
@@ -138,7 +140,7 @@ typedef struct Trace {
138 IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */ 140 IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */
139 IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */ 141 IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */
140 SnapShot *snap; /* Snapshot array. */ 142 SnapShot *snap; /* Snapshot array. */
141 IRRef2 *snapmap; /* Snapshot map. */ 143 SnapEntry *snapmap; /* Snapshot map. */
142 uint16_t nsnap; /* Number of snapshots. */ 144 uint16_t nsnap; /* Number of snapshots. */
143 uint16_t nsnapmap; /* Number of snapshot map elements. */ 145 uint16_t nsnapmap; /* Number of snapshot map elements. */
144 GCRef startpt; /* Starting prototype. */ 146 GCRef startpt; /* Starting prototype. */
@@ -223,7 +225,7 @@ typedef struct jit_State {
223 IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */ 225 IRRef loopref; /* Last loop reference or ref of final LOOP (or 0). */
224 226
225 SnapShot *snapbuf; /* Temp. snapshot buffer. */ 227 SnapShot *snapbuf; /* Temp. snapshot buffer. */
226 IRRef2 *snapmapbuf; /* Temp. snapshot map buffer. */ 228 SnapEntry *snapmapbuf; /* Temp. snapshot map buffer. */
227 MSize sizesnap; /* Size of temp. snapshot buffer. */ 229 MSize sizesnap; /* Size of temp. snapshot buffer. */
228 MSize sizesnapmap; /* Size of temp. snapshot map buffer. */ 230 MSize sizesnapmap; /* Size of temp. snapshot map buffer. */
229 231
diff --git a/src/lj_opt_dce.c b/src/lj_opt_dce.c
index e304d9fc..636d5183 100644
--- a/src/lj_opt_dce.c
+++ b/src/lj_opt_dce.c
@@ -23,7 +23,7 @@ static void dce_marksnap(jit_State *J)
23 SnapNo i, nsnap = J->cur.nsnap; 23 SnapNo i, nsnap = J->cur.nsnap;
24 for (i = 0; i < nsnap; i++) { 24 for (i = 0; i < nsnap; i++) {
25 SnapShot *snap = &J->cur.snap[i]; 25 SnapShot *snap = &J->cur.snap[i];
26 IRRef2 *map = &J->cur.snapmap[snap->mapofs]; 26 SnapEntry *map = &J->cur.snapmap[snap->mapofs];
27 BCReg s, nslots = snap->nslots; 27 BCReg s, nslots = snap->nslots;
28 for (s = 0; s < nslots; s++) { 28 for (s = 0; s < nslots; s++) {
29 IRRef ref = snap_ref(map[s]); 29 IRRef ref = snap_ref(map[s]);
diff --git a/src/lj_opt_loop.c b/src/lj_opt_loop.c
index 1fbc8091..f2950fe9 100644
--- a/src/lj_opt_loop.c
+++ b/src/lj_opt_loop.c
@@ -170,7 +170,7 @@ static void loop_unroll(jit_State *J)
170 uint32_t nphi = 0; 170 uint32_t nphi = 0;
171 IRRef1 *subst; 171 IRRef1 *subst;
172 SnapShot *osnap, *snap; 172 SnapShot *osnap, *snap;
173 IRRef2 *loopmap; 173 SnapEntry *loopmap;
174 BCReg loopslots; 174 BCReg loopslots;
175 MSize nsnap, nsnapmap; 175 MSize nsnap, nsnapmap;
176 IRRef ins, invar, osnapref; 176 IRRef ins, invar, osnapref;
@@ -198,9 +198,9 @@ static void loop_unroll(jit_State *J)
198 } 198 }
199 nsnapmap = J->cur.nsnapmap; /* Use temp. copy to avoid undo. */ 199 nsnapmap = J->cur.nsnapmap; /* Use temp. copy to avoid undo. */
200 if (LJ_UNLIKELY(nsnapmap*2 > J->sizesnapmap)) { 200 if (LJ_UNLIKELY(nsnapmap*2 > J->sizesnapmap)) {
201 J->snapmapbuf = (IRRef2 *)lj_mem_realloc(J->L, J->snapmapbuf, 201 J->snapmapbuf = (SnapEntry *)lj_mem_realloc(J->L, J->snapmapbuf,
202 J->sizesnapmap*sizeof(IRRef2), 202 J->sizesnapmap*sizeof(SnapEntry),
203 2*J->sizesnapmap*sizeof(IRRef2)); 203 2*J->sizesnapmap*sizeof(SnapEntry));
204 J->cur.snapmap = J->snapmapbuf; 204 J->cur.snapmap = J->snapmapbuf;
205 J->sizesnapmap *= 2; 205 J->sizesnapmap *= 2;
206 } 206 }
@@ -223,7 +223,7 @@ static void loop_unroll(jit_State *J)
223 223
224 /* Copy-substitute snapshot. */ 224 /* Copy-substitute snapshot. */
225 if (ins >= osnapref) { 225 if (ins >= osnapref) {
226 IRRef2 *nmap, *omap = &J->cur.snapmap[osnap->mapofs]; 226 SnapEntry *nmap, *omap = &J->cur.snapmap[osnap->mapofs];
227 BCReg s, nslots; 227 BCReg s, nslots;
228 uint32_t nmapofs, nframelinks; 228 uint32_t nmapofs, nframelinks;
229 if (irt_isguard(J->guardemit)) { /* Guard inbetween? */ 229 if (irt_isguard(J->guardemit)) { /* Guard inbetween? */
diff --git a/src/lj_record.c b/src/lj_record.c
index 5085d735..329cbdc5 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -2158,7 +2158,7 @@ static const BCIns *rec_setup_root(jit_State *J)
2158static void rec_setup_side(jit_State *J, Trace *T) 2158static void rec_setup_side(jit_State *J, Trace *T)
2159{ 2159{
2160 SnapShot *snap = &T->snap[J->exitno]; 2160 SnapShot *snap = &T->snap[J->exitno];
2161 IRRef2 *map = &T->snapmap[snap->mapofs]; 2161 SnapEntry *map = &T->snapmap[snap->mapofs];
2162 BCReg s, nslots = snap->nslots; 2162 BCReg s, nslots = snap->nslots;
2163 BloomFilter seen = 0; 2163 BloomFilter seen = 0;
2164 for (s = 0; s < nslots; s++) { 2164 for (s = 0; s < nslots; s++) {
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;
diff --git a/src/lj_trace.c b/src/lj_trace.c
index 683b8a58..a5468655 100644
--- a/src/lj_trace.c
+++ b/src/lj_trace.c
@@ -88,7 +88,7 @@ static Trace *trace_save(jit_State *J, Trace *T)
88 size_t szins = (T->nins-T->nk)*sizeof(IRIns); 88 size_t szins = (T->nins-T->nk)*sizeof(IRIns);
89 size_t sz = sztr + szins + 89 size_t sz = sztr + szins +
90 T->nsnap*sizeof(SnapShot) + 90 T->nsnap*sizeof(SnapShot) +
91 T->nsnapmap*sizeof(IRRef2); 91 T->nsnapmap*sizeof(SnapEntry);
92 Trace *T2 = lj_mem_newt(J->L, (MSize)sz, Trace); 92 Trace *T2 = lj_mem_newt(J->L, (MSize)sz, Trace);
93 char *p = (char *)T2 + sztr; 93 char *p = (char *)T2 + sztr;
94 memcpy(T2, T, sizeof(Trace)); 94 memcpy(T2, T, sizeof(Trace));
@@ -96,7 +96,7 @@ static Trace *trace_save(jit_State *J, Trace *T)
96 memcpy(p, T->ir+T->nk, szins); 96 memcpy(p, T->ir+T->nk, szins);
97 p += szins; 97 p += szins;
98 TRACE_COPYELEM(snap, nsnap, SnapShot) 98 TRACE_COPYELEM(snap, nsnap, SnapShot)
99 TRACE_COPYELEM(snapmap, nsnapmap, IRRef2) 99 TRACE_COPYELEM(snapmap, nsnapmap, SnapEntry)
100 lj_gc_barriertrace(J2G(J), T); 100 lj_gc_barriertrace(J2G(J), T);
101 return T2; 101 return T2;
102} 102}
@@ -118,7 +118,7 @@ static void trace_free(jit_State *J, TraceNo traceno)
118 J->trace[traceno] = NULL; 118 J->trace[traceno] = NULL;
119 lj_mem_free(J2G(J), T, 119 lj_mem_free(J2G(J), T,
120 ((sizeof(Trace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) + 120 ((sizeof(Trace)+7)&~7) + (T->nins-T->nk)*sizeof(IRIns) +
121 T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(IRRef2)); 121 T->nsnap*sizeof(SnapShot) + T->nsnapmap*sizeof(SnapEntry));
122 } 122 }
123} 123}
124 124
@@ -284,7 +284,7 @@ void lj_trace_freestate(global_State *g)
284#endif 284#endif
285 lj_mcode_free(J); 285 lj_mcode_free(J);
286 lj_ir_knum_freeall(J); 286 lj_ir_knum_freeall(J);
287 lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, IRRef2); 287 lj_mem_freevec(g, J->snapmapbuf, J->sizesnapmap, SnapEntry);
288 lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot); 288 lj_mem_freevec(g, J->snapbuf, J->sizesnap, SnapShot);
289 lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns); 289 lj_mem_freevec(g, J->irbuf + J->irbotlim, J->irtoplim - J->irbotlim, IRIns);
290 lj_mem_freevec(g, J->trace, J->sizetrace, Trace *); 290 lj_mem_freevec(g, J->trace, J->sizetrace, Trace *);