From 5bf89ce61c4e5948cde1b6d4eaec4d3ae4317596 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Thu, 21 Jun 2001 22:30:23 +0000 Subject: [PATCH] - Hopefully fix bug #11476 and improve garbage to be freed very quickly. Tree tagged as PRE_GRANULAR_GARBAGE_FIX before commiting. --- Zend/zend_execute.c | 3 +++ Zend/zend_execute_locks.h | 24 ++++++++++++------------ Zend/zend_globals.h | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 989a1dd4cc..0ea12af77e 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1008,6 +1008,9 @@ ZEND_API void execute(zend_op_array *op_array ELS_DC) zend_timeout(0); } #endif + + zend_clean_garbage(ELS_C); + switch(opline->opcode) { case ZEND_ADD: EG(binary_op) = add_function; diff --git a/Zend/zend_execute_locks.h b/Zend/zend_execute_locks.h index da389fb519..2b6d143a21 100644 --- a/Zend/zend_execute_locks.h +++ b/Zend/zend_execute_locks.h @@ -13,18 +13,18 @@ static inline zend_pzval_lock_func(zval *z) static inline zend_pzval_unlock_func(zval *z ELS_DC) { ((z)->refcount--); - if (!(z)->refcount) { - (z)->refcount = 1; - (z)->is_ref = 0; - if (EG(garbage_ptr) == 4) { - zval_ptr_dtor(&EG(garbage)[0]); - zval_ptr_dtor(&EG(garbage)[1]); - EG(garbage)[0] = EG(garbage)[2]; - EG(garbage)[1] = EG(garbage)[3]; - EG(garbage_ptr) -= 2; - } - EG(garbage)[EG(garbage_ptr)++] = (z); - } + if (!(z)->refcount) { + (z)->refcount = 1; + (z)->is_ref = 0; + EG(garbage)[EG(garbage_ptr)++] = (z); + } +} + +static inline zend_clean_garbage(ELS_D) +{ + while (EG(garbage_ptr)) { + zval_ptr_dtor(&EG(garbage)[--EG(garbage_ptr)]); + } } #define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index e6a6a03b66..0d8789077f 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -181,7 +181,7 @@ struct _zend_executor_globals { int (*unary_op)(zval *result, zval *op1); int (*binary_op)(zval *result, zval *op1, zval *op2); - zval *garbage[4]; + zval *garbage[2]; int garbage_ptr; zval *user_error_handler; -- 2.40.0