do not eliminate varargs from functions that do not use varargs
(confuses the debug lib and gains very little in performance)
This commit is contained in:
8
ldo.c
8
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 2.151 2015/12/16 16:40:07 roberto Exp roberto $
|
** $Id: ldo.c,v 2.152 2016/07/29 17:12:44 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -374,13 +374,13 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
int n = cast_int(L->top - func) - 1; /* number of real arguments */
|
int n = cast_int(L->top - func) - 1; /* number of real arguments */
|
||||||
int fsize = p->maxstacksize; /* frame size */
|
int fsize = p->maxstacksize; /* frame size */
|
||||||
checkstackp(L, fsize, func);
|
checkstackp(L, fsize, func);
|
||||||
if (p->is_vararg != 1) { /* do not use vararg? */
|
if (p->is_vararg)
|
||||||
|
base = adjust_varargs(L, p, n);
|
||||||
|
else { /* non vararg function */
|
||||||
for (; n < p->numparams; n++)
|
for (; n < p->numparams; n++)
|
||||||
setnilvalue(L->top++); /* complete missing arguments */
|
setnilvalue(L->top++); /* complete missing arguments */
|
||||||
base = func + 1;
|
base = func + 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
base = adjust_varargs(L, p, n);
|
|
||||||
ci = next_ci(L); /* now 'enter' new function */
|
ci = next_ci(L); /* now 'enter' new function */
|
||||||
ci->nresults = nresults;
|
ci->nresults = nresults;
|
||||||
ci->func = func;
|
ci->func = func;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 2.115 2015/10/28 17:28:40 roberto Exp roberto $
|
** $Id: lobject.h,v 2.116 2015/11/03 18:33:10 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -407,7 +407,7 @@ typedef struct LocVar {
|
|||||||
typedef struct Proto {
|
typedef struct Proto {
|
||||||
CommonHeader;
|
CommonHeader;
|
||||||
lu_byte numparams; /* number of fixed parameters */
|
lu_byte numparams; /* number of fixed parameters */
|
||||||
lu_byte is_vararg; /* 2: declared vararg; 1: uses vararg */
|
lu_byte is_vararg;
|
||||||
lu_byte maxstacksize; /* number of registers needed by this function */
|
lu_byte maxstacksize; /* number of registers needed by this function */
|
||||||
int sizeupvalues; /* size of 'upvalues' */
|
int sizeupvalues; /* size of 'upvalues' */
|
||||||
int sizek; /* size of 'k' */
|
int sizek; /* size of 'k' */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.153 2016/05/13 19:10:16 roberto Exp roberto $
|
** $Id: lparser.c,v 2.154 2016/06/22 15:48:25 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -766,7 +766,7 @@ static void parlist (LexState *ls) {
|
|||||||
}
|
}
|
||||||
case TK_DOTS: { /* param -> '...' */
|
case TK_DOTS: { /* param -> '...' */
|
||||||
luaX_next(ls);
|
luaX_next(ls);
|
||||||
f->is_vararg = 2; /* declared vararg */
|
f->is_vararg = 1; /* declared vararg */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: luaX_syntaxerror(ls, "<name> or '...' expected");
|
default: luaX_syntaxerror(ls, "<name> or '...' expected");
|
||||||
@@ -962,7 +962,6 @@ static void simpleexp (LexState *ls, expdesc *v) {
|
|||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
check_condition(ls, fs->f->is_vararg,
|
check_condition(ls, fs->f->is_vararg,
|
||||||
"cannot use '...' outside a vararg function");
|
"cannot use '...' outside a vararg function");
|
||||||
fs->f->is_vararg = 1; /* function actually uses vararg */
|
|
||||||
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
|
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1614,7 +1613,7 @@ static void mainfunc (LexState *ls, FuncState *fs) {
|
|||||||
BlockCnt bl;
|
BlockCnt bl;
|
||||||
expdesc v;
|
expdesc v;
|
||||||
open_func(ls, fs, &bl);
|
open_func(ls, fs, &bl);
|
||||||
fs->f->is_vararg = 2; /* main function is always declared vararg */
|
fs->f->is_vararg = 1; /* main function is always declared vararg */
|
||||||
init_exp(&v, VLOCAL, 0); /* create and... */
|
init_exp(&v, VLOCAL, 0); /* create and... */
|
||||||
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
|
newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */
|
||||||
luaX_next(ls); /* read first token */
|
luaX_next(ls); /* read first token */
|
||||||
|
|||||||
Reference in New Issue
Block a user