aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-12 11:38:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-07-12 11:38:42 -0300
commitf6aab3ec1f111cd8d968bdcb7ca800e93b819d24 (patch)
tree4c36c418ecc9062e6d95de73457198b38b0afce9 /manual
parentbe8445d7e4b6122620c428877b51a27d464253d5 (diff)
downloadlua-f6aab3ec1f111cd8d968bdcb7ca800e93b819d24.tar.gz
lua-f6aab3ec1f111cd8d968bdcb7ca800e93b819d24.tar.bz2
lua-f6aab3ec1f111cd8d968bdcb7ca800e93b819d24.zip
First implementation of constant propagation
Local constant variables initialized with compile-time constants are optimized away from the code.
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of31
1 files changed, 19 insertions, 12 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 136e9022..61fcdaa3 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -223,7 +223,7 @@ In Lua, the global variable @Lid{_G} is initialized with this same value.
223so changing its value will affect only your own code.) 223so changing its value will affect only your own code.)
224 224
225When Lua loads a chunk, 225When Lua loads a chunk,
226the default value for its @id{_ENV} upvalue 226the default value for its @id{_ENV} variable
227is the global environment @seeF{load}. 227is the global environment @seeF{load}.
228Therefore, by default, 228Therefore, by default,
229free names in Lua code refer to entries in the global environment 229free names in Lua code refer to entries in the global environment
@@ -233,7 +233,7 @@ and some functions there operate on that environment.
233You can use @Lid{load} (or @Lid{loadfile}) 233You can use @Lid{load} (or @Lid{loadfile})
234to load a chunk with a different environment. 234to load a chunk with a different environment.
235(In C, you have to load the chunk and then change the value 235(In C, you have to load the chunk and then change the value
236of its first upvalue.) 236of its first upvalue; see @See{lua_setupvalue}.)
237 237
238} 238}
239 239
@@ -1224,7 +1224,7 @@ As such, chunks can define local variables,
1224receive arguments, and return values. 1224receive arguments, and return values.
1225Moreover, such anonymous function is compiled as in the 1225Moreover, such anonymous function is compiled as in the
1226scope of an external local variable called @id{_ENV} @see{globalenv}. 1226scope of an external local variable called @id{_ENV} @see{globalenv}.
1227The resulting function always has @id{_ENV} as its only upvalue, 1227The resulting function always has @id{_ENV} as its only external variable,
1228even if it does not use that variable. 1228even if it does not use that variable.
1229 1229
1230A chunk can be stored in a file or in a string inside the host program. 1230A chunk can be stored in a file or in a string inside the host program.
@@ -2241,8 +2241,8 @@ and so the second @id{x} refers to the outside variable.
2241Because of the @x{lexical scoping} rules, 2241Because of the @x{lexical scoping} rules,
2242local variables can be freely accessed by functions 2242local variables can be freely accessed by functions
2243defined inside their scope. 2243defined inside their scope.
2244A local variable used by an inner function is called 2244A local variable used by an inner function is called an @def{upvalue}
2245an @def{upvalue}, or @emphx{external local variable}, 2245(or @emphx{external local variable}, or simply @emphx{external variable})
2246inside the inner function. 2246inside the inner function.
2247 2247
2248Notice that each execution of a @Rw{local} statement 2248Notice that each execution of a @Rw{local} statement
@@ -4765,11 +4765,7 @@ and returns its name.
4765Returns @id{NULL} (and pushes nothing) 4765Returns @id{NULL} (and pushes nothing)
4766when the index @id{n} is greater than the number of upvalues. 4766when the index @id{n} is greater than the number of upvalues.
4767 4767
4768For @N{C functions}, this function uses the empty string @T{""} 4768See @Lid{debug.getupvalue} for more information about upvalues.
4769as a name for all upvalues.
4770(For Lua functions,
4771upvalues are the external local variables that the function uses,
4772and that are consequently included in its closure.)
4773 4769
4774} 4770}
4775 4771
@@ -8485,6 +8481,8 @@ The first parameter or local variable has @N{index 1}, and so on,
8485following the order that they are declared in the code, 8481following the order that they are declared in the code,
8486counting only the variables that are active 8482counting only the variables that are active
8487in the current scope of the function. 8483in the current scope of the function.
8484Compile-time constants may not appear in this listing,
8485if they were optimized away by the compiler.
8488Negative indices refer to vararg arguments; 8486Negative indices refer to vararg arguments;
8489@num{-1} is the first vararg argument. 8487@num{-1} is the first vararg argument.
8490The function returns @nil if there is no variable with the given index, 8488The function returns @nil if there is no variable with the given index,
@@ -8520,8 +8518,15 @@ This function returns the name and the value of the upvalue
8520with index @id{up} of the function @id{f}. 8518with index @id{up} of the function @id{f}.
8521The function returns @nil if there is no upvalue with the given index. 8519The function returns @nil if there is no upvalue with the given index.
8522 8520
8523Variable names starting with @Char{(} (open parenthesis) @C{)} 8521(For Lua functions,
8524represent variables with no known names 8522upvalues are the external local variables that the function uses,
8523and that are consequently included in its closure.)
8524
8525For @N{C functions}, this function uses the empty string @T{""}
8526as a name for all upvalues.
8527
8528Variable name @Char{?} (interrogation mark)
8529represents variables with no known names
8525(variables from chunks saved without debug information). 8530(variables from chunks saved without debug information).
8526 8531
8527} 8532}
@@ -8626,6 +8631,8 @@ The function returns @nil if there is no upvalue
8626with the given index. 8631with the given index.
8627Otherwise, it returns the name of the upvalue. 8632Otherwise, it returns the name of the upvalue.
8628 8633
8634See @Lid{debug.getupvalue} for more information about upvalues.
8635
8629} 8636}
8630 8637
8631@LibEntry{debug.setuservalue (udata, value, n)| 8638@LibEntry{debug.setuservalue (udata, value, n)|