aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-05 01:16:22 +0100
committerMike Pall <mike>2010-02-05 01:16:22 +0100
commit8dcc4364cf2c56c9bdd8047fd0dceb4b70f727d2 (patch)
tree87377af1470716bf4b7bcd8feba1fc84fd34d5f9 /src
parentd7789821208336a7fe6e0b6d706b6b4844e6fa9e (diff)
downloadluajit-8dcc4364cf2c56c9bdd8047fd0dceb4b70f727d2.tar.gz
luajit-8dcc4364cf2c56c9bdd8047fd0dceb4b70f727d2.tar.bz2
luajit-8dcc4364cf2c56c9bdd8047fd0dceb4b70f727d2.zip
32/64 bit memory ref cleanup, part 3: GCproto ->lineinfo.
Diffstat (limited to 'src')
-rw-r--r--src/lib_jit.c5
-rw-r--r--src/lj_dispatch.c6
-rw-r--r--src/lj_err.c14
-rw-r--r--src/lj_func.c4
-rw-r--r--src/lj_gc.c2
-rw-r--r--src/lj_gdbjit.c2
-rw-r--r--src/lj_obj.h5
-rw-r--r--src/lj_parse.c26
8 files changed, 38 insertions, 26 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c
index 52368a8b..d0b9e833 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -184,8 +184,9 @@ LJLIB_CF(jit_util_funcinfo)
184 setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc); 184 setintfield(L, t, "gcconsts", (int32_t)pt->sizekgc);
185 setintfield(L, t, "nconsts", (int32_t)pt->sizekn); 185 setintfield(L, t, "nconsts", (int32_t)pt->sizekn);
186 setintfield(L, t, "upvalues", (int32_t)pt->sizeuv); 186 setintfield(L, t, "upvalues", (int32_t)pt->sizeuv);
187 if (pc > 0) 187 if (pc-1 < pt->sizebc)
188 setintfield(L, t, "currentline", pt->lineinfo ? pt->lineinfo[pc-1] : 0); 188 setintfield(L, t, "currentline",
189 proto_lineinfo(pt) ? proto_line(pt, pc-1) : 0);
189 lua_pushboolean(L, (pt->flags & PROTO_IS_VARARG)); 190 lua_pushboolean(L, (pt->flags & PROTO_IS_VARARG));
190 lua_setfield(L, -2, "isvararg"); 191 lua_setfield(L, -2, "isvararg");
191 setstrV(L, L->top++, proto_chunkname(pt)); 192 setstrV(L, L->top++, proto_chunkname(pt));
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
index 09cb2f5d..5378531d 100644
--- a/src/lj_dispatch.c
+++ b/src/lj_dispatch.c
@@ -301,12 +301,12 @@ void LJ_FASTCALL lj_dispatch_ins(lua_State *L, const BCIns *pc)
301 g->hookcount = g->hookcstart; 301 g->hookcount = g->hookcstart;
302 callhook(L, LUA_HOOKCOUNT, -1); 302 callhook(L, LUA_HOOKCOUNT, -1);
303 } 303 }
304 if ((g->hookmask & LUA_MASKLINE) && pt->lineinfo) { 304 if ((g->hookmask & LUA_MASKLINE) && proto_lineinfo(pt)) {
305 BCPos npc = proto_bcpos(pt, pc) - 1; 305 BCPos npc = proto_bcpos(pt, pc) - 1;
306 BCPos opc = proto_bcpos(pt, oldpc) - 1; 306 BCPos opc = proto_bcpos(pt, oldpc) - 1;
307 BCLine line = pt->lineinfo[npc]; 307 BCLine line = proto_line(pt, npc);
308 if (npc == 0 || pc <= oldpc || 308 if (npc == 0 || pc <= oldpc ||
309 opc >= pt->sizebc || line != pt->lineinfo[opc]) { 309 opc >= pt->sizebc || line != proto_line(pt, opc)) {
310 L->top = L->base + slots; /* Fix top again after instruction hook. */ 310 L->top = L->base + slots; /* Fix top again after instruction hook. */
311 callhook(L, LUA_HOOKLINE, line); 311 callhook(L, LUA_HOOKLINE, line);
312 } 312 }
diff --git a/src/lj_err.c b/src/lj_err.c
index 0c54cf62..cf7f9ae4 100644
--- a/src/lj_err.c
+++ b/src/lj_err.c
@@ -129,7 +129,7 @@ static BCLine currentline(lua_State *L, GCfunc *fn, cTValue *nextframe)
129 if (pc != ~(BCPos)0) { 129 if (pc != ~(BCPos)0) {
130 GCproto *pt = funcproto(fn); 130 GCproto *pt = funcproto(fn);
131 lua_assert(pc < pt->sizebc); 131 lua_assert(pc < pt->sizebc);
132 return pt->lineinfo ? pt->lineinfo[pc] : 0; 132 return proto_lineinfo(pt) ? proto_line(pt, pc) : 0;
133 } else { 133 } else {
134 return -1; 134 return -1;
135 } 135 }
@@ -224,7 +224,7 @@ void lj_err_pushloc(lua_State *L, GCproto *pt, BCPos pc)
224 MSize i, len = name->len; 224 MSize i, len = name->len;
225 BCLine line; 225 BCLine line;
226 if (pc) 226 if (pc)
227 line = pt->lineinfo ? pt->lineinfo[pc-1] : 0; 227 line = proto_lineinfo(pt) ? proto_line(pt, pc-1) : 0;
228 else 228 else
229 line = pt->linedefined; 229 line = pt->linedefined;
230 if (*s == '@') { 230 if (*s == '@') {
@@ -377,10 +377,12 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
377 case 'L': 377 case 'L':
378 if (isluafunc(fn)) { 378 if (isluafunc(fn)) {
379 GCtab *t = lj_tab_new(L, 0, 0); 379 GCtab *t = lj_tab_new(L, 0, 0);
380 BCLine *lineinfo = funcproto(fn)->lineinfo; 380 BCLine *lineinfo = proto_lineinfo(funcproto(fn));
381 uint32_t i, szl = funcproto(fn)->sizelineinfo; 381 if (lineinfo) {
382 for (i = 0; i < szl; i++) 382 uint32_t i, szl = funcproto(fn)->sizelineinfo;
383 setboolV(lj_tab_setint(L, t, lineinfo[i]), 1); 383 for (i = 0; i < szl; i++)
384 setboolV(lj_tab_setint(L, t, lineinfo[i]), 1);
385 }
384 settabV(L, L->top, t); 386 settabV(L, L->top, t);
385 } else { 387 } else {
386 setnilV(L->top); 388 setnilV(L->top);
diff --git a/src/lj_func.c b/src/lj_func.c
index 284bd3b3..4354aa21 100644
--- a/src/lj_func.c
+++ b/src/lj_func.c
@@ -37,7 +37,7 @@ GCproto *lj_func_newproto(lua_State *L)
37 pt->sizeuvname = 0; 37 pt->sizeuvname = 0;
38 pt->linedefined = 0; 38 pt->linedefined = 0;
39 pt->lastlinedefined = 0; 39 pt->lastlinedefined = 0;
40 pt->lineinfo = NULL; 40 setmref(pt->lineinfo, NULL);
41 pt->varinfo = NULL; 41 pt->varinfo = NULL;
42 setmref(pt->uvname, NULL); 42 setmref(pt->uvname, NULL);
43 setgcrefnull(pt->chunkname); 43 setgcrefnull(pt->chunkname);
@@ -52,7 +52,7 @@ void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt)
52 lj_mem_free(g, mref(pt->k, GCRef) - nkgc, sizek); 52 lj_mem_free(g, mref(pt->k, GCRef) - nkgc, sizek);
53 lj_mem_freevec(g, proto_bc(pt), pt->sizebc, BCIns); 53 lj_mem_freevec(g, proto_bc(pt), pt->sizebc, BCIns);
54 lj_mem_freevec(g, proto_uv(pt), pt->sizeuv, uint16_t); 54 lj_mem_freevec(g, proto_uv(pt), pt->sizeuv, uint16_t);
55 lj_mem_freevec(g, pt->lineinfo, pt->sizelineinfo, int32_t); 55 lj_mem_freevec(g, proto_lineinfo(pt), pt->sizelineinfo, BCLine);
56 lj_mem_freevec(g, pt->varinfo, pt->sizevarinfo, struct VarInfo); 56 lj_mem_freevec(g, pt->varinfo, pt->sizevarinfo, struct VarInfo);
57 lj_mem_freevec(g, mref(pt->uvname, GCRef), pt->sizeuvname, GCRef); 57 lj_mem_freevec(g, mref(pt->uvname, GCRef), pt->sizeuvname, GCRef);
58 lj_trace_freeproto(g, pt); 58 lj_trace_freeproto(g, pt);
diff --git a/src/lj_gc.c b/src/lj_gc.c
index 3c1b847a..04aa7161 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -330,7 +330,7 @@ static size_t propagatemark(global_State *g)
330 sizeof(GCRef) * pt->sizekgc + 330 sizeof(GCRef) * pt->sizekgc +
331 sizeof(lua_Number) * pt->sizekn + 331 sizeof(lua_Number) * pt->sizekn +
332 sizeof(uint16_t) * pt->sizeuv + 332 sizeof(uint16_t) * pt->sizeuv +
333 sizeof(int32_t) * pt->sizelineinfo + 333 sizeof(BCLine) * pt->sizelineinfo +
334 sizeof(VarInfo) * pt->sizevarinfo + 334 sizeof(VarInfo) * pt->sizevarinfo +
335 sizeof(GCRef) * pt->sizeuvname; 335 sizeof(GCRef) * pt->sizeuvname;
336 } else { 336 } else {
diff --git a/src/lj_gdbjit.c b/src/lj_gdbjit.c
index af31b277..e60a451b 100644
--- a/src/lj_gdbjit.c
+++ b/src/lj_gdbjit.c
@@ -706,7 +706,7 @@ void lj_gdbjit_addtrace(jit_State *J, Trace *T, TraceNo traceno)
706 ctx.spadjp = CFRAME_SIZE + (MSize)(parent ? J->trace[parent]->spadjust : 0); 706 ctx.spadjp = CFRAME_SIZE + (MSize)(parent ? J->trace[parent]->spadjust : 0);
707 ctx.spadj = CFRAME_SIZE + T->spadjust; 707 ctx.spadj = CFRAME_SIZE + T->spadjust;
708 if (startpc >= proto_bc(pt)) 708 if (startpc >= proto_bc(pt))
709 ctx.lineno = pt->lineinfo ? pt->lineinfo[proto_bcpos(pt, startpc)] : 0; 709 ctx.lineno = proto_lineinfo(pt) ? proto_line(pt,proto_bcpos(pt,startpc)): 0;
710 else 710 else
711 ctx.lineno = pt->linedefined; 711 ctx.lineno = pt->linedefined;
712 ctx.filename = strdata(proto_chunkname(pt)); 712 ctx.filename = strdata(proto_chunkname(pt));
diff --git a/src/lj_obj.h b/src/lj_obj.h
index 164ec853..cdb90dff 100644
--- a/src/lj_obj.h
+++ b/src/lj_obj.h
@@ -364,7 +364,7 @@ typedef struct GCproto {
364 MSize sizeuvname; /* Size of upvalue names array (may be 0). */ 364 MSize sizeuvname; /* Size of upvalue names array (may be 0). */
365 BCLine linedefined; /* First line of the function definition. */ 365 BCLine linedefined; /* First line of the function definition. */
366 BCLine lastlinedefined; /* Last line of the function definition. */ 366 BCLine lastlinedefined; /* Last line of the function definition. */
367 BCLine *lineinfo; /* Map from bytecode instructions to source lines. */ 367 MRef lineinfo; /* Map from bytecode instructions to source lines. */
368 struct VarInfo *varinfo; /* Names and extents of local variables. */ 368 struct VarInfo *varinfo; /* Names and extents of local variables. */
369 MRef uvname; /* Array of upvalue names (GCRef of GCstr). */ 369 MRef uvname; /* Array of upvalue names (GCRef of GCstr). */
370 GCRef chunkname; /* Name of the chunk this function was defined in. */ 370 GCRef chunkname; /* Name of the chunk this function was defined in. */
@@ -393,6 +393,9 @@ typedef struct GCproto {
393 check_exp((uintptr_t)(idx) < (pt)->sizeuvname, \ 393 check_exp((uintptr_t)(idx) < (pt)->sizeuvname, \
394 gcref(mref((pt)->uvname, GCRef)[(idx)])) 394 gcref(mref((pt)->uvname, GCRef)[(idx)]))
395#define proto_chunkname(pt) (gco2str(gcref((pt)->chunkname))) 395#define proto_chunkname(pt) (gco2str(gcref((pt)->chunkname)))
396#define proto_lineinfo(pt) (mref((pt)->lineinfo, BCLine))
397#define proto_line(pt, pos) \
398 check_exp((uintptr_t)(pos) < (pt)->sizebc, proto_lineinfo(pt)[(pos)])
396 399
397/* -- Upvalue object ------------------------------------------------------ */ 400/* -- Upvalue object ------------------------------------------------------ */
398 401
diff --git a/src/lj_parse.c b/src/lj_parse.c
index 864f9e20..a3291553 100644
--- a/src/lj_parse.c
+++ b/src/lj_parse.c
@@ -247,19 +247,22 @@ static void patchlist(FuncState *fs, BCPos list, BCPos target)
247static BCPos emitINS(FuncState *fs, BCIns i) 247static BCPos emitINS(FuncState *fs, BCIns i)
248{ 248{
249 GCproto *pt; 249 GCproto *pt;
250 BCIns *bc;
251 BCLine *lineinfo;
250 patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); 252 patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
251 fs->jpc = NO_JMP; 253 fs->jpc = NO_JMP;
252 pt = fs->pt; 254 pt = fs->pt;
255 bc = proto_bc(pt);
256 lineinfo = proto_lineinfo(pt);
253 if (LJ_UNLIKELY(fs->pc >= pt->sizebc)) { 257 if (LJ_UNLIKELY(fs->pc >= pt->sizebc)) {
254 BCIns *bc;
255 checklimit(fs, fs->pc, LJ_MAX_BCINS, "bytecode instructions"); 258 checklimit(fs, fs->pc, LJ_MAX_BCINS, "bytecode instructions");
256 bc = proto_bc(pt);
257 lj_mem_growvec(fs->L, bc, pt->sizebc, LJ_MAX_BCINS, BCIns); 259 lj_mem_growvec(fs->L, bc, pt->sizebc, LJ_MAX_BCINS, BCIns);
258 setmref(pt->bc, bc); 260 setmref(pt->bc, bc);
259 lj_mem_growvec(fs->L, pt->lineinfo, pt->sizelineinfo, LJ_MAX_BCINS, BCLine); 261 lj_mem_growvec(fs->L, lineinfo, pt->sizelineinfo, LJ_MAX_BCINS, BCLine);
262 setmref(pt->lineinfo, lineinfo);
260 } 263 }
261 *proto_insptr(pt, fs->pc) = i; 264 bc[fs->pc] = i;
262 pt->lineinfo[fs->pc] = fs->ls->lastline; 265 lineinfo[fs->pc] = fs->ls->lastline;
263 return fs->pc++; 266 return fs->pc++;
264} 267}
265 268
@@ -1233,6 +1236,7 @@ static void close_func(LexState *ls)
1233 GCproto *pt = fs->pt; 1236 GCproto *pt = fs->pt;
1234 BCIns *bc; 1237 BCIns *bc;
1235 GCRef *uvname; 1238 GCRef *uvname;
1239 BCLine *lineinfo;
1236 removevars(ls, 0); 1240 removevars(ls, 0);
1237 finalret(fs, pt); 1241 finalret(fs, pt);
1238 bc = proto_bc(pt); 1242 bc = proto_bc(pt);
@@ -1241,7 +1245,9 @@ static void close_func(LexState *ls)
1241 pt->sizebc = fs->pc; 1245 pt->sizebc = fs->pc;
1242 collectk(fs, pt); 1246 collectk(fs, pt);
1243 collectuv(fs, pt); 1247 collectuv(fs, pt);
1244 lj_mem_reallocvec(L, pt->lineinfo, pt->sizelineinfo, fs->pc, BCLine); 1248 lineinfo = proto_lineinfo(pt);
1249 lj_mem_reallocvec(L, lineinfo, pt->sizelineinfo, fs->pc, BCLine);
1250 setmref(pt->lineinfo, lineinfo);
1245 pt->sizelineinfo = fs->pc; 1251 pt->sizelineinfo = fs->pc;
1246 lj_mem_reallocvec(L, pt->varinfo, pt->sizevarinfo, fs->nlocvars, VarInfo); 1252 lj_mem_reallocvec(L, pt->varinfo, pt->sizevarinfo, fs->nlocvars, VarInfo);
1247 pt->sizevarinfo = fs->nlocvars; 1253 pt->sizevarinfo = fs->nlocvars;
@@ -1509,7 +1515,7 @@ static void funcargs(LexState *ls, ExpDesc *e)
1509 } 1515 }
1510 init_exp(e, VCALL, emitINS(fs, ins)); 1516 init_exp(e, VCALL, emitINS(fs, ins));
1511 e->u.s.aux = base; 1517 e->u.s.aux = base;
1512 fs->pt->lineinfo[fs->pc - 1] = line; 1518 proto_lineinfo(fs->pt)[fs->pc - 1] = line;
1513 fs->freereg = base+1; /* call removes function and arguments and leaves 1519 fs->freereg = base+1; /* call removes function and arguments and leaves
1514 (unless changed) one result */ 1520 (unless changed) one result */
1515} 1521}
@@ -1929,9 +1935,9 @@ static void forbody(LexState *ls, BCReg base, BCLine line, BCReg nvars,
1929 fixjump(fs, loop, fs->pc); 1935 fixjump(fs, loop, fs->pc);
1930 emitABC(fs, BC_ITERC, base+3, nvars+1, 2+1); 1936 emitABC(fs, BC_ITERC, base+3, nvars+1, 2+1);
1931 loopend = emitAJ(fs, BC_ITERL, base+3, NO_JMP); 1937 loopend = emitAJ(fs, BC_ITERL, base+3, NO_JMP);
1932 fs->pt->lineinfo[loopend-1] = line; 1938 proto_lineinfo(fs->pt)[loopend-1] = line;
1933 } 1939 }
1934 fs->pt->lineinfo[loopend] = line; /* pretend last op starts the loop */ 1940 proto_lineinfo(fs->pt)[loopend] = line; /* pretend last op starts the loop */
1935 fixjump(fs, loopend, loop+1); 1941 fixjump(fs, loopend, loop+1);
1936} 1942}
1937 1943
@@ -2091,7 +2097,7 @@ static void funcstat(LexState *ls, BCLine line)
2091 body(ls, &b, needself, line); 2097 body(ls, &b, needself, line);
2092 fs = ls->fs; 2098 fs = ls->fs;
2093 storevar(fs, &v, &b); 2099 storevar(fs, &v, &b);
2094 fs->pt->lineinfo[fs->pc - 1] = line; 2100 proto_lineinfo(fs->pt)[fs->pc - 1] = line;
2095} 2101}
2096 2102
2097static void exprstat(LexState *ls) 2103static void exprstat(LexState *ls)