Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 00148b3

Browse filesBrowse files
committed
deps: backport 066747e from upstream V8
This backport fixes a performance pathology in how arrays grow/shrink. Fixes: #3538 V8-Commit: v8/v8@066747e PR-URL: #4625 Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com> Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Original commit message: Make sure that NormalizeElements and ShouldConvertToFastElements are … …based on the same values BUG=v8:4518 LOG=n Review URL: https://codereview.chromium.org/1472293002 Cr-Commit-Position: refs/heads/master@{#32265}
1 parent 138e1e5 commit 00148b3
Copy full SHA for 00148b3

File tree

Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-6
lines changed
Open diff view settings
Collapse file

‎deps/v8/src/elements.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/elements.cc
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,13 +1071,18 @@ class FastElementsAccessor
10711071
}
10721072
int num_used = 0;
10731073
for (int i = 0; i < backing_store->length(); ++i) {
1074-
if (!backing_store->is_the_hole(i)) ++num_used;
1075-
// Bail out early if more than 1/4 is used.
1076-
if (4 * num_used > backing_store->length()) break;
1077-
}
1078-
if (4 * num_used <= backing_store->length()) {
1079-
JSObject::NormalizeElements(obj);
1074+
if (!backing_store->is_the_hole(i)) {
1075+
++num_used;
1076+
// Bail out if a number dictionary wouldn't be able to save at least
1077+
// 75% space.
1078+
if (4 * SeededNumberDictionary::ComputeCapacity(num_used) *
1079+
SeededNumberDictionary::kEntrySize >
1080+
backing_store->length()) {
1081+
return;
1082+
}
1083+
}
10801084
}
1085+
JSObject::NormalizeElements(obj);
10811086
}
10821087
}
10831088

Collapse file

‎deps/v8/src/objects.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/objects.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12226,6 +12226,8 @@ static bool ShouldConvertToFastElements(JSObject* object,
1222612226

1222712227
uint32_t dictionary_size = static_cast<uint32_t>(dictionary->Capacity()) *
1222812228
SeededNumberDictionary::kEntrySize;
12229+
12230+
// Turn fast if the dictionary only saves 50% space.
1222912231
return 2 * dictionary_size >= *new_capacity;
1223012232
}
1223112233

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.