Skip to content

Commit d664fbd

Browse files
Matt LoringMyles Borins
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 Ref: #7883 PR-URL: #7689 Reviewed-By: Matt Loring <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 5ab6edd commit d664fbd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

deps/v8/src/objects.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15213,6 +15213,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1521315213
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
1521415214
table->Rehash(isolate->factory()->undefined_value());
1521515215
}
15216+
// If we're out of luck, we didn't get a GC recently, and so rehashing
15217+
// isn't enough to avoid a crash.
15218+
int nof = table->NumberOfElements() + 1;
15219+
if (!table->HasSufficientCapacity(nof)) {
15220+
int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
15221+
if (capacity > ObjectHashTable::kMaxCapacity) {
15222+
for (size_t i = 0; i < 2; ++i) {
15223+
isolate->heap()->CollectAllGarbage(
15224+
Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
15225+
}
15226+
table->Rehash(isolate->factory()->undefined_value());
15227+
}
15228+
}
1521615229

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

0 commit comments

Comments
 (0)