Repository navigation
Commit 6807620
committed
Skip constant-array guards when creating conditional expressions for subtype-absorbed targets
- In MutatingScope::createConditionalExpressions(), a subtype-absorbed
variable is kept as a conditional-expression *target* (since #5876) so it
can be re-narrowed when its guard is re-asserted. Pairing such a target with
a constant-array guard, however, never re-narrows anything: a constant array
represents a unique literal value that is not re-asserted as a condition
later. Those conditional expressions were pure cost — the downstream
isSuperTypeOf() guard machinery (including the reverse check added in #5848)
compared these potentially huge constant arrays on every branch merge during
loop convergence.
- Skip creating a conditional expression for a subtype-absorbed target when the
guard's type is a constant array, avoiding both the holder creation and the
expensive guard-selection comparisons.
- Recovers the ~15% analysis-time regression on constant-array-heavy loop code
(tests/bench/data/bug-10538.php) while preserving the #5876 inference
improvement (bug-7948, bug-11281 remain green).
- Verified the removed conditional expressions never produced a re-narrowing
(a constant-array-guarded absorbed target already inferred the widened type
both before and after the change), so behavior is unchanged — all 1671
NodeScopeResolver inference tests pass identically.
- Probed broadening the skip to all targets (not just subtype-absorbed ones):
it recovers even more time but breaks a legitimate re-narrowing that relies
on a constant-array guard, so the skip is scoped to subtype-absorbed targets.1 parent ef3fe97 commit 6807620
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3927 | 3927 | | |
3928 | 3928 | | |
3929 | 3929 | | |
| 3930 | + | |
3930 | 3931 | | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
3931 | 3941 | | |
3932 | 3942 | | |
3933 | 3943 | | |
| |||
0 commit comments