Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
deps: cherry-pick b93c80a from v8 upstream
Browse files Browse the repository at this point in the history
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: nodejs/node#6180
Ref: nodejs/node#7883
PR-URL: nodejs/node#7689
Reviewed-By: Matt Loring <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
Matt Loring authored and BethGriggs committed Nov 9, 2016
1 parent b03629e commit af2da0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/v8z/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 5
#define V8_BUILD_NUMBER 103
#define V8_PATCH_LEVEL 39
#define V8_PATCH_LEVEL 40

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
13 changes: 13 additions & 0 deletions deps/v8z/src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15213,6 +15213,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);
Expand Down

0 comments on commit af2da0f

Please sign in to comment.