Commit dba57fa0 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Merge branch 'dev-esp32-idf4-lua53' into dev-esp32-idf4

parents 3a6961cc 8e5ce49d
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define lcode_c #define lcode_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <stdlib.h> #include <stdlib.h>
...@@ -781,8 +780,6 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { ...@@ -781,8 +780,6 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
} }
#ifdef LUA_OPTIMIZE_DEBUG
/* /*
* Attempted to write to last (null terminator) byte of lineinfo, so need * Attempted to write to last (null terminator) byte of lineinfo, so need
* to grow the lineinfo vector and extend the fill bytes * to grow the lineinfo vector and extend the fill bytes
...@@ -829,10 +826,8 @@ static void generateInfoDeltaLine(FuncState *fs, int line) { ...@@ -829,10 +826,8 @@ static void generateInfoDeltaLine(FuncState *fs, int line) {
fs->lastlineOffset = p - fs->f->packedlineinfo - 1; fs->lastlineOffset = p - fs->f->packedlineinfo - 1;
#undef addDLbyte #undef addDLbyte
} }
#endif
void luaK_fixline (FuncState *fs, int line) { void luaK_fixline (FuncState *fs, int line) {
#ifdef LUA_OPTIMIZE_DEBUG
/* The fixup line can be the same as existing one and in this case there's nothing to do */ /* The fixup line can be the same as existing one and in this case there's nothing to do */
if (line != fs->lastline) { if (line != fs->lastline) {
/* first remove the current line reference */ /* first remove the current line reference */
...@@ -863,9 +858,6 @@ void luaK_fixline (FuncState *fs, int line) { ...@@ -863,9 +858,6 @@ void luaK_fixline (FuncState *fs, int line) {
/* Then add the new line reference */ /* Then add the new line reference */
generateInfoDeltaLine(fs, line); generateInfoDeltaLine(fs, line);
} }
#else
fs->f->lineinfo[fs->pc - 1] = line;
#endif
} }
...@@ -877,7 +869,6 @@ static int luaK_code (FuncState *fs, Instruction i, int line) { ...@@ -877,7 +869,6 @@ static int luaK_code (FuncState *fs, Instruction i, int line) {
MAX_INT, "code size overflow"); MAX_INT, "code size overflow");
f->code[fs->pc] = i; f->code[fs->pc] = i;
/* save corresponding line information */ /* save corresponding line information */
#ifdef LUA_OPTIMIZE_DEBUG
/* note that frst time fs->lastline==0 through, so the else branch is taken */ /* note that frst time fs->lastline==0 through, so the else branch is taken */
if (fs->pc == fs->lineinfoLastPC+1) { if (fs->pc == fs->lineinfoLastPC+1) {
if (line == fs->lastline && f->packedlineinfo[fs->lastlineOffset] < INFO_MAX_LINECNT) { if (line == fs->lastline && f->packedlineinfo[fs->lastlineOffset] < INFO_MAX_LINECNT) {
...@@ -891,11 +882,6 @@ static int luaK_code (FuncState *fs, Instruction i, int line) { ...@@ -891,11 +882,6 @@ static int luaK_code (FuncState *fs, Instruction i, int line) {
luaK_fixline(fs,line); luaK_fixline(fs,line);
} }
fs->lineinfoLastPC = fs->pc; fs->lineinfoLastPC = fs->pc;
#else
luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int,
MAX_INT, "code size overflow");
f->lineinfo[fs->pc] = line;
#endif
return fs->pc++; return fs->pc++;
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define ldblib_c #define ldblib_c
#define LUA_LIB #define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <stdio.h> #include <stdio.h>
...@@ -18,8 +17,6 @@ ...@@ -18,8 +17,6 @@
#include "lualib.h" #include "lualib.h"
#include "lstring.h" #include "lstring.h"
#include "lflash.h" #include "lflash.h"
#include "lrotable.h"
#include "sdkconfig.h"
static int db_getregistry (lua_State *L) { static int db_getregistry (lua_State *L) {
...@@ -28,34 +25,16 @@ static int db_getregistry (lua_State *L) { ...@@ -28,34 +25,16 @@ static int db_getregistry (lua_State *L) {
} }
static int db_getstrings (lua_State *L) { static int db_getstrings (lua_State *L) {
size_t i,n=0; static const char *const opts[] = {"RAM","ROM",NULL};
stringtable *tb; int opt = luaL_checkoption(L, 1, "RAM", opts);
GCObject *o; if (lua_pushstringsarray(L, opt)) {
#ifndef LUA_CROSS_COMPILER if(lua_getglobal(L, "table") == LUA_TTABLE) {
const char *opt = lua_tolstring (L, 1, &n); lua_getfield(L, -1, "sort"); /* look up table.sort function */
if (n==3 && memcmp(opt, "ROM", 4) == 0) { lua_replace(L, -2); /* dump the table table */
if (G(L)->ROstrt.hash == NULL) lua_pushvalue(L, -2); /* duplicate the strt_copy ref */
return 0; lua_call(L, 1, 0); /* table.sort(strt_copy) */
tb = &G(L)->ROstrt;
}
else
#endif
tb = &G(L)->strt;
lua_settop(L, 0);
lua_createtable(L, tb->nuse, 0); /* create table the same size as the strt */
for (i=0, n=1; i<tb->size; i++) {
for(o = tb->hash[i]; o; o=o->gch.next) {
TString *ts =cast(TString *, o);
lua_pushnil(L);
setsvalue2s(L, L->top-1, ts);
lua_rawseti(L, -2, n++); /* enumerate the strt, adding elements */
} }
} }
lua_getfield(L, LUA_GLOBALSINDEX, "table");
lua_getfield(L, -1, "sort"); /* look up table.sort function */
lua_replace(L, -2); /* dump the table table */
lua_pushvalue(L, -2); /* duplicate the strt_copy ref */
lua_call(L, 1, 0); /* table.sort(strt_copy) */
return 1; return 1;
} }
...@@ -144,7 +123,7 @@ static int db_getinfo (lua_State *L) { ...@@ -144,7 +123,7 @@ static int db_getinfo (lua_State *L) {
return 1; return 1;
} }
} }
else if (lua_isfunction(L, arg+1) || lua_islightfunction(L, arg+1)) { else if (lua_isfunction(L, arg+1)) {
lua_pushfstring(L, ">%s", options); lua_pushfstring(L, ">%s", options);
options = lua_tostring(L, -1); options = lua_tostring(L, -1);
lua_pushvalue(L, arg+1); lua_pushvalue(L, arg+1);
...@@ -302,7 +281,7 @@ static int db_sethook (lua_State *L) { ...@@ -302,7 +281,7 @@ static int db_sethook (lua_State *L) {
} }
else { else {
const char *smask = luaL_checkstring(L, arg+2); const char *smask = luaL_checkstring(L, arg+2);
luaL_checkanyfunction(L, arg+1); luaL_checkfunction(L, arg+1);
count = luaL_optint(L, arg+3, 0); count = luaL_optint(L, arg+3, 0);
func = hookf; mask = makemask(smask, count); func = hookf; mask = makemask(smask, count);
} }
...@@ -367,7 +346,7 @@ static int db_debug (lua_State *L) { ...@@ -367,7 +346,7 @@ static int db_debug (lua_State *L) {
#define LEVELS1 12 /* size of the first part of the stack */ #define LEVELS1 12 /* size of the first part of the stack */
#define LEVELS2 10 /* size of the second part of the stack */ #define LEVELS2 10 /* size of the second part of the stack */
static int db_errorfb (lua_State *L) { static int debug_errorfb (lua_State *L) {
int level; int level;
int firstpart = 1; /* still before eventual `...' */ int firstpart = 1; /* still before eventual `...' */
int arg; int arg;
...@@ -419,7 +398,7 @@ static int db_errorfb (lua_State *L) { ...@@ -419,7 +398,7 @@ static int db_errorfb (lua_State *L) {
return 1; return 1;
} }
LROT_PUBLIC_BEGIN(dblib) LROT_BEGIN(dblib, NULL, 0)
#ifndef CONFIG_LUA_BUILTIN_DEBUG_MINIMAL #ifndef CONFIG_LUA_BUILTIN_DEBUG_MINIMAL
#if defined(LUA_CROSS_COMPILER) #if defined(LUA_CROSS_COMPILER)
LROT_FUNCENTRY( debug, db_debug ) LROT_FUNCENTRY( debug, db_debug )
...@@ -440,7 +419,7 @@ LROT_PUBLIC_BEGIN(dblib) ...@@ -440,7 +419,7 @@ LROT_PUBLIC_BEGIN(dblib)
LROT_FUNCENTRY( setmetatable, db_setmetatable ) LROT_FUNCENTRY( setmetatable, db_setmetatable )
LROT_FUNCENTRY( setupvalue, db_setupvalue ) LROT_FUNCENTRY( setupvalue, db_setupvalue )
#endif #endif
LROT_FUNCENTRY( traceback, db_errorfb ) LROT_FUNCENTRY( traceback, debug_errorfb )
LROT_END(dblib, NULL, 0) LROT_END(dblib, NULL, 0)
LUALIB_API int luaopen_debug (lua_State *L) { LUALIB_API int luaopen_debug (lua_State *L) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define ldebug_c #define ldebug_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <string.h> #include <string.h>
...@@ -183,8 +182,7 @@ static void info_tailcall (lua_Debug *ar) { ...@@ -183,8 +182,7 @@ static void info_tailcall (lua_Debug *ar) {
# define INFO_DELTA_7BITS 0x7F # define INFO_DELTA_7BITS 0x7F
# define INFO_MAX_LINECNT 126 # define INFO_MAX_LINECNT 126
Table *t = luaH_new(L, 0, 0); Table *t = luaH_new(L, 0, 0);
#ifdef LUA_OPTIMIZE_DEBUG
int line = 0; int line = 0;
unsigned char *p = f->l.p->packedlineinfo; unsigned char *p = f->l.p->packedlineinfo;
if (p) { if (p) {
...@@ -204,18 +202,11 @@ static void info_tailcall (lua_Debug *ar) { ...@@ -204,18 +202,11 @@ static void info_tailcall (lua_Debug *ar) {
setbvalue(luaH_setnum(L, t, line), 1); setbvalue(luaH_setnum(L, t, line), 1);
} }
} }
#else sethvalue(L, L->top, t);
int *lineinfo = f->l.p->lineinfo;
int i;
for (i=0; i<f->l.p->sizelineinfo; i++)
setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
#endif
sethvalue(L, L->top, t);
} }
incr_top(L); incr_top(L);
} }
#ifdef LUA_OPTIMIZE_DEBUG
/* /*
* This may seem expensive but this is only accessed frequently in traceexec * This may seem expensive but this is only accessed frequently in traceexec
* and the while loop will be executed roughly half the number of non-blank * and the while loop will be executed roughly half the number of non-blank
...@@ -250,19 +241,18 @@ int luaG_getline (const Proto *f, int pc) { ...@@ -250,19 +241,18 @@ int luaG_getline (const Proto *f, int pc) {
static int stripdebug (lua_State *L, Proto *f, int level) { static int stripdebug (lua_State *L, Proto *f, int level) {
int len = 0, sizepackedlineinfo; int len = 0, sizepackedlineinfo;
TString* dummy;
switch (level) { switch (level) {
case 3:
sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1;
f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char);
len += sizepackedlineinfo;
// fall-through
case 2: case 2:
len += f->sizelocvars * (sizeof(struct LocVar) + sizeof(dummy->tsv) + sizeof(struct LocVar *)); if (f->packedlineinfo) {
sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1;
f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char);
len += sizepackedlineinfo;
}
// fall-through
case 1:
f->locvars = luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); f->locvars = luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
f->upvalues = luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); f->upvalues = luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
len += f->sizelocvars * (sizeof(struct LocVar) + sizeof(dummy->tsv) + sizeof(struct LocVar *)) + len += f->sizelocvars*sizeof(struct LocVar) + f->sizeupvalues*sizeof(TString *);
f->sizeupvalues * (sizeof(dummy->tsv) + sizeof(TString *));
f->sizelocvars = 0; f->sizelocvars = 0;
f->sizeupvalues = 0; f->sizeupvalues = 0;
} }
...@@ -278,7 +268,6 @@ LUA_API int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv){ ...@@ -278,7 +268,6 @@ LUA_API int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv){
len += stripdebug (L, f, level); len += stripdebug (L, f, level);
return len; return len;
} }
#endif
static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
...@@ -328,21 +317,21 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { ...@@ -328,21 +317,21 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
lua_lock(L); lua_lock(L);
if (*what == '>') { if (*what == '>') {
StkId func = L->top - 1; StkId func = L->top - 1;
luai_apicheck(L, ttisfunction(func) || ttislightfunction(func)); luai_apicheck(L, ttisfunction(func));
what++; /* skip the '>' */ what++; /* skip the '>' */
if (ttisfunction(func)) if (ttislightfunction(func))
f = clvalue(func);
else
plight = fvalue(func); plight = fvalue(func);
else
f = clvalue(func);
L->top--; /* pop function */ L->top--; /* pop function */
} }
else if (ar->i_ci != 0) { /* no tail call? */ else if (ar->i_ci != 0) { /* no tail call? */
ci = L->base_ci + ar->i_ci; ci = L->base_ci + ar->i_ci;
lua_assert(ttisfunction(ci->func) || ttislightfunction(ci->func)); lua_assert(ttisfunction(ci->func));
if (ttisfunction(ci->func)) if (ttislightfunction(ci->func))
f = clvalue(ci->func);
else
plight = fvalue(ci->func); plight = fvalue(ci->func);
else
f = clvalue(ci->func);
} }
status = auxgetinfo(L, what, ar, f, plight, ci); status = auxgetinfo(L, what, ar, f, plight, ci);
if (strchr(what, 'f')) { if (strchr(what, 'f')) {
...@@ -381,9 +370,6 @@ static int precheck (const Proto *pt) { ...@@ -381,9 +370,6 @@ static int precheck (const Proto *pt) {
check(!(pt->is_vararg & VARARG_NEEDSARG) || check(!(pt->is_vararg & VARARG_NEEDSARG) ||
(pt->is_vararg & VARARG_HASARG)); (pt->is_vararg & VARARG_HASARG));
check(pt->sizeupvalues <= pt->nups); check(pt->sizeupvalues <= pt->nups);
#ifndef LUA_OPTIMIZE_DEBUG
check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
#endif
check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
return 1; return 1;
} }
...@@ -670,7 +656,7 @@ static int isinstack (CallInfo *ci, const TValue *o) { ...@@ -670,7 +656,7 @@ static int isinstack (CallInfo *ci, const TValue *o) {
void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *name = NULL; const char *name = NULL;
const char *t = luaT_typenames[ttype(o)]; const char *t = luaT_typenames[ttnov(o)];
const char *kind = (isinstack(L->ci, o)) ? const char *kind = (isinstack(L->ci, o)) ?
getobjname(L, L->ci, cast_int(o - L->base), &name) : getobjname(L, L->ci, cast_int(o - L->base), &name) :
NULL; NULL;
...@@ -698,8 +684,8 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { ...@@ -698,8 +684,8 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
const char *t1 = luaT_typenames[ttype(p1)]; const char *t1 = luaT_typenames[ttnov(p1)];
const char *t2 = luaT_typenames[ttype(p2)]; const char *t2 = luaT_typenames[ttnov(p2)];
if (t1[2] == t2[2]) if (t1[2] == t2[2])
luaG_runerror(L, "attempt to compare two %s values", t1); luaG_runerror(L, "attempt to compare two %s values", t1);
else else
...@@ -722,7 +708,7 @@ static void addinfo (lua_State *L, const char *msg) { ...@@ -722,7 +708,7 @@ static void addinfo (lua_State *L, const char *msg) {
void luaG_errormsg (lua_State *L) { void luaG_errormsg (lua_State *L) {
if (L->errfunc != 0) { /* is there an error handling function? */ if (L->errfunc != 0) { /* is there an error handling function? */
StkId errfunc = restorestack(L, L->errfunc); StkId errfunc = restorestack(L, L->errfunc);
if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR); if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
setobjs2s(L, L->top, L->top - 1); /* move argument */ setobjs2s(L, L->top, L->top - 1); /* move argument */
setobjs2s(L, L->top - 1, errfunc); /* push function */ setobjs2s(L, L->top - 1, errfunc); /* push function */
incr_top(L); incr_top(L);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1)
#ifdef LUA_OPTIMIZE_DEBUG
# include "lvm.h" # include "lvm.h"
# define getline(f,pc) (((f)->packedlineinfo) ? luaG_getline((f), pc) : 0) # define getline(f,pc) (((f)->packedlineinfo) ? luaG_getline((f), pc) : 0)
# define INFO_FILL_BYTE 0x7F # define INFO_FILL_BYTE 0x7F
...@@ -23,9 +22,6 @@ ...@@ -23,9 +22,6 @@
# define INFO_DELTA_7BITS 0x7F # define INFO_DELTA_7BITS 0x7F
# define INFO_MAX_LINECNT 126 # define INFO_MAX_LINECNT 126
# define lineInfoTop(fs) ((fs)->f->packedlineinfo + (fs)->lastlineOffset) # define lineInfoTop(fs) ((fs)->f->packedlineinfo + (fs)->lastlineOffset)
#else
# define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0)
#endif
#define resethookcount(L) (L->hookcount = L->basehookcount) #define resethookcount(L) (L->hookcount = L->basehookcount)
...@@ -41,9 +37,7 @@ LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); ...@@ -41,9 +37,7 @@ LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC void luaG_errormsg (lua_State *L); LUAI_FUNC void luaG_errormsg (lua_State *L);
LUAI_FUNC int luaG_checkcode (const Proto *pt); LUAI_FUNC int luaG_checkcode (const Proto *pt);
LUAI_FUNC int luaG_checkopenop (Instruction i); LUAI_FUNC int luaG_checkopenop (Instruction i);
#ifdef LUA_OPTIMIZE_DEBUG
LUAI_FUNC int luaG_getline (const Proto *f, int pc); LUAI_FUNC int luaG_getline (const Proto *f, int pc);
LUAI_FUNC int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv); LUAI_FUNC int luaG_stripdebug (lua_State *L, Proto *f, int level, int recv);
#endif
#endif #endif
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#define ldo_c #define ldo_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <string.h> #include <string.h>
...@@ -106,7 +105,7 @@ void luaD_throw (lua_State *L, int errcode) { ...@@ -106,7 +105,7 @@ void luaD_throw (lua_State *L, int errcode) {
lua_unlock(L); lua_unlock(L);
G(L)->panic(L); G(L)->panic(L);
} }
// exit(EXIT_FAILURE); // c_exit(EXIT_FAILURE);
} }
} }
...@@ -254,13 +253,13 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { ...@@ -254,13 +253,13 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
return base; return base;
} }
static StkId tryfuncTM (lua_State *L, StkId func) { static StkId tryfuncTM (lua_State *L, StkId func) {
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
StkId p; StkId p;
ptrdiff_t funcr = savestack(L, func); ptrdiff_t funcr = savestack(L, func);
if (!ttisfunction(tm)) if (!ttisfunction(tm)) {
luaG_typeerror(L, func, "call"); luaG_typeerror(L, func, "call");
}
/* Open a hole inside the stack at `func' */ /* Open a hole inside the stack at `func' */
for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
incr_top(L); incr_top(L);
...@@ -279,10 +278,10 @@ static StkId tryfuncTM (lua_State *L, StkId func) { ...@@ -279,10 +278,10 @@ static StkId tryfuncTM (lua_State *L, StkId func) {
int luaD_precall (lua_State *L, StkId func, int nresults) { int luaD_precall (lua_State *L, StkId func, int nresults) {
ptrdiff_t funcr; ptrdiff_t funcr;
LClosure *cl = NULL; LClosure *cl = NULL;
if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */ if (!ttisfunction(func)) /* `func' is not a function? */
func = tryfuncTM(L, func); /* check the `function' tag method */ func = tryfuncTM(L, func); /* check the `function' tag method */
funcr = savestack(L, func); funcr = savestack(L, func);
if (ttisfunction(func)) if (!ttislightfunction(func))
cl = &clvalue(func)->l; cl = &clvalue(func)->l;
L->ci->savedpc = L->savedpc; L->ci->savedpc = L->savedpc;
if (cl && !cl->isC) { /* Lua function? prepare its call */ if (cl && !cl->isC) { /* Lua function? prepare its call */
...@@ -332,10 +331,10 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { ...@@ -332,10 +331,10 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
if (L->hookmask & LUA_MASKCALL) if (L->hookmask & LUA_MASKCALL)
luaD_callhook(L, LUA_HOOKCALL, -1); luaD_callhook(L, LUA_HOOKCALL, -1);
lua_unlock(L); lua_unlock(L);
if (ttisfunction(ci->func)) if (ttislightfunction(ci->func))
n = (*curr_func(L)->c.f)(L); /* do the actual call */
else
n = ((lua_CFunction)fvalue(ci->func))(L); /* do the actual call */ n = ((lua_CFunction)fvalue(ci->func))(L); /* do the actual call */
else
n = (*curr_func(L)->c.f)(L); /* do the actual call */
lua_lock(L); lua_lock(L);
if (n < 0) /* yielding? */ if (n < 0) /* yielding? */
return PCRYIELD; return PCRYIELD;
...@@ -384,7 +383,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { ...@@ -384,7 +383,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) {
** The arguments are on the stack, right after the function. ** The arguments are on the stack, right after the function.
** When returns, all the results are on the stack, starting at the original ** When returns, all the results are on the stack, starting at the original
** function position. ** function position.
*/ */
void luaD_call (lua_State *L, StkId func, int nResults) { void luaD_call (lua_State *L, StkId func, int nResults) {
if (++L->nCcalls >= LUAI_MAXCCALLS) { if (++L->nCcalls >= LUAI_MAXCCALLS) {
if (L->nCcalls == LUAI_MAXCCALLS) if (L->nCcalls == LUAI_MAXCCALLS)
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define ldump_c #define ldump_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <string.h> #include <string.h>
...@@ -229,7 +228,6 @@ static void DumpDebug(const Proto* f, DumpState* D) ...@@ -229,7 +228,6 @@ static void DumpDebug(const Proto* f, DumpState* D)
{ {
int i,n; int i,n;
#ifdef LUA_OPTIMIZE_DEBUG
n = (D->strip || f->packedlineinfo == NULL) ? 0: strlen(cast(char *,f->packedlineinfo))+1; n = (D->strip || f->packedlineinfo == NULL) ? 0: strlen(cast(char *,f->packedlineinfo))+1;
DumpInt(n,D); DumpInt(n,D);
Align4(D); Align4(D);
...@@ -237,15 +235,6 @@ static void DumpDebug(const Proto* f, DumpState* D) ...@@ -237,15 +235,6 @@ static void DumpDebug(const Proto* f, DumpState* D)
{ {
DumpBlock(f->packedlineinfo, n, D); DumpBlock(f->packedlineinfo, n, D);
} }
#else
n= (D->strip) ? 0 : f->sizelineinfo;
DumpInt(n,D);
Align4(D);
for (i=0; i<n; i++)
{
DumpInt(f->lineinfo[i],D);
}
#endif
n= (D->strip) ? 0 : f->sizelocvars; n= (D->strip) ? 0 : f->sizelocvars;
DumpInt(n,D); DumpInt(n,D);
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#define lflash_c #define lflash_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include "lobject.h" #include "lobject.h"
...@@ -24,6 +23,8 @@ ...@@ -24,6 +23,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "lfs.h"
/* /*
* Flash memory is a fixed memory addressable block that is serially allocated by the * Flash memory is a fixed memory addressable block that is serially allocated by the
* luac build process and the out image can be downloaded into SPIFSS and loaded into * luac build process and the out image can be downloaded into SPIFSS and loaded into
...@@ -72,7 +73,7 @@ struct OUTPUT { ...@@ -72,7 +73,7 @@ struct OUTPUT {
outBlock buffer; outBlock buffer;
int ndx; int ndx;
uint32_t crc; uint32_t crc;
int (*fullBlkCB) (void); void (*fullBlkCB) (void);
int flashLen; int flashLen;
int flagsLen; int flagsLen;
int flagsNdx; int flagsNdx;
...@@ -80,12 +81,6 @@ struct OUTPUT { ...@@ -80,12 +81,6 @@ struct OUTPUT {
const char *error; const char *error;
} *out; } *out;
#ifdef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE
extern const char lua_flash_store_reserved[0];
#endif
#ifdef NODE_DEBUG #ifdef NODE_DEBUG
extern void printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
void dumpStrt(stringtable *tb, const char *type) { void dumpStrt(stringtable *tb, const char *type) {
...@@ -97,9 +92,8 @@ void dumpStrt(stringtable *tb, const char *type) { ...@@ -97,9 +92,8 @@ void dumpStrt(stringtable *tb, const char *type) {
for (i=0; i<tb->size; i++) for (i=0; i<tb->size; i++)
for(o = tb->hash[i], j=0; o; (o=o->gch.next), j++ ) { for(o = tb->hash[i], j=0; o; (o=o->gch.next), j++ ) {
TString *ts =cast(TString *, o); TString *ts =cast(TString *, o);
NODE_DBG("%5d %5d %08x %08x %5d %1s %s\n", NODE_DBG("%5d %5d %08x %08x %5d %s\n",
i, j, (size_t) ts, ts->tsv.hash, ts->tsv.len, i, j, (size_t) ts, ts->tsv.hash, ts->tsv.len, getstr(ts));
ts_isreadonly(ts) ? "R" : " ", getstr(ts));
} }
} }
...@@ -117,17 +111,25 @@ LUA_API void dumpStrings(lua_State *L) { ...@@ -117,17 +111,25 @@ LUA_API void dumpStrings(lua_State *L) {
* writes are suppressed if the global writeToFlash is false. This is used in * writes are suppressed if the global writeToFlash is false. This is used in
* phase I where the pass is used to size the structures in flash. * phase I where the pass is used to size the structures in flash.
*/ */
static void flashSetPosition(uint32_t offset){ static const char *flashPosition(void){
return flashAddr + curOffset;
}
static const char *flashSetPosition(uint32_t offset){
NODE_DBG("flashSetPosition(%04x)\n", offset); NODE_DBG("flashSetPosition(%04x)\n", offset);
curOffset = offset; curOffset = offset;
return flashPosition();
} }
static void flashBlock(const void* b, size_t size) { static const char *flashBlock(const void* b, size_t size) {
NODE_DBG("flashBlock((%04x),%08x,%04x)\n", curOffset,(unsigned int)b,size); const void *cur = flashPosition();
NODE_DBG("flashBlock((%04x),%p,%04x)\n", curOffset,b,size);
lua_assert(ALIGN_BITS(b) == 0 && ALIGN_BITS(size) == 0); lua_assert(ALIGN_BITS(b) == 0 && ALIGN_BITS(size) == 0);
platform_flash_write(b, flashAddrPhys+curOffset, size); platform_flash_write(b, flashAddrPhys+curOffset, size);
curOffset += size; curOffset += size;
return cur;
} }
...@@ -142,11 +144,11 @@ static void flashErase(uint32_t start, uint32_t end){ ...@@ -142,11 +144,11 @@ static void flashErase(uint32_t start, uint32_t end){
static int loadLFS (lua_State *L); static int loadLFS (lua_State *L);
static int loadLFSgc (lua_State *L); static int loadLFSgc (lua_State *L);
static int procFirstPass (void); static void procFirstPass (void);
#endif #endif
/* ===================================================================================== /* =====================================================================================
* luaN_init(), luaN_reload_reboot() and luaN_index() are exported via lflash.h. * luaN_init() is exported via lflash.h.
* The first is the startup hook used in lstate.c and the last two are * The first is the startup hook used in lstate.c and the last two are
* implementations of the node.flash API calls. * implementations of the node.flash API calls.
*/ */
...@@ -155,40 +157,15 @@ static int procFirstPass (void); ...@@ -155,40 +157,15 @@ static int procFirstPass (void);
* Hook in lstate.c:f_luaopen() to set up ROstrt and ROpvmain if needed * Hook in lstate.c:f_luaopen() to set up ROstrt and ROpvmain if needed
*/ */
LUAI_FUNC void luaN_init (lua_State *L) { LUAI_FUNC void luaN_init (lua_State *L) {
#ifdef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE lfs_location_info_t lfs_loc;
flashSize = CONFIG_NODEMCU_EMBEDDED_LFS_SIZE; if (!lfs_get_location(&lfs_loc))
flashAddr = lua_flash_store_reserved;
flashAddrPhys = spi_flash_cache2phys(lua_flash_store_reserved);
if (flashAddrPhys == SPI_FLASH_CACHE2PHYS_FAIL) {
NODE_ERR("spi_flash_cache2phys failed\n");
return; return;
}
#else
const esp_partition_t *part = esp_partition_find_first(
PLATFORM_PARTITION_TYPE_NODEMCU,
PLATFORM_PARTITION_SUBTYPE_NODEMCU_LFS,
NULL);
if (!part)
return; // Nothing to do if the size is zero
flashSize = part->size; // in bytes
flashAddrPhys = part->address;
flashAddr = spi_flash_phys2cache(flashAddrPhys, SPI_FLASH_MMAP_DATA);
if (!flashAddr) {
spi_flash_mmap_handle_t ignored;
esp_err_t err = spi_flash_mmap(
flashAddrPhys, flashSize, SPI_FLASH_MMAP_DATA,
cast(const void **, &flashAddr), &ignored);
if (err != ESP_OK) {
NODE_ERR("Unable to access LFS partition - is it 64kB aligned as it needs to be?\n");
return;
}
}
#endif
G(L)->LFSsize = flashSize;
flashSector = platform_flash_get_sector_of_address(flashAddrPhys);
FlashHeader *fh = cast(FlashHeader *, flashAddr); G(L)->LFSsize = flashSize = lfs_loc.size;
flashAddr = lfs_loc.addr_mem;
flashAddrPhys = lfs_loc.addr_phys;
flashSector = platform_flash_get_sector_of_address(lfs_loc.addr_phys);
FlashHeader *fh = cast(FlashHeader *, lfs_loc.addr_mem);
curOffset = 0; curOffset = 0;
/* /*
...@@ -204,15 +181,15 @@ LUAI_FUNC void luaN_init (lua_State *L) { ...@@ -204,15 +181,15 @@ LUAI_FUNC void luaN_init (lua_State *L) {
} }
if ((fh->flash_sig & (~FLASH_SIG_ABSOLUTE)) != FLASH_SIG ) { if ((fh->flash_sig & (~FLASH_SIG_ABSOLUTE)) != FLASH_SIG ) {
NODE_ERR("Flash sig not correct: %u vs %u\n", NODE_ERR("LFS sig not correct: 0x%x vs expected 0x%x\n",
fh->flash_sig & (~FLASH_SIG_ABSOLUTE), FLASH_SIG); fh->flash_sig & (~FLASH_SIG_ABSOLUTE), FLASH_SIG);
return; return;
} }
if (fh->pROhash == ALL_SET || if (fh->pROhash == ALL_SET ||
((fh->mainProto - cast(FlashAddr, fh)) >= fh->flash_size)) { ((fh->mainProto - cast(FlashAddr, fh)) >= fh->flash_size)) {
NODE_ERR("Flash size check failed: %x vs 0xFFFFFFFF; size: %u\n", NODE_ERR("Flash size check failed: 0x%08x vs 0xFFFFFFFF; 0x%08x >= 0x%08x\n",
fh->mainProto - cast(FlashAddr, fh), fh->flash_size); fh->pROhash, fh->mainProto - cast(FlashAddr, fh), fh->flash_size);
return; return;
} }
...@@ -222,23 +199,24 @@ LUAI_FUNC void luaN_init (lua_State *L) { ...@@ -222,23 +199,24 @@ LUAI_FUNC void luaN_init (lua_State *L) {
G(L)->ROpvmain = cast(Proto *,fh->mainProto); G(L)->ROpvmain = cast(Proto *,fh->mainProto);
} }
/* luaL_lfsreload() is exported via lauxlib.h */
/* /*
* Library function called by node.flashreload(filename). * Library function called by node.flashreload(filename).
*/ */
LUALIB_API int luaN_reload_reboot (lua_State *L) { LUALIB_API void luaL_lfsreload (lua_State *L) {
#ifdef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE #ifdef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE
// Updating the LFS section is disabled for now because any changes to the // Updating the LFS section is disabled for now because any changes to the
// image requires updating its checksum to prevent boot failure. // image requires updating its checksum to prevent boot failure.
lua_pushstring(L, "Not allowed to write to LFS section"); lua_pushstring(L, "Not allowed to write to LFS section");
return 1; return;
#else #else
// luaL_dbgbreak();
const char *fn = lua_tostring(L, 1), *msg = ""; const char *fn = lua_tostring(L, 1), *msg = "";
int status; int status;
if (G(L)->LFSsize == 0) { if (G(L)->LFSsize == 0) {
lua_pushstring(L, "No LFS partition allocated"); lua_pushstring(L, "No LFS partition allocated");
return 1; return;
} }
...@@ -270,7 +248,7 @@ LUALIB_API int luaN_reload_reboot (lua_State *L) { ...@@ -270,7 +248,7 @@ LUALIB_API int luaN_reload_reboot (lua_State *L) {
lua_cpcall(L, &loadLFSgc, NULL); lua_cpcall(L, &loadLFSgc, NULL);
lua_settop(L, 0); lua_settop(L, 0);
lua_pushstring(L, msg); lua_pushstring(L, msg);
return 1; return;
} }
if (status == 0) { if (status == 0) {
...@@ -290,62 +268,22 @@ LUALIB_API int luaN_reload_reboot (lua_State *L) { ...@@ -290,62 +268,22 @@ LUALIB_API int luaN_reload_reboot (lua_State *L) {
NODE_ERR("%s\n", msg); NODE_ERR("%s\n", msg);
esp_restart(); esp_restart();
return 0;
#endif // CONFIG_NODEMCU_EMBEDDED_LFS_SIZE #endif // CONFIG_NODEMCU_EMBEDDED_LFS_SIZE
} }
/* LUA_API void lua_getlfsconfig (lua_State *L, intptr_t *config) {
* If the arg is a valid LFS module name then return the LClosure if (!config)
* pointing to it. Otherwise return: return;
* - The Unix time that the LFS was built config[0] = (intptr_t) flashAddr; /* LFS region mapped address */
* - The base address and length of the LFS config[1] = flashAddrPhys; /* LFS region base flash address */
* - An array of the module names in the LFS config[2] = G(L)->LFSsize; /* LFS region actual size */
*/ config[3] = (G(L)->ROstrt.hash) ? cast(FlashHeader *, flashAddr)->flash_size : 0;
LUAI_FUNC int luaN_index (lua_State *L) { /* LFS region used */
int n = lua_gettop(L); config[4] = 0; /* Not used in Lua 5.1 */
/* Return nil + the LFS base address if the LFS size > 0 and it isn't loaded */
if (!(G(L)->ROpvmain)) {
lua_settop(L, 0);
lua_pushnil(L);
if (G(L)->LFSsize) {
lua_pushinteger(L, (lua_Integer) flashAddr);
lua_pushinteger(L, flashAddrPhys);
lua_pushinteger(L, G(L)->LFSsize);
return 4;
} else {
return 1;
}
}
/* Push the LClosure of the LFS index function */
Closure *cl = luaF_newLclosure(L, 0, hvalue(gt(L)));
cl->l.p = G(L)->ROpvmain;
lua_settop(L, n+1);
setclvalue(L, L->top-1, cl);
/* Move it infront of the arguments and call the index function */
lua_insert(L, 1);
lua_call(L, n, LUA_MULTRET);
/* Return it if the response if a single value (the function) */
if (lua_gettop(L) == 1)
return 1;
lua_assert(lua_gettop(L) == 2);
/* Otherwise add the base address of the LFS, and its size bewteen the */
/* Unix time and the module list, then return all 4 params. */
lua_pushinteger(L, (lua_Integer) flashAddr);
lua_insert(L, 2);
lua_pushinteger(L, flashAddrPhys);
lua_insert(L, 3);
lua_pushinteger(L, cast(FlashHeader *, flashAddr)->flash_size);
lua_insert(L, 4);
return 5;
} }
#ifndef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE #ifndef CONFIG_NODEMCU_EMBEDDED_LFS_SIZE
/* ===================================================================================== /* =====================================================================================
* The following routines use my uzlib which was based on pfalcon's inflate and * The following routines use my uzlib which was based on pfalcon's inflate and
...@@ -440,7 +378,7 @@ static uint8_t recall_byte (uint32_t offset) { ...@@ -440,7 +378,7 @@ static uint8_t recall_byte (uint32_t offset) {
* - Once the flags array is in-buffer this is also captured. * - Once the flags array is in-buffer this is also captured.
* This logic is slightly complicated by the last buffer is typically short. * This logic is slightly complicated by the last buffer is typically short.
*/ */
int procFirstPass (void) { void procFirstPass (void) {
int len = (out->ndx % WRITE_BLOCKSIZE) ? int len = (out->ndx % WRITE_BLOCKSIZE) ?
out->ndx % WRITE_BLOCKSIZE : WRITE_BLOCKSIZE; out->ndx % WRITE_BLOCKSIZE : WRITE_BLOCKSIZE;
if (out->ndx <= WRITE_BLOCKSIZE) { if (out->ndx <= WRITE_BLOCKSIZE) {
...@@ -475,12 +413,10 @@ int procFirstPass (void) { ...@@ -475,12 +413,10 @@ int procFirstPass (void) {
memcpy(out->flags + out->flagsNdx, out->block[0]->byte + start, len - start); memcpy(out->flags + out->flagsNdx, out->block[0]->byte + start, len - start);
out->flagsNdx += (len -start) / WORDSIZE; /* flashLen and len are word aligned */ out->flagsNdx += (len -start) / WORDSIZE; /* flashLen and len are word aligned */
} }
return 1;
} }
int procSecondPass (void) { void procSecondPass (void) {
/* /*
* The length rules are different for the second pass since this only processes * The length rules are different for the second pass since this only processes
* upto the flashLen and not the full image. This also works in word units. * upto the flashLen and not the full image. This also works in word units.
...@@ -518,12 +454,10 @@ int procSecondPass (void) { ...@@ -518,12 +454,10 @@ int procSecondPass (void) {
flashBlock(&out->flash_sig, WORDSIZE); flashBlock(&out->flash_sig, WORDSIZE);
out->fullBlkCB = NULL; out->fullBlkCB = NULL;
} }
return 1;
} }
/* /*
* loadLFS)() is protected called from luaN_reload_reboot so that it can recover * loadLFS)() is protected called from luaL_lfsreload so that it can recover
* from out of memory and other thrown errors. loadLFSgc() GCs any resources. * from out of memory and other thrown errors. loadLFSgc() GCs any resources.
*/ */
static int loadLFS (lua_State *L) { static int loadLFS (lua_State *L) {
...@@ -548,7 +482,7 @@ static int loadLFS (lua_State *L) { ...@@ -548,7 +482,7 @@ static int loadLFS (lua_State *L) {
in->len = vfs_size(in->fd); in->len = vfs_size(in->fd);
if (in->len <= 200 || /* size of an empty luac output */ if (in->len <= 200 || /* size of an empty luac output */
vfs_lseek(in->fd, in->len-4, VFS_SEEK_SET) != in->len-4 || vfs_lseek(in->fd, in->len-4, VFS_SEEK_SET) != in->len-4 ||
vfs_read(in->fd, &out->len, sizeof(uint)) != sizeof(uint)) vfs_read(in->fd, &out->len, sizeof(uint32_t)) != sizeof(uint32_t))
flash_error("read error on LFS image file"); flash_error("read error on LFS image file");
vfs_lseek(in->fd, 0, VFS_SEEK_SET); vfs_lseek(in->fd, 0, VFS_SEEK_SET);
......
...@@ -43,8 +43,5 @@ typedef struct { ...@@ -43,8 +43,5 @@ typedef struct {
} FlashHeader; } FlashHeader;
LUAI_FUNC void luaN_init (lua_State *L); LUAI_FUNC void luaN_init (lua_State *L);
LUAI_FUNC int luaN_flashSetup (lua_State *L);
LUAI_FUNC int luaN_reload_reboot (lua_State *L);
LUAI_FUNC int luaN_index (lua_State *L);
#endif #endif
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define lfunc_c #define lfunc_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <string.h> #include <string.h>
...@@ -126,12 +125,7 @@ Proto *luaF_newproto (lua_State *L) { ...@@ -126,12 +125,7 @@ Proto *luaF_newproto (lua_State *L) {
f->numparams = 0; f->numparams = 0;
f->is_vararg = 0; f->is_vararg = 0;
f->maxstacksize = 0; f->maxstacksize = 0;
#ifdef LUA_OPTIMIZE_DEBUG
f->packedlineinfo = NULL; f->packedlineinfo = NULL;
#else
f->sizelineinfo = 0;
f->lineinfo = NULL;
#endif
f->sizelocvars = 0; f->sizelocvars = 0;
f->locvars = NULL; f->locvars = NULL;
f->linedefined = 0; f->linedefined = 0;
...@@ -146,15 +140,9 @@ void luaF_freeproto (lua_State *L, Proto *f) { ...@@ -146,15 +140,9 @@ void luaF_freeproto (lua_State *L, Proto *f) {
luaM_freearray(L, f->k, f->sizek, TValue); luaM_freearray(L, f->k, f->sizek, TValue);
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *);
if (!proto_isreadonly(f)) { luaM_freearray(L, f->code, f->sizecode, Instruction);
luaM_freearray(L, f->code, f->sizecode, Instruction); if (f->packedlineinfo) {
#ifdef LUA_OPTIMIZE_DEBUG luaM_freearray(L, f->packedlineinfo, strlen(cast(char *, f->packedlineinfo))+1, unsigned char);
if (f->packedlineinfo) {
luaM_freearray(L, f->packedlineinfo, strlen(cast(char *, f->packedlineinfo))+1, unsigned char);
}
#else
luaM_freearray(L, f->lineinfo, f->sizelineinfo, int);
#endif
} }
luaM_free(L, f); luaM_free(L, f);
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define lgc_c #define lgc_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <string.h> #include <string.h>
...@@ -21,14 +20,12 @@ ...@@ -21,14 +20,12 @@
#include "lstring.h" #include "lstring.h"
#include "ltable.h" #include "ltable.h"
#include "ltm.h" #include "ltm.h"
#include "lrotable.h"
#define GCSTEPSIZE 1024u #define GCSTEPSIZE 1024u
#define GCSWEEPMAX 40 #define GCSWEEPMAX 40
#define GCSWEEPCOST 10 #define GCSWEEPCOST 10
#define GCFINALIZECOST 100 #define GCFINALIZECOST 100
#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) #define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS))
#define makewhite(g,x) \ #define makewhite(g,x) \
...@@ -55,7 +52,6 @@ ...@@ -55,7 +52,6 @@
#define markobject(g,t) { if (iswhite(obj2gco(t))) \ #define markobject(g,t) { if (iswhite(obj2gco(t))) \
reallymarkobject(g, obj2gco(t)); } reallymarkobject(g, obj2gco(t)); }
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) #define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
...@@ -82,7 +78,7 @@ static void reallymarkobject (global_State *g, GCObject *o) { ...@@ -82,7 +78,7 @@ static void reallymarkobject (global_State *g, GCObject *o) {
case LUA_TUSERDATA: { case LUA_TUSERDATA: {
Table *mt = gco2u(o)->metatable; Table *mt = gco2u(o)->metatable;
gray2black(o); /* udata are never gray */ gray2black(o); /* udata are never gray */
if (mt && !luaR_isrotable(mt)) markobject(g, mt); if (mt && isrwtable(mt)) markobject(g, mt);
markobject(g, gco2u(o)->env); markobject(g, gco2u(o)->env);
return; return;
} }
...@@ -160,7 +156,6 @@ size_t luaC_separateudata (lua_State *L, int all) { ...@@ -160,7 +156,6 @@ size_t luaC_separateudata (lua_State *L, int all) {
return deadmem; return deadmem;
} }
static int traversetable (global_State *g, Table *h) { static int traversetable (global_State *g, Table *h) {
int i; int i;
int weakkey = 0; int weakkey = 0;
...@@ -168,7 +163,7 @@ static int traversetable (global_State *g, Table *h) { ...@@ -168,7 +163,7 @@ static int traversetable (global_State *g, Table *h) {
const TValue *mode = luaO_nilobject; const TValue *mode = luaO_nilobject;
if (h->metatable) { if (h->metatable) {
if (!luaR_isrotable(h->metatable)) if (isrwtable(h->metatable))
markobject(g, h->metatable); markobject(g, h->metatable);
mode = gfasttm(g, h->metatable, TM_MODE); mode = gfasttm(g, h->metatable, TM_MODE);
} }
...@@ -331,14 +326,8 @@ static l_mem propagatemark (global_State *g) { ...@@ -331,14 +326,8 @@ static l_mem propagatemark (global_State *g) {
sizeof(TValue) * p->sizek + sizeof(TValue) * p->sizek +
sizeof(LocVar) * p->sizelocvars + sizeof(LocVar) * p->sizelocvars +
sizeof(TString *) * p->sizeupvalues + sizeof(TString *) * p->sizeupvalues +
(proto_isreadonly(p) ? 0 : sizeof(Instruction) * p->sizecode + sizeof(Instruction) * p->sizecode +
#ifdef LUA_OPTIMIZE_DEBUG (p->packedlineinfo ? strlen(cast(char *, p->packedlineinfo))+1 : 0);
(p->packedlineinfo ?
strlen(cast(char *, p->packedlineinfo))+1 :
0));
#else
sizeof(int) * p->sizelineinfo);
#endif
} }
default: lua_assert(0); return 0; default: lua_assert(0); return 0;
} }
...@@ -522,8 +511,8 @@ void luaC_freeall (lua_State *L) { ...@@ -522,8 +511,8 @@ void luaC_freeall (lua_State *L) {
static void markmt (global_State *g) { static void markmt (global_State *g) {
int i; int i;
for (i=0; i<NUM_TAGS; i++) for (i=0; i<LUA_NUMTAGS; i++)
if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]); if (g->mt[i] && isrwtable(g->mt[i])) markobject(g, g->mt[i]);
} }
...@@ -713,7 +702,7 @@ void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { ...@@ -713,7 +702,7 @@ void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L); global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
lua_assert(o->gch.tt != LUA_TTABLE); lua_assert((gettt(o) & LUA_TMASK) != LUA_TTABLE);
/* must keep invariant? */ /* must keep invariant? */
if (g->gcstate == GCSpropagate) if (g->gcstate == GCSpropagate)
reallymarkobject(g, v); /* Restore invariant */ reallymarkobject(g, v); /* Restore invariant */
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define llex_c #define llex_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <ctype.h> #include <ctype.h>
...@@ -62,6 +61,7 @@ static void save (LexState *ls, int c) { ...@@ -62,6 +61,7 @@ static void save (LexState *ls, int c) {
void luaX_init (lua_State *L) { void luaX_init (lua_State *L) {
(void)L;
} }
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
#define llimits_h #define llimits_h
//#include <limits.h>
#include "lua.h" #include "lua.h"
typedef LUAI_UINT32 lu_int32; typedef LUAI_UINT32 lu_int32;
...@@ -104,7 +102,7 @@ typedef lu_int32 Instruction; ...@@ -104,7 +102,7 @@ typedef lu_int32 Instruction;
#ifndef lua_lock #ifndef lua_lock
#define lua_lock(L) ((void) 0) #define lua_lock(L) ((void) 0)
#define lua_unlock(L) ((void) 0) #define lua_unlock(L) ((void) 0)
#endif #endif
...@@ -115,7 +113,7 @@ typedef lu_int32 Instruction; ...@@ -115,7 +113,7 @@ typedef lu_int32 Instruction;
/* /*
** macro to control inclusion of some hard tests on stack reallocation ** macro to control inclusion of some hard tests on stack reallocation
*/ */
#ifndef HARDSTACKTESTS #ifndef HARDSTACKTESTS
#define condhardstacktests(x) ((void)0) #define condhardstacktests(x) ((void)0)
#else #else
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define lmathlib_c #define lmathlib_c
#define LUA_LIB #define LUA_LIB
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
#include <stdlib.h> #include <stdlib.h>
...@@ -15,7 +14,6 @@ ...@@ -15,7 +14,6 @@
#include "lauxlib.h" #include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
#include "lrotable.h"
#undef PI #undef PI
#define PI (3.14159265358979323846) #define PI (3.14159265358979323846)
...@@ -309,7 +307,7 @@ static int math_randomseed (lua_State *L) { ...@@ -309,7 +307,7 @@ static int math_randomseed (lua_State *L) {
return 0; return 0;
} }
LROT_PUBLIC_BEGIN(math) LROT_BEGIN(mathlib, NULL, 0)
#ifdef LUA_NUMBER_INTEGRAL #ifdef LUA_NUMBER_INTEGRAL
LROT_FUNCENTRY( abs, math_abs ) LROT_FUNCENTRY( abs, math_abs )
LROT_FUNCENTRY( ceil, math_identity ) LROT_FUNCENTRY( ceil, math_identity )
...@@ -354,7 +352,7 @@ LROT_PUBLIC_BEGIN(math) ...@@ -354,7 +352,7 @@ LROT_PUBLIC_BEGIN(math)
LROT_NUMENTRY( pi, PI ) LROT_NUMENTRY( pi, PI )
LROT_NUMENTRY( huge, HUGE_VAL ) LROT_NUMENTRY( huge, HUGE_VAL )
#endif // #ifdef LUA_NUMBER_INTEGRAL #endif // #ifdef LUA_NUMBER_INTEGRAL
LROT_END(math, NULL, 0) LROT_END(mathlib, NULL, 0)
/* /*
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#define lmem_c #define lmem_c
#define LUA_CORE #define LUA_CORE
#define LUAC_CROSS_FILE
#include "lua.h" #include "lua.h"
......
...@@ -8,12 +8,6 @@ ...@@ -8,12 +8,6 @@
#define lmem_h #define lmem_h
//#ifdef LUA_CROSS_COMPILER
//#include <stddef.h>
//#else
//#include "c_stddef.h"
//#endif
#include "llimits.h" #include "llimits.h"
#include "lua.h" #include "lua.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment