From bbdff7ea24d97cdc198b413165a5218213b6c22d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 4 Sep 2016 12:36:16 +0200 Subject: [PATCH] Sync convert_to_null with VM cast behavior 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 | 13 ---------- Zend/zend_vm_def.h | 14 ----------- Zend/zend_vm_execute.h | 56 ------------------------------------------ 3 files changed, 83 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 4159e43e53..9a90250934 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -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); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 068235b884..2c90e0ff95 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -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: diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index e5e364c585..fe2e319dc2 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -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: -- 2.50.1