Roberto Ierusalimschy
34840301b5
To-be-closed variables in the C API
6 years ago
Roberto Ierusalimschy
c90176f969
Complete implementation of to-be-closed variables
6 years ago
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
6 years ago
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.
6 years ago
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.
6 years ago
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.
6 years ago
Roberto Ierusalimschy
34aa0c5bd7
new macros 'likely'/'unlikely' with hints for jump predictions
(used only in errors for now)
7 years ago
Roberto Ierusalimschy
02ed0b2c30
in 'luaD_poscall', there is no need to compute 'firstResult' when 'nres==0'
7 years ago
Roberto Ierusalimschy
4907444db9
'fTransfer' -> 'ftransfer' / 'nTransfer' -> 'ntransfer'
(keep the standard of names in lower case)
7 years ago
Roberto Ierusalimschy
6480e73599
details (avoid using non-C89 '//' comment)
7 years ago
Roberto Ierusalimschy
8c429311a3
typo in comment
7 years ago
Roberto Ierusalimschy
ef8263f81f
better names for macros for tags and types.
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag;
tnov -> ttype
7 years ago
Roberto Ierusalimschy
422318f677
two new fields 'fTransfer'/'nTransfer' in 'lua_Debug' structure
(for information about values being given and returned in function calls)
7 years ago
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.)
7 years ago
Roberto Ierusalimschy
0682fe8169
some simplifications/optimizations in returns from Lua functions
7 years ago
Roberto Ierusalimschy
b1379936cf
vararg back to '...' (but with another implementation)
new implementation should have zero overhead for non-vararg functions
7 years ago
Roberto Ierusalimschy
4e0de3a43c
details
7 years ago
Roberto Ierusalimschy
318a9a5859
new opcode 'PREPVARARG'
(avoids test for vararg function in all function calls)
7 years ago
Roberto Ierusalimschy
51280ef2ad
call hooks for Lua functions called by 'luaV_execute'
7 years ago
Roberto Ierusalimschy
dc0ab1e8ca
warnings in VS (implicit casts from ptrdiff_t to int)
7 years ago
Roberto Ierusalimschy
89110986d7
bug in tailcall of vararg functions
(when adjusting missing parameters)
7 years ago
Roberto Ierusalimschy
53979dfe0d
calling a vararg function needs to check GC
(because it creates a new table)
7 years ago
Roberto Ierusalimschy
ab0a851db4
'luaD_tryfuncTM' can ensure it does not change the stack
7 years ago
Roberto Ierusalimschy
28323aeaa6
by-one error when filling missing arguments in a tail call
7 years ago
Roberto Ierusalimschy
8691612f01
when calling a hook, cannot decrease 'ci->top' (to preserve stack
size if the stack is reallocated)
7 years ago
Roberto Ierusalimschy
1d5b885437
when running Lua code, there is no need to keep 'L->top' "correct";
set it only when needed.
7 years ago
Roberto Ierusalimschy
4dc0be950a
new macro 'isLuacode' (to distinguish regular Lua code from
hooks, where C code can run inside a Lua function).
7 years ago
Roberto Ierusalimschy
b3f924bc69
'Proto->numparams' does not include vararg parameter
(one less subtraction when calling functions...)
7 years ago
Roberto Ierusalimschy
725c15a4ca
when shrinking stack, always shrinks the CI list.
(Stack overflow is not corelated to CI overflow anymore.)
7 years ago
Roberto Ierusalimschy
bfb88e99e9
'luaD_growstack' cannot raise any errors when 'raiseerror' is
false (+ some comments)
7 years ago
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.
7 years ago
Roberto Ierusalimschy
e0bece77d6
detail
7 years ago
Roberto Ierusalimschy
c766e4103d
'luaV_execute' gets call info as extra argument (it is always
available on call sites)
7 years ago
Roberto Ierusalimschy
194a4f9710
small simplifications in 'luaD_poscall'
7 years ago
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)
7 years ago
Roberto Ierusalimschy
14c3aa12b5
more direct implementation for tail calls.
7 years ago
Roberto Ierusalimschy
5440b42f43
using 'trap' to stop 'luaV_execute' when necessary (tracing and
to update its copy of 'base' when the stack is reallocated)
7 years ago
Roberto Ierusalimschy
7d4828cc9f
avoid accessing wrong union field
7 years ago
Roberto Ierusalimschy
ad0704e40c
back to 'CallInfo' (no gains with its removal)
7 years ago
Roberto Ierusalimschy
93fd67b793
no more 'CallInfo' structure
7 years ago
Roberto Ierusalimschy
6bb3e40a8d
'lua_Debug' not using 'CallInfo'
7 years ago
Roberto Ierusalimschy
472c560705
no more useful fields in CallInfo
7 years ago
Roberto Ierusalimschy
54eb35a8aa
more fields moved out of 'CallInfo'
7 years ago
Roberto Ierusalimschy
ba36180fd7
new API for 'lua_resume' + cleaning the uses of the 'extra' field in
'CallInfo'
7 years ago
Roberto Ierusalimschy
b9e76be8a6
using 'L->func' when possible
7 years ago
Roberto Ierusalimschy
c5482468fd
baby steps to remove 'CallInfo': keeping 'L->func' correct
7 years ago
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)
7 years ago
Roberto Ierusalimschy
f96497397a
new type 'StackValue' for stack elements
(we may want to put extra info there in the future)
7 years ago
Roberto Ierusalimschy
c25380c28d
details (using proper version of 'setobj')
8 years ago
Roberto Ierusalimschy
6d95de83c6
no more field 'base' in CallInfo (base is always equal to 'func + 1',
with old/new vararg implementation)
8 years ago