]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.3' into PHP-7.4
authorDmitry Stogov <dmitry@zend.com>
Mon, 18 Nov 2019 08:27:43 +0000 (11:27 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 18 Nov 2019 08:27:43 +0000 (11:27 +0300)
* PHP-7.3:
  Fix $x = (bool)$x; for undefined with opcache

1  2 
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 287466df4ba64c79ebaa79aa2fef8a37ab1e4e8b,a1cef14b75f17819ca781631331079fbd4593274..e699e5dc23ac08cb2a1695c605a68d88970e3dfd
@@@ -1018,10 -741,12 +1018,12 @@@ ZEND_VM_COLD_CONST_HANDLER(14, ZEND_BOO
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_FALSE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_TRUE(EX_VAR(opline->result.var));
-               if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (OP1_TYPE == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -5319,10 -4848,12 +5321,12 @@@ ZEND_VM_COLD_CONST_HANDLER(52, ZEND_BOO
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_TRUE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_FALSE(EX_VAR(opline->result.var));
-               if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (OP1_TYPE == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
index bb01bb1ee3339180a887e156efd9876a6f7c9c85,11bc82c1c45e86837d73783d2fac9e9b02b172cf..a0cfc277bdd6855a448f77ea3fd199b2d407aaf7
@@@ -3276,10 -2485,12 +3276,12 @@@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_FALSE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_TRUE(EX_VAR(opline->result.var));
-               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (IS_CONST == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -3851,10 -3058,12 +3853,12 @@@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_TRUE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_FALSE(EX_VAR(opline->result.var));
-               if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (IS_CONST == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -13286,10 -12105,12 +13290,12 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_FALSE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_TRUE(EX_VAR(opline->result.var));
-               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -13548,10 -12369,12 +13554,12 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_TRUE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_FALSE(EX_VAR(opline->result.var));
-               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -36479,10 -36419,12 +36487,12 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_FALSE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_TRUE(EX_VAR(opline->result.var));
-               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (IS_CV == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {
@@@ -37362,10 -37244,12 +37372,12 @@@ static ZEND_OPCODE_HANDLER_RET ZEND_FAS
        if (Z_TYPE_INFO_P(val) == IS_TRUE) {
                ZVAL_TRUE(EX_VAR(opline->result.var));
        } else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
+               /* The result and op1 can be the same cv zval */
+               const uint32_t orig_val_type = Z_TYPE_INFO_P(val);
                ZVAL_FALSE(EX_VAR(opline->result.var));
-               if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
+               if (IS_CV == IS_CV && UNEXPECTED(orig_val_type == IS_UNDEF)) {
                        SAVE_OPLINE();
 -                      GET_OP1_UNDEF_CV(val, BP_VAR_R);
 +                      ZVAL_UNDEFINED_OP1();
                        ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
                }
        } else {