com php-src: Fix JMPZ+JMP => NOP+JMP optimization: ext/opcache/Optimizer/block_pass.c ext/opcache/Optimizer/ pass2.c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    6f950e83eb1467521853d6628f514d2eebef7ebb
Author:    Nikita Popov <[email protected]>         Mon, 10 Apr 2017 22:09:34 +0200
Parents:   8c53c346d45f7623d542b62b1622d6c7a8bf7c42
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=6f950e83eb1467521853d6628f514d2eebef7ebb

Log:
Fix JMPZ+JMP => NOP+JMP optimization

Changed paths:
  M  ext/opcache/Optimizer/block_pass.c
  M  ext/opcache/Optimizer/pass2.c


Diff:
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index 413b8b1..acce8b7 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -1462,7 +1462,9 @@ static void zend_jmp_optimization(zend_code_block *block, zend_op_array *op_arra
 						break;
 					}
 				}
-				if (last_op->op1_type & (IS_VAR|IS_TMP_VAR)) {
+				if (last_op->op1_type == IS_CV) {
+					break;
+				} else if (last_op->op1_type & (IS_VAR|IS_TMP_VAR)) {
 					last_op->opcode = ZEND_FREE;
 					last_op->op2.num = 0;
 					block->op2_to = NULL;
diff --git a/ext/opcache/Optimizer/pass2.c b/ext/opcache/Optimizer/pass2.c
index 4abaa30..098be51 100644
--- a/ext/opcache/Optimizer/pass2.c
+++ b/ext/opcache/Optimizer/pass2.c
@@ -156,7 +156,14 @@ void zend_optimizer_pass2(zend_op_array *op_array)
 					/* JMPNZ(X, L1), JMP(L2) => JMPZNZ(X, L2, L1) */
 					if (ZEND_OP2(opline).opline_num == ZEND_OP1(opline + 1).opline_num) {
 						/* JMPZ(X, L1), JMP(L1) => NOP, JMP(L1) */
-						MAKE_NOP(opline);
+						if (opline->op1_type == IS_CV) {
+							break;
+						} else if (opline->op1_type & (IS_TMP_VAR|IS_VAR)) {
+							opline->opcode = ZEND_FREE;
+							opline->op2.num = 0;
+						} else {
+							MAKE_NOP(opline);
+						}
 					} else {
 						if (opline->opcode == ZEND_JMPZ) {
 							opline->extended_value = ZEND_OP1(opline + 1).opline_num;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.