diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-16 15:44:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-16 15:44:37 -0300 |
commit | 4846f7e3bb1397142ab0de808ae59c08db9832a6 (patch) | |
tree | de10475ba2b2f0713edc91f5bff801bd7eaa0b3d /lcode.c | |
parent | c220b0a5d099372e58e517b9f13eaa7bb0bec45c (diff) | |
download | lua-4846f7e3bb1397142ab0de808ae59c08db9832a6.tar.gz lua-4846f7e3bb1397142ab0de808ae59c08db9832a6.tar.bz2 lua-4846f7e3bb1397142ab0de808ae59c08db9832a6.zip |
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".
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1745,10 +1745,10 @@ void luaK_finish (FuncState *fs) { | |||
1745 | SET_OPCODE(*pc, OP_RETURN); | 1745 | SET_OPCODE(*pc, OP_RETURN); |
1746 | } /* FALLTHROUGH */ | 1746 | } /* FALLTHROUGH */ |
1747 | case OP_RETURN: case OP_TAILCALL: { | 1747 | case OP_RETURN: case OP_TAILCALL: { |
1748 | if (fs->needclose || p->is_vararg) { | 1748 | if (fs->needclose) |
1749 | SETARG_C(*pc, p->is_vararg ? p->numparams + 1 : 0); | 1749 | SETARG_k(*pc, 1); /* signal that it needs to close */ |
1750 | SETARG_k(*pc, 1); /* signal that there is extra work */ | 1750 | if (p->is_vararg) |
1751 | } | 1751 | SETARG_C(*pc, p->numparams + 1); /* signal that it is vararg */ |
1752 | break; | 1752 | break; |
1753 | } | 1753 | } |
1754 | case OP_JMP: { | 1754 | case OP_JMP: { |