From 93fd67b7936f0f1fc20645d18eb85a193887c315 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Sat, 4 Nov 2017 10:57:02 -0200 Subject: no more 'CallInfo' structure --- lstate.c | 57 ++++----------------------------------------------------- 1 file changed, 4 insertions(+), 53 deletions(-) (limited to 'lstate.c') diff --git a/lstate.c b/lstate.c index 8e3177ca..76daa2e7 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.143 2017/10/31 17:54:35 roberto Exp roberto $ +** $Id: lstate.c,v 2.144 2017/11/03 12:12:30 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -97,51 +97,8 @@ void luaE_setdebt (global_State *g, l_mem debt) { } -CallInfo *luaE_extendCI (lua_State *L) { - CallInfo *ci = luaM_new(L, CallInfo); - lua_assert(L->ci->next == NULL); - L->ci->next = ci; - ci->previous = L->ci; - ci->next = NULL; - L->nci++; - return ci; -} - - -/* -** free all CallInfo structures not in use by a thread -*/ -void luaE_freeCI (lua_State *L) { - CallInfo *ci = L->ci; - CallInfo *next = ci->next; - ci->next = NULL; - while ((ci = next) != NULL) { - next = ci->next; - luaM_free(L, ci); - L->nci--; - } -} - - -/* -** free half of the CallInfo structures not in use by a thread -*/ -void luaE_shrinkCI (lua_State *L) { - CallInfo *ci = L->ci; - CallInfo *next2; /* next's next */ - /* while there are two nexts */ - while (ci->next != NULL && (next2 = ci->next->next) != NULL) { - luaM_free(L, ci->next); /* free next */ - L->nci--; - ci->next = next2; /* remove 'next' from the list */ - next2->previous = ci; - ci = next2; /* keep next's next */ - } -} - - static void stack_init (lua_State *L1, lua_State *L) { - int i; CallInfo *ci; + int i; /* initialize stack array */ L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, StackValue); L1->stacksize = BASIC_STACK_SIZE; @@ -149,24 +106,19 @@ static void stack_init (lua_State *L1, lua_State *L) { setnilvalue(s2v(L1->stack + i)); /* erase new stack */ L1->top = L1->stack; L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; - /* initialize first ci */ - ci = &L1->base_ci; - ci->next = ci->previous = NULL; - L1->func = ci->func = L1->top; + /* initialize first 'function' */ + L1->func = L1->stack; L1->func->stkci.previous = 0; /* end of linked list */ L1->func->stkci.framesize = LUA_MINSTACK + 1; callstatus(L1->func) = 0; setnilvalue(s2v(L1->top)); /* 'function' entry for this 'ci' */ L1->top++; - L1->ci = ci; } static void freestack (lua_State *L) { if (L->stack == NULL) return; /* stack not completely built yet */ - L->ci = &L->base_ci; /* free the entire 'ci' list */ - luaE_freeCI(L); lua_assert(L->nci == 0); luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ } @@ -216,7 +168,6 @@ static void f_luaopen (lua_State *L, void *ud) { static void preinit_thread (lua_State *L, global_State *g) { G(L) = g; L->stack = NULL; - L->ci = NULL; L->func = NULL; L->nci = 0; L->stacksize = 0; -- cgit v1.2.3-55-g6feb