Chromium Code Reviews| Index: runtime/vm/compiler.cc |
| diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc |
| index cf452bd71ea6bd45078844ff0092e3d388ad007f..8861712e2aaa4fa099852855f6470f1bb1d64602 100644 |
| --- a/runtime/vm/compiler.cc |
| +++ b/runtime/vm/compiler.cc |
| @@ -427,7 +427,15 @@ static bool CompileParsedFunctionHelper(CompilationPipeline* pipeline, |
| // builder uses it to attach it to nodes. |
| ASSERT(function.deoptimization_counter() < |
| FLAG_deoptimization_counter_threshold); |
| - function.RestoreICDataMap(ic_data_array); |
| + if ((osr_id == Compiler::kNoOSRDeoptId) && |
| + FLAG_background_compilation && optimized) { |
| + ASSERT(!Thread::Current()->IsMutatorThread()); |
|
siva
2015/10/27 23:36:45
ASSERT(!thread->IsMutatorThread());
srdjan
2015/10/28 16:54:43
Done.
|
| + // This 'freezes' ICData so that it does not change while compiling. |
| + function.CopyICDataMap(ic_data_array); |
| + } else { |
| + ASSERT(Thread::Current()->IsMutatorThread()); |
|
siva
2015/10/27 23:36:45
Ditto.
srdjan
2015/10/28 16:54:43
Done.
|
| + function.RestoreICDataMap(ic_data_array); |
| + } |
| if (FLAG_print_ic_data_map) { |
| for (intptr_t i = 0; i < ic_data_array->length(); i++) { |
| if ((*ic_data_array)[i] != NULL) { |
| @@ -1537,9 +1545,8 @@ void BackgroundCompiler::Run() { |
| ASSERT(error.IsNull()); |
| temp_function = RemoveFunctionOrNull(); |
| ASSERT(temp_function.raw() == function.raw()); |
| - // Reset to 0 so that it can be recompiled if needed. |
| - function.set_usage_counter(0); |
| function = LastFunctionOrNull(); |
| + ASSERT(!code.IsNull()); |
| AddCode(code); |
| } |
| } |
| @@ -1575,8 +1582,12 @@ void BackgroundCompiler::InstallGeneratedCode() { |
| code = queue.PopBackCode(); |
| if (code.IsDisabled()) continue; |
| owner = code.owner(); |
| - ASSERT(owner.IsFunction()); |
| - Function::Cast(owner).InstallOptimizedCode(code, false /* not OSR */); |
| + const Function& function = Function::Cast(owner); |
| + function.InstallOptimizedCode(code, false /* not OSR */); |
| + if (function.usage_counter() < 0) { |
| + // Reset to 0 so that it can be recompiled if needed. |
| + function.set_usage_counter(0); |
| + } |
| } |
| } |