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

ruby-changes:31427

From: tarui <ko1@a...>
Date: Fri, 1 Nov 2013 22:23:01 +0900 (JST)
Subject: [ruby-changes:31427] tarui:r43506 (trunk): * gc.c (make_deferred): Refactoring. Collect codes which should be

tarui	2013-11-01 22:22:54 +0900 (Fri, 01 Nov 2013)

  New Revision: 43506

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

  Log:
    * gc.c (make_deferred): Refactoring. Collect codes which should be
      atomic.
    
    * gc.c (make_io_deferred, obj_free, rb_objspace_call_finalizer,
      gc_page_sweep): Correspond to the above.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43505)
+++ ChangeLog	(revision 43506)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  1 22:20:28 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c (make_deferred): Refactoring. Collect codes which should be
+	  atomic.
+
+	* gc.c (make_io_deferred, obj_free, rb_objspace_call_finalizer,
+	  gc_page_sweep): Correspond to the above.
+
 Fri Nov  1 21:40:35 2013  Masaya Tarui  <tarui@r...>
 
 	* gc.c (typedef struct rb_objspace): Refactoring. Move some members
Index: gc.c
===================================================================
--- gc.c	(revision 43505)
+++ gc.c	(revision 43506)
@@ -1283,16 +1283,18 @@ rb_free_const_table(st_table *tbl) https://github.com/ruby/ruby/blob/trunk/gc.c#L1283
 }
 
 static inline void
-make_deferred(RVALUE *p)
+make_deferred(rb_objspace_t *objspace,RVALUE *p)
 {
     p->as.basic.flags = T_ZOMBIE;
+    p->as.free.next = heap_pages_deferred_final;
+    heap_pages_deferred_final = p;
 }
 
 static inline void
-make_io_deferred(RVALUE *p)
+make_io_deferred(rb_objspace_t *objspace,RVALUE *p)
 {
     rb_io_t *fptr = p->as.file.fptr;
-    make_deferred(p);
+    make_deferred(objspace, p);
     p->as.data.dfree = (void (*)(void*))rb_io_fptr_finalize;
     p->as.data.data = fptr;
 }
@@ -1391,7 +1393,7 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L1393
 		    (RDATA(obj)->dfree)(DATA_PTR(obj));
 		}
 		else {
-		    make_deferred(RANY(obj));
+		    make_deferred(objspace, RANY(obj));
 		    return 1;
 		}
 	    }
@@ -1408,7 +1410,7 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L1410
 	break;
       case T_FILE:
 	if (RANY(obj)->as.file.fptr) {
-	    make_io_deferred(RANY(obj));
+	    make_io_deferred(objspace, RANY(obj));
 	    return 1;
 	}
 	break;
@@ -1985,16 +1987,12 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/gc.c#L1987
 		    xfree(DATA_PTR(p));
 		}
 		else if (RANY(p)->as.data.dfree) {
-		    make_deferred(RANY(p));
-		    RANY(p)->as.free.next = heap_pages_deferred_final;
-		    heap_pages_deferred_final = p;
+		    make_deferred(objspace, RANY(p));
 		}
 	    }
 	    else if (BUILTIN_TYPE(p) == T_FILE) {
 		if (RANY(p)->as.file.fptr) {
-		    make_io_deferred(RANY(p));
-		    RANY(p)->as.free.next = heap_pages_deferred_final;
-		    heap_pages_deferred_final = p;
+		    make_io_deferred(objspace, RANY(p));
 		}
 	    }
 	    p++;
@@ -2381,7 +2379,6 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2379
     int i;
     size_t empty_num = 0, freed_num = 0, final_num = 0;
     RVALUE *p, *pend,*offset;
-    int deferred;
     bits_t *bits, bitset;
 
     rgengc_report(1, objspace, "page_sweep: start.\n");
@@ -2406,14 +2403,12 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2403
 			if (objspace->rgengc.during_minor_gc && RVALUE_PROMOTED(p)) rb_bug("page_sweep: %p (%s) is promoted.\n", p, obj_type_name((VALUE)p));
 			if (rgengc_remembered(objspace, (VALUE)p)) rb_bug("page_sweep: %p (%s) is remembered.\n", p, obj_type_name((VALUE)p));
 #endif
-			if ((deferred = obj_free(objspace, (VALUE)p)) || (FL_TEST(p, FL_FINALIZE))) {
-			    if (!deferred) {
-				p->as.free.flags = T_ZOMBIE;
-				RDATA(p)->dfree = 0;
-			    }
-			    p->as.free.next = heap_pages_deferred_final;
-			    heap_pages_deferred_final = p;
-			    assert(BUILTIN_TYPE(p) == T_ZOMBIE);
+			if (obj_free(objspace, (VALUE)p)) {
+			    final_num++;
+			}
+			else if (FL_TEST(p, FL_FINALIZE)) {
+			    RDATA(p)->dfree = 0;
+			    make_deferred(objspace,p);
 			    final_num++;
 			}
 			else {

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

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