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

ruby-changes:42373

From: ko1 <ko1@a...>
Date: Thu, 31 Mar 2016 15:51:32 +0900 (JST)
Subject: [ruby-changes:42373] ko1:r54447 (trunk): * gc.c (gc_page_sweep): return free slots count.

ko1	2016-03-31 15:51:27 +0900 (Thu, 31 Mar 2016)

  New Revision: 54447

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

  Log:
    * gc.c (gc_page_sweep): return free slots count.
    
    * gc.c (gc_sweep_step): use returned free slots count.
    
    * gc.c (gc_sweep_step): change variable name `next'
      to `next_sweep_page'.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54446)
+++ ChangeLog	(revision 54447)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 31 15:48:18 2016  Koichi Sasada  <ko1@a...>
+
+	* gc.c (gc_page_sweep): return free slots count.
+
+	* gc.c (gc_sweep_step): use returned free slots count.
+
+	* gc.c (gc_sweep_step): change variable name `next'
+	  to `next_sweep_page'.
+
 Thu Mar 31 11:33:49 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/date/date_core.c (d_lite_strftime, dt_lite_strftime): [DOC]
Index: gc.c
===================================================================
--- gc.c	(revision 54446)
+++ gc.c	(revision 54447)
@@ -3367,9 +3367,7 @@ gc_setup_mark_bits(struct heap_page *pag https://github.com/ruby/ruby/blob/trunk/gc.c#L3367
 #endif
 }
 
-/* TRUE : has empty slots                                             */
-/* FALSE: no empty slots (or move to tomb heap because no live slots) */
-static inline void
+static inline int
 gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_page)
 {
     int i;
@@ -3458,6 +3456,8 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L3456
     }
 
     gc_report(2, objspace, "page_sweep: end.\n");
+
+    return freed_slots + empty_slots;
 }
 
 /* allocate additional minimum page to work */
@@ -3577,7 +3577,7 @@ gc_sweep_finish(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L3577
 static int
 gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap)
 {
-    struct heap_page *sweep_page = heap->sweep_pages, *next;
+    struct heap_page *sweep_page = heap->sweep_pages;
     int unlink_limit = 3;
 #if GC_ENABLE_INCREMENTAL_MARK
     int need_pool = will_be_incremental_marking(objspace) ? TRUE : FALSE;
@@ -3594,17 +3594,17 @@ gc_sweep_step(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L3594
 #endif
 
     while (sweep_page) {
-	heap->sweep_pages = next = sweep_page->next;
-	gc_page_sweep(objspace, heap, sweep_page);
+	struct heap_page *next_sweep_page = heap->sweep_pages = sweep_page->next;
+	int free_slots = gc_page_sweep(objspace, heap, sweep_page);
 
-	if (sweep_page->final_slots + sweep_page->free_slots == sweep_page->total_slots &&
+	if (sweep_page->final_slots + free_slots == sweep_page->total_slots &&
 	    unlink_limit > 0) {
 	    unlink_limit--;
 	    /* there are no living objects -> move this page to tomb heap */
 	    heap_unlink_page(objspace, heap, sweep_page);
 	    heap_add_page(objspace, heap_tomb, sweep_page);
 	}
-	else if (sweep_page->free_slots > 0) {
+	else if (free_slots > 0) {
 #if GC_ENABLE_INCREMENTAL_MARK
 	    if (need_pool) {
 		if (heap_add_poolpage(objspace, heap, sweep_page)) {
@@ -3624,7 +3624,7 @@ gc_sweep_step(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L3624
 	    sweep_page->free_next = NULL;
 	}
 
-	sweep_page = next;
+	sweep_page = next_sweep_page;
     }
 
     if (heap->sweep_pages == NULL) {

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

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