Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: V8: cherry-pick 7ae0b77628f6 #40882

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.13',
'v8_embedder_string': '-node.14',

##### V8 defaults for Node.js #####

Expand Down
33 changes: 22 additions & 11 deletions deps/v8/src/interpreter/bytecode-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1889,17 +1889,28 @@ bool IsSwitchOptimizable(SwitchStatement* stmt, SwitchInfo* info) {
}

// GCC also jump-table optimizes switch statements with 6 cases or more.
if (!(static_cast<int>(info->covered_cases.size()) >=
FLAG_switch_table_min_cases &&
IsSpreadAcceptable(info->MaxCase() - info->MinCase(),
cases->length()))) {
// Invariant- covered_cases has all cases and only cases that will go in the
// jump table.
info->covered_cases.clear();
return false;
} else {
return true;
}
if (static_cast<int>(info->covered_cases.size()) >=
FLAG_switch_table_min_cases) {
// Due to case spread will be used as the size of jump-table,
// we need to check if it doesn't overflow by casting its
// min and max bounds to int64_t, and calculate if the difference is less
// than or equal to INT_MAX.
int64_t min = static_cast<int64_t>(info->MinCase());
int64_t max = static_cast<int64_t>(info->MaxCase());
int64_t spread = max - min + 1;

DCHECK_GT(spread, 0);

// Check if casted spread is acceptable and doesn't overflow.
if (spread <= INT_MAX &&
IsSpreadAcceptable(static_cast<int>(spread), cases->length())) {
return true;
}
}
// Invariant- covered_cases has all cases and only cases that will go in the
// jump table.
info->covered_cases.clear();
return false;
}

} // namespace
Expand Down