com php-src: Fixed bug (Phi sources removel): NEWS ext/opcache/ Optimizer/zend_ssa.c ext/opcache/tests/phi_remove_0 01.phpt
ext/opcache/tests/phi_remove_002.ph pt
| From: | Xinchen Hui | Date: | Mon, 16 Oct 2017 07:01:06 +0000 |
| Subject: | com php-src: Fixed bug (Phi sources removel): NEWS ext/opcache/ Optimizer/zend_ssa.c ext/opcache/tests/phi_remove_0 01.phpt ext/opcache/tests/phi_remove_002.ph pt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99757@lists.php.net to get a copy of this message | ||
Commit: 8e147f12b9b0cd9b2488411a2933affa99a13423
Author: Xinchen Hui <laruence@gmail.com> Mon, 16 Oct 2017 14:19:37 +0800
Parents: 7c556c44a10bfc53c37295626e61bd99dc4f550c
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8e147f12b9b0cd9b2488411a2933affa99a13423
Log:
Fixed bug (Phi sources removel)
Changed paths:
M NEWS
M ext/opcache/Optimizer/zend_ssa.c
A ext/opcache/tests/phi_remove_001.phpt
A ext/opcache/tests/phi_remove_002.phpt
Diff:
diff --git a/NEWS b/NEWS
index 8c03208..0fcb02c 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,7 @@ PHP NEWS
key). (Jakub Zelenka)
- Opcache:
+ . Fixed bug (Phi sources removel).. (Laruence)
. Fixed bug #75370 (Webserver hangs on valid PHP text). (Laruence)
. Fixed bug #75357 (segfault loading WordPress wp-admin). (Laruence)
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index 422813f..529cb61 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -1266,10 +1266,12 @@ static inline void zend_ssa_remove_defs_of_instr(zend_ssa *ssa, zend_ssa_op
*ssa
static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int pred_offset,
int predecessors_count) /* {{{ */
{
int j, var_num = phi->sources[pred_offset];
+ zend_ssa_phi *next_phi = phi->use_chains[pred_offset];
predecessors_count--;
if (pred_offset < predecessors_count) {
memmove(phi->sources + pred_offset, phi->sources + pred_offset + 1, (predecessors_count -
pred_offset) * sizeof(uint32_t));
+ memmove(phi->use_chains + pred_offset, phi->use_chains + pred_offset + 1,
(predecessors_count - pred_offset) * sizeof(zend_ssa_phi*));
}
/* Check if they same var is used in a different phi operand as well, in this case we don't
@@ -1278,19 +1280,15 @@ static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi
*phi,
if (phi->sources[j] == var_num) {
if (j < pred_offset) {
ZEND_ASSERT(phi->use_chains[pred_offset] == NULL);
- return;
- }
- if (j >= pred_offset) {
- phi->use_chains[j] = phi->use_chains[pred_offset];
- phi->use_chains[pred_offset] = NULL;
- return;
+ } else if (j >= pred_offset) {
+ phi->use_chains[j] = next_phi;
}
+ return;
}
}
/* Variable only used in one operand, remove the phi from the use chain. */
- zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, phi->use_chains[pred_offset]);
- phi->use_chains[pred_offset] = NULL;
+ zend_ssa_remove_use_of_phi_source(ssa, phi, var_num, next_phi);
}
/* }}} */
diff --git a/ext/opcache/tests/phi_remove_001.phpt b/ext/opcache/tests/phi_remove_001.phpt
new file mode 100644
index 0000000..4be8dcf
--- /dev/null
+++ b/ext/opcache/tests/phi_remove_001.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Phi sources remove 001
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function getOnlyMPEGaudioInfoBruteForce($info) {
+ $Distribution['bitrate'] = array();
+ $Distribution['frequency'] = array();
+ $Distribution['layer'] = array();
+ $Distribution['version'] = array();
+ $Distribution['padding'] = array();
+
+ $max_frames_scan = 5000;
+ $frames_scanned = 0;
+
+ $previousvalidframe = $info['avdataoffset'];
+ while ($info) {
+ if (!isset($MPEGaudioHeaderDecodeCache[$head4])) {
+ $MPEGaudioHeaderDecodeCache[$head4] = MPEGaudioHeaderDecode($head4);
+ }
+ if (!isset($MPEGaudioHeaderValidCache[$head4])) {
+ $MPEGaudioHeaderValidCache[$head4] = MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$head4],
false, false);
+ }
+ if ($MPEGaudioHeaderValidCache[$head4]) {
+
+ if ($MPEGaudioHeaderLengthCache[$head4] > 4) {
+ $WhereWeWere = mftell();
+ $next4 = test(4);
+ if ($next4{0} == "\xFF") {
+ if (!isset($MPEGaudioHeaderDecodeCache[$next4])) {
+ $MPEGaudioHeaderDecodeCache[$next4] = MPEGaudioHeaderDecode($next4);
+ }
+ if (!isset($MPEGaudioHeaderValidCache[$next4])) {
+ $MPEGaudioHeaderValidCache[$next4] =
MPEGaudioHeaderValid($MPEGaudioHeaderDecodeCache[$next4], false, false);
+ }
+ if ($MPEGaudioHeaderValidCache[$next4]) {
+ getid3_lib::safe_inc($Distribution['bitrate'][$LongMPEGbitrateLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['layer'][$LongMPEGlayerLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['version'][$LongMPEGversionLookup[$head4]]);
+ getid3_lib::safe_inc($Distribution['padding'][intval($LongMPEGpaddingLookup[$head4])]);
+ getid3_lib::safe_inc($Distribution['frequency'][$LongMPEGfrequencyLookup[$head4]]);
+ if ($max_frames_scan && (++$frames_scanned >= $max_frames_scan)) {
+ foreach ($Distribution as $key1 => $value1) {
+ foreach ($value1 as $key2 => $value2) {
+ $Distribution[$key1][$key2] = round($value2 / $pct_data_scanned);
+ }
+ }
+ break;
+ }
+ continue;
+ }
+ }
+ unset($next4);
+ }
+
+ }
+ }
+ return true;
+}
+?>
+okey
+--EXPECT--
+okey
diff --git a/ext/opcache/tests/phi_remove_002.phpt b/ext/opcache/tests/phi_remove_002.phpt
new file mode 100644
index 0000000..3b0c429
--- /dev/null
+++ b/ext/opcache/tests/phi_remove_002.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phi sources remove 002
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function func($blogname, $user = '' ) {
+ if (! is_object( $user ) || ( is_object($user) && ( $user->login != $blogname )) ) {
+ test();
+ }
+
+ $result = array('user' => $user);
+
+ return true;
+}
+?>
+okey
+--EXPECT--
+okey