aboutsummaryrefslogtreecommitdiff
path: root/testes/code.lua (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Another way to compile goto'sRoberto Ierusalimschy2025-01-101-2/+11
| | | | | | | | | | | | The compilation of a goto or a label just create an entry and generate boilerplate code for the gotos. As we don't know yet whether it needs a CLOSE, we code a jump followed by a CLOSE, which is then dead code. When a block ends (and then we know for sure whether there are variables that need to be closed), we check the goto's against the labels of that block. When closing a goto against a label, if it needs a CLOSE, the compiler swaps the order of the jump and the CLOSE, making the CLOSE active.
* Flexible limit for use of registers by constructorsRoberto Ierusalimschy2024-06-271-0/+11
| | | | | | | | Instead of a fixed limit of 50 registers (which, in a bad worst case, can limit the nesting of constructors to 5 levels), the compiler computes an individual limit for each constructor based on how many registers are available when it runs. This limit then controls the frequency of SETLIST instructions.
* Clearer code for controlling maximum registersRoberto Ierusalimschy2024-06-261-0/+15
| | | | Plus, added a test to check that limit.
* Avoid excessive name pollution in test filesRoberto Ierusalimschy2022-12-281-3/+3
| | | | | Test files are more polite regarding the use of globals when locals would do, and when globals are necessary deleting them after use.
* Changes in cache for function constantsRoberto Ierusalimschy2021-03-301-0/+14
| | | | | | | | In 'lcode.c', when adding constants to the list of constants of a function, integers represent themselves in the cache and floats with integral values get a small delta to avoid collision with integers. (This change avoids creating artificial addresses; the old implementation converted integers to pointers to index the cache.)
* Details (do not affect regular code)Roberto Ierusalimschy2020-12-071-0/+14
| | | | | | | * Avoids multiple definitions of 'lua_assert' in test file. * Smaller C-stack limit in test mode. * Note in the manual about the use of false * Extra test for constant reuse.
* Removed optimization for «if ... then goto»Roberto Ierusalimschy2020-11-111-22/+0
| | | | | That optimization was too complex and caused some weird traces when debugging. The more common case «if ... then break» was kept.
* Changed internal representation of booleansRoberto Ierusalimschy2020-01-061-5/+5
| | | | | | | Instead of an explicit value (field 'b'), true and false use different tag variants. This avoids reading an extra field and results in more direct code. (Most code that uses booleans needs to distinguish between true and false anyway.)
* Janitorial workRoberto Ierusalimschy2019-10-011-2/+5
| | | | | | | - Several details in 'lcode.c' - A few more tests for code generation - Bug in assert in 'lcode.c' ("=" x "==") - Comments in 'lopcodes.h' and 'ltable.c'
* Subtraction of small constant integers optimized with OP_ADDIRoberto Ierusalimschy2019-09-241-0/+1
|
* Removed arithmetic opcodes with immediate operandRoberto Ierusalimschy2019-09-101-9/+9
| | | | | | | The difference in performance between immediate operands and K operands does not seem to justify all those extra opcodes. We only keep OP_ADDI, due to its ubiquity and because the difference is a little more relevant. (Later, OP_SUBI will be implemented by OP_ADDI, negating the constant.)
* Use of 'MMBIN' opcodes extended to shift operatorsRoberto Ierusalimschy2019-08-281-4/+4
| | | | Plus, this commit removes useless 'tm' parameters in 'op_*' macros.
* First version of OP_MMBIN opcodesRoberto Ierusalimschy2019-08-271-28/+35
| | | | | | | | | | | In arithmetic/bitwise operators, the call to metamethods is made in a separate opcode following the main one. (The main opcode skips this next one when the operation succeeds.) This change reduces slightly the size of the binary and the complexity of the arithmetic/bitwise opcodes. It also simplfies the treatment of errors and yeld/resume in these operations, as there are much fewer cases to consider. (Only OP_MMBIN/OP_MMBINI/OP_MMBINK, instead of all variants of all arithmetic/bitwise operators.)
* Change in the syntax of attributesRoberto Ierusalimschy2019-07-301-18/+18
| | | | | | | Attributes changed to posfixed ('x <const>', instead of '<const> x'), and "toclose" renamed to "close". Posfixed attributes seem to make it clearer that it applies to only one variable when there are multiple variables.
* Fixed small issue with constant propagationRoberto Ierusalimschy2019-07-171-4/+6
| | | | | | | | Constants directly assigned to other constants were not propagating: For instance, in local <const> k1 = 10 local <const> k2 = k1 'k2' were not treated as a compile-time constant.
* New kind of expression VKSTRRoberto Ierusalimschy2019-07-171-0/+17
| | | | | | | String literal expressions have their own kind VKSTR, instead of the generic VK. This allows strings to "cross" functions without entering their constant tables (e.g., if they are used only by some nested function).
* OP_NEWTABLE keeps exact size of arraysRoberto Ierusalimschy2019-07-121-2/+4
| | | | | | OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep the exact size of the array part of the table to be created. (Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
* First implementation of constant propagationRoberto Ierusalimschy2019-07-121-31/+58
| | | | | Local constant variables initialized with compile-time constants are optimized away from the code.
* New semantics for the integer 'for' loopRoberto Ierusalimschy2019-03-191-2/+2
| | | | | | | | | | | The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
* Added opcodes for arithmetic with K operandsRoberto Ierusalimschy2018-11-231-31/+51
| | | | | | | | Added opcodes for all seven arithmetic operators with K operands (that is, operands that are numbers in the array of constants of the function). They cover the cases of constant float operands (e.g., 'x + .0.0', 'x^0.5') and large integer operands (e.g., 'x % 10000').
* Back with optimization for 'if cond then goto'Roberto Ierusalimschy2018-10-301-1/+19
| | | | | | | | | | | | Statements like 'if cond then goto label' generate code so that the jump in the 'if' goes directly to the given label. This optimization cannot be done when the jump is backwards leaving the scope of some variable, as it cannot add the needed 'close' instruction. (The jumps were already generated by the 'if'.) This commit also added 'likely'/'unlikely' for tests for errors in the parser, and it changed the way breaks outside loops are detected. (Now they are detected like other goto's with undefined labels.)
* Big revamp in the implmentation of labels/gotosRoberto Ierusalimschy2018-10-291-12/+7
| | | | | | | | Added restriction that, when a label is created, there cannot be another label with the same name visible. That allows backward goto's to be resolved when they are read. Backward goto's get a close if they jump out of the scope of some variable; labels get a close only if previous goto to it jumps out of the scope of some upvalue.
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-081-1/+5
| | | | | | | | | | | | Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
* Added directory to test file names in '$Id:'Roberto Ierusalimschy2018-07-251-1/+1
| | | | | | | From the point of view of 'git', all names are relative to the root directory of the project. So, file names in '$Id:' also should be relative to that directory: the proper name for test file 'all.lua' is 'testes/all.lua'.
* In tests of opcodes, avoid coercion in bitwise operationRoberto Ierusalimschy2018-07-101-1/+1
|
* Added manual and tests for version 5.4-w2Roberto Ierusalimschy2018-07-091-0/+347