Skip to content

Commit 71f9cdf

Browse files
abernixMylesBorins
authored andcommitted
deps: cherry-pick 09db540,686558d from V8 upstream
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: #6180 Refs: #7689 Refs: #6398 Fixes: #14228 PR-URL: #14829 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 751f1ac commit 71f9cdf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 4
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 103
14-
#define V8_PATCH_LEVEL 48
14+
#define V8_PATCH_LEVEL 49
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/objects.cc

+15
Original file line numberDiff line numberDiff line change
@@ -13744,6 +13744,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) {
1374413744
}
1374513745
}
1374613746
}
13747+
// Wipe deleted entries.
13748+
Heap* heap = GetHeap();
13749+
Object* the_hole = heap->the_hole_value();
13750+
Object* undefined = heap->undefined_value();
13751+
for (uint32_t current = 0; current < capacity; current++) {
13752+
if (get(EntryToIndex(current)) == the_hole) {
13753+
set(EntryToIndex(current), undefined);
13754+
}
13755+
}
13756+
SetNumberOfDeletedElements(0);
1374713757
}
1374813758

1374913759

@@ -15198,6 +15208,11 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table,
1519815208
return table;
1519915209
}
1520015210

15211+
// Rehash if more than 33% of the entries are deleted entries.
15212+
// TODO(jochen): Consider to shrink the fixed array in place.
15213+
if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
15214+
table->Rehash(isolate->factory()->undefined_value());
15215+
}
1520115216
// If we're out of luck, we didn't get a GC recently, and so rehashing
1520215217
// isn't enough to avoid a crash.
1520315218
if (!table->HasSufficientCapacityToAdd(1)) {

0 commit comments

Comments
 (0)