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

ruby-changes:30079

From: ko1 <ko1@a...>
Date: Tue, 23 Jul 2013 16:02:57 +0900 (JST)
Subject: [ruby-changes:30079] ko1:r42131 (trunk): * gc.c (heap_get_freeobj): clear slot->freelist here.

ko1	2013-07-23 16:02:44 +0900 (Tue, 23 Jul 2013)

  New Revision: 42131

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

  Log:
    * gc.c (heap_get_freeobj): clear slot->freelist here.
      This means that this slot doesn't have any free objects.
      And store this slot with objspace->heap.using_slot.
    * gc.c (gc_before_sweep): restore objspace->freelist
      into objspace->heap.using_slot->freelist.
      This means that using_slot has free objects which are
      pointed from objspace->freelist.
    * gc.c (gc_slot_sweep): do not need to clear slot->freelist.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42130)
+++ ChangeLog	(revision 42131)
@@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul 23 15:57:11 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (heap_get_freeobj): clear slot->freelist here.
+	  This means that this slot doesn't have any free objects.
+	  And store this slot with objspace->heap.using_slot.
+
+	* gc.c (gc_before_sweep): restore objspace->freelist
+	  into objspace->heap.using_slot->freelist.
+	  This means that using_slot has free objects which are
+	  pointed from objspace->freelist.
+
+	* gc.c (gc_slot_sweep): do not need to clear slot->freelist.
+
 Tue Jul 23 09:34:49 2013  Zachary Scott  <e@z...>
 
 	* sample/drb/README*.rdoc: [DOC] migrate DRb sample READMEs to rdoc
Index: gc.c
===================================================================
--- gc.c	(revision 42130)
+++ gc.c	(revision 42131)
@@ -305,6 +305,7 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L305
 	struct heap_slot *slots;
 	struct heap_slot *sweep_slots;
 	struct heap_slot *free_slots;
+	struct heap_slot *using_slot;
 	struct heap_slot **sorted;
 	size_t length;
 	size_t used;
@@ -933,7 +934,9 @@ heap_get_freeobj(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L934
 
     while (UNLIKELY(p == NULL)) {
 	struct heap_slot *slot = heap_get_freeslot(objspace);
+	objspace->heap.using_slot = slot;
 	p = objspace->freelist = slot->freelist;
+	slot->freelist = NULL;
     }
     objspace->freelist = p->as.free.next;
 
@@ -2230,7 +2233,6 @@ gc_slot_sweep(rb_objspace_t *objspace, s https://github.com/ruby/ruby/blob/trunk/gc.c#L2233
 
     rgengc_report(1, objspace, "slot_sweep: start.\n");
 
-    sweep_slot->freelist = NULL;
     p = sweep_slot->start; pend = p + sweep_slot->limit;
     offset = p - NUM_IN_SLOT(p);
     bits = GET_HEAP_MARK_BITS(p);
@@ -2269,7 +2271,6 @@ gc_slot_sweep(rb_objspace_t *objspace, s https://github.com/ruby/ruby/blob/trunk/gc.c#L2271
 			}
 		    }
 		    else {
-			heap_slot_add_freeobj(objspace, sweep_slot, (VALUE)p);
 			empty_num++;
 		    }
 		}
@@ -2340,7 +2341,13 @@ gc_before_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L2341
     objspace->heap.sweep_slots = heap_slots;
     objspace->heap.free_num = 0;
     objspace->heap.free_slots = NULL;
+
+    if (objspace->heap.using_slot) {
+	objspace->heap.using_slot->freelist = objspace->freelist;
+	objspace->heap.using_slot = NULL;
+    }
     objspace->freelist = NULL;
+    
 
     malloc_increase2 += ATOMIC_SIZE_EXCHANGE(malloc_increase,0);
 

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

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