summaryrefslogtreecommitdiff
path: root/Zend/zend_objects.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-08 17:10:24 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-09 16:21:54 +0200
commit257dbb04501391e0ac57e66aebe2e4d25dcc5c91 (patch)
tree2ea10373c366bc81468d3172ed49fb4860741a90 /Zend/zend_objects.c
parentbcada03f48b242930ded84d66c1f0b826176f696 (diff)
downloadphp-git-257dbb04501391e0ac57e66aebe2e4d25dcc5c91.tar.gz
Add zend_call_known_function() API family
This adds the following APIs: void zend_call_known_function( zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method( zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method_with_0_params( zend_function *fn, zend_object *object, zval *retval_ptr); void zend_call_known_instance_method_with_1_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param); void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); These are used to perform a call if you already have the zend_function you want to call. zend_call_known_function() is the base API, the rest are just really thin wrappers around it for the common case of instance method calls. Closes GH-5692.
Diffstat (limited to 'Zend/zend_objects.c')
-rw-r--r--Zend/zend_objects.c42
1 files changed, 2 insertions, 40 deletions
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index 13a6b45a7c..f25983ece3 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -98,9 +98,6 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
if (destructor) {
zend_object *old_exception;
zend_class_entry *orig_fake_scope;
- zend_fcall_info fci;
- zend_fcall_info_cache fcic;
- zval ret;
if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
@@ -162,22 +159,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
orig_fake_scope = EG(fake_scope);
EG(fake_scope) = NULL;
- ZVAL_UNDEF(&ret);
-
- fci.size = sizeof(fci);
- fci.object = object;
- fci.retval = &ret;
- fci.param_count = 0;
- fci.params = NULL;
- fci.no_separation = 1;
- ZVAL_UNDEF(&fci.function_name); /* Unused */
-
- fcic.function_handler = destructor;
- fcic.called_scope = object->ce;
- fcic.object = object;
-
- zend_call_function(&fci, &fcic);
- zval_ptr_dtor(&ret);
+ zend_call_known_instance_method_with_0_params(destructor, object, NULL);
if (old_exception) {
if (EG(exception)) {
@@ -264,28 +246,8 @@ ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object,
}
if (old_object->ce->clone) {
- zend_fcall_info fci;
- zend_fcall_info_cache fcic;
- zval ret;
-
GC_ADDREF(new_object);
-
- ZVAL_UNDEF(&ret);
-
- fci.size = sizeof(fci);
- fci.object = new_object;
- fci.retval = &ret;
- fci.param_count = 0;
- fci.params = NULL;
- fci.no_separation = 1;
- ZVAL_UNDEF(&fci.function_name); /* Unused */
-
- fcic.function_handler = new_object->ce->clone;
- fcic.called_scope = new_object->ce;
- fcic.object = new_object;
-
- zend_call_function(&fci, &fcic);
- zval_ptr_dtor(&ret);
+ zend_call_known_instance_method_with_0_params(new_object->ce->clone, new_object, NULL);
OBJ_RELEASE(new_object);
}
}