OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 | 8 |
9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 DEFINE_FLAG(bool, print_ic_data_map, false, | 57 DEFINE_FLAG(bool, print_ic_data_map, false, |
58 "Print the deopt-id to ICData map in optimizing compiler."); | 58 "Print the deopt-id to ICData map in optimizing compiler."); |
59 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); | 59 DEFINE_FLAG(bool, range_analysis, true, "Enable range analysis"); |
60 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); | 60 DEFINE_FLAG(bool, reorder_basic_blocks, true, "Enable basic-block reordering."); |
61 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 61 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
62 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 62 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
63 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); | 63 DEFINE_FLAG(bool, use_inlining, true, "Enable call-site inlining"); |
64 DEFINE_FLAG(bool, verify_compiler, false, | 64 DEFINE_FLAG(bool, verify_compiler, false, |
65 "Enable compiler verification assertions"); | 65 "Enable compiler verification assertions"); |
66 | 66 |
| 67 DECLARE_FLAG(bool, background_compilation); |
67 DECLARE_FLAG(bool, load_deferred_eagerly); | 68 DECLARE_FLAG(bool, load_deferred_eagerly); |
68 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 69 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
69 DECLARE_FLAG(bool, trace_inlining_intervals); | 70 DECLARE_FLAG(bool, trace_inlining_intervals); |
70 DECLARE_FLAG(bool, trace_irregexp); | 71 DECLARE_FLAG(bool, trace_irregexp); |
71 | 72 |
72 | 73 |
73 bool Compiler::always_optimize_ = false; | 74 bool Compiler::always_optimize_ = false; |
74 bool Compiler::allow_recompilation_ = true; | 75 bool Compiler::allow_recompilation_ = true; |
75 | 76 |
76 | 77 |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } | 1155 } |
1155 | 1156 |
1156 | 1157 |
1157 RawError* Compiler::CompileOptimizedFunction(Thread* thread, | 1158 RawError* Compiler::CompileOptimizedFunction(Thread* thread, |
1158 const Function& function, | 1159 const Function& function, |
1159 intptr_t osr_id) { | 1160 intptr_t osr_id) { |
1160 VMTagScope tagScope(thread, VMTag::kCompileOptimizedTagId); | 1161 VMTagScope tagScope(thread, VMTag::kCompileOptimizedTagId); |
1161 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, | 1162 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, |
1162 "OptimizedFunction", function); | 1163 "OptimizedFunction", function); |
1163 | 1164 |
| 1165 // Optimization must happen in non-mutator/Dart thread if background |
| 1166 // compilation is on. |
| 1167 ASSERT(!FLAG_background_compilation || |
| 1168 !thread->isolate()->MutatorThreadIsCurrentThread()); |
1164 CompilationPipeline* pipeline = | 1169 CompilationPipeline* pipeline = |
1165 CompilationPipeline::New(thread->zone(), function); | 1170 CompilationPipeline::New(thread->zone(), function); |
1166 return CompileFunctionHelper(pipeline, function, true, osr_id); | 1171 return CompileFunctionHelper(pipeline, function, true, osr_id); |
1167 } | 1172 } |
1168 | 1173 |
1169 | 1174 |
1170 // This is only used from unit tests. | 1175 // This is only used from unit tests. |
1171 RawError* Compiler::CompileParsedFunction( | 1176 RawError* Compiler::CompileParsedFunction( |
1172 ParsedFunction* parsed_function) { | 1177 ParsedFunction* parsed_function) { |
1173 LongJumpScope jump; | 1178 LongJumpScope jump; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 } | 1469 } |
1465 | 1470 |
1466 Thread::EnterIsolateAsHelper(isolate_); | 1471 Thread::EnterIsolateAsHelper(isolate_); |
1467 { | 1472 { |
1468 Thread* thread = Thread::Current(); | 1473 Thread* thread = Thread::Current(); |
1469 StackZone stack_zone(thread); | 1474 StackZone stack_zone(thread); |
1470 HANDLESCOPE(thread); | 1475 HANDLESCOPE(thread); |
1471 Function& function = Function::Handle(); | 1476 Function& function = Function::Handle(); |
1472 function = RemoveOrNull(); | 1477 function = RemoveOrNull(); |
1473 while (!function.IsNull()) { | 1478 while (!function.IsNull()) { |
1474 if (true) { | 1479 const Error& error = Error::Handle( |
1475 // Debugging printing | 1480 Compiler::CompileOptimizedFunction(thread, function)); |
1476 THR_Print("Background compilation: %s\n", | 1481 // TODO(srdjan): We do not expect errors while compiling optimized |
1477 function.ToQualifiedCString()); | 1482 // code, any errors should have been caught when compiling |
1478 } else { | 1483 // unoptimized code. |
1479 const Error& error = Error::Handle( | 1484 // If it still happens mark function as not optimizable. |
1480 Compiler::CompileOptimizedFunction(thread, function)); | 1485 ASSERT(error.IsNull()); |
1481 // TODO(srdjan): We do not expect errors while compiling optimized | |
1482 // code, any errors should have been caught when compiling | |
1483 // unotpimized code. | |
1484 // If it still happens mark function as not optimizable. | |
1485 ASSERT(error.IsNull()); | |
1486 } | |
1487 function = RemoveOrNull(); | 1486 function = RemoveOrNull(); |
1488 } | 1487 } |
1489 } | 1488 } |
1490 Thread::ExitIsolateAsHelper(); | 1489 Thread::ExitIsolateAsHelper(); |
1491 } | 1490 } |
1492 { | 1491 { |
1493 // Notify that the thread is done. | 1492 // Notify that the thread is done. |
1494 MonitorLocker ml_done(done_monitor_); | 1493 MonitorLocker ml_done(done_monitor_); |
1495 *done_ = true; | 1494 *done_ = true; |
1496 ml_done.Notify(); | 1495 ml_done.Notify(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 isolate->current_zone(), GrowableObjectArray::New())); | 1556 isolate->current_zone(), GrowableObjectArray::New())); |
1558 start_task = true; | 1557 start_task = true; |
1559 } | 1558 } |
1560 } | 1559 } |
1561 if (start_task) { | 1560 if (start_task) { |
1562 Dart::thread_pool()->Run(isolate->background_compiler()); | 1561 Dart::thread_pool()->Run(isolate->background_compiler()); |
1563 } | 1562 } |
1564 } | 1563 } |
1565 | 1564 |
1566 } // namespace dart | 1565 } // namespace dart |
OLD | NEW |