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

ruby-changes:41389

From: ko1 <ko1@a...>
Date: Fri, 8 Jan 2016 17:23:43 +0900 (JST)
Subject: [ruby-changes:41389] ko1:r53461 (trunk): * gc.c: remove heap_page::heap. This field is only used to recognize

ko1	2016-01-08 17:23:58 +0900 (Fri, 08 Jan 2016)

  New Revision: 53461

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

  Log:
    * gc.c: remove heap_page::heap. This field is only used to recognize
      whether a page is in a tomb or not. Instead of this field,
      heap_page::flags::in_tomb (1 bit field) is added.
    
      Also type of heap_page::(total|free|final)_slots are changed from
      int to short. 2B is enough for them.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 53460)
+++ gc.c	(revision 53461)
@@ -644,14 +644,14 @@ enum { https://github.com/ruby/ruby/blob/trunk/gc.c#L644
 struct heap_page {
     struct heap_page_body *body;
     struct heap_page *prev;
-    rb_heap_t *heap;
-    int total_slots;
-    int free_slots;
-    int final_slots;
+    short total_slots;
+    short free_slots;
+    short final_slots;
     struct {
 	unsigned int before_sweep : 1;
 	unsigned int has_remembered_objects : 1;
 	unsigned int has_uncollectible_shady_objects : 1;
+	unsigned int in_tomb : 1;
     } flags;
 
     struct heap_page *free_next;
@@ -1390,7 +1390,6 @@ heap_unlink_page(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L1390
     if (heap->pages == page) heap->pages = page->next;
     page->prev = NULL;
     page->next = NULL;
-    page->heap = NULL;
     heap->page_length--;
     heap->total_slots -= page->total_slots;
 }
@@ -1413,7 +1412,7 @@ heap_pages_free_unused_pages(rb_objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L1412
 	for (i = j = 1; j < heap_allocated_pages; i++) {
 	    struct heap_page *page = heap_pages_sorted[i];
 
-	    if (page->heap == heap_tomb && page->free_slots == page->total_slots) {
+	    if (page->flags.in_tomb && page->free_slots == page->total_slots) {
 		if (heap_pages_swept_slots - page->total_slots > heap_pages_max_free_slots) {
 		    if (0) fprintf(stderr, "heap_pages_free_unused_pages: %d free page %p, heap_pages_swept_slots: %d, heap_pages_max_free_slots: %d\n",
 				   (int)i, page, (int)heap_pages_swept_slots, (int)heap_pages_max_free_slots);
@@ -1542,7 +1541,7 @@ heap_page_create(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L1541
 static void
 heap_add_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
 {
-    page->heap = heap;
+    page->flags.in_tomb = (heap == heap_tomb);
     page->next = heap->pages;
     if (heap->pages) heap->pages->prev = page;
     heap->pages = page;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53460)
+++ ChangeLog	(revision 53461)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan  8 17:07:14 2016  Koichi Sasada  <ko1@a...>
+
+	* gc.c: remove heap_page::heap. This field is only used to recognize
+	  whether a page is in a tomb or not. Instead of this field, 
+	  heap_page::flags::in_tomb (1 bit field) is added.
+
+	  Also type of heap_page::(total|free|final)_slots are changed from
+	  int to short. 2B is enough for them.
+
 Fri Jan  8 12:30:54 2016  Shugo Maeda  <shugo@r...>
 
 	* tool/make-snapshot: fix for the changes of version.h in r53314.

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

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