]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Add build flag LUAJIT_DISABLE_TAILCALL to disable tailcall generation.
authorMike Pall <mike>
Wed, 3 Jul 2024 22:13:58 +0000 (00:13 +0200)
committerMike Pall <mike>
Wed, 3 Jul 2024 22:13:58 +0000 (00:13 +0200)
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

src/lj_parse.c

index db3ce8e75794e97866fe3efc927a58cf9b16d23a..4fdd4c65b09e27b49aa30121ccbf44c3b1043589 100644 (file)
@@ -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);
       }