Browse Source

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
R=hpayer@chromium.org

Committed: https://crrev.com/b93c80a6039c757723e70420ae73375b5d277814
Cr-Commit-Position: refs/heads/master@{#37591}

Fixes: https://github.com/nodejs/node/issues/6180
PR-URL: https://github.com/nodejs/node/pull/7689
Reviewed-By: Matt Loring <mattloring@google.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v7.x
Matt Loring 9 years ago
parent
commit
a3d62bdbaa
  1. 13
      deps/v8/src/objects.cc

13
deps/v8/src/objects.cc

@ -18740,6 +18740,19 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
table->Rehash(isolate->factory()->undefined_value()); 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. // Check whether the hash table should be extended.
table = EnsureCapacity(table, 1, key); table = EnsureCapacity(table, 1, key);

Loading…
Cancel
Save