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

ruby-changes:66066

From: Nobuyoshi <ko1@a...>
Date: Thu, 6 May 2021 12:12:33 +0900 (JST)
Subject: [ruby-changes:66066] f941dd5a9f (master): Reuse sysconf result

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

From f941dd5a9f80616fc1461625bead4774da8ab9ae Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 6 May 2021 12:09:57 +0900
Subject: Reuse sysconf result

---
 gc.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gc.c b/gc.c
index a1ed084..dcdc8fd 100644
--- a/gc.c
+++ b/gc.c
@@ -3213,6 +3213,17 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L3213
 {
     rb_objspace_t *objspace = &rb_objspace;
 
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
+    /* If Ruby's heap pages are not a multiple of the system page size, we
+     * cannot use mprotect for the read barrier, so we must disable automatic
+     * compaction. */
+    int pagesize;
+    pagesize = (int)sysconf(_SC_PAGE_SIZE);
+    if ((HEAP_PAGE_SIZE % pagesize) != 0) {
+        ruby_enable_autocompact = 0;
+    }
+#endif
+
 #if defined(HAVE_MMAP) && !HAVE_CONST_PAGE_SIZE && !defined(PAGE_MAX_SIZE)
     /* Need to determine if we can use mmap at runtime. */
 # ifdef PAGE_SIZE
@@ -3220,24 +3231,13 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L3231
     use_mmap_aligned_alloc = PAGE_SIZE <= HEAP_PAGE_SIZE;
 # elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
     /* If we can use sysconf to determine the page size. */
-    use_mmap_aligned_alloc = sysconf(_SC_PAGE_SIZE) <= HEAP_PAGE_SIZE;
+    use_mmap_aligned_alloc = pagesize <= HEAP_PAGE_SIZE;
 # else
     /* Otherwise we can't determine the system page size, so don't use mmap. */
     use_mmap_aligned_alloc = FALSE;
 # endif
 #endif
 
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
-    /* If Ruby's heap pages are not a multiple of the system page size, we
-     * cannot use mprotect for the read barrier, so we must disable automatic
-     * compaction. */
-    int pagesize;
-    pagesize = (int)sysconf(_SC_PAGE_SIZE);
-    if ((HEAP_PAGE_SIZE % pagesize) != 0) {
-        ruby_enable_autocompact = 0;
-    }
-#endif
-
     objspace->next_object_id = INT2FIX(OBJ_ID_INITIAL);
     objspace->id_to_obj_tbl = st_init_table(&object_id_hash_type);
     objspace->obj_to_id_tbl = st_init_numtable();
-- 
cgit v1.1


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

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