aboutsummaryrefslogtreecommitdiff
path: root/lstate.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-10-06 15:50:24 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-10-12 12:29:09 -0300
commit5aa36e894f5a0348dfd19bd9cdcdd27ce8aa5f05 (patch)
treeda97440202c35ef78d3ad9e440cba959835d88d9 /lstate.h
parent9ecd446141f572252a57cb33d2bba6aa00d96a55 (diff)
downloadlua-5aa36e894f5a0348dfd19bd9cdcdd27ce8aa5f05.tar.gz
lua-5aa36e894f5a0348dfd19bd9cdcdd27ce8aa5f05.tar.bz2
lua-5aa36e894f5a0348dfd19bd9cdcdd27ce8aa5f05.zip
No more field 'lua_State.stacksize'
The stack size is derived from 'stack_last', when needed. Moreover, the handling of stack sizes is more consistent, always excluding the extra space except when allocating/deallocating the array.
Diffstat (limited to 'lstate.h')
-rw-r--r--lstate.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/lstate.h b/lstate.h
index 5573898c..cbcf07e2 100644
--- a/lstate.h
+++ b/lstate.h
@@ -127,12 +127,20 @@ struct lua_longjmp; /* defined in ldo.c */
127#endif 127#endif
128 128
129 129
130/* extra stack space to handle TM calls and some other extras */ 130/*
131** Extra stack space to handle TM calls and some other extras. This
132** space is not included in 'stack_last'. It is used only to avoid stack
133** checks, either because the element will be promptly popped or because
134** there will be a stack check soon after the push. Function frames
135** never use this extra space, so it does not need to be kept clean.
136*/
131#define EXTRA_STACK 5 137#define EXTRA_STACK 5
132 138
133 139
134#define BASIC_STACK_SIZE (2*LUA_MINSTACK) 140#define BASIC_STACK_SIZE (2*LUA_MINSTACK)
135 141
142#define stacksize(th) cast_int((th)->stack_last - (th)->stack)
143
136 144
137/* kinds of Garbage Collection */ 145/* kinds of Garbage Collection */
138#define KGC_INC 0 /* incremental gc */ 146#define KGC_INC 0 /* incremental gc */
@@ -270,7 +278,7 @@ struct lua_State {
270 StkId top; /* first free slot in the stack */ 278 StkId top; /* first free slot in the stack */
271 global_State *l_G; 279 global_State *l_G;
272 CallInfo *ci; /* call info for current function */ 280 CallInfo *ci; /* call info for current function */
273 StkId stack_last; /* last free slot in the stack */ 281 StkId stack_last; /* end of stack (last element + 1) */
274 StkId stack; /* stack base */ 282 StkId stack; /* stack base */
275 UpVal *openupval; /* list of open upvalues in this stack */ 283 UpVal *openupval; /* list of open upvalues in this stack */
276 GCObject *gclist; 284 GCObject *gclist;
@@ -281,7 +289,6 @@ struct lua_State {
281 ptrdiff_t errfunc; /* current error handling function (stack index) */ 289 ptrdiff_t errfunc; /* current error handling function (stack index) */
282 l_uint32 nCcalls; /* number of nested (non-yieldable | C) calls */ 290 l_uint32 nCcalls; /* number of nested (non-yieldable | C) calls */
283 int oldpc; /* last pc traced */ 291 int oldpc; /* last pc traced */
284 int stacksize;
285 int basehookcount; 292 int basehookcount;
286 int hookcount; 293 int hookcount;
287 volatile l_signalT hookmask; 294 volatile l_signalT hookmask;