Uh oh!
There was an error while loading. Please reload this page.
re-use sprintf() optimisation for printf() - #19658
Conversation
There is one failing test now: That test got introduced in https://bugs.php.net/bug.php?id=66251 and honestly I am not sure about what that test is actually testing ... OPcodes for the test before this PR: and after: |
realFlowControl
commented
Sep 1, 2025
I just see that the |
Uh oh!
There was an error while loading. Please reload this page.
realFlowControl
commented
Sep 2, 2025
@dstogov do you have an idea why the to |
This is happening in pass1 php-src/Zend/Optimizer/pass1.c Lines 149 to 161 in d25687b The problem seems to be that the ROPE optimisation removes the diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c
index fe92db583fc..e83a87de5b8 100644
--- a/Zend/Optimizer/pass1.c+++ b/Zend/Optimizer/pass1.c@@ -264,6 +264,12 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
collect_constants = 0;
break;
}
+ case ZEND_DO_UCALL:+ case ZEND_DO_FCALL:+ case ZEND_DO_FCALL_BY_NAME:+ collect_constants = 0;+ break;
case ZEND_STRLEN:
if (opline->op1_type == IS_CONST &&
zend_optimizer_eval_strlen(&result, &ZEND_OP1_LITERAL(opline)) == SUCCESS) {solves the issue, although this might have side effects beyond my understanding .. I've applied this patch in 1526406 and CI is green, yet I fear that this has some consequences CI does not cover 😉 |
realFlowControl
commented
Sep 2, 2025
So as expected, with 1526406 the behaviour changes for <?phpechogetA();
constA="hello";
functiongetA() {return A;}from: to: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
743f76f to
56823aaCompareUh oh!
There was an error while loading. Please reload this page.
cf1da03 to
d41d8cbCompared41d8cb to
f1f5c41Comparearnaud-lb
commented
Sep 3, 2025
This looks good to me. I will merge after 8.5 is branched if there are no other comments. |
Uh oh!
There was an error while loading. Please reload this page.
kamil-tekiela
commented
Oct 15, 2025
@arnaud-lb Is this ready to be merged? |
TimWolla
left a comment
There was a problem hiding this comment.
Can't comment on the Optimizer changes, the compiler changes LGTM.
arnaud-lb
commented
Oct 17, 2025
Merged just now. Thank you @realFlowControl! |
This PR piggybacks on #14546
test.php:See
hyperfinerun, wherephp-origis without this patch:The generated opcodes before optimizer:
... and after optimizer: