From: Dmitry Stogov Date: Wed, 9 Dec 2015 19:22:07 +0000 (+0300) Subject: Explain the disabled optimization pattern X-Git-Tag: php-7.1.0alpha1~689 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fd7734e5872872e7e739bce3e074f463927ba25;p=php Explain the disabled optimization pattern --- diff --git a/ext/opcache/Optimizer/pass2.c b/ext/opcache/Optimizer/pass2.c index 3573c1038c..b61d799fad 100644 --- a/ext/opcache/Optimizer/pass2.c +++ b/ext/opcache/Optimizer/pass2.c @@ -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;