Skip to content

Commit e1f12fb

Browse files
Matt LoringMylesBorins
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 Ref: #7883 PR-URL: #7689 Reviewed-By: Matt Loring <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 2d07fd7 commit e1f12fb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 4
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 103
14-
#define V8_PATCH_LEVEL 39
14+
#define V8_PATCH_LEVEL 40
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/objects.cc

+13
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)