@@ -17347,6 +17347,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) {
17347
17347
}
17348
17348
}
17349
17349
}
17350
+ // Wipe deleted entries.
17351
+ Heap* heap = GetHeap();
17352
+ Object* the_hole = heap->the_hole_value();
17353
+ Object* undefined = heap->undefined_value();
17354
+ for (uint32_t current = 0; current < capacity; current++) {
17355
+ if (get(EntryToIndex(current)) == the_hole) {
17356
+ set(EntryToIndex(current), undefined);
17357
+ }
17358
+ }
17359
+ SetNumberOfDeletedElements(0);
17350
17360
}
17351
17361
17352
17362
@@ -18168,6 +18178,16 @@ void CompilationCacheTable::Age() {
18168
18178
}
18169
18179
}
18170
18180
}
18181
+ // Wipe deleted entries.
18182
+ Heap* heap = GetHeap();
18183
+ Object* the_hole = heap->the_hole_value();
18184
+ Object* undefined = heap->undefined_value();
18185
+ for (uint32_t current = 0; current < capacity; current++) {
18186
+ if (get(EntryToIndex(current)) == the_hole) {
18187
+ set(EntryToIndex(current), undefined);
18188
+ }
18189
+ }
18190
+ SetNumberOfDeletedElements(0);
18171
18191
}
18172
18192
18173
18193
@@ -18707,6 +18727,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
18707
18727
return table;
18708
18728
}
18709
18729
18730
+ // Rehash if more than 25% of the entries are deleted entries.
18731
+ // TODO(jochen): Consider to shrink the fixed array in place.
18732
+ if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
18733
+ table->Rehash(isolate->factory()->undefined_value());
18734
+ }
18735
+
18710
18736
// Check whether the hash table should be extended.
18711
18737
table = EnsureCapacity(table, 1, key);
18712
18738
table->AddEntry(table->FindInsertionEntry(hash), *key, *value);
0 commit comments