aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-08 10:56:27 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-08 10:56:27 +0000
commitb6261054cda125869a481d8e51cc86fd3631b9d6 (patch)
treea727152017b37ef8809c4b12c9697dff42be22d7 /gc.c
parent92f33ef216357e06b122131a3b347e8c63a31156 (diff)
downloadruby-b6261054cda125869a481d8e51cc86fd3631b9d6.tar.gz
* gc.c: remove heap_page::body. Instead of this field,
heap_page::start field works well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/gc.c b/gc.c
index 9a0d4295dd..d4f338733e 100644
--- a/gc.c
+++ b/gc.c
@@ -642,7 +642,6 @@ enum {
};
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, struct heap_page *page)
{
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 *objspace)
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 *objspace)
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 *objspace)
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
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;