| 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/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 Code::Handle(function.CurrentCode()).EntryPoint()); | 105 Code::Handle(function.CurrentCode()).EntryPoint()); |
| 106 } | 106 } |
| 107 function.SwitchToUnoptimizedCode(); | 107 function.SwitchToUnoptimizedCode(); |
| 108 if (FLAG_trace_compiler) { | 108 if (FLAG_trace_compiler) { |
| 109 OS::Print("--> restoring entry at %#"Px"\n", | 109 OS::Print("--> restoring entry at %#"Px"\n", |
| 110 Code::Handle(function.unoptimized_code()).EntryPoint()); | 110 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 static void PrintGraph(const char* phase, FlowGraph* flow_graph) { | |
| 116 OS::Print("*** BEGIN CFG\n%s\n", phase); | |
| 117 FlowGraphPrinter printer(*flow_graph); | |
| 118 printer.PrintBlocks(); | |
| 119 OS::Print("*** END CFG\n"); | |
| 120 } | |
| 121 | |
| 122 | |
| 123 // Return false if bailed out. | 115 // Return false if bailed out. |
| 124 static bool CompileParsedFunctionHelper(const ParsedFunction& parsed_function, | 116 static bool CompileParsedFunctionHelper(const ParsedFunction& parsed_function, |
| 125 bool optimized) { | 117 bool optimized) { |
| 126 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 118 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); |
| 127 bool is_compiled = false; | 119 bool is_compiled = false; |
| 128 Isolate* isolate = Isolate::Current(); | 120 Isolate* isolate = Isolate::Current(); |
| 129 HANDLESCOPE(isolate); | 121 HANDLESCOPE(isolate); |
| 130 ASSERT(isolate->ic_data_array() == Array::null()); // Must be reset to null. | 122 ASSERT(isolate->ic_data_array() == Array::null()); // Must be reset to null. |
| 131 const intptr_t prev_deopt_id = isolate->deopt_id(); | 123 const intptr_t prev_deopt_id = isolate->deopt_id(); |
| 132 isolate->set_deopt_id(0); | 124 isolate->set_deopt_id(0); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 TimerScope timer(FLAG_compiler_stats, | 157 TimerScope timer(FLAG_compiler_stats, |
| 166 &CompilerStats::ssa_timer, | 158 &CompilerStats::ssa_timer, |
| 167 isolate); | 159 isolate); |
| 168 // Transform to SSA (virtual register 0 and no inlining arguments). | 160 // Transform to SSA (virtual register 0 and no inlining arguments). |
| 169 flow_graph->ComputeSSA(0, NULL); | 161 flow_graph->ComputeSSA(0, NULL); |
| 170 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 162 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 171 } | 163 } |
| 172 | 164 |
| 173 if (FLAG_print_flow_graph || | 165 if (FLAG_print_flow_graph || |
| 174 (optimized && FLAG_print_flow_graph_optimized)) { | 166 (optimized && FLAG_print_flow_graph_optimized)) { |
| 175 PrintGraph("Before Optimizations", flow_graph); | 167 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); |
| 176 } | 168 } |
| 177 | 169 |
| 178 if (optimized) { | 170 if (optimized) { |
| 179 TimerScope timer(FLAG_compiler_stats, | 171 TimerScope timer(FLAG_compiler_stats, |
| 180 &CompilerStats::graphoptimizer_timer, | 172 &CompilerStats::graphoptimizer_timer, |
| 181 isolate); | 173 isolate); |
| 182 | 174 |
| 183 FlowGraphOptimizer optimizer(flow_graph); | 175 FlowGraphOptimizer optimizer(flow_graph); |
| 184 optimizer.ApplyICData(); | 176 optimizer.ApplyICData(); |
| 185 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 177 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 248 |
| 257 // The final canonicalization pass before the code generation. | 249 // The final canonicalization pass before the code generation. |
| 258 optimizer.Canonicalize(); | 250 optimizer.Canonicalize(); |
| 259 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 251 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 260 | 252 |
| 261 // Perform register allocation on the SSA graph. | 253 // Perform register allocation on the SSA graph. |
| 262 FlowGraphAllocator allocator(*flow_graph); | 254 FlowGraphAllocator allocator(*flow_graph); |
| 263 allocator.AllocateRegisters(); | 255 allocator.AllocateRegisters(); |
| 264 | 256 |
| 265 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 257 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 266 PrintGraph("After Optimizations", flow_graph); | 258 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
| 267 } | 259 } |
| 268 } | 260 } |
| 269 | 261 |
| 270 Assembler assembler; | 262 Assembler assembler; |
| 271 FlowGraphCompiler graph_compiler(&assembler, | 263 FlowGraphCompiler graph_compiler(&assembler, |
| 272 *flow_graph, | 264 *flow_graph, |
| 273 optimized); | 265 optimized); |
| 274 { | 266 { |
| 275 TimerScope timer(FLAG_compiler_stats, | 267 TimerScope timer(FLAG_compiler_stats, |
| 276 &CompilerStats::graphcompiler_timer, | 268 &CompilerStats::graphcompiler_timer, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 Object::Handle(isolate->object_store()->sticky_error()); | 646 Object::Handle(isolate->object_store()->sticky_error()); |
| 655 isolate->object_store()->clear_sticky_error(); | 647 isolate->object_store()->clear_sticky_error(); |
| 656 isolate->set_long_jump_base(base); | 648 isolate->set_long_jump_base(base); |
| 657 return result.raw(); | 649 return result.raw(); |
| 658 } | 650 } |
| 659 UNREACHABLE(); | 651 UNREACHABLE(); |
| 660 return Object::null(); | 652 return Object::null(); |
| 661 } | 653 } |
| 662 | 654 |
| 663 } // namespace dart | 655 } // namespace dart |
| OLD | NEW |