summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-11 10:34:22 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-11 10:34:22 -0200
commit73517e86b02b47531bec189d4230e359274d8d04 (patch)
treed5ccf4675f7923be9cc328a210947afa71482a66
parent9e8face8d83646c830cc932bf97ae1c3f5fb48ba (diff)
downloadlua-73517e86b02b47531bec189d4230e359274d8d04.tar.gz
lua-73517e86b02b47531bec189d4230e359274d8d04.tar.bz2
lua-73517e86b02b47531bec189d4230e359274d8d04.zip
OP_TFORLOOP uses extra stack space
-rw-r--r--lcode.c4
-rw-r--r--lcode.h3
-rw-r--r--ldebug.c4
-rw-r--r--lparser.c3
4 files changed, 8 insertions, 6 deletions
diff --git a/lcode.c b/lcode.c
index 3e22de75..0d96f632 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 1.113 2002/11/14 16:15:53 roberto Exp roberto $ 2** $Id: lcode.c,v 1.114 2002/12/04 17:38:31 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -176,7 +176,7 @@ void luaK_concat (FuncState *fs, int *l1, int l2) {
176} 176}
177 177
178 178
179static void luaK_checkstack (FuncState *fs, int n) { 179void luaK_checkstack (FuncState *fs, int n) {
180 int newstack = fs->freereg + n; 180 int newstack = fs->freereg + n;
181 if (newstack > fs->f->maxstacksize) { 181 if (newstack > fs->f->maxstacksize) {
182 if (newstack >= MAXSTACK) 182 if (newstack >= MAXSTACK)
diff --git a/lcode.h b/lcode.h
index 3c5da39a..8a0eece9 100644
--- a/lcode.h
+++ b/lcode.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.h,v 1.36 2002/05/13 13:07:48 roberto Exp roberto $ 2** $Id: lcode.h,v 1.37 2002/06/12 19:16:00 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -47,6 +47,7 @@ int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
47void luaK_fixline (FuncState *fs, int line); 47void luaK_fixline (FuncState *fs, int line);
48void luaK_nil (FuncState *fs, int from, int n); 48void luaK_nil (FuncState *fs, int from, int n);
49void luaK_reserveregs (FuncState *fs, int n); 49void luaK_reserveregs (FuncState *fs, int n);
50void luaK_checkstack (FuncState *fs, int n);
50int luaK_stringK (FuncState *fs, TString *s); 51int luaK_stringK (FuncState *fs, TString *s);
51int luaK_numberK (FuncState *fs, lua_Number r); 52int luaK_numberK (FuncState *fs, lua_Number r);
52void luaK_dischargevars (FuncState *fs, expdesc *e); 53void luaK_dischargevars (FuncState *fs, expdesc *e);
diff --git a/ldebug.c b/ldebug.c
index 9f170c6b..bf58d0a8 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.141 2002/12/04 17:38:31 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.142 2002/12/06 17:15:35 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -364,7 +364,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
364 break; 364 break;
365 } 365 }
366 case OP_TFORLOOP: 366 case OP_TFORLOOP:
367 checkreg(pt, a+2+c); 367 checkreg(pt, a+c+5);
368 if (reg >= a) last = pc; /* affect all registers above base */ 368 if (reg >= a) last = pc; /* affect all registers above base */
369 /* go through */ 369 /* go through */
370 case OP_FORLOOP: 370 case OP_FORLOOP:
diff --git a/lparser.c b/lparser.c
index ef1a1b03..e016b835 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.200 2002/12/04 17:38:31 roberto Exp roberto $ 2** $Id: lparser.c,v 1.201 2002/12/06 17:09:00 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1070,6 +1070,7 @@ static void forlist (LexState *ls, TString *indexname) {
1070 check(ls, TK_IN); 1070 check(ls, TK_IN);
1071 line = ls->linenumber; 1071 line = ls->linenumber;
1072 adjust_assign(ls, nvars, explist1(ls, &e), &e); 1072 adjust_assign(ls, nvars, explist1(ls, &e), &e);
1073 luaK_checkstack(fs, 3); /* extra space to call generator */
1073 luaK_codeAsBx(fs, OP_TFORPREP, base, NO_JUMP); 1074 luaK_codeAsBx(fs, OP_TFORPREP, base, NO_JUMP);
1074 forbody(ls, base, line, nvars, 0); 1075 forbody(ls, base, line, nvars, 0);
1075} 1076}