Skip to content

Commit a3d62bd

Browse files
author
Matt Loring
committed
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 392c70a commit a3d62bd

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
@@ -18740,6 +18740,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1874018740
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
1874118741
table->Rehash(isolate->factory()->undefined_value());
1874218742
}
18743+
// If we're out of luck, we didn't get a GC recently, and so rehashing
18744+
// isn't enough to avoid a crash.
18745+
int nof = table->NumberOfElements() + 1;
18746+
if (!table->HasSufficientCapacity(nof)) {
18747+
int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
18748+
if (capacity > ObjectHashTable::kMaxCapacity) {
18749+
for (size_t i = 0; i < 2; ++i) {
18750+
isolate->heap()->CollectAllGarbage(
18751+
Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
18752+
}
18753+
table->Rehash(isolate->factory()->undefined_value());
18754+
}
18755+
}
1874318756

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

0 commit comments

Comments
 (0)