com php-src: Fixed edge cases introduced by 170ed1f5a7b2f2f052445761080c96a3a3cfa884: ext/opcache/Optimizer /block_pass.c
ext/opcache/tests/opt/block_pass_00 1.phpt ext/opcache/tests/opt/block_pass_002.p hpt

From: Date: Thu, 10 Oct 2019 08:48:31 +0000
Subject: com php-src: Fixed edge cases introduced by 170ed1f5a7b2f2f052445761080c96a3a3cfa884: ext/opcache/Optimizer /block_pass.c
ext/opcache/tests/opt/block_pass_00 1.phpt ext/opcache/tests/opt/block_pass_002.p hpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108850@lists.php.net to get a copy of this message
Commit: 0cb977a69129056b4ee71f67dd1a63fdc883de67 Author: Dmitry Stogov <dmitry@zend.com> Thu, 10 Oct 2019 11:48:31 +0300 Parents: c1da10b77b370c6689675af2c4ce6ffc4ce124df Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0cb977a69129056b4ee71f67dd1a63fdc883de67 Log: Fixed edge cases introduced by 170ed1f5a7b2f2f052445761080c96a3a3cfa884 Changed paths: M ext/opcache/Optimizer/block_pass.c A ext/opcache/tests/opt/block_pass_001.phpt A ext/opcache/tests/opt/block_pass_002.phpt Diff: diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 46ec6c0769d..983d5cf1a9c 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -892,7 +892,12 @@ optimize_const_unary_op: !zend_bitset_in(used_ext, VAR_NUM(opline->op1.var))) { /* T1 = ..., T2 = QM_ASSIGN(T1) to T2 = ..., NOP */ src = VAR_SOURCE(opline->op1); - if (src) { + if (src && + src->opcode != ZEND_COPY_TMP && + src->opcode != ZEND_ADD_ARRAY_ELEMENT && + src->opcode != ZEND_ADD_ARRAY_UNPACK && + (src->opcode != ZEND_DECLARE_LAMBDA_FUNCTION || + src == opline -1)) { src->result.var = opline->result.var; VAR_SOURCE(opline->op1) = NULL; VAR_SOURCE(opline->result) = src; diff --git a/ext/opcache/tests/opt/block_pass_001.phpt b/ext/opcache/tests/opt/block_pass_001.phpt new file mode 100644 index 00000000000..788994ea4e0 --- /dev/null +++ b/ext/opcache/tests/opt/block_pass_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +Block Pass 001: QM_ASSIGN and DECLARE_LAMBDA_FUNCTION +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +abstract class Broadcaster { + protected function normalizeChannelHandlerToCallable($callback) + { + return is_callable($callback) ? $callback : function (...$args) use ($callback) { + return Container::getInstance() + ->make($callback) + ->join(...$args); + }; + } +} +?> +OK +--EXPECT-- +OK diff --git a/ext/opcache/tests/opt/block_pass_002.phpt b/ext/opcache/tests/opt/block_pass_002.phpt new file mode 100644 index 00000000000..ef7bf479c5b --- /dev/null +++ b/ext/opcache/tests/opt/block_pass_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +Block Pass 002: QM_ASSIGN and INIT_ARRAY +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +function foo($key, $value, array $attributes) { + return is_array($value) + ? [$key, array_merge($value, $attributes)] + : [$value, $attributes]; +} +?> +OK +--EXPECT-- +OK

« previous php.cvs (#108850) next »