]> granicus.if.org Git - php/commitdiff
Explain the disabled optimization pattern
authorDmitry Stogov <dmitry@zend.com>
Wed, 9 Dec 2015 19:22:07 +0000 (22:22 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 9 Dec 2015 19:22:07 +0000 (22:22 +0300)
ext/opcache/Optimizer/pass2.c

index 3573c1038c1cbdbf8d73b54fcfc618fa1c09f221..b61d799fade78c36e289524836cb1745f8b5d382 100644 (file)
@@ -114,14 +114,21 @@ void zend_optimizer_pass2(zend_op_array *op_array)
                        case ZEND_JMPZ_EX:
                        case ZEND_JMPNZ_EX:
                                /* convert Ti = JMPZ_EX(Ti, L) to JMPZ(Ti, L) */
-                               if (0 && /* FIXME: temporary disable unsafe pattern */
-                                   ZEND_OP1_TYPE(opline) == IS_TMP_VAR &&
+#if 0
+                               /* Disabled unsafe pattern: in conjunction with
+                                * ZEND_VM_SMART_BRANCH() this may improperly eliminate
+                                * assignment to Ti.
+                                */
+                               if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR &&
                                    ZEND_RESULT_TYPE(opline) == IS_TMP_VAR &&
                                    ZEND_OP1(opline).var == ZEND_RESULT(opline).var) {
                                        opline->opcode -= 3;
+                                       SET_UNUSED(opline->result);
+                               } else
+#endif
                                /* convert Ti = JMPZ_EX(C, L) => Ti = QM_ASSIGN(C)
                                   in case we know it wouldn't jump */
-                               } else if (ZEND_OP1_TYPE(opline) == IS_CONST) {
+                               if (ZEND_OP1_TYPE(opline) == IS_CONST) {
                                        int should_jmp = zend_is_true(&ZEND_OP1_LITERAL(opline));
                                        if (opline->opcode == ZEND_JMPZ_EX) {
                                                should_jmp = !should_jmp;