From 5f5a3282d4b21eb0800f1d1af85926670ba0d904 Mon Sep 17 00:00:00 2001 From: machenbach Date: Fri, 15 Apr 2016 05:15:54 -0700 Subject: [PATCH] Revert of Rehash and clear deleted entries in weak collections during GC (patchset #8 id:140001 of https://codereview.chromium.org/1877233005/ ) Reason for revert: [Sheriff] Speculative revert. Suspect for gc stress crashes, like: https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20GC%20Stress%20-%20custom%20snapshot/builds/5119 Original issue's description: > Rehash and clear deleted entries in weak collections during GC > > Otherwise, they'll just keep growing until we run out of memory or hit the FixedArray's maximum capacity. > > BUG=v8:4909 > R=hpayer@chromium.org > LOG=n > > Committed: https://crrev.com/e093a047796d4c0575fe63d36529e7fe89b8865d > Cr-Commit-Position: refs/heads/master@{#35514} TBR=hpayer@chromium.org,jochen@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:4909 Review URL: https://codereview.chromium.org/1891863003 Cr-Commit-Position: refs/heads/master@{#35519} --- src/heap/mark-compact.cc | 7 ------- src/heap/mark-compact.h | 4 ---- src/objects.cc | 10 ---------- test/cctest/test-weakmaps.cc | 2 +- test/cctest/test-weaksets.cc | 4 ++-- 5 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 83eeeb5ea3..edc75cfa41 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -2572,13 +2572,6 @@ void MarkCompactCollector::ClearWeakCollections() { table->RemoveEntry(i); } } - // Rehash if more than 25% of the entries are deleted entries. - // TODO(jochen): Consider to shrink the fixed array in place. - if ((table->NumberOfDeletedElements() << kJSWeakCollectionLoadFactorExp) > - table->NumberOfElements()) { - HandleScope scope(heap()->isolate()); - table->Rehash(heap()->isolate()->factory()->undefined_value()); - } } weak_collection_obj = weak_collection->next(); weak_collection->set_next(heap()->undefined_value()); diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index 85ef608ae8..3c542bd2ed 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -512,10 +512,6 @@ class MarkCompactCollector { static const uint32_t kSingleFreeEncoding = 0; static const uint32_t kMultiFreeEncoding = 1; - // If the number of deleted slots in a JSWeakCollection exceeds the number - // of entries / 2^(factor), we rehash the table. - static const int kJSWeakCollectionLoadFactorExp = 1; - static inline bool IsMarked(Object* obj); static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); diff --git a/src/objects.cc b/src/objects.cc index 9f2c4e0b34..7b455bfe38 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -16867,16 +16867,6 @@ void HashTable::Rehash(Key key) { } } } - // Wipe deleted entries. - Heap* heap = GetHeap(); - Object* the_hole = heap->the_hole_value(); - Object* undefined = heap->undefined_value(); - for (uint32_t current = 0; current < capacity; current++) { - if (get(EntryToIndex(current)) == the_hole) { - set(EntryToIndex(current), undefined); - } - } - SetNumberOfDeletedElements(0); } diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc index c16bdf5094..781ad1f69f 100644 --- a/test/cctest/test-weakmaps.cc +++ b/test/cctest/test-weakmaps.cc @@ -124,7 +124,7 @@ TEST(Weakness) { heap->CollectAllGarbage(false); CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ(0, + CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); } diff --git a/test/cctest/test-weaksets.cc b/test/cctest/test-weaksets.cc index 0de63b9228..643bb48ab1 100644 --- a/test/cctest/test-weaksets.cc +++ b/test/cctest/test-weaksets.cc @@ -123,8 +123,8 @@ TEST(WeakSet_Weakness) { heap->CollectAllGarbage(false); CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); - CHECK_EQ(0, - ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); + CHECK_EQ( + 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); }