Skip to content

Commit b93c80a

Browse files
jeisingerCommit bot
authored andcommitted
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}
1 parent b3b1bf2 commit b93c80a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/objects.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17696,6 +17696,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1769617696
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
1769717697
table->Rehash(isolate->factory()->undefined_value());
1769817698
}
17699+
// If we're out of luck, we didn't get a GC recently, and so rehashing
17700+
// isn't enough to avoid a crash.
17701+
int nof = table->NumberOfElements() + 1;
17702+
if (!table->HasSufficientCapacity(nof)) {
17703+
int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
17704+
if (capacity > ObjectHashTable::kMaxCapacity) {
17705+
for (size_t i = 0; i < 2; ++i) {
17706+
isolate->heap()->CollectAllGarbage(
17707+
Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
17708+
}
17709+
table->Rehash(isolate->factory()->undefined_value());
17710+
}
17711+
}
1769917712

1770017713
// Check whether the hash table should be extended.
1770117714
table = EnsureCapacity(table, 1, key);

0 commit comments

Comments
 (0)