Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Unified Diff: src/objects.cc

Issue 2129933002: If we can't rehash the backing store for weak sets & maps, do a last resort GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 9f7524ccefb7a4dc85ae9ee1677840b14e8d1bad..3d8f3d5c99500ee4dd7034a82052b5f1d9ecec64 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -17747,6 +17747,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
table->Rehash(isolate->factory()->undefined_value());
}
+ // If we're out of luck, we didn't get a GC recently, and so rehashing
+ // isn't enough to avoid a crash.
+ int nof = table->NumberOfElements() + 1;
+ if (!table->HasSufficientCapacity(nof)) {
+ int capacity = ObjectHashTable::ComputeCapacity(nof * 2);
+ if (capacity > ObjectHashTable::kMaxCapacity) {
+ for (size_t i = 0; i < 2; ++i) {
+ isolate->heap()->CollectAllGarbage(
+ Heap::kFinalizeIncrementalMarkingMask, "full object hash table");
+ }
+ table->Rehash(isolate->factory()->undefined_value());
+ }
+ }
// Check whether the hash table should be extended.
table = EnsureCapacity(table, 1, key);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698