Prevent inlining of zend_compile_expr_inner() to guarantee low stack usage of compilation - #23294
Open
kubawerlos wants to merge 2 commits into
Conversation
zend_compile_expr_inner() to reduce stack usage of compilationzend_compile_expr_inner() to guarantee low stack usage of compilation
…k usage of compilation
kubawerlos
marked this pull request as ready for review
August 15, 2026 14:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zend_compile_expr_inner()sits in the per-nesting-level recursion cycle of the compiler but normally releases its ~456-byte frame via a tail call before recursing, so a nesting level costs ~155 bytes of stack. Inlined into the cycle, the cost triples (~467 bytes) and the max nesting depth under a 1 MBzend.max_allowed_stack_sizedrops from ~6700 to ~2200. This actually happened: 07d308a made GCC start inlining it (master shipped ~3 weeks with 3× cost until deeply nested generated code stopped compiling), and fde23df accidentally undid it. Both flips were side effects of unrelated lineno changes — which are planned to return in another form.zend_never_inlinemakes the cheap state guaranteed instead of accidental; on current master (GCC 13.3 -O2) the compiled output is byte-identical with and without it.No regression test: one existed while the inlined state was on master and genuinely discriminated there, but since fde23df both builds are identical, so it passes either way on release builds while false-failing on debug (-O0) builds. A test cannot detect an annotation with no observable effect; the attribute and its code comment carry the protection.