summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UPGRADING.INTERNALS7
-rw-r--r--Zend/zend.c3
-rw-r--r--Zend/zend_gc.c4
-rw-r--r--Zend/zend_gc.h6
4 files changed, 18 insertions, 2 deletions
diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 900ec41170..426288d3c5 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -15,6 +15,7 @@ PHP 7.0 INTERNALS UPGRADE NOTES
n. ZEND_ENGINE_2 removal
o. Updated final class modifier
p. TSRM changes
+ q. gc_collect_cycles() is now hookable
2. Build system changes
a. Unix build system changes
@@ -169,6 +170,12 @@ PHP 7.0 INTERNALS UPGRADE NOTES
Additionally, if an extension triggers its own threads, TSRMLS_CACHE shouldn't
be passed to that threads directly.
+ q. gc_collect_cycles() is now a function pointer, and can be replaced in the
+ same manner as zend_execute_ex() if needed (for example, to include the
+ time spent in the garbage collector in a profiler). The default
+ implementation has been renamed to zend_gc_collect_cycles(), and is
+ exported with ZEND_API.
+
========================
2. Build system changes
diff --git a/Zend/zend.c b/Zend/zend.c
index dcc95a851a..d28d8ef241 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -616,6 +616,9 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) /
zend_compile_string = compile_string;
zend_throw_exception_hook = NULL;
+ /* Set up the default garbage collection implementation. */
+ gc_collect_cycles = zend_gc_collect_cycles;
+
zend_init_opcodes_handlers();
/* set up version */
diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c
index 986659dedc..dba490025f 100644
--- a/Zend/zend_gc.c
+++ b/Zend/zend_gc.c
@@ -31,6 +31,8 @@ ZEND_API int gc_globals_id;
ZEND_API zend_gc_globals gc_globals;
#endif
+ZEND_API int (*gc_collect_cycles)(TSRMLS_D);
+
#define GC_REMOVE_FROM_ROOTS(current) \
gc_remove_from_roots((current))
@@ -701,7 +703,7 @@ tail_call:
}
}
-ZEND_API int gc_collect_cycles(void)
+ZEND_API int zend_gc_collect_cycles(void)
{
int count = 0;
diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h
index 80425fc7ec..2be98ee8ec 100644
--- a/Zend/zend_gc.h
+++ b/Zend/zend_gc.h
@@ -119,13 +119,17 @@ extern ZEND_API zend_gc_globals gc_globals;
#endif
BEGIN_EXTERN_C()
-ZEND_API int gc_collect_cycles(void);
+ZEND_API extern int (*gc_collect_cycles)(void);
+
ZEND_API void gc_possible_root(zend_refcounted *ref);
ZEND_API void gc_remove_from_buffer(zend_refcounted *ref);
ZEND_API void gc_globals_ctor(void);
ZEND_API void gc_globals_dtor(void);
ZEND_API void gc_init(void);
ZEND_API void gc_reset(void);
+
+/* The default implementation of the gc_collect_cycles callback. */
+ZEND_API int zend_gc_collect_cycles(void);
END_EXTERN_C()
#define GC_ZVAL_CHECK_POSSIBLE_ROOT(z) \