From 1fce5bea817de50e055a84c153a975f25bfcf493 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 29 Oct 2021 13:41:24 -0300 Subject: More uniform implementation for tail calls 'luaD_pretailcall' mimics 'luaD_precall', handling call metamethods and calling C functions directly. That makes the code in the interpreter loop simpler. This commit also goes back to emulating the tail call in 'luaD_precall' with a goto, as C compilers may not do proper tail calls and the C stack can overflow much sooner than the Lua stack (which grows as the metamethod is added to it). --- ldo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ldo.h') diff --git a/ldo.h b/ldo.h index 9fb772fe..911e67f6 100644 --- a/ldo.h +++ b/ldo.h @@ -58,7 +58,7 @@ LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, LUAI_FUNC void luaD_hook (lua_State *L, int event, int line, int fTransfer, int nTransfer); LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci); -LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n); +LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1, int delta); LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); -- cgit v1.2.3-55-g6feb