Skip to content

Commit a03e3d3

Browse files
Matt Loringcjihrig
Matt Loring
authored andcommitted
deps: cherry-pick b93c80a from v8 upstream
Original commit message: If we can't rehash the backing store for weak sets & maps, do a last resort GC BUG=v8:4909 [email protected] Committed: https://crrev.com/b93c80a6039c757723e70420ae73375b5d277814 Cr-Commit-Position: refs/heads/master@{#37591} Fixes: #6180 PR-URL: #7689 Reviewed-By: Matt Loring <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d714309 commit a03e3d3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

deps/v8/src/objects.cc

+13
Original file line numberDiff line numberDiff line change
@@ -18789,6 +18789,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1878918789
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
1879018790
table->Rehash(isolate->factory()->undefined_value());
1879118791
}
18792+
// If we're out of luck, we didn't get a GC recently, and so rehashing
18793+
// isn't enough to avoid a crash.
18794+
int nof = table->NumberOfElements() + 1;
18795+
if (!table->HasSufficientCapacity(nof)) {
18796+
int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
18797+
if (capacity > ObjectHashTable::kMaxCapacity) {
18798+
for (size_t i = 0; i < 2; ++i) {
18799+
isolate->heap()->CollectAllGarbage(
18800+
Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
18801+
}
18802+
table->Rehash(isolate->factory()->undefined_value());
18803+
}
18804+
}
1879218805

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

0 commit comments

Comments
 (0)