com php-src: Fixed SCCP failure, because of aliased objects. For now, mark aliased objects as "escaping". A more clever solution would requitre Heap
Array SSA + Definitely Same and Definitely Different sets construction.: ext/opcache/Optimizer/escape_analysis.c ext/opcache/tests /opt/sccp_017.phpt
ext/opcache/tests/opt/sccp_0 18.phpt
| From: | Dmitry Stogov | Date: | Mon, 11 Sep 2017 13:23:17 +0000 |
| Subject: | com php-src: Fixed SCCP failure, because of aliased objects. For now, mark aliased objects as "escaping". A more clever solution would requitre Heap Array SSA + Definitely Same and Definitely Different sets construction.: ext/opcache/Optimizer/escape_analysis.c ext/opcache/tests /opt/sccp_017.phpt ext/opcache/tests/opt/sccp_0 18.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99349@lists.php.net to get a copy of this message | ||
Commit: d5c527c9db12a1e4a9d1d62c8ed933c60228ae73
Author: Dmitry Stogov <dmitry@zend.com> Mon, 11 Sep 2017 16:23:17 +0300
Parents: 441b826e3a66e09a7be2f153277d1d41361d2e1c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d5c527c9db12a1e4a9d1d62c8ed933c60228ae73
Log:
Fixed SCCP failure, because of aliased objects.
For now, mark aliased objects as "escaping".
A more clever solution would requitre Heap Array SSA + Definitely Same and Definitely Different sets
construction.
Changed paths:
M ext/opcache/Optimizer/escape_analysis.c
A ext/opcache/tests/opt/sccp_017.phpt
A ext/opcache/tests/opt/sccp_018.phpt
Diff:
diff --git a/ext/opcache/Optimizer/escape_analysis.c b/ext/opcache/Optimizer/escape_analysis.c
index db2923b..99e3d26 100644
--- a/ext/opcache/Optimizer/escape_analysis.c
+++ b/ext/opcache/Optimizer/escape_analysis.c
@@ -224,12 +224,12 @@ static int is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int
va
/* no_val */
break;
case ZEND_QM_ASSIGN:
-#if 0
if (opline->op1_type == IS_CV) {
- /* array duplication */
- return 1;
+ if (OP1_INFO() & MAY_BE_OBJECT) {
+ /* object aliasing */
+ return 1;
+ }
}
-#endif
break;
case ZEND_ISSET_ISEMPTY_DIM_OBJ:
case ZEND_ISSET_ISEMPTY_PROP_OBJ:
@@ -274,12 +274,12 @@ static int is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int
va
/* reference dependencies processed separately */
break;
case ZEND_ASSIGN:
-#if 0
if (opline->op2_type == IS_CV) {
- /* array duplication */
- return 1;
+ if (OP2_INFO() & MAY_BE_OBJECT) {
+ /* object aliasing */
+ return 1;
+ }
}
-#endif
break;
default:
return 1;
diff --git a/ext/opcache/tests/opt/sccp_017.phpt b/ext/opcache/tests/opt/sccp_017.phpt
new file mode 100644
index 0000000..4aa7f96
--- /dev/null
+++ b/ext/opcache/tests/opt/sccp_017.phpt
@@ -0,0 +1,29 @@
+--TEST--
+SCCP 017: Array assignemnt
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.opt_debug_level=0x20000
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function foo() {
+ $a = [];
+ $b = $a;
+ $a[0] = 5;
+ $b[0] = 42;
+ return $a[0];
+}
+?>
+--EXPECTF--
+$_main: ; (lines=1, args=0, vars=0, tmps=0)
+ ; (after optimizer)
+ ; %ssccp_017.php:1-10
+L0: RETURN int(1)
+
+foo: ; (lines=1, args=0, vars=0, tmps=0)
+ ; (after optimizer)
+ ; %ssccp_017.php:2-8
+L0: RETURN int(5)
diff --git a/ext/opcache/tests/opt/sccp_018.phpt b/ext/opcache/tests/opt/sccp_018.phpt
new file mode 100644
index 0000000...66a4b6c
--- /dev/null
+++ b/ext/opcache/tests/opt/sccp_018.phpt
@@ -0,0 +1,23 @@
+--TEST--
+SCCP 018: Object assignemnt
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+;opcache.opt_debug_level=0x20000
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function foo() {
+ $a = new stdClass;
+ $b = $a;
+ $a->x = 5;
+ $b->x = 42;
+ echo $a->x;
+ echo "\n";
+}
+foo();
+?>
+--EXPECT--
+42