You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interpreter relies on tail call optimization, which is enabled when
using -O2 and -O3 optimization levels. Consequently, if the optimization
level is set to -O1, the interpreter may encounter a segmentation fault
due to the absence of tail-optimized calls.
In practice, GCC uses the term "tail" as a synonym. Formally, it applies
to functions that have a return type of the same size and a parameter
list with the same total word size.
A sibling call is a special case of a tail call where the caller function
and callee function do not need to be the same, but they must have
compatible stack footprints. This means that the return types of both
functions must be the same, and the arguments being passed must occupy
the same amount of stack space. Every tail recursive call is considered
a sibling call since the definition implies that every function is a
sibling of itself.
Why make this distinction? Because of the identical stack footprint,
replacing the stack frame becomes relatively easier. Compiler developer
do not have to resize the stack frame, and in-place mutation becomes
straightforward.
To ensure efficient instruction dispatch, it is necessary to pass the
option "-foptimize-sibling-calls" to GCC/Clang.
Known issue:
A segmentation fault occurs when compiler optimization is disabled (i.e.,
"-O0").
0 commit comments