Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index efa49e2fcbfcbdecb67e689e08ab5a30b60346a4..65869fe60639c1079c8e456f153ab1fc03bc351f 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -16867,6 +16867,16 @@ void HashTable<Derived, Shape, Key>::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); |
} |
@@ -18217,6 +18227,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
return table; |
} |
+ // Rehash if more than 25% of the entries are deleted entries. |
+ // TODO(jochen): Consider to shrink the fixed array in place. |
+ if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { |
+ table->Rehash(isolate->factory()->undefined_value()); |
+ } |
+ |
// Check whether the hash table should be extended. |
table = EnsureCapacity(table, 1, key); |
table->AddEntry(table->FindInsertionEntry(hash), *key, *value); |