-
Notifications
You must be signed in to change notification settings - Fork 8k
VAR|TMP overhaul #20628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
VAR|TMP overhaul #20628
Changes from all commits
c771409
f8b7219
5710a4a
9bdeafe
e38a22d
dba2294
143dfe8
6320984
9ad830a
ce61886
9ddff66
a4fa551
6babcab
545d56f
d63a4ff
4ad5861
448ce15
8491949
30e866d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,10 +162,16 @@ static inline bool may_have_side_effects( | |
| case ZEND_EXT_FCALL_END: | ||
| case ZEND_TICKS: | ||
| case ZEND_YIELD: | ||
| case ZEND_YIELD_FROM: | ||
| case ZEND_VERIFY_NEVER_TYPE: | ||
| /* Intrinsic side effects */ | ||
| return true; | ||
| case ZEND_YIELD_FROM: { | ||
| uint32_t t1 = OP1_INFO(); | ||
| if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && MAY_BE_EMPTY_ONLY(t1)) { | ||
| return false; | ||
| } | ||
| return true; | ||
| } | ||
|
Comment on lines
+168
to
+174
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This allows DCE pass to drop
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree this is not a very useful optimization, though see ext/opcache/tests/opt/sccp_032.phpt where
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems I was wrong and elimination is possible. This is not clear from the |
||
| case ZEND_DO_FCALL: | ||
| case ZEND_DO_FCALL_BY_NAME: | ||
| case ZEND_DO_ICALL: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5336,6 +5336,13 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op | |
| return 1; | ||
| } | ||
| return 0; | ||
| case ZEND_YIELD_FROM: { | ||
| uint32_t t1 = OP1_INFO(); | ||
| if ((t1 & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY && MAY_BE_EMPTY_ONLY(t1)) { | ||
| return false; | ||
| } | ||
| return true; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would not mind doing the inverse - changing YIELD_FROM to not throw on empty array, though...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking into account the "closed" generator, this is wrong. |
||
| } | ||
| default: | ||
| return 1; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --TEST-- | ||
| Nullsafe operator does not support BP_VAR_W | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function &test($foo) { | ||
| return $foo?->bar(); | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot take reference of a nullsafe chain in %s on line %d |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --TEST-- | ||
| Pipes support return-by-reference | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function &foo($val) { | ||
| global $x; | ||
| $x = $val; | ||
| return $x; | ||
| } | ||
|
|
||
| function &bar() { | ||
| return 42 |> foo(...); | ||
| } | ||
|
|
||
| $xRef = &bar(); | ||
| $xRef++; | ||
| var_dump($x); | ||
|
|
||
| ?> | ||
| --EXPECT-- | ||
| int(43) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing
QM_ASSIGNwithFREEopens possibility to deeper application of the same optimization.