Commit b0dcf6ab authored by titzer's avatar titzer Committed by Commit bot

Allow TurboFan to compile more methods.

Reorganize some bailout conditions to be after the decision to use TurboFan.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1110573002

Cr-Commit-Position: refs/heads/master@{#28172}
parent f17a297e
......@@ -322,33 +322,13 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
return RetryOptimization(kDebuggerHasBreakPoints);
}
// Limit the number of times we re-compile a functions with
// the optimizing compiler.
// Limit the number of times we try to optimize functions.
const int kMaxOptCount =
FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
if (info()->opt_count() > kMaxOptCount) {
return AbortOptimization(kOptimizedTooManyTimes);
}
// Due to an encoding limit on LUnallocated operands in the Lithium
// language, we cannot optimize functions with too many formal parameters
// or perform on-stack replacement for function with too many
// stack-allocated local variables.
//
// The encoding is as a signed value, with parameters and receiver using
// the negative indices and locals the non-negative ones.
const int parameter_limit = -LUnallocated::kMinFixedSlotIndex;
Scope* scope = info()->scope();
if ((scope->num_parameters() + 1) > parameter_limit) {
return AbortOptimization(kTooManyParameters);
}
const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
if (info()->is_osr() &&
scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) {
return AbortOptimization(kTooManyParametersLocals);
}
// Check the whitelist for Crankshaft.
if (!info()->closure()->PassesFilter(FLAG_hydrogen_filter)) {
return AbortOptimization(kHydrogenFilter);
......@@ -379,6 +359,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
if (((FLAG_turbo_asm && info()->shared_info()->asm_function()) ||
info()->closure()->PassesFilter(FLAG_turbo_filter)) &&
(FLAG_turbo_osr || !info()->is_osr())) {
// Use TurboFan for the compilation.
if (FLAG_trace_opt) {
OFStream os(stdout);
os << "[compiling method " << Brief(*info()->closure())
......@@ -403,8 +384,23 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
}
}
// Do not use Crankshaft if the code is intended to be serialized.
if (!isolate()->use_crankshaft()) return SetLastStatus(FAILED);
if (!isolate()->use_crankshaft()) {
// Crankshaft is entirely disabled.
return SetLastStatus(FAILED);
}
Scope* scope = info()->scope();
if (LUnallocated::TooManyParameters(scope->num_parameters())) {
// Crankshaft would require too many Lithium operands.
return AbortOptimization(kTooManyParameters);
}
if (info()->is_osr() &&
LUnallocated::TooManyParametersOrStackSlots(scope->num_parameters(),
scope->num_stack_slots())) {
// Crankshaft would require too many Lithium operands.
return AbortOptimization(kTooManyParametersLocals);
}
if (scope->HasIllegalRedeclaration()) {
// Crankshaft cannot handle illegal redeclarations.
......
......@@ -252,6 +252,17 @@ class LUnallocated : public LOperand {
DCHECK(basic_policy() == EXTENDED_POLICY);
return LifetimeField::decode(value_) == USED_AT_START;
}
static bool TooManyParameters(int num_parameters) {
const int parameter_limit = -LUnallocated::kMinFixedSlotIndex;
return num_parameters + 1 > parameter_limit;
}
static bool TooManyParametersOrStackSlots(int num_parameters,
int num_stack_slots) {
const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
return num_parameters + 1 + num_stack_slots > locals_limit;
}
};
......
......@@ -143,6 +143,8 @@
# TODO(titzer): --always-opt incorrectly disables CrankShaft soft deopt points
'result-table-min': [PASS, NO_VARIANTS],
'result-table-max': [PASS, NO_VARIANTS],
# TODO(titzer): too slow in --turbo mode due to O(n^2) graph verification.
'regress/regress-1122': [PASS, NO_VARIANTS],
##############################################################################
# Too slow in debug mode with --stress-opt mode.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment