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

ruby-changes:69520

From: Matt <ko1@a...>
Date: Fri, 29 Oct 2021 22:17:49 +0900 (JST)
Subject: [ruby-changes:69520] ed8540ebf4 (master): Prefer size pool heap macros over direct access

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

From ed8540ebf400e7574f5a8e5c7e3f1d50f76b263d Mon Sep 17 00:00:00 2001
From: Matt Valentine-House <matt@e...>
Date: Fri, 29 Oct 2021 10:38:41 +0100
Subject: Prefer size pool heap macros over direct access

---
 gc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/gc.c b/gc.c
index cfe0f3098b9..48b7b80b4bb 100644
--- a/gc.c
+++ b/gc.c
@@ -1001,7 +1001,7 @@ static inline bool https://github.com/ruby/ruby/blob/trunk/gc.c#L1001
 has_sweeping_pages(rb_objspace_t *objspace)
 {
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        if (size_pools[i].eden_heap.sweeping_page) {
+        if (SIZE_POOL_EDEN_HEAP(&size_pools[i])->sweeping_page) {
             return TRUE;
         }
     }
@@ -1013,7 +1013,7 @@ heap_eden_total_pages(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L1013
 {
     size_t count = 0;
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        count += size_pools[i].eden_heap.total_pages;
+        count += SIZE_POOL_EDEN_HEAP(&size_pools[i])->total_pages;
     }
     return count;
 }
@@ -1023,7 +1023,7 @@ heap_eden_total_slots(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L1023
 {
     size_t count = 0;
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        count += size_pools[i].eden_heap.total_slots;
+        count += SIZE_POOL_EDEN_HEAP(&size_pools[i])->total_slots;
     }
     return count;
 }
@@ -1033,7 +1033,7 @@ heap_tomb_total_pages(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L1033
 {
     size_t count = 0;
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        count += size_pools[i].tomb_heap.total_pages;
+        count += SIZE_POOL_TOMB_HEAP(&size_pools[i])->total_pages;
     }
     return count;
 }
@@ -1915,7 +1915,7 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L1915
 
     bool has_pages_in_tomb_heap = FALSE;
     for (i = 0; i < SIZE_POOL_COUNT; i++) {
-        if (!list_empty(&size_pools[i].tomb_heap.pages)) {
+        if (!list_empty(&SIZE_POOL_TOMB_HEAP(&size_pools[i])->pages)) {
             has_pages_in_tomb_heap = TRUE;
             break;
         }
@@ -3487,7 +3487,7 @@ Init_heap(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L3487
     objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
 #endif
 
-    heap_add_pages(objspace, &size_pools[0], &size_pools[0].eden_heap, gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
+    heap_add_pages(objspace, &size_pools[0], SIZE_POOL_EDEN_HEAP(&size_pools[0]), gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
 
     /* Give other size pools allocatable pages. */
     for (int i = 1; i < SIZE_POOL_COUNT; i++) {
@@ -5905,7 +5905,7 @@ gc_compact_start(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L5905
     struct heap_page *page = NULL;
 
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        rb_heap_t *heap = &size_pools[i].eden_heap;
+        rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(&size_pools[i]);
         list_for_each(&heap->pages, page, page_node) {
             page->flags.before_sweep = TRUE;
         }
@@ -5956,7 +5956,7 @@ gc_sweep(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L5956
         }
 
         for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-            list_for_each(&size_pools[i].eden_heap.pages, page, page_node) {
+            list_for_each(&(SIZE_POOL_EDEN_HEAP(&size_pools[i])->pages), page, page_node) {
                 page->flags.before_sweep = TRUE;
             }
         }
@@ -7760,8 +7760,8 @@ gc_verify_heap_pages(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L7760
 {
     int remembered_old_objects = 0;
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        remembered_old_objects += gc_verify_heap_pages_(objspace, &size_pools[i].eden_heap.pages);
-        remembered_old_objects += gc_verify_heap_pages_(objspace, &size_pools[i].tomb_heap.pages);
+        remembered_old_objects += gc_verify_heap_pages_(objspace, &(SIZE_POOL_EDEN_HEAP(&size_pools[i])->pages));
+        remembered_old_objects += gc_verify_heap_pages_(objspace, &(SIZE_POOL_TOMB_HEAP(&size_pools[i])->pages));
     }
     return remembered_old_objects;
 }
@@ -7925,7 +7925,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark) https://github.com/ruby/ruby/blob/trunk/gc.c#L7925
 	objspace->marked_slots = 0;
 
         for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-            rgengc_mark_and_rememberset_clear(objspace, &size_pools[i].eden_heap);
+            rgengc_mark_and_rememberset_clear(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
         }
     }
     else {
@@ -7935,7 +7935,7 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark) https://github.com/ruby/ruby/blob/trunk/gc.c#L7935
 	objspace->profile.minor_gc_count++;
 
         for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-            rgengc_rememberset_mark(objspace, &size_pools[i].eden_heap);
+            rgengc_rememberset_mark(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
         }
     }
 
@@ -8041,7 +8041,7 @@ gc_marks_finish(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8041
 	objspace->flags.during_incremental_marking = FALSE;
 	/* check children of all marked wb-unprotected objects */
         for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-            gc_marks_wb_unprotected_objects(objspace, &size_pools[i].eden_heap);
+            gc_marks_wb_unprotected_objects(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
         }
     }
 #endif /* GC_ENABLE_INCREMENTAL_MARK */
@@ -8172,7 +8172,7 @@ gc_marks_rest(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8172
 
 #if GC_ENABLE_INCREMENTAL_MARK
     for (int i = 0; i < SIZE_POOL_COUNT; i++) {
-        size_pools[i].eden_heap.pooled_pages = NULL;
+        SIZE_POOL_EDEN_HEAP(&size_pools[i])->pooled_pages = NULL;
     }
 #endif
 
@@ -10945,7 +10945,7 @@ gc_set_initial_pages(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L10945
         heap_add_pages(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool), pages_per_class);
     }
 
-    heap_add_pages(objspace, &size_pools[0], &size_pools[0].eden_heap, min_pages - heap_eden_total_pages(objspace));
+    heap_add_pages(objspace, &size_pools[0], SIZE_POOL_EDEN_HEAP(&size_pools[0]), min_pages - heap_eden_total_pages(objspace));
 }
 
 /*
-- 
cgit v1.2.1


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

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