Commit b93c80a6 authored by jochen's avatar jochen Committed by Commit bot

If we can't rehash the backing store for weak sets & maps, do a last resort GC

BUG=v8:4909
R=hpayer@chromium.org

Review-Url: https://codereview.chromium.org/2129933002
Cr-Commit-Position: refs/heads/master@{#37591}
parent b3b1bf27
......@@ -17696,6 +17696,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
table->Rehash(isolate->factory()->undefined_value());
}
// If we're out of luck, we didn't get a GC recently, and so rehashing
// isn't enough to avoid a crash.
int nof = table->NumberOfElements() + 1;
if (!table->HasSufficientCapacity(nof)) {
int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
if (capacity > ObjectHashTable::kMaxCapacity) {
for (size_t i = 0; i < 2; ++i) {
isolate->heap()->CollectAllGarbage(
Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
}
table->Rehash(isolate->factory()->undefined_value());
}
}
// Check whether the hash table should be extended.
table = EnsureCapacity(table, 1, key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment