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}
This commit is contained in:
jochen 2016-07-07 08:48:05 -07:00 committed by Commit bot
parent b3b1bf279a
commit b93c80a603

View File

@ -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);