-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Convert ZEND_ECHO operand to string #5118
Conversation
596d4c8
to
64387ef
Compare
} | ||
/* TODO: In a subsequent pass, *after* this step and compacting nops, combine consecutive ZEND_ECHOs using the block information from ssa->cfg */ | ||
/* (e.g. for ext/opcache/tests/opt/sccp_010.phpt) */ | ||
/* https://github.com/php/php-src/pull/5097#issuecomment-577306560 */ |
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.
These comments don't really make sense in this context anymore.
val = CT_CONSTANT_EX(op_array, opline->op1.constant); | ||
} else { | ||
opline->op1.constant = zend_optimizer_add_literal(op_array, val); | ||
} |
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.
I'd write this as:
if (Z_TYPE_P(val) != IS_STRING && zend_optimizer_eval_cast(&zv, IS_STRING, val) == SUCCESS) {
zval_ptr_dtor_nogc(val);
val = &zv;
}
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
Destroying val
is technically not necessary because it so happens that the cast can only succeed if the original value wasn't refcounted, but I think this makes the logic of the code more obvious.
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.
Is IS_RESOURCE possible (e.g. STDOUT)? That is refcounted
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.
I believe inside opcache it's not possible.
64387ef
to
cb97922
Compare
And filter out echoes of the empty string (e.g. false/null) Split out of php#5097
9f4aed5
to
bbf16d9
Compare
And filter out echoes of the empty string (e.g. false/null)
Split out of #5097