Roberto Ierusalimschy
c90176f969
Complete implementation of to-be-closed variables
2018-10-22 14:55:51 -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
b114c7d487
Added "cost" for the use of C stack by a coroutine invocation.
...
Resuming a coroutine uses more C stack than other operations (such as
function calls or recursive syntax). So, to avoid stack overflow
in recursive coroutine invocations, either LUAI_MAXCCALLS must be
too small or a coroutine invocation must "pay" a higher price.
New constant LUAL_COROCSTK ("COROutine C STaK") defines how much
is this price.
2018-09-11 14:24:14 -03:00
Roberto Ierusalimschy
96f9643f33
Bug: wrong 'nCcalls' when resuming a coroutine
...
The counter 'nCcalls' now includes the number of CallInfo structures
pre-allocated (so that these "potential" C calls can be made without
checking 'nCcalls'). So, when copying this value from a thread to
another, in 'lua_resume', it must be corrected to the number of
CallInfo structures in the thread being resumed.
2018-07-11 16:11:50 -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
4907444db9
'fTransfer' -> 'ftransfer' / 'nTransfer' -> 'ntransfer'
...
(keep the standard of names in lower case)
2018-03-16 12:33:34 -03:00
Roberto Ierusalimschy
6480e73599
details (avoid using non-C89 '//' comment)
2018-03-07 13:26:01 -03:00
Roberto Ierusalimschy
8c429311a3
typo in comment
2018-03-05 11:13:55 -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
422318f677
two new fields 'fTransfer'/'nTransfer' in 'lua_Debug' structure
...
(for information about values being given and returned in function calls)
2018-02-17 17:29:29 -02:00
Roberto Ierusalimschy
104d249ffb
in return hook, 'top' must be corrected only if smaller than 'ci->top'.
...
(It may be larger when returning multiple values, and then it must
be larger to preserve that stack slice.)
2018-02-17 16:22: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
4e0de3a43c
details
2018-02-07 13:55:18 -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
89110986d7
bug in tailcall of vararg functions
...
(when adjusting missing parameters)
2018-01-28 11:39:52 -02:00
Roberto Ierusalimschy
53979dfe0d
calling a vararg function needs to check GC
...
(because it creates a new table)
2018-01-28 10:08:04 -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
28323aeaa6
by-one error when filling missing arguments in a tail call
2017-12-29 13:44:51 -02:00
Roberto Ierusalimschy
8691612f01
when calling a hook, cannot decrease 'ci->top' (to preserve stack
...
size if the stack is reallocated)
2017-12-28 12:17:09 -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
4dc0be950a
new macro 'isLuacode' (to distinguish regular Lua code from
...
hooks, where C code can run inside a Lua function).
2017-12-19 14:40:17 -02:00
Roberto Ierusalimschy
b3f924bc69
'Proto->numparams' does not include vararg parameter
...
(one less subtraction when calling functions...)
2017-12-15 11:07:10 -02:00
Roberto Ierusalimschy
725c15a4ca
when shrinking stack, always shrinks the CI list.
...
(Stack overflow is not corelated to CI overflow anymore.)
2017-12-12 09:57:30 -02:00
Roberto Ierusalimschy
bfb88e99e9
'luaD_growstack' cannot raise any errors when 'raiseerror' is
...
false (+ some comments)
2017-12-11 10:43:40 -02:00
Roberto Ierusalimschy
e663a24ab0
more freedom in handling memory-allocation errors (not all allocations
...
automatically raise an error), which allows fixing a bug when resizing
a table.
2017-12-08 15:28:25 -02:00
Roberto Ierusalimschy
e0bece77d6
detail
2017-12-01 13:44:51 -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
194a4f9710
small simplifications in 'luaD_poscall'
2017-11-23 16:29:41 -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
14c3aa12b5
more direct implementation for tail calls.
2017-11-21 12:18:03 -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
7d4828cc9f
avoid accessing wrong union field
2017-11-13 10:26:30 -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
6bb3e40a8d
'lua_Debug' not using 'CallInfo'
2017-11-03 18:41:05 -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
ba36180fd7
new API for 'lua_resume' + cleaning the uses of the 'extra' field in
...
'CallInfo'
2017-11-02 09:28:56 -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
6d998055c8
no more reference 'memerrmsg' + new reference to "n"
...
(both can be retrieved by 'luaS_newliteral' without creating anything,
because they are fixed, but "n" deserves fast access while 'memerrmsg'
does not)
2017-07-27 10:50:16 -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
c25380c28d
details (using proper version of 'setobj')
2017-05-23 09:50:11 -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
24f6e236a3
'moveresults' and 'luaD_poscall' moved up in the file
2016-12-13 13:52:21 -02:00
Roberto Ierusalimschy
8edbf57fb8
detail (ANSI C does not accept empty arguments to macros)
2016-09-20 13:37:45 -03:00
Roberto Ierusalimschy
7fe1a4cff3
cleaner and more correct code for 'luaD_shrinkstack' (the old
...
test "inuse <= LUAI_MAXSTACK" for stack overflow is not correct,
as the real maximum usable size is "LUAI_MAXSTACK - EXTRA_STACK")
2016-09-08 13:36:26 -03:00
Roberto Ierusalimschy
aeb4c6fff1
comments + removed unused variable
2016-09-05 15:53:02 -03:00
Roberto Ierusalimschy
e4a9e6fcca
do not eliminate varargs from functions that do not use varargs
...
(confuses the debug lib and gains very little in performance)
2016-08-01 16:51:24 -03:00
Roberto Ierusalimschy
9de2bb0d62
bug: When a coroutine tries to resume a non-suspended coroutine,
...
it coud do some mess (and break C assertions) before detecting the error.
Now it tests for those errors before anything else.
2016-07-29 14:12:44 -03:00
Roberto Ierusalimschy
a051b3323e
comments (about hooks vs signals)
2015-12-16 14:40:07 -02:00
Roberto Ierusalimschy
d103312661
details (typos in comments)
2015-11-19 17:16:22 -02:00
Roberto Ierusalimschy
9a5d6aedb7
trying to optimize a little 'luaD_poscall'
2015-11-13 11:24:26 -02:00
Roberto Ierusalimschy
e61ee8a036
in 'luaD_call', use two functions instead of one with fixed boolean
...
argument + stack error handling in 'luaD_call' moved to a separated
function
2015-11-02 16:48:49 -02:00
Roberto Ierusalimschy
8c1fb91802
macro 'incr_top' replaced by function 'luaD_inctop'. (It is not used
...
in critical time pathes, can save a few bytes without the macro)
2015-11-02 14:09:30 -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
ffd0d1232d
using more "conventional" loops in 'luaD_poscall' (probably a little
...
more efficient?)
2015-11-02 09:48:59 -02:00
Roberto Ierusalimschy
6707ce6349
function prepares vararg only if it really uses them (chunks
...
are always declared vararg but seldom uses them)
2015-10-28 15:28:40 -02:00
Roberto Ierusalimschy
ae515a346c
comments for luaD_precall/luaD_poscall
2015-10-28 10:25:36 -02:00
Roberto Ierusalimschy
3cdf1d676b
details (avoid 'case' inside block + avoid using one variable for
...
two roles)
2015-10-28 10:06:45 -02:00
Roberto Ierusalimschy
5bdee4f810
small changes to allow 'precall' to spend time preserving 'func'
...
only when needed (that is, when stack actually changes)
2015-10-21 16:40:47 -02: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
dcad08b76d
details (use original type when saving variable's value)
2015-06-18 11:19:52 -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
484bf14a6b
calls to 'luaC_checkGC' in luaD_precall moved near to 'luaD_checkstack'
...
(which is what can need memory)
2015-03-30 13:05:23 -03:00
Roberto Ierusalimschy
a30c66f0fc
macro 'luai_apicheck'/'api_check' back with a 'lua_State' parameter
...
(some people use it)
2015-03-06 16:49:50 -03:00
Roberto Ierusalimschy
9a38c08011
no need to ensure any stack space for panic function + some changes
...
in 'tryfuncTM' (small simplification)
2014-11-11 15:13:39 -02:00
Roberto Ierusalimschy
bfa0898312
bug: memory error in panic mode does not push error message on
...
the stack + stack check in tryfuncTM + comments
2014-11-10 15:42:04 -02:00
Roberto Ierusalimschy
e75c0148c3
comments (references to "ANSI C" changed to "ISO C", which is the
...
international name
2014-11-02 17:33: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
bdf566a8a3
`name' in comments changed to 'name'
2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
f97c64d7bf
macros 'LUA_QL'/'LUA_QL' deprecated
2014-10-17 13:28:21 -03:00
Roberto Ierusalimschy
85fc9ecd5f
detail ('G(L)' -> 'g')
2014-10-08 09:20:26 -03:00
Roberto Ierusalimschy
2a21f6c894
'lua_Kcontext' -> 'lua_KContext'
2014-10-07 15:29:13 -03:00
Roberto Ierusalimschy
2be88d5084
'lua_Ctx' -> 'lua_Kcontext'
2014-08-01 14:33:08 -03:00
Roberto Ierusalimschy
1aa4f69b51
new type 'lua_Ctx' for continuation-function contexts (to allow type
...
to be configurable)
2014-07-17 10:53:37 -03:00
Roberto Ierusalimschy
5bbb4a06a6
removed unused parameter Ä'L' in macro 'api_check' and company
2014-07-15 18:26:50 -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
fa3113ffbf
cleaner way to handle bit CIST_OAH (with auxiliar macros)
2014-06-12 16:07:30 -03:00
Roberto Ierusalimschy
d94bb6c273
janitor work on 'lua_resume' and related code
2014-06-11 13:01:55 -03:00
Roberto Ierusalimschy
88a9e51f34
bit-field CIST_YIELDED removed (it was never consulted)
2014-06-10 16:18:50 -03:00
Roberto Ierusalimschy
542b6cfc02
no need for field 'status' in structure 'CallInfo' (after removal
...
of 'lua_getctx') + field 'old_allowhook' can be packed into a single
bit
2014-06-10 15:51:21 -03:00
Roberto Ierusalimschy
6f6fd96e3b
new type lua_KFunction + no more 'lua_getctx'
2014-06-10 14:41:38 -03:00
Roberto Ierusalimschy
35a6aad0d7
added comments
2014-06-09 13:32:18 -03:00
Roberto Ierusalimschy
1bd70a8e40
new function 'lua_isyieldable' (and 'coroutine.isyieldable')
2014-05-08 10:52:20 -03:00
Roberto Ierusalimschy
da4811238a
details (typos in comments)
2014-03-21 10:52:33 -03:00
Roberto Ierusalimschy
c6c41e85b2
more uniformity for defining system-dependent features
2014-02-26 12:27:56 -03:00
Roberto Ierusalimschy
ffa96d988d
field 'op' renamed to 'open'
2014-02-15 11:12:01 -02:00
Roberto Ierusalimschy
7a8eb83b4a
bug: attempting to resume the running coroutine makes it unyieldable
2013-11-08 16:16:33 -02:00
Roberto Ierusalimschy
4c6dfc342b
CallInfo lists shrinks together with their associated stacks
2013-09-17 12:40:06 -03:00
Roberto Ierusalimschy
af35c7f398
upvalues collected by reference count
2013-08-27 15:53:35 -03:00
Roberto Ierusalimschy
fa3b126a23
BUG: stack overflow in vararg functions with many fixed
...
parameters called with few arguments
2013-04-19 18:05:04 -03:00
Roberto Ierusalimschy
b157f3546e
BUG: 'pcall' may not restore previous error function when
...
inside coroutines
2012-10-01 11:05:04 -03:00