Last active
October 10, 2019 08:38
-
-
Save dstogov/f1b5560d642eabd258e1080242e12937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c | |
index 46ec6c0769..983d5cf1a9 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 0000000000..788994ea4e | |
--- /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 0000000000..ef7bf479c5 | |
--- /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment