@@ -17347,6 +17347,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) {
1734717347 }
1734817348 }
1734917349 }
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);
1735017360}
1735117361
1735217362
@@ -18168,6 +18178,16 @@ void CompilationCacheTable::Age() {
1816818178 }
1816918179 }
1817018180 }
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);
1817118191}
1817218192
1817318193
@@ -18707,6 +18727,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1870718727 return table;
1870818728 }
1870918729
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+
1871018736 // Check whether the hash table should be extended.
1871118737 table = EnsureCapacity(table, 1, key);
1871218738 table->AddEntry(table->FindInsertionEntry(hash), *key, *value);
0 commit comments