lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 01f1ac36b13f4fb23527785add70afe64f275944
parent a4d06736d4a66e1653599fad3df39099bf5b1276
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed,  8 May 2002 14:34:01 -0300

`global' tables (registry, etc.) stored in proper place, not in the stack

Diffstat:
Mlgc.c | 6++++--
Mlstate.c | 4++--
Mlstate.h | 19++++++++++---------
3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/lgc.c b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 1.134 2002/04/05 18:54:31 roberto Exp roberto $ +** $Id: lgc.c,v 1.135 2002/04/23 15:04:39 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -100,7 +100,6 @@ static void marktable (GCState *st, Table *h) { if (!ismarked(h)) { h->mark = st->tmark; /* chain it for later traversal */ st->tmark = h; - marktable(st, h->metatable); } } @@ -153,6 +152,9 @@ static void markstacks (GCState *st) { luaE_closethread(st->L, L1->previous); /* collect it */ continue; } + markobject(st, defaultmeta(L1)); + markobject(st, gt(L1)); + markobject(st, registry(L1)); for (o=L1->stack; o<L1->top; o++) markobject(st, o); lim = o; diff --git a/lstate.c b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 1.92 2002/05/01 20:40:42 roberto Exp roberto $ +** $Id: lstate.c,v 1.93 2002/05/07 17:36:56 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -38,7 +38,7 @@ static int default_panic (lua_State *L) { static void stack_init (lua_State *L, lua_State *OL) { L->stack = luaM_newvector(OL, BASIC_STACK_SIZE, TObject); L->stacksize = BASIC_STACK_SIZE; - L->top = L->stack + RESERVED_STACK_PREFIX; + L->top = L->stack; L->stack_last = L->stack+(BASIC_STACK_SIZE-EXTRA_STACK)-1; L->base_ci = luaM_newvector(OL, BASIC_CI_SIZE, CallInfo); L->ci = L->base_ci; diff --git a/lstate.h b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 1.83 2002/04/16 17:08:28 roberto Exp roberto $ +** $Id: lstate.h,v 1.84 2002/04/23 15:04:39 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -50,23 +50,23 @@ struct lua_longjmp; /* defined in ldo.c */ /* -** reserve init of stack to store some global values +** array of `global' objects */ +#define NUMGLOBS 3 + /* default meta table (both for tables and udata) */ -#define defaultmeta(L) (L->stack) +#define defaultmeta(L) (L->globs) /* table of globals */ -#define gt(L) (L->stack + 1) +#define gt(L) (L->globs + 1) /* registry */ -#define registry(L) (L->stack + 2) - -#define RESERVED_STACK_PREFIX 3 +#define registry(L) (L->globs + 2) -/* space to handle TM calls */ -#define EXTRA_STACK 4 +/* space to handle TM calls and other temporary overflows */ +#define EXTRA_STACK 5 #define BASIC_CI_SIZE 8 @@ -130,6 +130,7 @@ struct lua_State { CallInfo *end_ci; /* points after end of ci array*/ CallInfo *base_ci; /* array of CallInfo's */ global_State *l_G; + TObject globs[NUMGLOBS]; /* registry, table of globals, etc. */ struct lua_longjmp *errorJmp; /* current error recover point */ UpVal *openupval; /* list of open upvalues in this stack */ lua_State *next; /* circular double linked list of states */