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

ruby-changes:41394

From: ko1 <ko1@a...>
Date: Fri, 8 Jan 2016 19:56:11 +0900 (JST)
Subject: [ruby-changes:41394] ko1:r53466 (trunk): * gc.c: remove heap_page::body. Instead of this field,

ko1	2016-01-08 19:56:27 +0900 (Fri, 08 Jan 2016)

  New Revision: 53466

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

  Log:
    * gc.c: remove heap_page::body. Instead of this field,
      heap_page::start field works well.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53465)
+++ ChangeLog	(revision 53466)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan  8 19:49:27 2016  Koichi Sasada  <ko1@a...>
+
+	* gc.c: remove heap_page::body. Instead of this field,
+	  heap_page::start field works well.
+
 Fri Jan  8 19:31:52 2016  Koichi Sasada  <ko1@a...>
 
 	* gc.c: rename rb_heap_t::page_length to rb_heap_t::total_pages.
Index: gc.c
===================================================================
--- gc.c	(revision 53465)
+++ gc.c	(revision 53466)
@@ -642,7 +642,6 @@ enum { https://github.com/ruby/ruby/blob/trunk/gc.c#L642
 };
 
 struct heap_page {
-    struct heap_page_body *body;
     struct heap_page *prev;
     short total_slots;
     short free_slots;
@@ -1399,7 +1398,7 @@ heap_page_free(rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L1398
 {
     heap_allocated_pages--;
     objspace->profile.total_freed_pages++;
-    aligned_free(page->body);
+    aligned_free(GET_PAGE_BODY(page->start));
     free(page);
 }
 
@@ -1456,7 +1455,14 @@ heap_page_allocate(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L1455
 	rb_memerror();
     }
 
-    page->body = page_body;
+    /* adjust obj_limit (object number available in this page) */
+    start = (RVALUE*)((VALUE)page_body + sizeof(struct heap_page_header));
+    if ((VALUE)start % sizeof(RVALUE) != 0) {
+	int delta = (int)(sizeof(RVALUE) - ((VALUE)start % sizeof(RVALUE)));
+	start = (RVALUE*)((VALUE)start + delta);
+	limit = (HEAP_SIZE - (int)((VALUE)start - (VALUE)page_body))/(int)sizeof(RVALUE);
+    }
+    end = start + limit;
 
     /* setup heap_pages_sorted */
     lo = 0;
@@ -1466,10 +1472,10 @@ heap_page_allocate(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L1472
 
 	mid = (lo + hi) / 2;
 	mid_page = heap_pages_sorted[mid];
-	if (mid_page->body < page_body) {
+	if (mid_page->start < start) {
 	    lo = mid + 1;
 	}
-	else if (mid_page->body > page_body) {
+	else if (mid_page->start > start) {
 	    hi = mid;
 	}
 	else {
@@ -1487,15 +1493,6 @@ heap_page_allocate(rb_objspace_t *objspa https://github.com/ruby/ruby/blob/trunk/gc.c#L1493
 
     if (RGENGC_CHECK_MODE) assert(heap_allocated_pages <= heap_pages_sorted_length);
 
-    /* adjust obj_limit (object number available in this page) */
-    start = (RVALUE*)((VALUE)page_body + sizeof(struct heap_page_header));
-    if ((VALUE)start % sizeof(RVALUE) != 0) {
-	int delta = (int)(sizeof(RVALUE) - ((VALUE)start % sizeof(RVALUE)));
-	start = (RVALUE*)((VALUE)start + delta);
-	limit = (HEAP_SIZE - (int)((VALUE)start - (VALUE)page_body))/(int)sizeof(RVALUE);
-    }
-    end = start + limit;
-
     if (heap_pages_lomem == 0 || heap_pages_lomem > start) heap_pages_lomem = start;
     if (heap_pages_himem < end) heap_pages_himem = end;
 
@@ -2279,20 +2276,18 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L2276
 objspace_each_objects(VALUE arg)
 {
     size_t i;
-    struct heap_page_body *last_body = 0;
     struct heap_page *page;
-    RVALUE *pstart, *pend;
+    RVALUE *pstart = NULL, *pend;
     rb_objspace_t *objspace = &rb_objspace;
     struct each_obj_args *args = (struct each_obj_args *)arg;
 
     i = 0;
     while (i < heap_allocated_pages) {
-	while (0 < i && last_body < heap_pages_sorted[i-1]->body)              i--;
-	while (i < heap_allocated_pages && heap_pages_sorted[i]->body <= last_body) i++;
+	while (0 < i && pstart < heap_pages_sorted[i-1]->start)              i--;
+	while (i < heap_allocated_pages && heap_pages_sorted[i]->start <= pstart) i++;
 	if (heap_allocated_pages <= i) break;
 
 	page = heap_pages_sorted[i];
-	last_body = page->body;
 
 	pstart = page->start;
 	pend = pstart + page->total_slots;

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

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