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

ruby-changes:61413

From: Aaron <ko1@a...>
Date: Fri, 29 May 2020 07:01:42 +0900 (JST)
Subject: [ruby-changes:61413] c7ceaa6d3c (master): Extract "free moved list" function

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

From c7ceaa6d3c518d77130fbb04e4e3d3148fb49072 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Thu, 28 May 2020 14:13:15 -0700
Subject: Extract "free moved list" function

Extract a function to free the moved list.  We'll use this function
later on to compact at the same time as sweep.

diff --git a/gc.c b/gc.c
index 9674d67..6e8005e 100644
--- a/gc.c
+++ b/gc.c
@@ -8614,6 +8614,34 @@ gc_check_references_for_moved(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8614
 }
 
 static void
+gc_unlink_moved_list(rb_objspace_t *objspace, VALUE moved_list_head)
+{
+    /* For each moved slot */
+    while (moved_list_head) {
+        VALUE next_moved;
+        struct heap_page *page;
+
+        page = GET_HEAP_PAGE(moved_list_head);
+        next_moved = RMOVED(moved_list_head)->next;
+
+        /* clear the memory for that moved slot */
+        RMOVED(moved_list_head)->flags = 0;
+        RMOVED(moved_list_head)->destination = 0;
+        RMOVED(moved_list_head)->next = 0;
+        page->free_slots++;
+        heap_page_add_freeobj(objspace, page, moved_list_head);
+
+        if (page->free_slots == page->total_slots && heap_pages_freeable_pages > 0) {
+            heap_pages_freeable_pages--;
+            heap_unlink_page(objspace, heap_eden, page);
+            heap_add_page(objspace, heap_tomb, page);
+        }
+        objspace->profile.total_freed_objects++;
+        moved_list_head = next_moved;
+    }
+}
+
+static void
 gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_double_pages, int use_verifier)
 {
     if (0) fprintf(stderr, "gc_compact_after_gc: %d,%d,%d\n", use_toward_empty, use_double_pages, use_verifier);
@@ -8653,29 +8681,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8681
     heap_eden->free_pages = NULL;
     heap_eden->using_page = NULL;
 
-    /* For each moved slot */
-    while (moved_list_head) {
-        VALUE next_moved;
-        struct heap_page *page;
-
-        page = GET_HEAP_PAGE(moved_list_head);
-        next_moved = RMOVED(moved_list_head)->next;
-
-        /* clear the memory for that moved slot */
-        RMOVED(moved_list_head)->flags = 0;
-        RMOVED(moved_list_head)->destination = 0;
-        RMOVED(moved_list_head)->next = 0;
-        page->free_slots++;
-        heap_page_add_freeobj(objspace, page, moved_list_head);
-
-        if (page->free_slots == page->total_slots && heap_pages_freeable_pages > 0) {
-            heap_pages_freeable_pages--;
-	    heap_unlink_page(objspace, heap_eden, page);
-	    heap_add_page(objspace, heap_tomb, page);
-        }
-        objspace->profile.total_freed_objects++;
-        moved_list_head = next_moved;
-    }
+    gc_unlink_moved_list(objspace, moved_list_head);
 
     /* Add any eden pages with free slots back to the free pages list */
     struct heap_page *page = NULL;
-- 
cgit v0.10.2


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

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