Skip to content

Convert ZEND_ECHO operand to string - #5118

Closed
TysonAndre wants to merge 1 commit into
php:masterfrom
TysonAndre:optimize-echo
Closed

Convert ZEND_ECHO operand to string#5118
TysonAndre wants to merge 1 commit into
php:masterfrom
TysonAndre:optimize-echo

Conversation

@TysonAndre

Copy link
Copy Markdown
Contributor

And filter out echoes of the empty string (e.g. false/null)

Split out of #5097

Comment threadext/opcache/Optimizer/sccp.c Outdated

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
ContributorAuthor

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

Copy link
Copy Markdown
Member

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.

@TysonAndreTysonAndre changed the title Convert ZEND_ECHO operand to string during sccpConvert ZEND_ECHO operand to stringJan 27, 2020
And filter out echoes of the empty string (e.g. false/null)
Split out of php#5097
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@TysonAndre@nikic