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

ruby-changes:58513

From: Aaron <ko1@a...>
Date: Thu, 31 Oct 2019 10:06:07 +0900 (JST)
Subject: [ruby-changes:58513] 79d96b42df (master): Revert "Fix zero free objects assertion"

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

From 79d96b42df8850b7ba5dd3a78cb72c23cf8cbe91 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Wed, 30 Oct 2019 18:05:32 -0700
Subject: Revert "Fix zero free objects assertion"

This reverts commit e1bf29314feee6aaf535917da0178e868e7ff3fa.

I'm not sure why this broke stuff, I need to investigate later.

diff --git a/gc.c b/gc.c
index 22a3d1b..97133e6 100644
--- a/gc.c
+++ b/gc.c
@@ -8553,14 +8553,14 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8553
         heap_add_pages(objspace, heap_eden, heap_allocated_pages);
     }
 
-    VALUE moved_list_head;
+    VALUE moved_list;
     VALUE disabled = rb_gc_disable();
 
     if (use_toward_empty) {
-        moved_list_head = gc_compact_heap(objspace, compare_free_slots);
+        moved_list = gc_compact_heap(objspace, compare_free_slots);
     }
     else {
-        moved_list_head = gc_compact_heap(objspace, compare_pinned);
+        moved_list = gc_compact_heap(objspace, compare_pinned);
     }
     heap_eden->freelist = NULL;
 
@@ -8573,46 +8573,32 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8573
 
     rb_clear_method_cache_by_class(rb_cObject);
     rb_clear_constant_cache();
+    heap_eden->free_pages = NULL;
+    heap_eden->using_page = NULL;
 
-    /* Clear RMOVED manual rather than rely on GC */
-    while (moved_list_head) {
+    while (moved_list) {
         VALUE next_moved;
         struct heap_page *page;
 
-        page = GET_HEAP_PAGE(moved_list_head);
-        next_moved = RMOVED(moved_list_head)->next;
+        page = GET_HEAP_PAGE(moved_list);
+        next_moved = RMOVED(moved_list)->next;
 
-        RMOVED(moved_list_head)->flags = 0;
-        RMOVED(moved_list_head)->destination = 0;
-        RMOVED(moved_list_head)->next = 0;
+        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_head);
+        heap_page_add_freeobj(objspace, page, moved_list);
         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;
-    }
-
-    heap_eden->free_pages = NULL;
-
-    /* Rebuild free_pages linked list */
-    size_t i;
-    for (i = 0; i < heap_allocated_pages; ++i) {
-        struct heap_page *page = heap_pages_sorted[i];
-        if (page->free_slots > 0) {
-            page->free_next = heap_eden->free_pages;
-            heap_eden->free_pages = page;
-        } else {
+        } else if (page->free_slots == page->total_slots) {
             page->free_next = NULL;
         }
+        objspace->profile.total_freed_objects++;
+        moved_list = next_moved;
     }
 
-    heap_eden->using_page = heap_eden->free_pages;
-    heap_eden->free_pages = heap_eden->free_pages->free_next;
-
     if (use_verifier) {
         gc_verify_internal_consistency(objspace);
     }
-- 
cgit v0.10.2


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

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