Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

TysonAndre
Copy link
Contributor

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

Split out of #5097

ext/opcache/Optimizer/sccp.c Outdated Show resolved Hide resolved
}
/* 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 */
Copy link
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.

val = CT_CONSTANT_EX(op_array, opline->op1.constant);
} else {
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
}
Copy link
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
Contributor Author

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
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.

@TysonAndre TysonAndre changed the title Convert ZEND_ECHO operand to string during sccp Convert ZEND_ECHO operand to string Jan 27, 2020
And filter out echoes of the empty string (e.g. false/null)

Split out of php#5097
@php-pulls php-pulls closed this in 5f92a08 Jan 28, 2020
Sign up for free to 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