diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-10-06 15:50:24 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-10-12 12:29:09 -0300 |
| commit | 5aa36e894f5a0348dfd19bd9cdcdd27ce8aa5f05 (patch) | |
| tree | da97440202c35ef78d3ad9e440cba959835d88d9 /lstate.c | |
| parent | 9ecd446141f572252a57cb33d2bba6aa00d96a55 (diff) | |
| download | lua-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.c')
| -rw-r--r-- | lstate.c | 8 |
1 files changed, 3 insertions, 5 deletions
| @@ -180,12 +180,11 @@ LUAI_FUNC void luaE_incCstack (lua_State *L) { | |||
| 180 | static void stack_init (lua_State *L1, lua_State *L) { | 180 | static void stack_init (lua_State *L1, lua_State *L) { |
| 181 | int i; CallInfo *ci; | 181 | int i; CallInfo *ci; |
| 182 | /* initialize stack array */ | 182 | /* initialize stack array */ |
| 183 | L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, StackValue); | 183 | L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue); |
| 184 | L1->stacksize = BASIC_STACK_SIZE; | ||
| 185 | for (i = 0; i < BASIC_STACK_SIZE; i++) | 184 | for (i = 0; i < BASIC_STACK_SIZE; i++) |
| 186 | setnilvalue(s2v(L1->stack + i)); /* erase new stack */ | 185 | setnilvalue(s2v(L1->stack + i)); /* erase new stack */ |
| 187 | L1->top = L1->stack; | 186 | L1->top = L1->stack; |
| 188 | L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; | 187 | L1->stack_last = L1->stack + BASIC_STACK_SIZE; |
| 189 | /* initialize first ci */ | 188 | /* initialize first ci */ |
| 190 | ci = &L1->base_ci; | 189 | ci = &L1->base_ci; |
| 191 | ci->next = ci->previous = NULL; | 190 | ci->next = ci->previous = NULL; |
| @@ -206,7 +205,7 @@ static void freestack (lua_State *L) { | |||
| 206 | L->ci = &L->base_ci; /* free the entire 'ci' list */ | 205 | L->ci = &L->base_ci; /* free the entire 'ci' list */ |
| 207 | luaE_freeCI(L); | 206 | luaE_freeCI(L); |
| 208 | lua_assert(L->nci == 0); | 207 | lua_assert(L->nci == 0); |
| 209 | luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ | 208 | luaM_freearray(L, L->stack, stacksize(L) + EXTRA_STACK); /* free stack */ |
| 210 | } | 209 | } |
| 211 | 210 | ||
| 212 | 211 | ||
| @@ -256,7 +255,6 @@ static void preinit_thread (lua_State *L, global_State *g) { | |||
| 256 | L->stack = NULL; | 255 | L->stack = NULL; |
| 257 | L->ci = NULL; | 256 | L->ci = NULL; |
| 258 | L->nci = 0; | 257 | L->nci = 0; |
| 259 | L->stacksize = 0; | ||
| 260 | L->twups = L; /* thread has no upvalues */ | 258 | L->twups = L; /* thread has no upvalues */ |
| 261 | L->errorJmp = NULL; | 259 | L->errorJmp = NULL; |
| 262 | L->hook = NULL; | 260 | L->hook = NULL; |
