mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Don't replace SEND opcodes with different by-ref behavior
update_op1_const() implements the right logic here -- these cannot be replaced by different opcodes, as the by-ref passing behavior is not the same.
This commit is contained in:
parent
46d1e503dd
commit
4ad9dbbac9
2 changed files with 19 additions and 11 deletions
|
@ -539,17 +539,6 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array,
|
|||
if (opline->op1_type == type &&
|
||||
opline->op1.var == var) {
|
||||
switch (opline->opcode) {
|
||||
case ZEND_SEND_VAR_EX:
|
||||
case ZEND_SEND_FUNC_ARG:
|
||||
opline->extended_value = 0;
|
||||
opline->opcode = ZEND_SEND_VAL_EX;
|
||||
break;
|
||||
case ZEND_SEND_VAR_NO_REF_EX:
|
||||
opline->opcode = ZEND_SEND_VAL;
|
||||
break;
|
||||
case ZEND_SEND_USER:
|
||||
opline->opcode = ZEND_SEND_VAL_EX;
|
||||
break;
|
||||
/* In most cases IS_TMP_VAR operand may be used only once.
|
||||
* The operands are usually destroyed by the opcode handler.
|
||||
* However, there are some exception which keep the operand alive. In that case
|
||||
|
|
19
Zend/tests/by_ref_optimization.phpt
Normal file
19
Zend/tests/by_ref_optimization.phpt
Normal file
|
@ -0,0 +1,19 @@
|
|||
--TEST--
|
||||
Don't optimize send opcodes that differ in by-ref behavior
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
call_user_func('ref', function_exists('strlen'));
|
||||
ref(function_exists('strlen'));
|
||||
|
||||
function ref(&$x) {
|
||||
var_dump($x);
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: ref(): Argument #1 ($x) must be passed by reference, value given in %s on line %d
|
||||
bool(true)
|
||||
|
||||
Notice: Only variables should be passed by reference in %s on line %d
|
||||
bool(true)
|
Loading…
Add table
Add a link
Reference in a new issue