Commit Graph

719 Commits

Author SHA1 Message Date
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
Roberto Ierusalimschy
093c16b67b new opcodes 'OP_LTI' and 'OP_LEI' 2017-11-27 15:44:31 -02:00
Roberto Ierusalimschy
73abfde2ef small simplifications around 'luaT_callorderTM' 2017-11-23 17:18:10 -02:00
Roberto Ierusalimschy
196c87c9ce no more 'stackless' implementation; 'luaV_execute' calls itself
recursively to execute function calls. 'unroll' continues all
executions suspended by an yield (through a long jump)
2017-11-23 14:41:16 -02:00
Roberto Ierusalimschy
3c230cc825 using 'A' for register instead of 'B' in relational opcodes
('R(A)' is already created by default for all instructions.)
2017-11-22 17:15:44 -02:00
Roberto Ierusalimschy
41f2936d8f new opcode 'OP_EQI' for equality with immediate numbers 2017-11-22 16:41:20 -02:00
Roberto Ierusalimschy
14c3aa12b5 more direct implementation for tail calls. 2017-11-21 12:18:03 -02:00
Roberto Ierusalimschy
f3ca52bfa9 in order comparison opcodes, fast track for floats too 2017-11-20 10:57:39 -02:00
Roberto Ierusalimschy
4c0e36a46e new instruction 'OP_EQK' (for equality with constants) 2017-11-16 10:59:14 -02:00
Roberto Ierusalimschy
5440b42f43 using 'trap' to stop 'luaV_execute' when necessary (tracing and
to update its copy of 'base' when the stack is reallocated)
2017-11-13 13:36:52 -02:00
Roberto Ierusalimschy
32fef60743 detail ('Protect' defined as an expression) 2017-11-08 17:01:02 -02:00
Roberto Ierusalimschy
26679ea35b new function 'luaV_flttointeger' to convert floats to integers (without
string coercions) + string operands to bitwise operations handled
by string metamethods
2017-11-08 12:50:23 -02:00
Roberto Ierusalimschy
c3e5946fb2 new format for JUMP instructions (to allow larger offsets) 2017-11-07 15:20:42 -02:00
Roberto Ierusalimschy
ad0704e40c back to 'CallInfo' (no gains with its removal) 2017-11-07 11:25:26 -02:00
Roberto Ierusalimschy
93fd67b793 no more 'CallInfo' structure 2017-11-04 10:57:02 -02:00
Roberto Ierusalimschy
7612f7735d removing uses of 'CallInfo' 2017-11-03 17:33:22 -02:00
Roberto Ierusalimschy
472c560705 no more useful fields in CallInfo 2017-11-03 15:22:54 -02:00
Roberto Ierusalimschy
54eb35a8aa more fields moved out of 'CallInfo' 2017-11-03 10:12:30 -02:00
Roberto Ierusalimschy
b9e76be8a6 using 'L->func' when possible 2017-11-01 16:20:48 -02:00
Roberto Ierusalimschy
c5482468fd baby steps to remove 'CallInfo': keeping 'L->func' correct 2017-10-31 15:54:35 -02:00
Roberto Ierusalimschy
a1ef58b3a5 eplicit 1-bit opcode operand 'k' 2017-10-04 18:56:32 -03:00
Roberto Ierusalimschy
8fbe9e3470 new opcodes with immediate integer operand for all arithmetic operations 2017-10-04 12:49:24 -03:00
Roberto Ierusalimschy
bc1b0733b8 avoid the use of bit 'Bk' ('B' will lose this bit soon) 2017-10-01 16:13:43 -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
1b10033583 new function 'luaT_trybiniTM'
to handle tag methods for instructions with immediate integer arguments
2017-09-27 15:59:08 -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
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
4dff277255 coercion string->number in arithmetic operations moved to string
library
2017-07-07 13:34:32 -03:00
Roberto Ierusalimschy
07db10813c 'OP_VARARG' has the vararg parameter as an operand 2017-06-29 12:38:41 -03:00
Roberto Ierusalimschy
f96497397a new type 'StackValue' for stack elements
(we may want to put extra info there in the future)
2017-06-29 12:06:44 -03:00
Roberto Ierusalimschy
d13a3fb070 detail
(removed empty spaces at the end of lines)
2017-06-09 16:16:41 -03:00
Roberto Ierusalimschy
b029e7ea20 macro 'luaV_fastget' may need protection ({}) to be used inside
'if's
2017-06-01 17:22:33 -03:00
Roberto Ierusalimschy
c25380c28d details (using proper version of 'setobj') 2017-05-23 09:50:11 -03:00
Roberto Ierusalimschy
de74289049 table field names for dedicated opcodes can be restricted to
small strings for slightly faster access
2017-05-18 16:44:19 -03:00
Roberto Ierusalimschy
92b3deaffa details in OP_CALL + comments 2017-05-18 16:34:39 -03:00
Roberto Ierusalimschy
6d95de83c6 no more field 'base' in CallInfo (base is always equal to 'func + 1',
with old/new vararg implementation)
2017-05-13 10:54:47 -03:00
Roberto Ierusalimschy
5c8770f896 back to old-style vararg system (with vararg table collecting extra
arguments)
2017-05-13 10:04:33 -03:00
Roberto Ierusalimschy
7647d5d13d revamp of fast track for table access (table set uses the same
macros as table get + new macro for integer keys)
2017-05-11 15:57:46 -03:00
Roberto Ierusalimschy
7184f6343a more integer fast tracks (for OP_LT, OP_LE, OP_SETTABLE, and OP_GETTABLE) 2017-05-10 14:32:19 -03:00
Roberto Ierusalimschy
ab5a650029 details (direct access to 'Ck' bit in instructions) 2017-05-08 13:08:01 -03:00
Roberto Ierusalimschy
e8757a73e6 'luaV_execute' keeps local copy of program counter and hook mask,
to avoid excessive access to globals.
2017-05-05 14:16:11 -03:00
Roberto Ierusalimschy
2376eb6347 barrier for prototype's cache (with new gray list 'protogray' to keep
prototypes to have their caches visited again) + constant 'MAXMISS'
2017-05-04 10:32:01 -03:00
Roberto Ierusalimschy
8634b2a011 added 'cachemiss' field to prototype to avoid wasting time checking
hits that fail too often
2017-04-30 17:43:26 -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
cb3d5dce30 opcodes 'OP_GETTABUP'/'OP_SETTABUP' operate only with string keys,
so they can use fast-track table access
2017-04-24 17:26:39 -03:00
Roberto Ierusalimschy
6a98aa0bb0 new opcode LOADI (for loading immediate integers) 2017-04-20 16:53:55 -03:00
Roberto Ierusalimschy
a3d36fe283 Upvalues collected like everything else (with mark-sweep) instead
of reference count (simpler and better for generational mode)
2017-04-11 15:41:09 -03:00
Roberto Ierusalimschy
2331e1beec small changes in 'luaC_upvalbarrier' 2017-04-06 10:08:56 -03:00
Roberto Ierusalimschy
fd51651684 new macro 'vmfetch' to help changing code to computed goto's (macro
abstracts the code to run before each instruction)
2016-02-05 17:59:14 -02:00
Roberto Ierusalimschy
1a44e82200 'luaV_fastget' only treats the real fast case (table with a non-nil
value at given key, so that it does not need to check metamethods)
2016-01-05 14:07:21 -02:00
Roberto Ierusalimschy
a272fa66f0 bug: Metatable may access its own dealocated field when
it has a self reference in __newindex + some refactoring
2016-01-04 14:44:50 -02:00
Roberto Ierusalimschy
c5112f7b15 details (comments) 2015-11-23 09:30:45 -02:00
Roberto Ierusalimschy
d103312661 details (typos in comments) 2015-11-19 17:16:22 -02:00
Roberto Ierusalimschy
2e8f8a18e4 detail 2015-11-17 14:00:28 -02:00
Roberto Ierusalimschy
9a5d6aedb7 trying to optimize a little 'luaD_poscall' 2015-11-13 11:24:26 -02:00
Roberto Ierusalimschy
04587b6256 macro with empty argument can be seen as macro with no argument; better
to avoid that
2015-11-12 16:08:58 -02:00
Roberto Ierusalimschy
ff1289a361 in 'luaD_call', use two functions instead of one with fixed boolean
argument
2015-11-02 16:48:07 -02:00
Roberto Ierusalimschy
c5363a1b58 in 'luaD_precall', in vararg functions, complete missing parameters
only after moving them to final place (avoids checking the stack
again)
2015-11-02 12:06:01 -02:00
Roberto Ierusalimschy
07a2dcacbf flag CIST_REENTRY changed to CIST_FRESH (its negation); fresh invocations
seem to be less frequent than reentries. (So, avoid setting flag on
the frequent case.)
2015-11-02 09:43:17 -02:00
Roberto Ierusalimschy
257961c601 OP_SELF can use 'luaV_fastget' specialized for strings, as it
is applied only to string keys
2015-10-28 12:50:09 -02:00
Roberto Ierusalimschy
8004ab756f hook test in 'luaV_execute' reduced to minimum (rest done in
'luaG_traceexec'; no difference in performance for the non-hook
case, but keeps 'luaV_execute' a little simpler) + 'base' updates
replaced by 'Protect' (which serves this rule)
2015-10-22 12:40:47 -02:00
Roberto Ierusalimschy
f7670781cf cleaner definition for 'luaC_condGC', using 'pre'/'pos' parameters 2015-10-20 15:56:21 -02:00
Roberto Ierusalimschy
df8b996bcc 'Protect' in table operations is not needed in the fast track
+ removal of a few dead macros
2015-10-20 15:41:35 -02:00
Roberto Ierusalimschy
ee5edb6b68 macros 'getaddrstr' and 'getstr' unified (they do the same thing) 2015-09-17 12:51:05 -03:00
Roberto Ierusalimschy
b91bc93fd3 'setobj2t' incorporated into 'luaV_fastset' + 'invalidateTMcache'
is not needed in the fast track (as it does not create new
entries)
2015-09-09 10:44:07 -03:00
Roberto Ierusalimschy
41964648ee long strings are created directly in final position when possible
(instead of using an auxiliar buffer to first create the string
and then allocate the final string and copy result there)
2015-09-08 12:41:05 -03:00
Roberto Ierusalimschy
8f25d08637 'invalidateTMcache' not needed in all 'settable' uses 2015-08-03 17:40:26 -03:00
Roberto Ierusalimschy
3b795541c4 fast track for 'settable' 2015-08-03 16:50:49 -03:00
Roberto Ierusalimschy
e247c3ada3 implementation of fast track for gettable operations 2015-07-20 15:24:50 -03:00
Roberto Ierusalimschy
319ccfefbc computations in numerical for loop must avoid overflows too 2015-07-04 13:31:03 -03:00
Roberto Ierusalimschy
f01c12c891 detail (cast to avoid mixing types in conditional expression) 2015-06-25 11:00:01 -03:00
Roberto Ierusalimschy
a1415c0d72 bug in order NaN x int (tests must ensure that NaN does not get
converted to integer)
2015-06-09 12:53:35 -03:00
Roberto Ierusalimschy
ed1fe28bb8 When comparing integers with floats, use float as common type when
possible (i.e., when integer fits in a float without losses); seems
to be more efficient in architectures with native support for used
Lua numbers
2015-06-02 16:11:24 -03:00
Roberto Ierusalimschy
d39bb51faa bug: interpreter cannot pop activation frame before calling return
hook (as it may want to access local variables active by the end
of the function)
2015-05-22 14:48:19 -03:00
Roberto Ierusalimschy
6dc20ff293 'l <= r' for numbers has its own function, instead of using
'not (r < l)' (seems to be slightly more efficient)
2015-05-20 15:19:11 -03:00
Roberto Ierusalimschy
0ec12c1bd1 new semantics for numerical order (following math regardless
representation)
2015-05-20 13:22:55 -03:00
Roberto Ierusalimschy
04ba6ea83b new semantics for equality int-float 2015-04-29 15:27:16 -03:00
Roberto Ierusalimschy
ae76c39712 Bug: suspended '__le' metamethod can give wrong result 2015-04-10 14:56:25 -03:00
Roberto Ierusalimschy
abb2f5511d detail ('b + base' -> 'base + b' to follow all other similar uses) 2015-03-30 12:45:01 -03:00
Roberto Ierusalimschy
4ba0cb4580 always use macros to operate on lua_Numbers 2015-03-07 16:30:16 -03:00
Roberto Ierusalimschy
6408bc0b7f new macros 'chgfltvalue'/'chgivalue' (numerical for loop does
not need to set the type of its internal variable at each iteration)
2015-03-02 13:04:52 -03:00
Roberto Ierusalimschy
81245b1ad5 'numisinteger' (for table keys) replaced by 'luaV_tointeger' (old
'tointeger_aux'), which can do the same job.
2015-02-20 12:27:53 -02:00
Roberto Ierusalimschy
c8d6cb0136 macros 'luai_num*' (for float arithmetic operations) moved to
llimits.h.
2015-02-05 15:15:33 -02:00
Roberto Ierusalimschy
7e2015a46d size of short strings stored in a single byte, to reduce the size
of struct 'TString'
2015-01-16 14:54:37 -02:00
Roberto Ierusalimschy
50e2eb8954 change in macro 'vmcase', avoding code inside it. (Code inside the
macro harms tools such as debuggers.)
2014-12-27 18:30:38 -02:00
Roberto Ierusalimschy
2b83711fba new macro 'nvalue' (to convert an object to a float when we know
object is a number)
2014-12-19 11:36:32 -02:00
Roberto Ierusalimschy
049cf14cf9 'x//y' extended to floats + more comments about module and floor
division operations
2014-11-21 10:15:00 -02:00
Roberto Ierusalimschy
5d628519d3 simpler definition for 'luaV_tonumber_' 2014-11-19 13:05:15 -02:00
Roberto Ierusalimschy
bde14c3adc macro to change method of conversion from float to integer (make it
use floor intead of requiring an exact integral value)
2014-11-03 18:07:47 -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
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
463edee2fd 'lua_numtointeger' -> 'lua_numbertointeger' 2014-10-24 09:42:06 -02:00
Roberto Ierusalimschy
f97c64d7bf macros 'LUA_QL'/'LUA_QL' deprecated 2014-10-17 13:28:21 -03:00
Roberto Ierusalimschy
3a15c7ce43 size for array part of a table ('sizearray') changed from 'int' to
'unsigned int', which allows twice as many elements in the array part
2014-09-04 15:15:29 -03:00
Roberto Ierusalimschy
d861706620 new macro 'cvt2num' to better control whether strings are convertible
to numbers
2014-07-30 11:42:44 -03:00
Roberto Ierusalimschy
34ac039fb8 new macro 'cvt2str' to better control whether numbers are convertible
to strings
2014-07-30 11:00:14 -03:00
Roberto Ierusalimschy
17ee57f8e0 'iswhite' and related macros now can work directly on any object
(no need to convert to 'GCObject')
2014-07-21 13:02:10 -03:00
Roberto Ierusalimschy
ca41b43f53 type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
2014-07-18 10:36:14 -03:00
Roberto Ierusalimschy
8bb272a3e3 new conversion float->integer: conversion is valid only when
float has an exact representation as an integer
2014-07-17 09:30:53 -03:00
Roberto Ierusalimschy
b9dcf9974d detail (typos in comments) 2014-06-30 16:48:08 -03:00
Roberto Ierusalimschy
89b56e7d84 more precision between closure types ('LClosure' x 'CClosure') 2014-06-19 15:27:20 -03:00
Roberto Ierusalimschy
1a3656e56e more relaxed rules for __eq metamethod (more similar to other
operators)
2014-06-10 15:53:18 -03:00
Roberto Ierusalimschy
c98f195eb9 function 'luaV_numtointeger' changed to a global macro
'lua_numtointeger' (tricky, small, and useful in several places)
2014-05-26 14:10:22 -03:00
Roberto Ierusalimschy
36715ab7c1 detail (comment) 2014-05-23 15:32:21 -03:00
Roberto Ierusalimschy
8a0acf0898 comments 2014-05-20 11:12:59 -03:00
Roberto Ierusalimschy
3e977f02ac added a few comments 2014-05-15 17:08:32 -03:00
Roberto Ierusalimschy
f8daddba50 added a compat option (although it will be off by default) to
the addition of '.0' to float->string conversions
2014-05-14 16:47:11 -03:00
Roberto Ierusalimschy
45c430eac0 addition of '.0' to float representation done by the kernel 2014-05-12 18:44:17 -03:00
Roberto Ierusalimschy
27d9219cf3 no more integer exponentiation 2014-05-12 18:22:05 -03:00
Roberto Ierusalimschy
12bd01c567 added comments to several functions 2014-05-12 16:13:32 -03:00
Roberto Ierusalimschy
06dc893f88 in 'for' loops, make the limit an integer whenever initial value and
step are integers
2014-05-09 11:20:52 -03:00
Roberto Ierusalimschy
c549d4fe64 'lua_strtonum' (and 'luaO_str2num') now return string size, instead of
receiving it
2014-05-01 15:18:06 -03:00
Roberto Ierusalimschy
ddff6ecf30 function 'limittointeger' no needed (now that 'tointeger_aux' handles
integers too)
2014-04-30 16:29:51 -03:00
Roberto Ierusalimschy
1a6ef098b0 'luaO_str2d' + 'luaO_str2int' replaced by 'luaO_str2num' plus proper
conversion from strings to integers
2014-04-30 13:50:16 -03:00
Roberto Ierusalimschy
b123a88673 merge of common parts from 'limittointeger' and 'luaV_tointeger_' 2014-04-29 17:06:05 -03:00
Roberto Ierusalimschy
ffa43df3cd 'setnvalue' -> 'setfltvalue' (for consitency with 'fltvalue') 2014-04-29 15:14:16 -03:00
Roberto Ierusalimschy
9c4398de8f 'for' loop tries to convert limit to integer when initial value and
step are integers
2014-04-29 15:11:57 -03:00
Roberto Ierusalimschy
e98ba351ce n^-m gives float result (instead of error) 2014-04-27 11:41:11 -03:00
Roberto Ierusalimschy
037a70dfea cast_u2s/cast_s2u renamed l_castS2U/l_castU2S to be configurable from
outside (mostly for testing)
2014-04-15 13:32:49 -03:00
Roberto Ierusalimschy
8f961da3db macros cast_integer/cast_unsigned replaced by cast_u2s/cast_s2u, that
should be used only between lua_Integer and lua_Unsigned
2014-04-15 11:29:30 -03:00
Roberto Ierusalimschy
2771050dfa 'MIN/MAX_INTEGER' replaced by 'LUA_MIN/MAXINTEGER' 2014-04-11 16:02:16 -03:00
Roberto Ierusalimschy
a8aede68c7 new definition for 'luai_nummod' (using 'fmod') 2014-04-09 14:05:11 -03:00
Roberto Ierusalimschy
c7859a046d using 'volatile' in 'tofloat' to ensure result has the same precision
(lua_Number) of other computations
2014-04-08 11:28:04 -03:00
Roberto Ierusalimschy
7d514af0bc bug (in work version): comparisons should not try to convert
strings to numbers
2014-04-02 13:54:20 -03:00
Roberto Ierusalimschy
3d1c6730da detail ('1U' -> '1u', like other unsigned constants in the code) 2014-03-31 16:18:24 -03:00
Roberto Ierusalimschy
ea69f17d98 macro 'tostring' is used only by 'luaV_concat' 2014-03-31 15:37:52 -03:00
Roberto Ierusalimschy
114d10cbc5 detail (comment) 2014-03-15 09:29:48 -03:00
Roberto Ierusalimschy
9f3f5b6f41 details 2014-03-14 13:54:08 -03:00
Roberto Ierusalimschy
cd12410195 new macro 'cast_void' 2014-03-07 13:19:00 -03:00
Roberto Ierusalimschy
5ff1c18a71 back with 'L' for macros 'luai_num*', but now with a new macro
'luai_numinvalidop' to protect constant folding
2014-03-06 13:15:18 -03:00
Roberto Ierusalimschy
d438e1379d insertion of ".0" in floats with integer values done by "luaL_tolstring",
not by the core
2014-02-05 17:14:53 -02:00
Roberto Ierusalimschy
86dd8bf3f5 no more 'L' in macros "luai_num*" (several places that use those macros
cannot throw errors anyway...)
2014-01-27 11:34:32 -02:00
Roberto Ierusalimschy
0a850e641d larger limit + better error messages for loop detection in inheritance 2014-01-22 18:02: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
a8f8c7fd80 integer exponentiation with negative exponent is invalid 2013-12-16 12:30:22 -02:00
Roberto Ierusalimschy
26629d0af1 details (a few casts moved from macro invocation to macro definition) 2013-08-29 10:49:57 -03:00
Roberto Ierusalimschy
af35c7f398 upvalues collected by reference count 2013-08-27 15:53:35 -03:00