com php-src: Replace var is introduced: ext/opcache/Optimizer/z end_optimizer.c ext/opcache/tests/bug69038.ph pt
| From: | Xinchen Hui | Date: | Tue, 17 Feb 2015 13:16:37 +0000 |
| Subject: | com php-src: Replace var is introduced: ext/opcache/Optimizer/z end_optimizer.c ext/opcache/tests/bug69038.ph pt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84962@lists.php.net to get a copy of this message | ||
Commit: e22759b1e550b29117531fdce07df618234e79a0
Author: Xinchen Hui <laruence@php.net> Tue, 17 Feb 2015 21:16:37 +0800
Parents: dec83ea4ac96aa3d5b888b850d90d93e9e19ac78
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e22759b1e550b29117531fdce07df618234e79a0
Log:
Replace var is introduced
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 bd1bf44..588aab9 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -331,6 +331,41 @@ static int replace_var_by_const(zend_op_array *op_array,
}
opline->opcode = ZEND_SEND_VAL;
break;
+ case ZEND_CASE: {
+ zend_op *m, *n;
+ int brk = op_array->last_brk_cont;
+ 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)) {
+ break;
+ }
+ }
+ m = opline;
+ n = op_array->opcodes + op_array->brk_cont_array[brk].brk + 1;
+ while (m < n) {
+ if (ZEND_OP1_TYPE(m) == IS_VAR &&
+ ZEND_OP1(m).var == var) {
+ if (m->opcode == ZEND_CASE) {
+ zval old_val;
+ old_val = *val;
+ zval_copy_ctor(val);
+ update_op1_const(op_array, m, val TSRMLS_CC);
+ *val = old_val;
+ } else if (m->opcode == ZEND_SWITCH_FREE) {
+ MAKE_NOP(m);
+ } else {
+ ZEND_ASSERT(0);
+ }
+ }
+ m++;
+ }
+ zval_dtor(val);
+ return 1;
+ }
+ case ZEND_SWITCH_FREE:
+ MAKE_NOP(opline);
+ zval_dtor(val);
+ return 1;
default:
break;
}
diff --git a/ext/opcache/tests/bug69038.phpt b/ext/opcache/tests/bug69038.phpt
index 9aeecfe..f0c5491 100644
--- a/ext/opcache/tests/bug69038.phpt
+++ b/ext/opcache/tests/bug69038.phpt
@@ -39,7 +39,18 @@ function b($b = "bad") {
return $b;
}
var_dump(b());
+
+function c($b = "bad") {
+ switch (extension_loaded("standard")) {
+ case 0 : return "LALALAL";
+ case 1 : return "okey";
+ default : return "bad";
+ }
+}
+var_dump(c());
+
?>
--EXPECT--
string(4) "okey"
string(4) "okey"
+string(4) "okey"