From 5f18fb273f5554e9f61e11957857eb14f9a53647 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Mon, 14 Aug 2017 22:28:08 +0300 Subject: [PATCH] deps: cherry-pick 09db540,686558d from V8 upstream Original commit messages: https://github.com/v8/v8/commit/09db540 Reland of Rehash and clear deleted entries in weak collections during GC BUG=v8:4909 R=hpayer@chromium.org,ulan@chromium.org LOG=n Review URL: https://codereview.chromium.org/1890123002 Cr-Commit-Position: refs/heads/master@{#35538} https://github.com/v8/v8/commit/686558d Fix comment about when we rehash ObjectHashTables before growing them R=ulan@chromium.org BUG= Review-Url: https://codereview.chromium.org/1918403003 Cr-Commit-Position: refs/heads/master@{#35853} Refs: https://crbug.com/v8/4909 Refs: https://github.com/nodejs/node/issues/6180 Refs: https://github.com/nodejs/node/pull/7689 Refs: https://github.com/nodejs/node/pull/6398 Fixes: https://github.com/nodejs/node/issues/14228 --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/objects.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 5cd33a0827f6fc..9042d9bc826b57 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -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.) diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 29eceb9724f003..e9bbad5ae8ccd5 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -13744,6 +13744,16 @@ void HashTable::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); } @@ -15198,6 +15208,11 @@ Handle ObjectHashTable::Put(Handle 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)) {