From: Mike Pall Date: Wed, 3 Jul 2024 22:13:58 +0000 (+0200) Subject: Add build flag LUAJIT_DISABLE_TAILCALL to disable tailcall generation. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=510f88d468b8a6d6feb02890417a7261073bcd87;p=thirdparty%2FLuaJIT.git Add build flag LUAJIT_DISABLE_TAILCALL to disable tailcall generation. Only use this for debugging purposes. NEVER set it for regular builds or distro builds! In Lua, tailcalls are a language guarantee. Suggested by Steve Vermeulen. #1220 --- diff --git a/src/lj_parse.c b/src/lj_parse.c index db3ce8e7..4fdd4c65 100644 --- a/src/lj_parse.c +++ b/src/lj_parse.c @@ -2339,11 +2339,15 @@ static void parse_return(LexState *ls) BCReg nret = expr_list(ls, &e); if (nret == 1) { /* Return one result. */ if (e.k == VCALL) { /* Check for tail call. */ +#ifdef LUAJIT_DISABLE_TAILCALL + goto notailcall; +#else BCIns *ip = bcptr(fs, &e); /* It doesn't pay off to add BC_VARGT just for 'return ...'. */ if (bc_op(*ip) == BC_VARG) goto notailcall; fs->pc--; ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip)); +#endif } else { /* Can return the result from any register. */ ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2); }