From 48a34bc1202e9664121c9e9aa004c79ac71af3f5 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 24 Apr 2020 18:59:13 +0200 Subject: Add helper APIs for get_gc implementations get_gc() implementations that need to explore heterogeneous data currently work by computing how many GC entries they need, allocating a buffer for that and storing it on the object. This is inefficient and wastes memory, because the buffer is retained after the GC run. This commit adds an API for a single global GC buffer, which can be reused by get_gc implementations (as only one get_gc call is ever active at the same time). The GC buffer will automatically grow during the GC run and be discarded at the end. --- Zend/zend_execute_API.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Zend/zend_execute_API.c') diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 1c7c904b19..ce801c3098 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -184,6 +184,8 @@ void init_executor(void) /* {{{ */ EG(persistent_functions_count) = EG(function_table)->nNumUsed; EG(persistent_classes_count) = EG(class_table)->nNumUsed; + EG(get_gc_buffer).start = EG(get_gc_buffer).end = EG(get_gc_buffer).cur = NULL; + zend_weakrefs_init(); EG(active) = 1; -- cgit v1.2.1