Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Uh oh!
There was an error while loading. Please reload this page.
VAR|TMP overhaul #20628
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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; | ||
| } | ||
iluuu1994 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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; | ||
MemberAuthor 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --TEST-- | ||
| Missing separation for ASSIGN_DIM with ref OP_DATA | ||
| --FILE-- | ||
| <?php | ||
| function a() { | ||
| $a[] = $b[] = &$a; | ||
| var_dump($a, $b); | ||
| } | ||
| function b() { | ||
| $a = []; | ||
| $b = []; | ||
| $a[] = $b[] = &$a; | ||
| var_dump($a, $b); | ||
| } | ||
| function c() { | ||
| $a[] = $b = &$a; | ||
| var_dump($a, $b); | ||
| } | ||
| function d() { | ||
| $a = $b[] = &$a; | ||
| var_dump($a, $b); | ||
| } | ||
| a(); | ||
| b(); | ||
| c(); | ||
| d(); | ||
| ?> | ||
| --EXPECT-- | ||
| array(1) { | ||
| [0]=> | ||
| NULL | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| &array(1) { | ||
| [0]=> | ||
| NULL | ||
| } | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| array(0) { | ||
| } | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| &array(1) { | ||
| [0]=> | ||
| array(0) { | ||
| } | ||
| } | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| NULL | ||
| } | ||
| array(1) { | ||
| [0]=> | ||
| NULL | ||
| } | ||
| NULL | ||
| array(1) { | ||
| [0]=> | ||
| &NULL | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <?php | ||
| $this->bar(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --TEST-- | ||
| Invalid opcode for method call with FETCH_THIS | ||
| --FILE-- | ||
| <?php | ||
| class Foo { | ||
| public function bar() { | ||
| var_dump($this, __METHOD__); | ||
| } | ||
| public function test() { | ||
| require __DIR__ . '/gh20628_004.inc'; | ||
| } | ||
| } | ||
| (new Foo)->test(); | ||
| ?> | ||
| --EXPECTF-- | ||
| object(Foo)#%d (0) { | ||
| } | ||
| string(8) "Foo::bar" |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.