| Index: runtime/vm/compiler.cc
|
| diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
|
| index cc3b69161b382adfc552185160f65bb74e610fc2..1bc179cdd3f696979ca6d252f09ef86522b1d08d 100644
|
| --- a/runtime/vm/compiler.cc
|
| +++ b/runtime/vm/compiler.cc
|
| @@ -1167,8 +1167,10 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
|
| done = true;
|
| }
|
|
|
| - // Clear the error if it was not a real error, but just a bailout.
|
| - if (error.IsLanguageError() &&
|
| + // If is is not a background compilation, clear the error if it was not a
|
| + // real error, but just a bailout. If we're it a background compilation
|
| + // this will be dealt with in the caller.
|
| + if (!Compiler::IsBackgroundCompilation() && error.IsLanguageError() &&
|
| (LanguageError::Cast(error).kind() == Report::kBailout)) {
|
| thread()->clear_sticky_error();
|
| }
|
| @@ -1277,6 +1279,21 @@ static RawError* CompileFunctionHelper(CompilationPipeline* pipeline,
|
| THR_Print("Aborted background compilation: %s\n",
|
| function.ToFullyQualifiedCString());
|
| }
|
| + {
|
| + // If it was a bailout, then disable optimization.
|
| + Error& error = Error::Handle();
|
| + // We got an error during compilation.
|
| + error = thread->sticky_error();
|
| + thread->clear_sticky_error();
|
| + if (error.IsLanguageError() &&
|
| + LanguageError::Cast(error).kind() == Report::kBailout) {
|
| + if (FLAG_trace_compiler) {
|
| + THR_Print("--> disabling optimizations for '%s'\n",
|
| + function.ToFullyQualifiedCString());
|
| + }
|
| + function.SetIsOptimizable(false);
|
| + }
|
| + }
|
| return Error::null();
|
| }
|
| // Optimizer bailed out. Disable optimizations and never try again.
|
| @@ -1295,6 +1312,7 @@ static RawError* CompileFunctionHelper(CompilationPipeline* pipeline,
|
| // We got an error during compilation.
|
| error = thread->sticky_error();
|
| thread->clear_sticky_error();
|
| + // The non-optimizing compiler should not bail out.
|
| ASSERT(error.IsLanguageError() &&
|
| LanguageError::Cast(error).kind() != Report::kBailout);
|
| return error.raw();
|
| @@ -1870,8 +1888,9 @@ void BackgroundCompiler::Run() {
|
| function = Function::null();
|
| } else {
|
| qelem = function_queue()->Remove();
|
| - if (FLAG_stress_test_background_compilation) {
|
| - const Function& old = Function::Handle(qelem->Function());
|
| + const Function& old = Function::Handle(qelem->Function());
|
| + if ((!old.HasOptimizedCode() && old.IsOptimizable()) ||
|
| + FLAG_stress_test_background_compilation) {
|
| if (Compiler::CanOptimizeFunction(thread, old)) {
|
| QueueElement* repeat_qelem = new QueueElement(old);
|
| function_queue()->Add(repeat_qelem);
|
|
|