]> granicus.if.org Git - php/commitdiff
Make gc_collect_cycles hookable.
authorAdam Harvey <aharvey@php.net>
Tue, 2 Dec 2014 20:18:18 +0000 (12:18 -0800)
committerAdam Harvey <aharvey@php.net>
Fri, 23 Jan 2015 19:23:58 +0000 (19:23 +0000)
UPGRADING.INTERNALS
Zend/zend.c
Zend/zend_gc.c
Zend/zend_gc.h

index 900ec41170b3548f7b9181440f86944bb66dc671..426288d3c508e7d82e0e501b81825bbdc5b7ea27 100644 (file)
@@ -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
index dcc95a851a688521c9a72acca8c0966690550948..d28d8ef2410c1286d69adb87c721e2b0655d429d 100644 (file)
@@ -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 */
index 986659dedc2bc4d5ff346e0f5590643bdb550396..dba490025f5bdd5d7c70244a9feea79a34a26363 100644 (file)
@@ -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;
 
index 80425fc7ec26a3d9c1b84b3724d9c33b54557a4e..2be98ee8ec7ca89830adb4eebbb1b1e76afcc75f 100644 (file)
@@ -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) \