diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-06-22 14:29:54 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-06-22 14:29:54 +0300 |
commit | 34e58a6447ec516af1cef0dd25dd132fe0fdf272 (patch) | |
tree | 5f5fda496e37c5511d50e0cd20a19ca3a457bedb /Zend/zend_object_handlers.c | |
parent | 3c600e2d61161b2db2c2e9b0e67b2cc8e93df906 (diff) | |
download | php-git-34e58a6447ec516af1cef0dd25dd132fe0fdf272.tar.gz |
Reduced overhead of magic method calls (__get/__set/__unset/__isset/__dectructor/__clone).
Diffstat (limited to 'Zend/zend_object_handlers.c')
-rw-r--r-- | Zend/zend_object_handlers.c | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 5a4c0c075e..1148944a18 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -179,6 +179,8 @@ static void zend_std_call_getter(zval *object, zval *member, zval *retval) /* {{ { zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *orig_fake_scope = EG(fake_scope); + zend_fcall_info fci; + zend_fcall_info_cache fcic; EG(fake_scope) = NULL; @@ -187,7 +189,20 @@ static void zend_std_call_getter(zval *object, zval *member, zval *retval) /* {{ it should return whether the call was successful or not */ - zend_call_method_with_1_params(object, ce, &ce->__get, ZEND_GET_FUNC_NAME, retval, member); + + fci.size = sizeof(fci); + fci.object = Z_OBJ_P(object); + fci.retval = retval; + fci.param_count = 1; + fci.params = member; + fci.no_separation = 1; + ZVAL_UNDEF(&fci.function_name); /* Unused */ + + fcic.function_handler = ce->__get; + fcic.called_scope = ce; + fcic.object = Z_OBJ_P(object); + + zend_call_function(&fci, &fcic); EG(fake_scope) = orig_fake_scope; } @@ -197,6 +212,9 @@ static void zend_std_call_setter(zval *object, zval *member, zval *value) /* {{{ { zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *orig_fake_scope = EG(fake_scope); + zend_fcall_info fci; + zend_fcall_info_cache fcic; + zval args[2], ret; EG(fake_scope) = NULL; @@ -204,7 +222,25 @@ static void zend_std_call_setter(zval *object, zval *member, zval *value) /* {{{ property name value to be set */ - zend_call_method_with_2_params(object, ce, &ce->__set, ZEND_SET_FUNC_NAME, NULL, member, value); + + ZVAL_COPY_VALUE(&args[0], member); + ZVAL_COPY_VALUE(&args[1], value); + ZVAL_UNDEF(&ret); + + fci.size = sizeof(fci); + fci.object = Z_OBJ_P(object); + fci.retval = &ret; + fci.param_count = 2; + fci.params = args; + fci.no_separation = 1; + ZVAL_UNDEF(&fci.function_name); /* Unused */ + + fcic.function_handler = ce->__set; + fcic.called_scope = ce; + fcic.object = Z_OBJ_P(object); + + zend_call_function(&fci, &fcic); + zval_ptr_dtor(&ret); EG(fake_scope) = orig_fake_scope; } @@ -214,6 +250,9 @@ static void zend_std_call_unsetter(zval *object, zval *member) /* {{{ */ { zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *orig_fake_scope = EG(fake_scope); + zend_fcall_info fci; + zend_fcall_info_cache fcic; + zval ret; EG(fake_scope) = NULL; @@ -221,7 +260,22 @@ static void zend_std_call_unsetter(zval *object, zval *member) /* {{{ */ property name */ - zend_call_method_with_1_params(object, ce, &ce->__unset, ZEND_UNSET_FUNC_NAME, NULL, member); + ZVAL_UNDEF(&ret); + + fci.size = sizeof(fci); + fci.object = Z_OBJ_P(object); + fci.retval = &ret; + fci.param_count = 1; + fci.params = member; + fci.no_separation = 1; + ZVAL_UNDEF(&fci.function_name); /* Unused */ + + fcic.function_handler = ce->__unset; + fcic.called_scope = ce; + fcic.object = Z_OBJ_P(object); + + zend_call_function(&fci, &fcic); + zval_ptr_dtor(&ret); EG(fake_scope) = orig_fake_scope; } @@ -231,6 +285,8 @@ static void zend_std_call_issetter(zval *object, zval *member, zval *retval) /* { zend_class_entry *ce = Z_OBJCE_P(object); zend_class_entry *orig_fake_scope = EG(fake_scope); + zend_fcall_info fci; + zend_fcall_info_cache fcic; EG(fake_scope) = NULL; @@ -240,7 +296,19 @@ static void zend_std_call_issetter(zval *object, zval *member, zval *retval) /* it should return whether the property is set or not */ - zend_call_method_with_1_params(object, ce, &ce->__isset, ZEND_ISSET_FUNC_NAME, retval, member); + fci.size = sizeof(fci); + fci.object = Z_OBJ_P(object); + fci.retval = retval; + fci.param_count = 1; + fci.params = member; + fci.no_separation = 1; + ZVAL_UNDEF(&fci.function_name); /* Unused */ + + fcic.function_handler = ce->__isset; + fcic.called_scope = ce; + fcic.object = Z_OBJ_P(object); + + zend_call_function(&fci, &fcic); EG(fake_scope) = orig_fake_scope; } |