[前][次][番号順一覧][スレッド一覧]

ruby-changes:34275

From: ko1 <ko1@a...>
Date: Thu, 5 Jun 2014 16:15:08 +0900 (JST)
Subject: [ruby-changes:34275] ko1:r46356 (trunk): * gc.c (gc_page_sweep): refactoring.

ko1	2014-06-05 16:14:53 +0900 (Thu, 05 Jun 2014)

  New Revision: 46356

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46356

  Log:
    * gc.c (gc_page_sweep): refactoring.
    * gc.c (gc_page_sweep): should not set, but add final_slots into
      sweep_page->final_slots.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46355)
+++ ChangeLog	(revision 46356)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun  5 16:08:39 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_page_sweep): refactoring.
+
+	* gc.c (gc_page_sweep): should not set, but add final_slots into
+	  sweep_page->final_slots.
+
 Thu Jun  5 14:36:24 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (jemalloc): check for the header regardless drop-in
Index: gc.c
===================================================================
--- gc.c	(revision 46355)
+++ gc.c	(revision 46356)
@@ -2810,25 +2810,33 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2810
 	if (bitset) {
 	    p = offset  + i * BITS_BITLENGTH;
 	    do {
-		if ((bitset & 1) && BUILTIN_TYPE(p) != T_ZOMBIE) {
-		    if (p->as.basic.flags) {
-			rgengc_report(3, objspace, "page_sweep: free %p (%s)\n", p, obj_type_name((VALUE)p));
+		if (bitset & 1) {
+		    switch (BUILTIN_TYPE(p)) {
+		      default: { /* majority case */
+			  rgengc_report(3, objspace, "page_sweep: free %p (%s)\n", p, obj_type_name((VALUE)p));
 #if USE_RGENGC && RGENGC_CHECK_MODE
-			if (objspace->rgengc.during_minor_gc && RVALUE_OLD_P((VALUE)p)) rb_bug("page_sweep: %p (%s) is old while minor GC.", p, obj_type_name((VALUE)p));
-			if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p (%s) is remembered.", p, obj_type_name((VALUE)p));
+			  if (objspace->rgengc.during_minor_gc && RVALUE_OLD_P((VALUE)p)) rb_bug("page_sweep: %p (%s) is old while minor GC.", p, obj_type_name((VALUE)p));
+			  if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p (%s) is remembered.", p, obj_type_name((VALUE)p));
 #endif
-			if (obj_free(objspace, (VALUE)p)) {
-			    final_slots++;
-			}
-			else {
-			    (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
-			    heap_page_add_freeobj(objspace, sweep_page, (VALUE)p);
-			    rgengc_report(3, objspace, "page_sweep: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p));
-			    freed_slots++;
-			}
-		    }
-		    else {
-			empty_slots++;
+			  if (obj_free(objspace, (VALUE)p)) {
+			      final_slots++;
+			  }
+			  else {
+			      (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, sizeof(RVALUE));
+			      heap_page_add_freeobj(objspace, sweep_page, (VALUE)p);
+			      rgengc_report(3, objspace, "page_sweep: %p (%s) is added to freelist\n", p, obj_type_name((VALUE)p));
+			      freed_slots++;
+			  }
+			  break;
+		      }
+
+		      /* minor cases */
+		      case T_ZOMBIE:
+			/* already counted */
+			break;
+		      case T_NONE:
+			empty_slots++; /* already freed */
+			break;
 		    }
 		}
 		p++;
@@ -2864,7 +2872,7 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2872
     heap_pages_swept_slots += freed_slots + empty_slots;
     objspace->profile.total_freed_object_num += freed_slots;
     heap_pages_final_slots += final_slots;
-    sweep_page->final_slots = final_slots;
+    sweep_page->final_slots += final_slots;
 
     if (0) fprintf(stderr, "gc_page_sweep(%d): freed?: %d, limt: %d, freed_slots: %d, empty_slots: %d, final_slots: %d\n",
 		   (int)rb_gc_count(),

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]