aboutsummaryrefslogtreecommitdiff
path: root/lvm.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* DetailsRoberto Ierusalimschy2018-11-221-5/+7
| | | | comments and other janitorial work.
* To-be-closed variable in 'for' loop separated from the stateRoberto Ierusalimschy2018-11-071-11/+12
| | | | | | | | | The variable to be closed in a generic 'for' loop now is the 4th value produced in the loop initialization, instead of being the loop state (the 2nd value produced). That allows a loop to use a state with a '__toclose' metamethod but do not close it. (As an example, 'f:lines()' might use the file 'f' as a state for the loop, but it should not close the file when the loop ends.)
* New macros for arithmetic/bitwise operations in 'luaV_execute'Roberto Ierusalimschy2018-11-051-216/+152
| | | | | | | The repetitive code of the arithmetic and bitwise operators in the main iterpreter loop was moved to appropriate macros. (As a detail, the function 'luaV_div' was renamed 'luaV_idiv', as it does an "integer division" (floor division).
* Removed internal cache for closuresRoberto Ierusalimschy2018-11-011-37/+2
| | | | | | | | | | | | | | | | | | | The mechanism of "caching the last closure created for a prototype to try to reuse it the next time a closure for that prototype is created" was removed. There are several reasons: - It is hard to find a natural example where this cache has a measurable impact on performance. - Programmers already perceive closure creation as something slow, so they tend to avoid it inside hot paths. (Any case where the cache could reuse a closure can be rewritten predefining the closure in some variable and using that variable.) - The implementation was somewhat complex, due to a bad interaction with the generational collector. (Typically, new closures are new, while prototypes are old. So, the cache breaks the invariant that old objects should not point to new ones.)
* State in generic 'for' acts as a to-be-closed variableRoberto Ierusalimschy2018-10-311-13/+28
| | | | | | | | | | | The implicit variable 'state' in a generic 'for' is marked as a to-be-closed variable, so that the state will be closed as soon as the loop ends, no matter how. Taking advantage of this new facility, the call 'io.lines(filename)' now returns the open file as a second result. Therefore, an iteraction like 'for l in io.lines(name)...' will close the file even when the loop ends with a break or an error.
* Better error messages for invalid operands in numeric 'for'Roberto Ierusalimschy2018-10-301-4/+4
| | | | | | "Better" and similar to error messages for invalid function arguments. *old message: 'for' limit must be a number *new message: bad 'for' limit (number expected, got table)
* More uniformity in code generation for 'for' loopsRoberto Ierusalimschy2018-10-261-0/+4
| | | | | | | Added new instruction 'OP_TFORPREP' to prepare a generic for loop. Currently it is equivalent to a jump (but with a format 'iABx', similar to other for-loop preparing instructions), but soon it will be the place to create upvalues for closing loop states.
* Closing methods should not interfere with returning valuesRoberto Ierusalimschy2018-10-251-2/+4
| | | | | | | | | | | | A closing method cannot be called in its own stack slot, as there may be returning values in the stack after that slot, and the call would corrupt those values. Instead, the closing method must be copied to the top of the stack to be called. Moreover, even when a function returns no value, its return istruction still has to have its position (which will set the stack top) after the local variables, otherwise a closing method might corrupt another not-yet-called closing method.
* Handling of memory errors when creating to-be-closed upvaluesRoberto Ierusalimschy2018-10-181-2/+1
|
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-4/+3
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-081-0/+6
| | | | | | | | | | | | 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.
* Corrections in the implementation of '%' for floats.Roberto Ierusalimschy2018-08-281-6/+12
| | | | | | | | | The multiplication (m*b) used to test whether 'm' is non-zero and 'm' and 'b' have different signs can underflow for very small numbers, giving a wrong result. The use of explicit comparisons solves this problem. This commit also adds several new tests for '%' (both for floats and for integers) to exercise more corner cases, such as very large and very small values.
* Deprecated the emulation of '__le' using '__lt'Roberto Ierusalimschy2018-08-241-0/+2
| | | | | | | | | | | As hinted in the manual for Lua 5.3, the emulation of the metamethod for '__le' using '__le' has been deprecated. It is slow, complicates the logic, and it is easy to avoid this emulation by defining a proper '__le' function. Moreover, often this emulation was used wrongly, with a programmer assuming that an order is total when it is not (e.g., NaN in floating-point numbers).
* detailsRoberto Ierusalimschy2018-08-171-6/+6
| | | | | Minor optimizations in 'lvm.c'. (Not exactly optimizations, but more chances for optimizations.)
* Fixed bug in OP_IDIVIRoberto Ierusalimschy2018-07-091-2/+2
| | | | | Opocode was using 'luai_numdiv' (float division) instead of 'luai_numidiv' (integer division).
* in generational mode, an emergency collection can turn any object blackRoberto Ierusalimschy2018-06-181-3/+3
| | | | | | during any memory allocation + 'luaT_getvarargs' may reallocate the stack, and therefore the top must be correct.
* field 'sizearray' in struct 'Table' changed to 'alimit', which canRoberto Ierusalimschy2018-06-151-2/+2
| | | | be used as a hint for '#t'
* no more 'luaH_emptyobject' and comparisons of addresses of global variablesRoberto Ierusalimschy2018-06-011-5/+5
| | | | | (instead, use a different kind of nil to signal the fake entry returned when a key is not found in a table)
* new macros 'likely'/'unlikely' with hints for jump predictionsRoberto Ierusalimschy2018-05-301-11/+11
| | | | (used only in errors for now)
* in 'luaD_poscall', there is no need to compute 'firstResult' when 'nres==0'Roberto Ierusalimschy2018-05-221-9/+16
|
* minimizing the code ran by 'vmfetch' + no more 'vra'Roberto Ierusalimschy2018-05-021-113/+109
| | | | (the code is simpler without 'vra' and conversion is a no-op)
* no more nil-in-tableRoberto Ierusalimschy2018-04-041-14/+1
|
* using unsigned comparison in 'l_intfitsf' (avoids one comparison)Roberto Ierusalimschy2018-04-021-9/+13
|
* cannot use 'defined' inside a macro +Roberto Ierusalimschy2018-03-161-3/+8
| | | | call to 'luaT_keydef' must be protected
* new experimental syntax using reserved word 'undef'Roberto Ierusalimschy2018-03-071-1/+13
|
* using jump tables when availableRoberto Ierusalimschy2018-03-021-1/+14
|
* better names for macros for tags and types.Roberto Ierusalimschy2018-02-261-5/+5
| | | | | rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag; tnov -> ttype
* first version of empty entries in tablesRoberto Ierusalimschy2018-02-231-10/+11
| | | | (so that, in the future, tables can contain regular nil entries)
* conditional jumps "deunified"Roberto Ierusalimschy2018-02-211-15/+28
| | | | (if a jump table is used, the unification may harm jump prediction.)
* new opcodes OP_GTI/OP_GEIRoberto Ierusalimschy2018-02-211-17/+28
|
* simpler implementation for 'LTintfloat'/'LEintfloat'Roberto Ierusalimschy2018-02-211-45/+71
| | | | + 'LTfloatint'/'LEfloatint'
* small reorganization of 'luaV_flttointeger'/'luaV_tointeger'Roberto Ierusalimschy2018-02-211-21/+27
|
* more generic way to handle 'gclist'Roberto Ierusalimschy2018-02-191-3/+3
|
* correct way to check stack space for vararg functionsRoberto Ierusalimschy2018-02-171-4/+4
|
* some simplifications/optimizations in returns from Lua functionsRoberto Ierusalimschy2018-02-151-34/+26
|
* vararg back to '...' (but with another implementation)Roberto Ierusalimschy2018-02-091-13/+27
| | | | new implementation should have zero overhead for non-vararg functions
* new opcode 'PREPVARARG'Roberto Ierusalimschy2018-02-071-4/+19
| | | | (avoids test for vararg function in all function calls)
* call hooks for Lua functions called by 'luaV_execute'Roberto Ierusalimschy2018-02-061-2/+5
|
* warnings in VS (implicit casts from ptrdiff_t to int)Roberto Ierusalimschy2018-01-291-2/+2
|
* OP_CONCAT does not move its result (to simplify its execution)Roberto Ierusalimschy2018-01-271-17/+7
|
* 'OP_TAILCALL' calling C functions finishes the call and returnsRoberto Ierusalimschy2018-01-141-5/+10
| | | | (instead of waiting for following 'OP_RETURN')
* 'luaD_tryfuncTM' can ensure it does not change the stackRoberto Ierusalimschy2018-01-101-4/+2
|
* avoid jumping into a variable scope (C++ does not allow that)Roberto Ierusalimschy2018-01-091-8/+8
|
* typos in commentsRoberto Ierusalimschy2017-12-301-2/+2
|
* keep control of stack top in Lua functions concentrated in 'luaV_execute'Roberto Ierusalimschy2017-12-281-17/+29
|
* new macros 'isOT'/'isIT'Roberto Ierusalimschy2017-12-221-4/+4
| | | | | (plus exchanged parameters of OP_VARARG to make it similar to other 'isOT' instructions)
* when running Lua code, there is no need to keep 'L->top' "correct";Roberto Ierusalimschy2017-12-201-20/+6
| | | | set it only when needed.
* no need to save 'pc' in case of allocation errorsRoberto Ierusalimschy2017-12-191-3/+1
| | | | (allocation errors do not call message handlers)
* new opcodes 'FORLOOP1'/'FORPREP1' for "basic for" (integer variableRoberto Ierusalimschy2017-12-181-1/+27
| | | | with increment of 1)
* new opcodes BANDK/BORK/BXORK. (They do not use immediate operandsRoberto Ierusalimschy2017-12-131-1/+35
| | | | | because, too often, masks in bitwise operations are integers larger than one byte.)