Micro optimization in OP_RETURN and OP_TAILCALL

Many functions are vararg but create no upvalues, so it is better
to separate the tests for these two kinds of "extra work".
This commit is contained in:
Roberto Ierusalimschy
2019-07-16 15:44:37 -03:00
parent c220b0a5d0
commit 4846f7e3bb
3 changed files with 13 additions and 15 deletions

View File

@@ -1745,10 +1745,10 @@ void luaK_finish (FuncState *fs) {
SET_OPCODE(*pc, OP_RETURN);
} /* FALLTHROUGH */
case OP_RETURN: case OP_TAILCALL: {
if (fs->needclose || p->is_vararg) {
SETARG_C(*pc, p->is_vararg ? p->numparams + 1 : 0);
SETARG_k(*pc, 1); /* signal that there is extra work */
}
if (fs->needclose)
SETARG_k(*pc, 1); /* signal that it needs to close */
if (p->is_vararg)
SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */
break;
}
case OP_JMP: {