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 d6ae50f

Browse filesBrowse files
rayw000targos
authored andcommitted
deps: V8: cherry-pick 7ae0b77628f6
Original commit message: [interpreter] Stop jump-table optimizing switch stms when spread overflows Bug: v8:12389 Change-Id: I53c728ab0c8ba38c7dd96c7e1089f771ba44b9f0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3289227 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#77995} Refs: v8/v8@7ae0b77 PR-URL: #40882 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e60053d commit d6ae50f
Copy full SHA for d6ae50f

File tree

Expand file treeCollapse file tree

2 files changed

+23
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+23
-12
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.10',
39+
'v8_embedder_string': '-node.11',
4040

4141
##### V8 defaults for Node.js #####
4242

Collapse file

‎deps/v8/src/interpreter/bytecode-generator.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/interpreter/bytecode-generator.cc
+22-11Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,17 +1889,28 @@ bool IsSwitchOptimizable(SwitchStatement* stmt, SwitchInfo* info) {
18891889
}
18901890

18911891
// GCC also jump-table optimizes switch statements with 6 cases or more.
1892-
if (!(static_cast<int>(info->covered_cases.size()) >=
1893-
FLAG_switch_table_min_cases &&
1894-
IsSpreadAcceptable(info->MaxCase() - info->MinCase(),
1895-
cases->length()))) {
1896-
// Invariant- covered_cases has all cases and only cases that will go in the
1897-
// jump table.
1898-
info->covered_cases.clear();
1899-
return false;
1900-
} else {
1901-
return true;
1902-
}
1892+
if (static_cast<int>(info->covered_cases.size()) >=
1893+
FLAG_switch_table_min_cases) {
1894+
// Due to case spread will be used as the size of jump-table,
1895+
// we need to check if it doesn't overflow by casting its
1896+
// min and max bounds to int64_t, and calculate if the difference is less
1897+
// than or equal to INT_MAX.
1898+
int64_t min = static_cast<int64_t>(info->MinCase());
1899+
int64_t max = static_cast<int64_t>(info->MaxCase());
1900+
int64_t spread = max - min + 1;
1901+
1902+
DCHECK_GT(spread, 0);
1903+
1904+
// Check if casted spread is acceptable and doesn't overflow.
1905+
if (spread <= INT_MAX &&
1906+
IsSpreadAcceptable(static_cast<int>(spread), cases->length())) {
1907+
return true;
1908+
}
1909+
}
1910+
// Invariant- covered_cases has all cases and only cases that will go in the
1911+
// jump table.
1912+
info->covered_cases.clear();
1913+
return false;
19031914
}
19041915

19051916
} // namespace

0 commit comments

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