mirror of https://github.com/rusefi/lua.git
global table now is only kept in the registry
This commit is contained in:
parent
064e406f67
commit
a8d3aa14fd
16
lapi.c
16
lapi.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lapi.c,v 2.116 2010/03/25 19:37:23 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.117 2010/03/26 20:58:11 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -843,11 +843,17 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
|
|||
if (!chunkname) chunkname = "?";
|
||||
luaZ_init(L, &z, reader, data);
|
||||
status = luaD_protectedparser(L, &z, chunkname);
|
||||
if (status == LUA_OK) {
|
||||
Closure *f = clvalue(L->top - 1);
|
||||
if (status == LUA_OK) { /* no errors? */
|
||||
Closure *f = clvalue(L->top - 1); /* get newly created function */
|
||||
lua_assert(!f->c.isC);
|
||||
if (f->l.nupvalues == 1)
|
||||
sethvalue(L, f->l.upvals[0]->v, G(L)->l_gt);
|
||||
if (f->l.nupvalues == 1) { /* does it have one upvalue? */
|
||||
/* get global table from registry */
|
||||
Table *reg = hvalue(&G(L)->l_registry);
|
||||
const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
|
||||
/* set global table as 1st upvalue of 'f' (may be _ENV) */
|
||||
setobj(L, f->l.upvals[0]->v, gt);
|
||||
luaC_barrier(L, f, gt);
|
||||
}
|
||||
}
|
||||
lua_unlock(L);
|
||||
return status;
|
||||
|
|
4
lgc.c
4
lgc.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lgc.c,v 2.73 2010/03/25 19:37:23 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.74 2010/03/26 20:58:11 roberto Exp roberto $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -235,8 +235,6 @@ static void markroot (lua_State *L) {
|
|||
g->grayagain = NULL;
|
||||
g->weak = g->ephemeron = g->allweak = NULL;
|
||||
markobject(g, g->mainthread);
|
||||
/* make global table and registry to be traversed before main stack */
|
||||
markobject(g, g->l_gt);
|
||||
markvalue(g, &g->l_registry);
|
||||
markmt(g);
|
||||
markbeingfnz(g); /* mark any finalizing object left from previous cycle */
|
||||
|
|
8
lstate.c
8
lstate.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.c,v 2.74 2010/03/25 19:37:23 roberto Exp roberto $
|
||||
** $Id: lstate.c,v 2.75 2010/03/26 20:58:11 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -140,8 +140,8 @@ static void init_registry (lua_State *L, global_State *g) {
|
|||
cp->c.f = ccall;
|
||||
setclvalue(L, &mt, cp);
|
||||
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_CCALL), &mt);
|
||||
/* registry[LUA_RIDX_GLOBALS] = l_gt */
|
||||
sethvalue(L, &mt, g->l_gt);
|
||||
/* registry[LUA_RIDX_GLOBALS] = table of globals */
|
||||
sethvalue(L, &mt, luaH_new(L));
|
||||
setobj2t(L, luaH_setint(L, registry, LUA_RIDX_GLOBALS), &mt);
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,6 @@ static void f_luaopen (lua_State *L, void *ud) {
|
|||
global_State *g = G(L);
|
||||
UNUSED(ud);
|
||||
stack_init(L, L); /* init stack */
|
||||
g->l_gt = luaH_new(L); /* table of globals */
|
||||
init_registry(L, g);
|
||||
luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */
|
||||
luaT_init(L);
|
||||
|
@ -256,7 +255,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
|
|||
g->strt.nuse = 0;
|
||||
g->strt.hash = NULL;
|
||||
setnilvalue(&g->l_registry);
|
||||
g->l_gt = NULL;
|
||||
luaZ_initbuffer(L, &g->buff);
|
||||
g->panic = NULL;
|
||||
g->version = lua_version(NULL);
|
||||
|
|
3
lstate.h
3
lstate.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.h,v 2.57 2010/03/25 19:37:23 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 2.58 2010/03/26 20:58:11 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -121,7 +121,6 @@ typedef struct global_State {
|
|||
lu_mem lastmajormem; /* memory in use after last major collection */
|
||||
stringtable strt; /* hash table for strings */
|
||||
TValue l_registry;
|
||||
struct Table *l_gt; /* table of globals */
|
||||
unsigned short nCcalls; /* number of nested C calls */
|
||||
lu_byte currentwhite;
|
||||
lu_byte gcstate; /* state of garbage collector */
|
||||
|
|
3
ltests.c
3
ltests.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltests.c,v 2.89 2010/03/25 13:06:36 roberto Exp roberto $
|
||||
** $Id: ltests.c,v 2.90 2010/03/26 20:58:11 roberto Exp roberto $
|
||||
** Internal Module for Debugging of the Lua Implementation
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -372,7 +372,6 @@ int lua_checkmemory (lua_State *L) {
|
|||
GCObject *o;
|
||||
UpVal *uv;
|
||||
checkliveness(g, &g->l_registry);
|
||||
lua_assert(!isdead(g, obj2gco(g->l_gt)));
|
||||
checkstack(g, g->mainthread);
|
||||
for (o = g->allgc; o != NULL; o = gch(o)->next) {
|
||||
lua_assert(!testbits(o->gch.marked, bitmask(SEPARATED)));
|
||||
|
|
Loading…
Reference in New Issue