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

ruby-changes:66410

From: Peter <ko1@a...>
Date: Thu, 3 Jun 2021 04:49:47 +0900 (JST)
Subject: [ruby-changes:66410] ad734a8cc3 (master): Allocate exact space for objspace_each_objects

https://git.ruby-lang.org/ruby.git/commit/?id=ad734a8cc3

From ad734a8cc3181cb4ad510e3c7dc73dd8bb943742 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Wed, 2 Jun 2021 14:42:09 -0400
Subject: Allocate exact space for objspace_each_objects

We are only iterating over the eden heap so `heap_eden->total_pages`
contains the exact number of pages we need to allocate for.
`heap_allocated_pages` may contain pages in the tomb.
---
 gc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gc.c b/gc.c
index 7f1ff7c..903d23c 100644
--- a/gc.c
+++ b/gc.c
@@ -3635,7 +3635,7 @@ objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void https://github.com/ruby/ruby/blob/trunk/gc.c#L3635
     }
 
     /* Create pages buffer */
-    size_t size = size_mul_or_raise(heap_allocated_pages, sizeof(struct heap_page *), rb_eRuntimeError);
+    size_t size = size_mul_or_raise(heap_eden->total_pages, sizeof(struct heap_page *), rb_eRuntimeError);
     struct heap_page **pages = malloc(size);
     if (!pages) rb_memerror();
 
@@ -3650,7 +3650,7 @@ objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void https://github.com/ruby/ruby/blob/trunk/gc.c#L3650
         pages[pages_count] = page;
         pages_count++;
     }
-    GC_ASSERT(pages_count <= heap_allocated_pages);
+    GC_ASSERT(pages_count == heap_eden->total_pages);
 
     /* Run the callback */
     struct each_obj_data each_obj_data = {
-- 
cgit v1.1


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

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