@@ -13744,6 +13744,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) {
13744
13744
}
13745
13745
}
13746
13746
}
13747
+ // Wipe deleted entries.
13748
+ Heap* heap = GetHeap();
13749
+ Object* the_hole = heap->the_hole_value();
13750
+ Object* undefined = heap->undefined_value();
13751
+ for (uint32_t current = 0; current < capacity; current++) {
13752
+ if (get(EntryToIndex(current)) == the_hole) {
13753
+ set(EntryToIndex(current), undefined);
13754
+ }
13755
+ }
13756
+ SetNumberOfDeletedElements(0);
13747
13757
}
13748
13758
13749
13759
@@ -14656,6 +14666,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutRegExp(
14656
14666
void CompilationCacheTable::Age() {
14657
14667
DisallowHeapAllocation no_allocation;
14658
14668
Object* the_hole_value = GetHeap()->the_hole_value();
14669
+ uint32_t capacity = Capacity();
14659
14670
for (int entry = 0, size = Capacity(); entry < size; entry++) {
14660
14671
int entry_index = EntryToIndex(entry);
14661
14672
int value_index = entry_index + 1;
@@ -14679,6 +14690,16 @@ void CompilationCacheTable::Age() {
14679
14690
}
14680
14691
}
14681
14692
}
14693
+ // Wipe deleted entries.
14694
+ Heap* heap = GetHeap();
14695
+ Object* the_hole = heap->the_hole_value();
14696
+ Object* undefined = heap->undefined_value();
14697
+ for (uint32_t current = 0; current < capacity; current++) {
14698
+ if (get(EntryToIndex(current)) == the_hole) {
14699
+ set(EntryToIndex(current), undefined);
14700
+ }
14701
+ }
14702
+ SetNumberOfDeletedElements(0);
14682
14703
}
14683
14704
14684
14705
@@ -15187,6 +15208,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
15187
15208
return table;
15188
15209
}
15189
15210
15211
+ // Rehash if more than 25% of the entries are deleted entries.
15212
+ // TODO(jochen): Consider to shrink the fixed array in place.
15213
+ if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
15214
+ table->Rehash(isolate->factory()->undefined_value());
15215
+ }
15216
+
15190
15217
// Check whether the hash table should be extended.
15191
15218
table = EnsureCapacity(table, 1, key);
15192
15219
table->AddEntry(table->FindInsertionEntry(hash), *key, *value);
0 commit comments