Roberto Ierusalimschy
6e9b719694
More uniformity in code generation for 'for' loops
...
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.
2018-10-26 10:38:50 -03:00
Roberto Ierusalimschy
41c800b352
Closing methods should not interfere with returning values
...
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.
2018-10-25 12:50:20 -03:00
Roberto Ierusalimschy
3c7dc52909
Handling of memory errors when creating to-be-closed upvalues
2018-10-18 16:15:09 -03:00
Roberto Ierusalimschy
bd96330d03
First "complete" implementation of to-be-closed variables
...
Still missing:
- handling of memory errors when creating upvalue (must run closing
method all the same)
- interaction with coroutines
2018-10-17 10:44:42 -03:00
Roberto Ierusalimschy
4cd1f4aac0
Towards "to closed" local variables
...
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.
2018-10-08 10:42:07 -03:00
Roberto Ierusalimschy
5382a22e0e
Corrections in the implementation of '%' for floats.
...
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.
2018-08-28 12:36:58 -03:00
Roberto Ierusalimschy
8c8a91f2ef
Deprecated the emulation of '__le' using '__lt'
...
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).
2018-08-24 10:17:54 -03:00
Roberto Ierusalimschy
3dcd04ad61
details
...
Minor optimizations in 'lvm.c'. (Not exactly optimizations, but more
chances for optimizations.)
2018-08-17 15:53:39 -03:00
Roberto Ierusalimschy
06e08c6d05
Fixed bug in OP_IDIVI
...
Opocode was using 'luai_numdiv' (float division) instead of
'luai_numidiv' (integer division).
2018-07-09 12:41:24 -03:00
Roberto Ierusalimschy
a314409dba
in generational mode, an emergency collection can turn any object black
...
during any memory allocation +
'luaT_getvarargs' may reallocate the stack, and therefore the top must
be correct.
2018-06-18 14:58:21 -03:00
Roberto Ierusalimschy
6e600695f8
field 'sizearray' in struct 'Table' changed to 'alimit', which can
...
be used as a hint for '#t'
2018-06-15 11:14:20 -03:00
Roberto Ierusalimschy
fb8fa66136
no more 'luaH_emptyobject' and comparisons of addresses of global variables
...
(instead, use a different kind of nil to signal the fake entry returned
when a key is not found in a table)
2018-06-01 13:51:34 -03:00
Roberto Ierusalimschy
34aa0c5bd7
new macros 'likely'/'unlikely' with hints for jump predictions
...
(used only in errors for now)
2018-05-30 11:25:52 -03:00
Roberto Ierusalimschy
02ed0b2c30
in 'luaD_poscall', there is no need to compute 'firstResult' when 'nres==0'
2018-05-22 09:02:36 -03:00
Roberto Ierusalimschy
e64e20ac81
minimizing the code ran by 'vmfetch' + no more 'vra'
...
(the code is simpler without 'vra' and conversion is a no-op)
2018-05-02 15:17:59 -03:00
Roberto Ierusalimschy
03c6a05ec8
no more nil-in-table
2018-04-04 11:23:41 -03:00
Roberto Ierusalimschy
3d0b5edfe4
using unsigned comparison in 'l_intfitsf' (avoids one comparison)
2018-04-02 14:52:07 -03:00
Roberto Ierusalimschy
7b0b6b3b39
cannot use 'defined' inside a macro +
...
call to 'luaT_keydef' must be protected
2018-03-16 11:21:20 -03:00
Roberto Ierusalimschy
4a1612ff9b
new experimental syntax using reserved word 'undef'
2018-03-07 12:55:38 -03:00
Roberto Ierusalimschy
62a392ff46
using jump tables when available
2018-03-02 15:59:19 -03:00
Roberto Ierusalimschy
ef8263f81f
better names for macros for tags and types.
...
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag;
tnov -> ttype
2018-02-26 11:16:05 -03:00
Roberto Ierusalimschy
9243c414d9
first version of empty entries in tables
...
(so that, in the future, tables can contain regular nil entries)
2018-02-23 10:16:18 -03:00
Roberto Ierusalimschy
c72ac048b9
conditional jumps "deunified"
...
(if a jump table is used, the unification may harm jump prediction.)
2018-02-21 16:43:44 -03:00
Roberto Ierusalimschy
212095a601
new opcodes OP_GTI/OP_GEI
2018-02-21 12:49:32 -03:00
Roberto Ierusalimschy
06865aa01d
simpler implementation for 'LTintfloat'/'LEintfloat'
...
+ 'LTfloatint'/'LEfloatint'
2018-02-21 10:47:03 -03:00
Roberto Ierusalimschy
465b474899
small reorganization of 'luaV_flttointeger'/'luaV_tointeger'
2018-02-21 09:54:26 -03:00
Roberto Ierusalimschy
1afd5a152d
more generic way to handle 'gclist'
2018-02-19 17:06:56 -03:00
Roberto Ierusalimschy
49dae52d08
correct way to check stack space for vararg functions
2018-02-17 17:20:00 -02:00
Roberto Ierusalimschy
0682fe8169
some simplifications/optimizations in returns from Lua functions
2018-02-15 13:34:29 -02:00
Roberto Ierusalimschy
b1379936cf
vararg back to '...' (but with another implementation)
...
new implementation should have zero overhead for non-vararg functions
2018-02-09 13:16:06 -02:00
Roberto Ierusalimschy
318a9a5859
new opcode 'PREPVARARG'
...
(avoids test for vararg function in all function calls)
2018-02-07 13:18:04 -02:00
Roberto Ierusalimschy
51280ef2ad
call hooks for Lua functions called by 'luaV_execute'
2018-02-06 17:16:56 -02:00
Roberto Ierusalimschy
dc0ab1e8ca
warnings in VS (implicit casts from ptrdiff_t to int)
2018-01-29 14:21:35 -02:00
Roberto Ierusalimschy
5bd8d388de
OP_CONCAT does not move its result (to simplify its execution)
2018-01-27 14:56:33 -02:00
Roberto Ierusalimschy
d2fb34ac88
'OP_TAILCALL' calling C functions finishes the call and returns
...
(instead of waiting for following 'OP_RETURN')
2018-01-14 15:27:50 -02:00
Roberto Ierusalimschy
ab0a851db4
'luaD_tryfuncTM' can ensure it does not change the stack
2018-01-10 17:19:27 -02:00
Roberto Ierusalimschy
ad960095bf
avoid jumping into a variable scope (C++ does not allow that)
2018-01-09 12:23:40 -02:00
Roberto Ierusalimschy
a9295a2b8e
typos in comments
2017-12-30 18:46:18 -02:00
Roberto Ierusalimschy
cf7eff45f3
keep control of stack top in Lua functions concentrated in 'luaV_execute'
2017-12-28 13:42:57 -02:00
Roberto Ierusalimschy
4676f6599e
new macros 'isOT'/'isIT'
...
(plus exchanged parameters of OP_VARARG to make it similar to other
'isOT' instructions)
2017-12-22 12:16:46 -02:00
Roberto Ierusalimschy
1d5b885437
when running Lua code, there is no need to keep 'L->top' "correct";
...
set it only when needed.
2017-12-20 12:58:05 -02:00
Roberto Ierusalimschy
3153a41e33
no need to save 'pc' in case of allocation errors
...
(allocation errors do not call message handlers)
2017-12-19 14:18:04 -02:00
Roberto Ierusalimschy
d388c165ef
new opcodes 'FORLOOP1'/'FORPREP1' for "basic for" (integer variable
...
with increment of 1)
2017-12-18 15:53:50 -02:00
Roberto Ierusalimschy
86431a2f1c
new opcodes BANDK/BORK/BXORK. (They do not use immediate operands
...
because, too often, masks in bitwise operations are integers larger
than one byte.)
2017-12-13 16:32:09 -02:00
Roberto Ierusalimschy
c7ee7fe026
new opcodes OP_SHLI/OP_SHRI
2017-12-04 15:41:30 -02:00
Roberto Ierusalimschy
10b8c99bbb
small peephole optimizations
2017-11-30 11:29:18 -02:00
Roberto Ierusalimschy
745eb41993
new opcodes OP_RETURN0/OP_RETURN1
2017-11-29 14:57:36 -02:00
Roberto Ierusalimschy
c766e4103d
'luaV_execute' gets call info as extra argument (it is always
...
available on call sites)
2017-11-29 11:02:17 -02:00
Roberto Ierusalimschy
1a5e8c1014
conditional jumps unified in label "condjump' + new variable 'vra'
...
to avoid excessive use of macro 's2v'
2017-11-28 12:51:00 -02:00
Roberto Ierusalimschy
ff5fe51044
using register 'k' for conditions in tests (we only need one bit there)
2017-11-28 10:58:18 -02:00