-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Change YIELD/YIELD_FROM to do not increment opline #15328
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
Change YIELD/YIELD_FROM to do not increment opline #15328
Conversation
Zend/zend_generators.c
Outdated
* generator is being force-closed (opline points to the start of a finally | ||
* block). | ||
*/ | ||
if (EXPECTED(generator->execute_data->opline->opcode != ZEND_HANDLE_EXCEPTION |
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.
The check for ZEND_HANDLE_EXCEPTION is not really necessary as EG(exception_op) has a couple ops at once. Only thing needing check is the force close.
Though, for that case, you can just decrement the opline in zend_generator_dtor_storage before calling this function, eliminating the need for the branch altogether.
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.
Nice!
This changes the ReflectionGenerator::getExecutingLine() output, but I believe that's a good thing. |
This targets master, but do you think we can target 8.2? This may be a breaking change for extensions |
No, you should not target 8.2 I think. I suspect you need to merge the other PR for 8.2, then use this one on master. |
* PHP-8.2: [ci skip] NEWS for phpGH-15275 Fix crash during GC of suspended generator delegate (php#15275)
* PHP-8.3: [ci skip] NEWS for phpGH-15275 [ci skip] NEWS for phpGH-15275 Fix crash during GC of suspended generator delegate (php#15275)
8a7dcbd
to
84ea7a6
Compare
…ndre-daubois) This PR was merged into the 5.4 branch. Discussion ---------- [VarDumper] Fix generator dump format for PHP 8.4 | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Generator dump format likely changed because of php/php-src#15328. I propose to update the test dedicated to dumping generators in PHP >= 8.4. cc `@xabbuh` Commits ------- 6bb252d [VarDumper] Fix generator dump format for PHP 8.4
This is an alternative of #15275
YIELD
andYIELD_FROM
increment opline before returning, but in most places we need the opline to point to theYIELD
andYIELD_FROM
.Here I change
YIELD
/YIELD_FROM
to not increment opline. This simplifies the code a fixes a few crashes.