Elide the type check on typed property writes when the value type is statically proven#22347
Open
azjezz wants to merge 3 commits into
Open
Elide the type check on typed property writes when the value type is statically proven#22347azjezz wants to merge 3 commits into
azjezz wants to merge 3 commits into
Conversation
Signed-off-by: azjezz <azjezz@protonmail.com>
1bbd75c to
faa7adc
Compare
Signed-off-by: azjezz <azjezz@protonmail.com>
azjezz
commented
Jun 16, 2026
Comment on lines
14900
to
+14997
| @@ -14989,7 +14994,7 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit, | |||
| ir_END_list(slow_inputs); | |||
| ir_IF_TRUE(if_def); | |||
| } | |||
| if (ZEND_TYPE_IS_SET(prop_info->type)) { | |||
| if (ZEND_TYPE_IS_SET(prop_info->type) && !skip_type_check) { | |||
Author
There was a problem hiding this comment.
I couldn't verify this locally. and honestly not sure about it..
Signed-off-by: azjezz <azjezz@protonmail.com>
Contributor
|
This PR implements #13100. I am suprised this PR only improves the performance by 0.04% on Symfony demo. I would expect more performance gain. Does this PR really drops most of the type checks? |
Author
|
@mvorisek Sorry did not see the open issue for this! As for Symfony, honestly no idea, haven't benchmarked it. It does remove type checks for cases that i have tested. |
Member
|
I agree, a statistic of how many type checks in something like Symfony Demo can be elided would be nice. The instruction count difference is effectively nonexistent, so maybe it doesn't work as expected. |
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.
Assigning to a typed property runs
zend_assign_to_typed_prop()on every write, azend_never_inlinecall that verifies (and may coerce) the value against the property type. When the optimizer can already prove the value satisfies the property type with no coercion, that check is pure overhead.This is extremely common: constructor property promotion, plain
$this->x = $xfrom typed parameters, and fluent setters all hit it on every call. Neither the DFA optimizer nor the JIT elided it before.