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

ruby-changes:66091

From: Nobuyoshi <ko1@a...>
Date: Fri, 7 May 2021 00:13:42 +0900 (JST)
Subject: [ruby-changes:66091] 99644514db (master): Conditionally used functions

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

From 99644514db3768e4fd47d6ff9111091ab1a5a6d2 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 6 May 2021 23:53:26 +0900
Subject: Conditionally used functions

---
 gc.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/gc.c b/gc.c
index 6c9664c..cdc8f4f 100644
--- a/gc.c
+++ b/gc.c
@@ -570,7 +570,8 @@ struct RPayload { https://github.com/ruby/ruby/blob/trunk/gc.c#L570
 };
 #define RPAYLOAD(obj) ((struct RPayload *)obj)
 static unsigned short
-RPAYLOAD_LEN(VALUE obj) {
+RPAYLOAD_LEN(VALUE obj)
+{
     unsigned short len = (unsigned short)(RPAYLOAD(obj)->flags >> FL_USHIFT);
     return len;
 }
@@ -1302,7 +1303,8 @@ payload_or_self(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L1303
                 return cur;
             }
             cur += RPAYLOAD_LEN(cur) * sizeof(RVALUE);
-        } else {
+        }
+        else {
             cur += sizeof(RVALUE);
         }
         if (poisoned) {
@@ -2275,6 +2277,7 @@ rvargc_slot_count(size_t size) https://github.com/ruby/ruby/blob/trunk/gc.c#L2277
     return roomof(size + sizeof(struct RPayload), sizeof(RVALUE));
 }
 
+#if USE_RVARGC
 static RVALUE *
 rvargc_find_contiguous_slots(int slots, RVALUE *freelist)
 {
@@ -2289,14 +2292,16 @@ rvargc_find_contiguous_slots(int slots, RVALUE *freelist) https://github.com/ruby/ruby/blob/trunk/gc.c#L2292
             // Peek ahead to see if the region is contiguous
             if (search->as.free.next == (search - 1)) {
                 search = search->as.free.next;
-            } else {
+            }
+            else {
                 // Next slot is not contiguous
                 if (search->as.free.next) {
                     cursor = search->as.free.next;
                     previous_region = search;
 
                     break;
-                } else {
+                }
+                else {
                     // Hit the end of the free list
                     return NULL;
                 }
@@ -2313,11 +2318,13 @@ rvargc_find_contiguous_slots(int slots, RVALUE *freelist) https://github.com/ruby/ruby/blob/trunk/gc.c#L2318
     }
     rb_bug("rvargc_find_contiguous_slots: unreachable");
 }
+#endif
 
 static inline bool heap_add_freepage(rb_heap_t *heap, struct heap_page *page);
 static struct heap_page * heap_next_freepage(rb_objspace_t *objspace, rb_heap_t *heap);
 static inline void ractor_set_cache(rb_ractor_t *cr, struct heap_page *page);
 
+#if USE_RVARGC
 static inline void *
 rvargc_find_region(size_t size, rb_ractor_t *cr, RVALUE *freelist)
 {
@@ -2372,6 +2379,7 @@ rvargc_find_region(size_t size, rb_ractor_t *cr, RVALUE *freelist) https://github.com/ruby/ruby/blob/trunk/gc.c#L2379
     }
     return NULL;
 }
+#endif
 
 int
 rb_slot_size()
@@ -4779,7 +4787,8 @@ count_objects(int argc, VALUE *argv, VALUE os) https://github.com/ruby/ruby/blob/trunk/gc.c#L4787
             if (RB_TYPE_P(vp, T_PAYLOAD)) {
                 stride = RPAYLOAD_LEN(vp);
                 counts[BUILTIN_TYPE(vp)] += RPAYLOAD_LEN(vp);
-            } else
+            }
+            else
 #endif
             if (p->as.basic.flags) {
                 counts[BUILTIN_TYPE(vp)]++;
@@ -5465,7 +5474,8 @@ gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap) https://github.com/ruby/ruby/blob/trunk/gc.c#L5474
                 }
                 p->as.free.next = freelist;
                 asan_poison_object((VALUE)p);
-            } else {
+            }
+            else {
                 page->freelist = freelist;
             }
             asan_poison_memory_region(&page->freelist, sizeof(RVALUE*));
@@ -7454,7 +7464,8 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L7464
 #if USE_RVARGC
         if (BUILTIN_TYPE(val) == T_PAYLOAD) {
             stride = RPAYLOAD_LEN(val);
-        } else {
+        }
+        else {
             stride = default_stride;
         }
 #endif
-- 
cgit v1.1


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

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