aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-10 14:00:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-10 14:00:22 -0300
commit3d296304ef14ac9a6d1fa9357541ddd9bb54722f (patch)
treee7c8ac1ff0a0750b5db63da68adc0bfa676d1cc3 /lcode.c
parent54f7b46c1e8a0188e1649046a3a72522f2d769f4 (diff)
downloadlua-3d296304ef14ac9a6d1fa9357541ddd9bb54722f.tar.gz
lua-3d296304ef14ac9a6d1fa9357541ddd9bb54722f.tar.bz2
lua-3d296304ef14ac9a6d1fa9357541ddd9bb54722f.zip
Towards constant propagation
This commit detaches the number of active variables from the number of variables in the stack, during compilation. Soon, compile-time constants will be propagated and therefore will not exist during run time (in the stack).
Diffstat (limited to '')
-rw-r--r--lcode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lcode.c b/lcode.c
index cb6ea0dc..837253f4 100644
--- a/lcode.c
+++ b/lcode.c
@@ -458,7 +458,7 @@ void luaK_reserveregs (FuncState *fs, int n) {
458) 458)
459*/ 459*/
460static void freereg (FuncState *fs, int reg) { 460static void freereg (FuncState *fs, int reg) {
461 if (reg >= fs->nactvar) { 461 if (reg >= luaY_nvarstack(fs)) {
462 fs->freereg--; 462 fs->freereg--;
463 lua_assert(reg == fs->freereg); 463 lua_assert(reg == fs->freereg);
464 } 464 }
@@ -850,7 +850,7 @@ int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
850 if (e->k == VNONRELOC) { /* expression already has a register? */ 850 if (e->k == VNONRELOC) { /* expression already has a register? */
851 if (!hasjumps(e)) /* no jumps? */ 851 if (!hasjumps(e)) /* no jumps? */
852 return e->u.info; /* result is already in a register */ 852 return e->u.info; /* result is already in a register */
853 if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ 853 if (e->u.info >= luaY_nvarstack(fs)) { /* reg. is not a local? */
854 exp2reg(fs, e, e->u.info); /* put final result in it */ 854 exp2reg(fs, e, e->u.info); /* put final result in it */
855 return e->u.info; 855 return e->u.info;
856 } 856 }