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

ruby-changes:58154

From: Aaron <ko1@a...>
Date: Tue, 8 Oct 2019 02:57:52 +0900 (JST)
Subject: [ruby-changes:58154] 0a2f04e156 (master): Eliminate second GC pass for eliminating T_MOVED

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

From 0a2f04e156cb717dcf78f2ea9bfe26f864a24616 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Mon, 7 Oct 2019 10:14:13 -0700
Subject: Eliminate second GC pass for eliminating T_MOVED

`T_MOVED` is a linked list, so we can just iterate through the `T_MOVED`
objects, clearing them out and adding them to respective free lists.

diff --git a/gc.c b/gc.c
index 86c9c67..28ac208 100644
--- a/gc.c
+++ b/gc.c
@@ -8401,20 +8401,23 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8401
         gc_verify_internal_consistency(objspace);
     }
 
-#if __has_feature(address_sanitizer)
     while (moved_list) {
-        VALUE current = moved_list;
-        moved_list = RANY(moved_list)->as.moved.next;
-        asan_poison_object(current);
+        VALUE next_moved;
+        struct heap_page *page;
+
+        page = GET_HEAP_PAGE(moved_list);
+        next_moved = RMOVED(moved_list)->next;
+
+        RMOVED(moved_list)->flags = 0;
+        RMOVED(moved_list)->destination = 0;
+        RMOVED(moved_list)->next = 0;
+        page->free_slots++;
+        heap_page_add_freeobj(objspace, page, moved_list);
+        objspace->profile.total_freed_objects++;
+        moved_list = next_moved;
     }
-#else
-    (void)moved_list;
-#endif
 
     mjit_gc_exit_hook(); // unlock MJIT here, because `rb_gc()` calls `mjit_gc_start_hook()` again.
-
-    /* GC after compaction to eliminate T_MOVED */
-    garbage_collect(objspace, GPR_DEFAULT_REASON);
 }
 
 /*
-- 
cgit v0.10.2


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

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