summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-06-05 14:20:39 +0300
committerDmitry Stogov <dmitry@zend.com>2020-06-05 14:20:39 +0300
commit91f283a0bfc6792d84fb9a6361e21f6f33769c4d (patch)
treeb653acc1ceef639f370b06dd3c47225641191d44
parent3a031e0b03f11b40b8b374472336d9a6df4d81b8 (diff)
downloadphp-git-91f283a0bfc6792d84fb9a6361e21f6f33769c4d.tar.gz
micro-optimization
-rw-r--r--Zend/zend_execute.c9
-rw-r--r--Zend/zend_execute.h24
2 files changed, 20 insertions, 13 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 11e1904461..6a56dfdb1e 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -3109,10 +3109,17 @@ static zend_always_inline void i_zval_ptr_dtor_noref(zval *zval_ptr) {
}
}
-ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, zend_uchar value_type, zend_bool strict, zend_refcounted *ref)
+ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *orig_value, zend_uchar value_type, zend_bool strict)
{
zend_bool ret;
zval value;
+ zend_refcounted *ref = NULL;
+
+ if (Z_ISREF_P(orig_value)) {
+ ref = Z_COUNTED_P(orig_value);
+ orig_value = Z_REFVAL_P(orig_value);
+ }
+
ZVAL_COPY(&value, orig_value);
ret = zend_verify_ref_assignable_zval(Z_REF_P(variable_ptr), &value, strict);
variable_ptr = Z_REFVAL_P(variable_ptr);
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 2299adf62f..58e1bbc2a9 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -86,10 +86,17 @@ ZEND_API zend_bool zend_value_instanceof_static(zval *zv);
ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
-ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict, zend_refcounted *ref);
+ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict);
-static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type, zend_refcounted *ref)
+static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
{
+ zend_refcounted *ref = NULL;
+
+ if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
+ ref = Z_COUNTED_P(value);
+ value = Z_REFVAL_P(value);
+ }
+
ZVAL_COPY_VALUE(variable_ptr, value);
if (ZEND_CONST_COND(value_type == IS_CONST, 0)) {
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
@@ -110,20 +117,13 @@ static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *v
static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type, zend_bool strict)
{
- zend_refcounted *ref = NULL;
-
- if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
- ref = Z_COUNTED_P(value);
- value = Z_REFVAL_P(value);
- }
-
do {
if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
zend_refcounted *garbage;
if (Z_ISREF_P(variable_ptr)) {
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) {
- return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict, ref);
+ return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict);
}
variable_ptr = Z_REFVAL_P(variable_ptr);
@@ -132,7 +132,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
}
}
garbage = Z_COUNTED_P(variable_ptr);
- zend_copy_to_variable(variable_ptr, value, value_type, ref);
+ zend_copy_to_variable(variable_ptr, value, value_type);
if (GC_DELREF(garbage) == 0) {
rc_dtor_func(garbage);
} else { /* we need to split */
@@ -145,7 +145,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
}
} while (0);
- zend_copy_to_variable(variable_ptr, value, value_type, ref);
+ zend_copy_to_variable(variable_ptr, value, value_type);
return variable_ptr;
}