mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
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
This commit is contained in:
parent
444c8ff19a
commit
510f88d468
@ -2339,11 +2339,15 @@ static void parse_return(LexState *ls)
|
|||||||
BCReg nret = expr_list(ls, &e);
|
BCReg nret = expr_list(ls, &e);
|
||||||
if (nret == 1) { /* Return one result. */
|
if (nret == 1) { /* Return one result. */
|
||||||
if (e.k == VCALL) { /* Check for tail call. */
|
if (e.k == VCALL) { /* Check for tail call. */
|
||||||
|
#ifdef LUAJIT_DISABLE_TAILCALL
|
||||||
|
goto notailcall;
|
||||||
|
#else
|
||||||
BCIns *ip = bcptr(fs, &e);
|
BCIns *ip = bcptr(fs, &e);
|
||||||
/* It doesn't pay off to add BC_VARGT just for 'return ...'. */
|
/* It doesn't pay off to add BC_VARGT just for 'return ...'. */
|
||||||
if (bc_op(*ip) == BC_VARG) goto notailcall;
|
if (bc_op(*ip) == BC_VARG) goto notailcall;
|
||||||
fs->pc--;
|
fs->pc--;
|
||||||
ins = BCINS_AD(bc_op(*ip)-BC_CALL+BC_CALLT, bc_a(*ip), bc_c(*ip));
|
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. */
|
} else { /* Can return the result from any register. */
|
||||||
ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2);
|
ins = BCINS_AD(BC_RET1, expr_toanyreg(fs, &e), 2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user