Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 9f7524ccefb7a4dc85ae9ee1677840b14e8d1bad..351862d78d144fe9619079c9bec7cd76aab48d39 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -17747,6 +17747,20 @@ 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, |
| + "last resort gc (object hash table)"); |
|
Hannes Payer (out of office)
2016/07/07 15:22:00
let's not call this last resort gc, to not confuse
|
| + } |
| + table->Rehash(isolate->factory()->undefined_value()); |
| + } |
| + } |
| // Check whether the hash table should be extended. |
| table = EnsureCapacity(table, 1, key); |