php-internal-docs 8.4.8
Unofficial docs for php/php-src
|
#include "zend.h"
#include "zend_API.h"
#include "zend_compile.h"
#include "zend_errors.h"
#include "zend_fibers.h"
#include "zend_hrtime.h"
#include "zend_portability.h"
#include "zend_types.h"
#include "zend_weakrefs.h"
#include "zend_string.h"
Go to the source code of this file.
Data Structures | |
struct | _gc_root_buffer |
struct | _zend_gc_globals |
struct | _gc_stack |
Typedefs | |
typedef struct _gc_root_buffer | gc_root_buffer |
typedef struct _zend_gc_globals | zend_gc_globals |
typedef struct _gc_stack | gc_stack |
Functions | |
void | gc_globals_ctor (void) |
void | gc_globals_dtor (void) |
void | gc_reset (void) |
ZEND_API bool | gc_enable (bool enable) |
ZEND_API bool | gc_enabled (void) |
ZEND_API bool | gc_protect (bool protect) |
ZEND_API bool | gc_protected (void) |
ZEND_API void ZEND_FASTCALL | gc_possible_root (zend_refcounted *ref) |
ZEND_API void ZEND_FASTCALL | gc_remove_from_buffer (zend_refcounted *ref) |
ZEND_API int | zend_gc_collect_cycles (void) |
ZEND_API void | zend_gc_get_status (zend_gc_status *status) |
ZEND_API zend_get_gc_buffer * | zend_get_gc_buffer_create (void) |
ZEND_API void | zend_get_gc_buffer_grow (zend_get_gc_buffer *gc_buffer) |
void | gc_init (void) |
Variables | |
ZEND_API int(* | gc_collect_cycles )(void) |
#define GC_FETCH_NEXT_UNUSED | ( | ) |
#define GC_HAS_NEXT_UNUSED | ( | ) |
#define GC_HAS_NEXT_UNUSED_UNDER_THRESHOLD | ( | ) |
#define GC_HAS_UNUSED | ( | ) |
#define GC_IDX2LIST | ( | idx | ) |
#define GC_IDX2PTR | ( | idx | ) |
#define GC_LINK_UNUSED | ( | root | ) |
#define GC_LIST2IDX | ( | list | ) |
#define GC_REF_ADDRESS | ( | ref | ) |
#define GC_REF_COLOR | ( | ref | ) |
#define GC_REF_SET_BLACK | ( | ref | ) |
#define GC_REF_SET_COLOR | ( | ref, | |
c ) |
#define GC_REF_SET_INFO | ( | ref, | |
info ) |
#define GC_REF_SET_PURPLE | ( | ref | ) |
#define GC_STACK_POP | ( | ) |
#define GC_STACK_PUSH | ( | ref | ) |
#define GC_STACK_SEGMENT_SIZE (((4096 - ZEND_MM_OVERHEAD) / sizeof(void*)) - 2) |
#define GC_THRESHOLD_DEFAULT (10000 + GC_FIRST_ROOT) |
#define GC_UNUSED 0x1 /* part of linked list of unused buffers */ |
#define ZEND_GC_DEBUG 0 |
BLACK (GC_BLACK) - In use or free. GREY (GC_GREY) - Possible member of cycle. WHITE (GC_WHITE) - Member of garbage cycle. PURPLE (GC_PURPLE) - Possible root of cycle.
GREEN - Acyclic RED - Candidate cycle undergoing ORANGE - Candidate cycle awaiting epoch boundary.
The garbage collect cycle starts from 'gc_mark_roots', which traverses the possible roots, and calls mark_grey for roots are marked purple with depth-first traverse.
After all possible roots are traversed and marked, gc_scan_roots will be called, and each root will be called with gc_scan(root->ref)
gc_scan checks the colors of possible members.
If the node is marked as grey and the refcount > 0 gc_scan_black will be called on that node to scan it's subgraph. otherwise (refcount == 0), it marks the node white.
A node MAY be added to possible roots when ZEND_UNSET_VAR happens or zend_assign_to_variable is called only when possible garbage node is produced. gc_possible_root() will be called to add the nodes to possible roots.
For objects, we call their get_gc handler (by default 'zend_std_get_gc') to get the object properties to scan.
typedef struct _gc_root_buffer gc_root_buffer |
typedef struct _zend_gc_globals zend_gc_globals |
ZEND_API void ZEND_FASTCALL gc_possible_root | ( | zend_refcounted * | ref | ) |
ZEND_API void ZEND_FASTCALL gc_remove_from_buffer | ( | zend_refcounted * | ref | ) |
ZEND_API void zend_gc_get_status | ( | zend_gc_status * | status | ) |
ZEND_API zend_get_gc_buffer * zend_get_gc_buffer_create | ( | void | ) |
ZEND_API void zend_get_gc_buffer_grow | ( | zend_get_gc_buffer * | gc_buffer | ) |