Commit Graph

96 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
0ddc0f47bd Several details about 5.4.0 rc1
Corrected several small details: added 'const', adjusts in tabs x
spaces, removed unused #includes and #defines, misspellings, etc.
2020-04-23 14:48:15 -03:00
Roberto Ierusalimschy
9b7987a9d1 OP_LOADFALSE broken in two instructions 2020-02-11 11:12:33 -03:00
Roberto Ierusalimschy
5ff408d218 Changed internal representation of booleans
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.)
2020-01-06 11:38:31 -03:00
Roberto Ierusalimschy
91dad09f65 Removed arithmetic opcodes with immediate operand
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.)
2019-09-10 13:20:03 -03:00
Roberto Ierusalimschy
4518e5df24 Added macro 'testMMMode'
Macro 'testMMMode' checks whether opcode is an MM opcode.
2019-09-06 14:14:11 -03:00
Roberto Ierusalimschy
df13f25948 First version of OP_MMBIN opcodes
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.)
2019-08-27 13:59:39 -03:00
Roberto Ierusalimschy
b80077b8f3 Change in the handling of 'L->top' when calling metamethods
Instead of updating 'L->top' in every place that may call a
metamethod, the metamethod functions themselves (luaT_trybinTM and
luaT_callorderTM) correct the top. (When calling metamethods from
the C API, however, the callers must preserve 'L->top'.)
2019-07-26 14:59:39 -03:00
Roberto Ierusalimschy
23e6bac8a0 Keep correct type for immediate operands in comparisons
When calling metamethods for things like 'a < 3.0', which generates
the opcode OP_LTI, the C register tells that the operand was
converted to an integer, so that it can be corrected to float when
calling a metamethod.

This commit also includes some other stuff:
- file 'onelua.c' added to the project
- opcode OP_PREPVARARG renamed to OP_VARARGPREP
- comparison opcodes rewritten through macros
2019-03-22 13:37:17 -03:00
Roberto Ierusalimschy
9b37a4695e New semantics for the integer 'for' loop
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.)
2019-03-19 10:53:18 -03:00
Roberto Ierusalimschy
84e32ad2eb Added opcodes for arithmetic with K operands
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').
2018-11-23 12:23:45 -02:00
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
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
f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy
b08c9079c5 Opcode names moved to a new header file
The array with the names of the opcodes was moved to a header file
('lopnames.h'), as it is not used by the Lua kernel. Files that need
that array ('luac.c' and 'ltests.c') include the header file to get
a private (static) copy.
2018-07-09 12:50:51 -03:00
Roberto Ierusalimschy
26eb144541 no need to define 'luaP_opnames' in regular builds 2018-04-19 12:42:41 -03:00
Roberto Ierusalimschy
03c6a05ec8 no more nil-in-table 2018-04-04 11:23:41 -03:00
Roberto Ierusalimschy
4a1612ff9b new experimental syntax using reserved word 'undef' 2018-03-07 12:55:38 -03:00
Roberto Ierusalimschy
212095a601 new opcodes OP_GTI/OP_GEI 2018-02-21 12:49:32 -03: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
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
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
745eb41993 new opcodes OP_RETURN0/OP_RETURN1 2017-11-29 14:57:36 -02:00
Roberto Ierusalimschy
093c16b67b new opcodes 'OP_LTI' and 'OP_LEI' 2017-11-27 15:44:31 -02:00
Roberto Ierusalimschy
41f2936d8f new opcode 'OP_EQI' for equality with immediate numbers 2017-11-22 16:41:20 -02:00
Roberto Ierusalimschy
4c0e36a46e new instruction 'OP_EQK' (for equality with constants) 2017-11-16 10:59:14 -02:00
Roberto Ierusalimschy
c3e5946fb2 new format for JUMP instructions (to allow larger offsets) 2017-11-07 15:20:42 -02:00
Roberto Ierusalimschy
8fbe9e3470 new opcodes with immediate integer operand for all arithmetic operations 2017-10-04 12:49:24 -03:00
Roberto Ierusalimschy
722bdbe17d no more 'getBMode'-'getCMode' (imprecise + we will need more space
for op mode) + better control of op modes
2017-09-28 13:53:29 -03:00
Roberto Ierusalimschy
00e728af88 binary operators use R instead of RK
faster + nobody uses RK(B), so B can be smaller (freeing one bit
for more opcodes, soon)
2017-09-26 15:14:45 -03:00
Roberto Ierusalimschy
abb17cf19b new opcode OP_LOADF (load immediate float) 2017-09-19 15:38:14 -03:00
Roberto Ierusalimschy
022e4427cf detail (keep OP_LOADK and OP_LOADKX together) 2017-09-15 11:19:06 -03:00
Roberto Ierusalimschy
80d9b09f35 jumps do not close upvalues (to be faster and simpler);
explicit instruction to close upvalues; command 'break' not
handled like a 'goto' (to optimize removal of uneeded 'close'
instructions)
2017-09-13 16:50:08 -03:00
Roberto Ierusalimschy
ac65bab25f jumps in 'for' loops don't need to be signed 2017-08-14 15:33:14 -03:00
Roberto Ierusalimschy
07db10813c 'OP_VARARG' has the vararg parameter as an operand 2017-06-29 12:38:41 -03:00
Roberto Ierusalimschy
502a1d1108 new opcodes for table access with constant keys (strings and integers) 2017-04-28 17:57:45 -03:00
Roberto Ierusalimschy
173e41b2eb new opcode OP_ADDI (for immediate integer operand) (Experimental) 2017-04-26 14:46:52 -03:00
Roberto Ierusalimschy
6a98aa0bb0 new opcode LOADI (for loading immediate integers) 2017-04-20 16:53:55 -03:00
Roberto Ierusalimschy
3317f5c6d9 includes 'stddef.h' (as it uses NULL) 2015-01-05 11:48:33 -02:00
Roberto Ierusalimschy
28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
1ea2d20f74 first implementation of '<<', '>>', and '~' (bitwise not) 2013-12-30 18:47:58 -02:00
Roberto Ierusalimschy
c0edab0f6d first implementation of bitwise operators '&' (band), '|' (bor),
and '~' (bxor)
2013-12-18 12:12:03 -02:00
Roberto Ierusalimschy
a948054a19 new order for binary operations (grouping them by type of result) 2013-12-16 17:06:52 -02:00
Roberto Ierusalimschy
a2f5c28a80 new operation '//' (integer division) 2013-04-26 10:08:29 -03:00
Roberto Ierusalimschy
edfa9e007d details (header comments) 2012-05-14 10:34:18 -03:00
Roberto Ierusalimschy
4758113043 change in opcode OP_LOADNIL: B is used as a counter instead of a
register. (Avoids an assignment to R(B), not present in any other
instruction.)
2011-04-19 13:22:13 -03:00
Roberto Ierusalimschy
c86586e866 small corrections in description of OP_TEST and OP_LOADKX 2011-04-12 14:27:35 -03:00