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

ruby-changes:68003

From: Peter <ko1@a...>
Date: Wed, 15 Sep 2021 22:59:52 +0900 (JST)
Subject: [ruby-changes:68003] db51bcada4 (master): Fix total_freed_objects for invalidated pages

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

From db51bcada408f8b0b93a11d41f8e4222436bd9f2 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter.zhu@s...>
Date: Wed, 15 Sep 2021 09:37:46 -0400
Subject: Fix total_freed_objects for invalidated pages

When the object is moved back into the T_MOVED, the flags of the T_MOVED
is not copied, so the FL_FROM_FREELIST flag is lost. This causes
total_freed_objects to always be incremented.
---
 gc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gc.c b/gc.c
index 639feac..57a757d 100644
--- a/gc.c
+++ b/gc.c
@@ -5833,6 +5833,7 @@ invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_ https://github.com/ruby/ruby/blob/trunk/gc.c#L5833
 
                     CLEAR_IN_BITMAP(GET_HEAP_PINNED_BITS(forwarding_object), forwarding_object);
 
+                    bool from_freelist = FL_TEST_RAW(forwarding_object, FL_FROM_FREELIST);
                     object = rb_gc_location(forwarding_object);
 
                     gc_move(objspace, object, forwarding_object, page->size_pool->slot_size);
@@ -5840,7 +5841,7 @@ invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_ https://github.com/ruby/ruby/blob/trunk/gc.c#L5841
                      * is the free slot for the original page */
                     struct heap_page *orig_page = GET_HEAP_PAGE(object);
                     orig_page->free_slots++;
-                    if (!FL_TEST_RAW(object, FL_FROM_FREELIST)) {
+                    if (!from_freelist) {
                         objspace->profile.total_freed_objects++;
                     }
                     heap_page_add_freeobj(objspace, orig_page, object);
-- 
cgit v1.1


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

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