cvs: ZendEngine2(PHP_5_3) / zend_gc.c

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

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2	zend_gc.c 
  Log:
  Fixed GC slowdown
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_gc.c?r1=1.1.2.12&r2=1.1.2.13&diff_format=u
Index: ZendEngine2/zend_gc.c
diff -u ZendEngine2/zend_gc.c:1.1.2.12 ZendEngine2/zend_gc.c:1.1.2.13
--- ZendEngine2/zend_gc.c:1.1.2.12	Sun Apr 13 12:25:15 2008
+++ ZendEngine2/zend_gc.c	Tue Apr 29 13:43:31 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_gc.c,v 1.1.2.12 2008/04/13 12:25:15 iliaa Exp $ */
+/* $Id: zend_gc.c,v 1.1.2.13 2008/04/29 13:43:31 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.