Chromium Code Reviews| 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/code_generator.h" | 11 #include "vm/code_generator.h" |
| 11 #include "vm/code_patcher.h" | 12 #include "vm/code_patcher.h" |
| 12 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 13 #include "vm/debugger.h" | 14 #include "vm/debugger.h" |
| 14 #include "vm/deopt_instructions.h" | 15 #include "vm/deopt_instructions.h" |
| 15 #include "vm/exceptions.h" | 16 #include "vm/exceptions.h" |
| 16 #include "vm/flags.h" | 17 #include "vm/flags.h" |
| 17 #include "vm/flow_graph.h" | 18 #include "vm/flow_graph.h" |
| 18 #include "vm/flow_graph_allocator.h" | 19 #include "vm/flow_graph_allocator.h" |
| 19 #include "vm/flow_graph_builder.h" | 20 #include "vm/flow_graph_builder.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 288 |
| 288 if (FLAG_print_flow_graph || | 289 if (FLAG_print_flow_graph || |
| 289 (optimized && FLAG_print_flow_graph_optimized)) { | 290 (optimized && FLAG_print_flow_graph_optimized)) { |
| 290 if (osr_id == Isolate::kNoDeoptId) { | 291 if (osr_id == Isolate::kNoDeoptId) { |
| 291 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); | 292 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); |
| 292 } else { | 293 } else { |
| 293 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); | 294 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); |
| 294 } | 295 } |
| 295 } | 296 } |
| 296 | 297 |
| 298 BlockScheduler block_scheduler(flow_graph); | |
|
Florian Schneider
2013/08/12 11:30:09
Maybe add a flag FLAG_reorder_basic_blocks to cont
Kevin Millikin (Google)
2013/08/13 11:14:57
Done.
| |
| 299 if (optimized) { | |
| 300 block_scheduler.AssignEdgeWeights(); | |
| 301 } | |
| 302 | |
| 297 if (optimized) { | 303 if (optimized) { |
| 298 TimerScope timer(FLAG_compiler_stats, | 304 TimerScope timer(FLAG_compiler_stats, |
| 299 &CompilerStats::ssa_timer, | 305 &CompilerStats::ssa_timer, |
| 300 isolate); | 306 isolate); |
| 301 // Transform to SSA (virtual register 0 and no inlining arguments). | 307 // Transform to SSA (virtual register 0 and no inlining arguments). |
| 302 flow_graph->ComputeSSA(0, NULL); | 308 flow_graph->ComputeSSA(0, NULL); |
| 303 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 309 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 304 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 310 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 305 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); | 311 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); |
| 306 } | 312 } |
| 307 } | 313 } |
| 308 | 314 |
| 309 | |
| 310 // Collect all instance fields that are loaded in the graph and | 315 // Collect all instance fields that are loaded in the graph and |
| 311 // have non-generic type feedback attached to them that can | 316 // have non-generic type feedback attached to them that can |
| 312 // potentially affect optimizations. | 317 // potentially affect optimizations. |
| 313 GrowableArray<const Field*> guarded_fields(10); | 318 GrowableArray<const Field*> guarded_fields(10); |
| 314 if (optimized) { | 319 if (optimized) { |
| 315 TimerScope timer(FLAG_compiler_stats, | 320 TimerScope timer(FLAG_compiler_stats, |
| 316 &CompilerStats::graphoptimizer_timer, | 321 &CompilerStats::graphoptimizer_timer, |
| 317 isolate); | 322 isolate); |
| 318 | 323 |
| 319 FlowGraphOptimizer optimizer(flow_graph, &guarded_fields); | 324 FlowGraphOptimizer optimizer(flow_graph, &guarded_fields); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 // sinking from the flow graph and let them float on the side referenced | 479 // sinking from the flow graph and let them float on the side referenced |
| 475 // only from environments. Register allocator will consider them | 480 // only from environments. Register allocator will consider them |
| 476 // as part of a deoptimization environment. | 481 // as part of a deoptimization environment. |
| 477 sinking->DetachMaterializations(); | 482 sinking->DetachMaterializations(); |
| 478 } | 483 } |
| 479 | 484 |
| 480 // Perform register allocation on the SSA graph. | 485 // Perform register allocation on the SSA graph. |
| 481 FlowGraphAllocator allocator(*flow_graph); | 486 FlowGraphAllocator allocator(*flow_graph); |
| 482 allocator.AllocateRegisters(); | 487 allocator.AllocateRegisters(); |
| 483 | 488 |
| 489 block_scheduler.ReorderBlocks(); | |
| 490 | |
| 484 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { | 491 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) { |
| 485 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); | 492 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
| 486 } | 493 } |
| 487 } | 494 } |
| 488 | 495 |
| 489 Assembler assembler; | 496 Assembler assembler; |
| 490 FlowGraphCompiler graph_compiler(&assembler, | 497 FlowGraphCompiler graph_compiler(&assembler, flow_graph, optimized); |
| 491 *flow_graph, | |
| 492 optimized); | |
| 493 { | 498 { |
| 494 TimerScope timer(FLAG_compiler_stats, | 499 TimerScope timer(FLAG_compiler_stats, |
| 495 &CompilerStats::graphcompiler_timer, | 500 &CompilerStats::graphcompiler_timer, |
| 496 isolate); | 501 isolate); |
| 497 graph_compiler.CompileGraph(); | 502 graph_compiler.CompileGraph(); |
| 498 } | 503 } |
| 499 { | 504 { |
| 500 TimerScope timer(FLAG_compiler_stats, | 505 TimerScope timer(FLAG_compiler_stats, |
| 501 &CompilerStats::codefinalizer_timer, | 506 &CompilerStats::codefinalizer_timer, |
| 502 isolate); | 507 isolate); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 Object::Handle(isolate->object_store()->sticky_error()); | 884 Object::Handle(isolate->object_store()->sticky_error()); |
| 880 isolate->object_store()->clear_sticky_error(); | 885 isolate->object_store()->clear_sticky_error(); |
| 881 isolate->set_long_jump_base(base); | 886 isolate->set_long_jump_base(base); |
| 882 return result.raw(); | 887 return result.raw(); |
| 883 } | 888 } |
| 884 UNREACHABLE(); | 889 UNREACHABLE(); |
| 885 return Object::null(); | 890 return Object::null(); |
| 886 } | 891 } |
| 887 | 892 |
| 888 } // namespace dart | 893 } // namespace dart |
| OLD | NEW |