diff --git a/radio/src/lua/src/linit.c b/radio/src/lua/src/linit.c index 58e8c1dd9..6258b40d4 100644 --- a/radio/src/lua/src/linit.c +++ b/radio/src/lua/src/linit.c @@ -29,7 +29,7 @@ static const luaL_Reg loadedlibs[] = { {"_G", luaopen_base}, // {LUA_LOADLIBNAME, luaopen_package}, // {LUA_COLIBNAME, luaopen_coroutine}, - {LUA_TABLIBNAME, luaopen_table}, + // {LUA_TABLIBNAME, luaopen_table}, // {LUA_IOLIBNAME, luaopen_io}, // {LUA_OSLIBNAME, luaopen_os}, // {LUA_STRLIBNAME, luaopen_string}, diff --git a/radio/src/lua/src/lmem.c b/radio/src/lua/src/lmem.c index 83d2349ee..79ee944d3 100644 --- a/radio/src/lua/src/lmem.c +++ b/radio/src/lua/src/lmem.c @@ -40,7 +40,7 @@ -#define MINSIZEARRAY 4 +#define MINSIZEARRAY 2 void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, int limit, const char *what) { @@ -80,6 +80,7 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { if (nsize > realosize && g->gcrunning) luaC_fullgc(L, 1); /* force a GC whenever possible */ #endif + // TRACE("ALLOC %d %d", (int)osize, (int)nsize); newblock = (*g->frealloc)(g->ud, block, osize, nsize); if (newblock == NULL && nsize > 0) { api_check(L, nsize > realosize, diff --git a/radio/src/lua/src/lobject.h b/radio/src/lua/src/lobject.h index dd23b9143..7ee7ef9fa 100644 --- a/radio/src/lua/src/lobject.h +++ b/radio/src/lua/src/lobject.h @@ -8,6 +8,9 @@ #ifndef lobject_h #define lobject_h +#ifndef PACK +#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) +#endif #include @@ -101,9 +104,9 @@ typedef union Value Value; ** an actual value plus a tag with its type. */ -#define TValuefields Value value_; int tt_ +#define TValuefields Value value_; int8_t tt_ -typedef struct lua_TValue TValue; +#define TValue lua_TValue /* macro defining a nil value */ @@ -394,9 +397,9 @@ union Value { }; -struct lua_TValue { +PACK(typedef struct { TValuefields; -}; +}) lua_TValue; typedef TValue *StkId; /* index to stack elements */ @@ -543,10 +546,10 @@ typedef union Closure { */ typedef union TKey { - struct { + PACK(struct { TValuefields; struct Node *next; /* for chaining */ - } nk; + }) nk; TValue tvk; } TKey; @@ -560,7 +563,7 @@ typedef struct Node { typedef struct Table { CommonHeader; lu_byte flags; /* 1<

lsizenode)) +#define sizenode(t) ((t)->lsizenode) /* diff --git a/radio/src/lua/src/ltable.c b/radio/src/lua/src/ltable.c index 305149d6b..9ef8af5df 100644 --- a/radio/src/lua/src/ltable.c +++ b/radio/src/lua/src/ltable.c @@ -282,14 +282,16 @@ static void setnodevector (lua_State *L, Table *t, int size) { int lsize; if (size == 0) { /* no elements to hash part? */ t->node = cast(Node *, dummynode); /* use common `dummynode' */ - lsize = 0; + lsize = 1; } else { int i; - lsize = luaO_ceillog2(size); - if (lsize > MAXBITS) - luaG_runerror(L, "table overflow"); - size = twoto(lsize); + // lsize = luaO_ceillog2(size); + // if (lsize > MAXBITS) + // luaG_runerror(L, "table overflow"); + // size = twoto(lsize); + // size += size/2; + lsize = size; t->node = luaM_newvector(L, size, Node); for (i=0; iarray, oldasize, nasize, TValue); } /* re-insert elements from hash part */ - for (i = twoto(oldhsize) - 1; i >= 0; i--) { + for (i = oldhsize - 1; i >= 0; i--) { Node *old = nold+i; if (!ttisnil(gval(old))) { /* doesn't need barrier/invalidate cache, as entry was @@ -331,7 +333,7 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) { } } if (!isdummy(nold)) - luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */ + luaM_freearray(L, nold, cast(size_t, oldhsize)); /* free old array */ }