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 09db540,686558d from V8 upstream
Browse files Browse the repository at this point in the history
Original commit messages:
v8/v8@09db540
  Reland of Rehash and clear deleted entries in weak collections during GC

  BUG=v8:4909
  [email protected],[email protected]
  LOG=n

  Review URL: https://codereview.chromium.org/1890123002

  Cr-Commit-Position: refs/heads/master@{#35538}

v8/v8@686558d
  Fix comment about when we rehash ObjectHashTables before growing them

  [email protected]
  BUG=

  Review-Url: https://codereview.chromium.org/1918403003
  Cr-Commit-Position: refs/heads/master@{#35853}

Refs: https://crbug.com/v8/4909
Refs: nodejs/node#6180
Refs: nodejs/node#7689
Refs: nodejs/node#6398
Fixes: nodejs/node#14228

PR-URL: nodejs/node#14829
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
abernix authored and gibfahn committed Nov 24, 2017
1 parent 42d83fd commit b77def2
Show file tree
Hide file tree
Showing 2 changed files with 16 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 48
#define V8_PATCH_LEVEL 49

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
15 changes: 15 additions & 0 deletions deps/v8z/src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13744,6 +13744,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) {
}
}
}
// Wipe deleted entries.
Heap* heap = GetHeap();
Object* the_hole = heap->the_hole_value();
Object* undefined = heap->undefined_value();
for (uint32_t current = 0; current < capacity; current++) {
if (get(EntryToIndex(current)) == the_hole) {
set(EntryToIndex(current), undefined);
}
}
SetNumberOfDeletedElements(0);
}


Expand Down Expand Up @@ -15198,6 +15208,11 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
return table;
}

// Rehash if more than 33% of the entries are deleted entries.
// TODO(jochen): Consider to shrink the fixed array in place.
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.
if (!table->HasSufficientCapacityToAdd(1)) {
Expand Down

0 comments on commit b77def2

Please sign in to comment.