cvs: ZendEngine2 / zend_gc.c

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1209476629@cvsserver>
dmitry		Tue Apr 29 13:43:49 2008 UTC

  Modified files:              
    /ZendEngine2	zend_gc.c 
  Log:
  Fixed GC slowdown
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_gc.c?r1=1.12&r2=1.13&diff_format=u
Index: ZendEngine2/zend_gc.c
diff -u ZendEngine2/zend_gc.c:1.12 ZendEngine2/zend_gc.c:1.13
--- ZendEngine2/zend_gc.c:1.12	Thu Apr 24 16:15:33 2008
+++ ZendEngine2/zend_gc.c	Tue Apr 29 13:43:49 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.c,v 1.12 2008/04/24 16:15:33 felipe Exp $ */
+/* $Id: zend_gc.c,v 1.13 2008/04/29 13:43:49 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -137,15 +137,12 @@
 {
 	if (UNEXPECTED(GC_G(free_list) != NULL &&
 	               GC_ZVAL_ADDRESS(zv) != NULL &&
-		           GC_ZVAL_GET_COLOR(zv) == GC_BLACK)) {
-		zval_gc_info **p = &GC_G(free_list);
-
-		while (*p != NULL) {
-			if (*p == (zval_gc_info*)zv) {
-				return;
-			}
-			p = &(*p)->u.next;
-		}
+		           GC_ZVAL_GET_COLOR(zv) == GC_BLACK) &&
+		           (GC_ZVAL_ADDRESS(zv) < GC_G(buf) ||
+		            GC_ZVAL_ADDRESS(zv) >= GC_G(last_unused))) {
+		/* The given zval is a gurbage that is going to be delated by
+		 * currently running GC */
+		return;
 	}
 
 	if (zv->type == IS_OBJECT) {
@@ -261,19 +258,15 @@
 	TSRMLS_FETCH();
 
 	if (UNEXPECTED(GC_G(free_list) != NULL &&
-		           GC_ZVAL_GET_COLOR(zv) == GC_BLACK)) {
-		zval_gc_info **p = &GC_G(free_list);
-
-		while (*p != NULL) {
-			if (*p == (zval_gc_info*)zv) {
-				if (GC_G(next_to_free) == (zval_gc_info*)zv) {
-					GC_G(next_to_free) = ((zval_gc_info*)zv)->u.next;
-				}
-				*p = (*p)->u.next;
-				return;
-			}
-			p = &(*p)->u.next;
+		           GC_ZVAL_GET_COLOR(zv) == GC_BLACK) &&
+		           (GC_ZVAL_ADDRESS(zv) < GC_G(buf) ||
+		            GC_ZVAL_ADDRESS(zv) >= GC_G(last_unused))) {
+		/* The given zval is a gurbage that is going to be delated by
+		 * currently running GC */
+		if (GC_G(next_to_free) == (zval_gc_info*)zv) {
+			GC_G(next_to_free) = ((zval_gc_info*)zv)->u.next;
 		}
+		return;
 	}
 	GC_BENCH_INC(zval_remove_from_buffer);
 	GC_REMOVE_FROM_BUFFER(root_buffer);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.