Skip to content

Commit daccbf0

Browse files
committed
Re-apply 2d07fd7 more conservatively.
I think this matches up more precisely with the original intention, though I may be completely wrong. Notably though, this leaves out the rehashing which uses kJSWeakCollectionLoadFactorExp.
1 parent f4c4c08 commit daccbf0

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

deps/v8/src/objects.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14667,6 +14667,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutRegExp(
1466714667
void CompilationCacheTable::Age() {
1466814668
DisallowHeapAllocation no_allocation;
1466914669
Object* the_hole_value = GetHeap()->the_hole_value();
14670+
uint32_t capacity = Capacity();
1467014671
for (int entry = 0, size = Capacity(); entry < size; entry++) {
1467114672
int entry_index = EntryToIndex(entry);
1467214673
int value_index = entry_index + 1;
@@ -14690,6 +14691,16 @@ void CompilationCacheTable::Age() {
1469014691
}
1469114692
}
1469214693
}
14694+
// Wipe deleted entries.
14695+
Heap* heap = GetHeap();
14696+
Object* the_hole = heap->the_hole_value();
14697+
Object* undefined = heap->undefined_value();
14698+
for (uint32_t current = 0; current < capacity; current++) {
14699+
if (get(EntryToIndex(current)) == the_hole) {
14700+
set(EntryToIndex(current), undefined);
14701+
}
14702+
}
14703+
SetNumberOfDeletedElements(0);
1469314704
}
1469414705

1469514706

@@ -15212,6 +15223,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1521215223
}
1521315224
}
1521415225

15226+
// Rehash if more than 25% of the entries are deleted entries.
15227+
// TODO(jochen): Consider to shrink the fixed array in place.
15228+
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
15229+
table->Rehash(isolate->factory()->undefined_value());
15230+
}
15231+
1521515232
// Check whether the hash table should be extended.
1521615233
table = EnsureCapacity(table, 1, key);
1521715234
table->AddEntry(table->FindInsertionEntry(hash), *key, *value);

deps/v8/test/cctest/test-weakmaps.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ TEST(Weakness) {
123123
heap->CollectAllGarbage(false);
124124
CHECK_EQ(1, NumberOfWeakCalls);
125125
CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
126-
CHECK_EQ(2,
126+
CHECK_EQ(0,
127127
ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
128128
}
129129

deps/v8/test/cctest/test-weaksets.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ TEST(WeakSet_Weakness) {
122122
heap->CollectAllGarbage(false);
123123
CHECK_EQ(1, NumberOfWeakCalls);
124124
CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements());
125-
CHECK_EQ(
126-
1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
125+
CHECK_EQ(0,
126+
ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
127127
}
128128

129129

0 commit comments

Comments
 (0)