com php-src: Improve fix for #69038: ext/opcache/Optimizer/zend _optimizer.c ext/opcache/tests/bug69038.phpt
| From: | Xinchen Hui | Date: | Wed, 25 Feb 2015 12:07:02 +0000 |
| Subject: | com php-src: Improve fix for #69038: ext/opcache/Optimizer/zend _optimizer.c ext/opcache/tests/bug69038.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85082@lists.php.net to get a copy of this message | ||
Commit: d508ff9640469bf451b975d83fd2879710db0b46
Author: Xinchen Hui <laruence@php.net> Wed, 25 Feb 2015 20:07:02 +0800
Parents: ffdc5728c8d0c1cc31e2a13d1d7a03e85a85e7f0
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d508ff9640469bf451b975d83fd2879710db0b46
Log:
Improve fix for #69038
Bugs:
https://bugs.php.net/69038
Changed paths:
M ext/opcache/Optimizer/zend_optimizer.c
M ext/opcache/tests/bug69038.phpt
Diff:
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index 7829ee7..6da3370 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -290,15 +290,24 @@ static void replace_tmp_by_const(zend_op_array *op_array,
* and allows its reuse. The number of ZEND_CASE instructions
* usually terminated by ZEND_FREE that finally kills the value.
*/
- if (opline->opcode == ZEND_CASE) {
+ if (opline->opcode == ZEND_CASE || opline->opcode == ZEND_FREE) {
zend_op *m, *n;
int brk = op_array->last_brk_cont;
+ zend_bool in_case = 0;
while (brk--) {
if (op_array->brk_cont_array[brk].start <= (opline - op_array->opcodes) &&
op_array->brk_cont_array[brk].brk > (opline - op_array->opcodes)) {
+ in_case = 1;
break;
}
}
+
+ if (!in_case) {
+ MAKE_NOP(opline);
+ zval_dtor(val);
+ break;
+ }
+
m = opline;
n = op_array->opcodes + op_array->brk_cont_array[brk].brk + 1;
while (m < n) {
@@ -320,10 +329,6 @@ static void replace_tmp_by_const(zend_op_array *op_array,
}
zval_dtor(val);
break;
- } else if (opline->opcode == ZEND_FREE) {
- MAKE_NOP(opline);
- zval_dtor(val);
- break;
} else {
update_op1_const(op_array, opline, val TSRMLS_CC);
break;
diff --git a/ext/opcache/tests/bug69038.phpt b/ext/opcache/tests/bug69038.phpt
index 9aeecfe..bba3c33 100644
--- a/ext/opcache/tests/bug69038.phpt
+++ b/ext/opcache/tests/bug69038.phpt
@@ -39,7 +39,17 @@ function b($b = "bad") {
return $b;
}
var_dump(b());
+
+function c() {
+ switch (PHP_OS) {
+ default: return "bad";
+ case PHP_OS: return "okey";
+ }
+}
+
+var_dump(c());
?>
--EXPECT--
string(4) "okey"
string(4) "okey"
+string(4) "okey"