Skip to content

Commit

Permalink
Reland of Rehash and clear deleted entries in weak collections during GC
Browse files Browse the repository at this point in the history
BUG=v8:4909
R=hpayer@chromium.org,ulan@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/1890123002

Cr-Commit-Position: refs/heads/master@{#35538}
  • Loading branch information
jeisinger authored and Commit bot committed Apr 15, 2016
1 parent 146400a commit 09db540
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -18229,6 +18239,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);
Expand Down

0 comments on commit 09db540

Please sign in to comment.