Skip to content

Commit 7c45b95

Browse files
committed
Store a reference to closures in the FCC
1 parent 98646e3 commit 7c45b95

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Zend/zend_API.c

+2
Original file line numberDiff line numberDiff line change
@@ -3856,6 +3856,7 @@ ZEND_API bool zend_is_callable_at_frame(
38563856
fcc->called_scope = NULL;
38573857
fcc->function_handler = NULL;
38583858
fcc->object = NULL;
3859+
fcc->closure = NULL;
38593860

38603861
again:
38613862
switch (Z_TYPE_P(callable)) {
@@ -3929,6 +3930,7 @@ ZEND_API bool zend_is_callable_at_frame(
39293930
case IS_OBJECT:
39303931
if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(Z_OBJ_P(callable), &fcc->calling_scope, &fcc->function_handler, &fcc->object, 1) == SUCCESS) {
39313932
fcc->called_scope = fcc->calling_scope;
3933+
fcc->closure = Z_OBJ_P(callable);
39323934
if (fcc == &fcc_local) {
39333935
zend_release_fcall_info_cache(fcc);
39343936
}

Zend/zend_API.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ typedef struct _zend_fcall_info_cache {
5858
zend_function *function_handler;
5959
zend_class_entry *calling_scope;
6060
zend_class_entry *called_scope;
61-
zend_object *object;
61+
zend_object *object; /* Instance of object for method calls */
62+
zend_object *closure; /* Closure reference, only if the callable *is* the object */
6263
} zend_fcall_info_cache;
6364

6465
#define ZEND_NS_NAME(ns, name) ns "\\" name

Zend/zend_execute_API.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ZEND_API zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_n
5050

5151
/* true globals */
5252
ZEND_API const zend_fcall_info empty_fcall_info = {0};
53-
ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { NULL, NULL, NULL, NULL };
53+
ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = {0};
5454

5555
#ifdef ZEND_WIN32
5656
ZEND_TLS HANDLE tq_timer = NULL;

0 commit comments

Comments
 (0)