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

ruby-changes:68001

From: Peter <ko1@a...>
Date: Wed, 15 Sep 2021 22:01:00 +0900 (JST)
Subject: [ruby-changes:68001] a65ac2d6fa (master): Don't overwrite free_slots count during sweeping

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

From a65ac2d6fa4e7381d88b79a2881f7c05daa903c3 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter.zhu@s...>
Date: Mon, 13 Sep 2021 09:19:10 -0400
Subject: Don't overwrite free_slots count during sweeping

gc_compact_finish may invalidate pages, which may move objects from this
page to other pages, which updates the free_slots of this page.
---
 gc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gc.c b/gc.c
index 47762c2..639feac 100644
--- a/gc.c
+++ b/gc.c
@@ -5414,6 +5414,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea https://github.com/ruby/ruby/blob/trunk/gc.c#L5414
     }
 
     sweep_page->flags.before_sweep = FALSE;
+    sweep_page->free_slots = 0;
 
     p = sweep_page->start;
     bits = sweep_page->mark_bits;
@@ -5462,7 +5463,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea https://github.com/ruby/ruby/blob/trunk/gc.c#L5463
 		   sweep_page->total_slots,
 		   ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
 
-    sweep_page->free_slots = ctx->freed_slots + ctx->empty_slots;
+    sweep_page->free_slots += ctx->freed_slots + ctx->empty_slots;
     objspace->profile.total_freed_objects += ctx->freed_slots;
 
     if (heap_pages_deferred_final && !finalizing) {
-- 
cgit v1.1


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

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