diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-08-01 16:51:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2016-08-01 16:51:24 -0300 |
commit | e4a9e6fcca4ac2a14c9832b1a40b74cdca7016b9 (patch) | |
tree | f4e6a467d530017d905a331ea41114cb9333ffd4 | |
parent | 9de2bb0d62a2531c47e5b8197f57a48c9aea05d2 (diff) | |
download | lua-e4a9e6fcca4ac2a14c9832b1a40b74cdca7016b9.tar.gz lua-e4a9e6fcca4ac2a14c9832b1a40b74cdca7016b9.tar.bz2 lua-e4a9e6fcca4ac2a14c9832b1a40b74cdca7016b9.zip |
do not eliminate varargs from functions that do not use varargs
(confuses the debug lib and gains very little in performance)
-rw-r--r-- | ldo.c | 8 | ||||
-rw-r--r-- | lobject.h | 4 | ||||
-rw-r--r-- | lparser.c | 7 |
3 files changed, 9 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.151 2015/12/16 16:40:07 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.152 2016/07/29 17:12:44 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -374,13 +374,13 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
374 | int n = cast_int(L->top - func) - 1; /* number of real arguments */ | 374 | int n = cast_int(L->top - func) - 1; /* number of real arguments */ |
375 | int fsize = p->maxstacksize; /* frame size */ | 375 | int fsize = p->maxstacksize; /* frame size */ |
376 | checkstackp(L, fsize, func); | 376 | checkstackp(L, fsize, func); |
377 | if (p->is_vararg != 1) { /* do not use vararg? */ | 377 | if (p->is_vararg) |
378 | base = adjust_varargs(L, p, n); | ||
379 | else { /* non vararg function */ | ||
378 | for (; n < p->numparams; n++) | 380 | for (; n < p->numparams; n++) |
379 | setnilvalue(L->top++); /* complete missing arguments */ | 381 | setnilvalue(L->top++); /* complete missing arguments */ |
380 | base = func + 1; | 382 | base = func + 1; |
381 | } | 383 | } |
382 | else | ||
383 | base = adjust_varargs(L, p, n); | ||
384 | ci = next_ci(L); /* now 'enter' new function */ | 384 | ci = next_ci(L); /* now 'enter' new function */ |
385 | ci->nresults = nresults; | 385 | ci->nresults = nresults; |
386 | ci->func = func; | 386 | ci->func = func; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 2.115 2015/10/28 17:28:40 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.116 2015/11/03 18:33:10 roberto Exp roberto $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -407,7 +407,7 @@ typedef struct LocVar { | |||
407 | typedef struct Proto { | 407 | typedef struct Proto { |
408 | CommonHeader; | 408 | CommonHeader; |
409 | lu_byte numparams; /* number of fixed parameters */ | 409 | lu_byte numparams; /* number of fixed parameters */ |
410 | lu_byte is_vararg; /* 2: declared vararg; 1: uses vararg */ | 410 | lu_byte is_vararg; |
411 | lu_byte maxstacksize; /* number of registers needed by this function */ | 411 | lu_byte maxstacksize; /* number of registers needed by this function */ |
412 | int sizeupvalues; /* size of 'upvalues' */ | 412 | int sizeupvalues; /* size of 'upvalues' */ |
413 | int sizek; /* size of 'k' */ | 413 | int sizek; /* size of 'k' */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.153 2016/05/13 19:10:16 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.154 2016/06/22 15:48:25 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -766,7 +766,7 @@ static void parlist (LexState *ls) { | |||
766 | } | 766 | } |
767 | case TK_DOTS: { /* param -> '...' */ | 767 | case TK_DOTS: { /* param -> '...' */ |
768 | luaX_next(ls); | 768 | luaX_next(ls); |
769 | f->is_vararg = 2; /* declared vararg */ | 769 | f->is_vararg = 1; /* declared vararg */ |
770 | break; | 770 | break; |
771 | } | 771 | } |
772 | default: luaX_syntaxerror(ls, "<name> or '...' expected"); | 772 | default: luaX_syntaxerror(ls, "<name> or '...' expected"); |
@@ -962,7 +962,6 @@ static void simpleexp (LexState *ls, expdesc *v) { | |||
962 | FuncState *fs = ls->fs; | 962 | FuncState *fs = ls->fs; |
963 | check_condition(ls, fs->f->is_vararg, | 963 | check_condition(ls, fs->f->is_vararg, |
964 | "cannot use '...' outside a vararg function"); | 964 | "cannot use '...' outside a vararg function"); |
965 | fs->f->is_vararg = 1; /* function actually uses vararg */ | ||
966 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); | 965 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); |
967 | break; | 966 | break; |
968 | } | 967 | } |
@@ -1614,7 +1613,7 @@ static void mainfunc (LexState *ls, FuncState *fs) { | |||
1614 | BlockCnt bl; | 1613 | BlockCnt bl; |
1615 | expdesc v; | 1614 | expdesc v; |
1616 | open_func(ls, fs, &bl); | 1615 | open_func(ls, fs, &bl); |
1617 | fs->f->is_vararg = 2; /* main function is always declared vararg */ | 1616 | fs->f->is_vararg = 1; /* main function is always declared vararg */ |
1618 | init_exp(&v, VLOCAL, 0); /* create and... */ | 1617 | init_exp(&v, VLOCAL, 0); /* create and... */ |
1619 | newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ | 1618 | newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ |
1620 | luaX_next(ls); /* read first token */ | 1619 | luaX_next(ls); /* read first token */ |