]> granicus.if.org Git - php/commitdiff
Sync convert_to_null with VM cast behavior
authorNikita Popov <nikic@php.net>
Sun, 4 Sep 2016 10:36:16 +0000 (12:36 +0200)
committerNikita Popov <nikic@php.net>
Sun, 4 Sep 2016 10:36:16 +0000 (12:36 +0200)
Do not call cast_object, this is useless and we haven't been doing
it in the VM as of 7.0.

Zend/zend_operators.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index 4159e43e530a7d604d8f1bac1bf785fa034bfbdc..9a90250934af4320ebf23a0462b2601cc1abeb2e 100644 (file)
@@ -411,19 +411,6 @@ try_again:
 
 ZEND_API void ZEND_FASTCALL convert_to_null(zval *op) /* {{{ */
 {
-       if (Z_TYPE_P(op) == IS_OBJECT) {
-               if (Z_OBJ_HT_P(op)->cast_object) {
-                       zval org;
-
-                       ZVAL_COPY_VALUE(&org, op);
-                       if (Z_OBJ_HT_P(op)->cast_object(&org, op, IS_NULL) == SUCCESS) {
-                               zval_dtor(&org);
-                               return;
-                       }
-                       ZVAL_COPY_VALUE(op, &org);
-               }
-       }
-
        zval_ptr_dtor(op);
        ZVAL_NULL(op);
 }
index 068235b884ab8e82021f07a113b8d288c190e42a..2c90e0ff95eac28f3db02cc4c30e1615b8583c92 100644 (file)
@@ -5278,20 +5278,6 @@ ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE)
 
        switch (opline->extended_value) {
                case IS_NULL:
-                       /* This code is taken from convert_to_null. However, it does not seems very useful,
-                        * because a conversion to null always results in the same value. This could only
-                        * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
-#if 0
-                       if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
-                               ZVAL_DEREF(expr);
-                       }
-                       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
-                               if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
-                                       break;
-                               }
-                       }
-#endif
-
                        ZVAL_NULL(result);
                        break;
                case _IS_BOOL:
index e5e364c585aa7d074cdb14c69ae3204eab4262a0..fe2e319dc2aef78889923650c4064c381575153f 100644 (file)
@@ -3291,20 +3291,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CONST_HANDLER(ZEND_O
 
        switch (opline->extended_value) {
                case IS_NULL:
-                       /* This code is taken from convert_to_null. However, it does not seems very useful,
-                        * because a conversion to null always results in the same value. This could only
-                        * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
-#if 0
-                       if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
-                               ZVAL_DEREF(expr);
-                       }
-                       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
-                               if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
-                                       break;
-                               }
-                       }
-#endif
-
                        ZVAL_NULL(result);
                        break;
                case _IS_BOOL:
@@ -12416,20 +12402,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_TMP_HANDLER(ZEND_OPC
 
        switch (opline->extended_value) {
                case IS_NULL:
-                       /* This code is taken from convert_to_null. However, it does not seems very useful,
-                        * because a conversion to null always results in the same value. This could only
-                        * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
-#if 0
-                       if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) {
-                               ZVAL_DEREF(expr);
-                       }
-                       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
-                               if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
-                                       break;
-                               }
-                       }
-#endif
-
                        ZVAL_NULL(result);
                        break;
                case _IS_BOOL:
@@ -15982,20 +15954,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_VAR_HANDLER(ZEND_OPC
 
        switch (opline->extended_value) {
                case IS_NULL:
-                       /* This code is taken from convert_to_null. However, it does not seems very useful,
-                        * because a conversion to null always results in the same value. This could only
-                        * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
-#if 0
-                       if (IS_VAR == IS_VAR || IS_VAR == IS_CV) {
-                               ZVAL_DEREF(expr);
-                       }
-                       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
-                               if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
-                                       break;
-                               }
-                       }
-#endif
-
                        ZVAL_NULL(result);
                        break;
                case _IS_BOOL:
@@ -35015,20 +34973,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CAST_SPEC_CV_HANDLER(ZEND_OPCO
 
        switch (opline->extended_value) {
                case IS_NULL:
-                       /* This code is taken from convert_to_null. However, it does not seems very useful,
-                        * because a conversion to null always results in the same value. This could only
-                        * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
-#if 0
-                       if (IS_CV == IS_VAR || IS_CV == IS_CV) {
-                               ZVAL_DEREF(expr);
-                       }
-                       if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
-                               if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
-                                       break;
-                               }
-                       }
-#endif
-
                        ZVAL_NULL(result);
                        break;
                case _IS_BOOL: