diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-10 14:00:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-10 14:00:22 -0300 |
commit | 3d296304ef14ac9a6d1fa9357541ddd9bb54722f (patch) | |
tree | e7c8ac1ff0a0750b5db63da68adc0bfa676d1cc3 /lcode.c | |
parent | 54f7b46c1e8a0188e1649046a3a72522f2d769f4 (diff) | |
download | lua-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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -458,7 +458,7 @@ void luaK_reserveregs (FuncState *fs, int n) { | |||
458 | ) | 458 | ) |
459 | */ | 459 | */ |
460 | static void freereg (FuncState *fs, int reg) { | 460 | static 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 | } |