]> granicus.if.org Git - php/commitdiff
- Hopefully fix bug #11476 and improve garbage to be freed very quickly.
authorAndi Gutmans <andi@php.net>
Thu, 21 Jun 2001 22:30:23 +0000 (22:30 +0000)
committerAndi Gutmans <andi@php.net>
Thu, 21 Jun 2001 22:30:23 +0000 (22:30 +0000)
  Tree tagged as PRE_GRANULAR_GARBAGE_FIX before commiting.

Zend/zend_execute.c
Zend/zend_execute_locks.h
Zend/zend_globals.h

index 989a1dd4cc1566d3ac6878b2ad2be8bc8a390784..0ea12af77ecc1be699db6ed74eebb55ff15d994f 100644 (file)
@@ -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;
index da389fb519d73d617a22165d9f0cf75b73fcdd08..2b6d143a218501d78e665a53e32410990966109c 100644 (file)
@@ -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); }
index e6a6a03b669d3b29d58079e051f373759e55d1fe..0d8789077f01b707ef5d473c9716a479cec929df 100644 (file)
@@ -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;