summaryrefslogtreecommitdiff
path: root/src/lj_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_parse.c')
-rw-r--r--src/lj_parse.c26
1 files changed, 16 insertions, 10 deletions
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)