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/block_scheduler.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 bool optimized, | 407 bool optimized, |
| 408 intptr_t osr_id) { | 408 intptr_t osr_id) { |
| 409 const Function& function = parsed_function->function(); | 409 const Function& function = parsed_function->function(); |
| 410 if (optimized && !function.IsOptimizable()) { | 410 if (optimized && !function.IsOptimizable()) { |
| 411 return false; | 411 return false; |
| 412 } | 412 } |
| 413 bool is_compiled = false; | 413 bool is_compiled = false; |
| 414 Thread* const thread = Thread::Current(); | 414 Thread* const thread = Thread::Current(); |
| 415 Zone* const zone = thread->zone(); | 415 Zone* const zone = thread->zone(); |
| 416 Isolate* const isolate = thread->isolate(); | 416 Isolate* const isolate = thread->isolate(); |
| 417 TimelineStream* compiler_timeline = isolate->GetCompilerStream(); | |
| 417 CSTAT_TIMER_SCOPE(thread, codegen_timer); | 418 CSTAT_TIMER_SCOPE(thread, codegen_timer); |
| 418 HANDLESCOPE(thread); | 419 HANDLESCOPE(thread); |
| 419 | 420 |
| 420 // Get current generation count so that we can check and ensure that the code | 421 // Get current generation count so that we can check and ensure that the code |
| 421 // was not invalidated while we were compiling in the background. | 422 // was not invalidated while we were compiling in the background. |
| 422 uint32_t cha_invalidation_gen_at_start = isolate->cha_invalidation_gen(); | 423 uint32_t cha_invalidation_gen_at_start = isolate->cha_invalidation_gen(); |
| 423 uint32_t field_invalidation_gen_at_start = isolate->field_invalidation_gen(); | 424 uint32_t field_invalidation_gen_at_start = isolate->field_invalidation_gen(); |
| 424 uint32_t prefix_invalidation_gen_at_start = | 425 uint32_t prefix_invalidation_gen_at_start = |
| 425 isolate->prefix_invalidation_gen(); | 426 isolate->prefix_invalidation_gen(); |
| 426 | 427 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 if (FLAG_print_ic_data_map) { | 469 if (FLAG_print_ic_data_map) { |
| 469 for (intptr_t i = 0; i < ic_data_array->length(); i++) { | 470 for (intptr_t i = 0; i < ic_data_array->length(); i++) { |
| 470 if ((*ic_data_array)[i] != NULL) { | 471 if ((*ic_data_array)[i] != NULL) { |
| 471 THR_Print("%" Pd " ", i); | 472 THR_Print("%" Pd " ", i); |
| 472 FlowGraphPrinter::PrintICData(*(*ic_data_array)[i]); | 473 FlowGraphPrinter::PrintICData(*(*ic_data_array)[i]); |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 } | 476 } |
| 476 } | 477 } |
| 477 | 478 |
| 479 TimelineDurationScope tds(thread, | |
| 480 compiler_timeline, | |
| 481 "BuildFlowGraph"); | |
| 478 flow_graph = pipeline->BuildFlowGraph(zone, | 482 flow_graph = pipeline->BuildFlowGraph(zone, |
| 479 parsed_function, | 483 parsed_function, |
| 480 *ic_data_array, | 484 *ic_data_array, |
| 481 osr_id); | 485 osr_id); |
| 482 } | 486 } |
| 483 | 487 |
| 484 const bool print_flow_graph = | 488 const bool print_flow_graph = |
| 485 (FLAG_print_flow_graph || | 489 (FLAG_print_flow_graph || |
| 486 (optimized && FLAG_print_flow_graph_optimized)) && | 490 (optimized && FLAG_print_flow_graph_optimized)) && |
| 487 FlowGraphPrinter::ShouldPrint(function); | 491 FlowGraphPrinter::ShouldPrint(function); |
| 488 | 492 |
| 489 if (print_flow_graph) { | 493 if (print_flow_graph) { |
| 490 if (osr_id == Compiler::kNoOSRDeoptId) { | 494 if (osr_id == Compiler::kNoOSRDeoptId) { |
| 491 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); | 495 FlowGraphPrinter::PrintGraph("Before Optimizations", flow_graph); |
| 492 } else { | 496 } else { |
| 493 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); | 497 FlowGraphPrinter::PrintGraph("For OSR", flow_graph); |
| 494 } | 498 } |
| 495 } | 499 } |
| 496 | 500 |
| 497 BlockScheduler block_scheduler(flow_graph); | 501 BlockScheduler block_scheduler(flow_graph); |
| 498 const bool reorder_blocks = | 502 const bool reorder_blocks = |
| 499 FlowGraph::ShouldReorderBlocks(function, optimized); | 503 FlowGraph::ShouldReorderBlocks(function, optimized); |
| 500 if (reorder_blocks) { | 504 if (reorder_blocks) { |
| 505 TimelineDurationScope tds(thread, | |
| 506 compiler_timeline, | |
| 507 "BlockScheduler::AssignEdgeWeights"); | |
| 501 block_scheduler.AssignEdgeWeights(); | 508 block_scheduler.AssignEdgeWeights(); |
| 502 } | 509 } |
| 503 | 510 |
| 504 if (optimized) { | 511 if (optimized) { |
| 505 CSTAT_TIMER_SCOPE(thread, ssa_timer); | 512 CSTAT_TIMER_SCOPE(thread, ssa_timer); |
| 506 // Transform to SSA (virtual register 0 and no inlining arguments). | 513 // Transform to SSA (virtual register 0 and no inlining arguments). |
| 507 flow_graph->ComputeSSA(0, NULL); | 514 flow_graph->ComputeSSA(0, NULL); |
| 508 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 515 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 509 if (print_flow_graph) { | 516 if (print_flow_graph) { |
| 510 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); | 517 FlowGraphPrinter::PrintGraph("After SSA", flow_graph); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 sinking->DetachMaterializations(); | 754 sinking->DetachMaterializations(); |
| 748 } | 755 } |
| 749 | 756 |
| 750 // Compute and store graph informations (call & instruction counts) | 757 // Compute and store graph informations (call & instruction counts) |
| 751 // to be later used by the inliner. | 758 // to be later used by the inliner. |
| 752 FlowGraphInliner::CollectGraphInfo(flow_graph, true); | 759 FlowGraphInliner::CollectGraphInfo(flow_graph, true); |
| 753 | 760 |
| 754 // Perform register allocation on the SSA graph. | 761 // Perform register allocation on the SSA graph. |
| 755 FlowGraphAllocator allocator(*flow_graph); | 762 FlowGraphAllocator allocator(*flow_graph); |
| 756 allocator.AllocateRegisters(); | 763 allocator.AllocateRegisters(); |
| 757 if (reorder_blocks) block_scheduler.ReorderBlocks(); | 764 if (reorder_blocks) { |
| 765 TimelineDurationScope tds(thread, | |
| 766 compiler_timeline, | |
| 767 "BlockScheduler::ReorderBlocks"); | |
| 768 block_scheduler.ReorderBlocks(); | |
| 769 } | |
| 758 | 770 |
| 759 if (print_flow_graph) { | 771 if (print_flow_graph) { |
| 760 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); | 772 FlowGraphPrinter::PrintGraph("After Optimizations", flow_graph); |
| 761 } | 773 } |
| 762 } | 774 } |
|
Florian Schneider
2015/12/15 09:47:27
Why just measure this phase? I think the whole opt
Cutch
2015/12/15 16:59:25
Done.
Florian Schneider
2015/12/15 17:15:34
Oh ok - that's more than I expected. I thought one
| |
| 763 | 775 |
| 764 ASSERT(inline_id_to_function.length() == caller_inline_id.length()); | 776 ASSERT(inline_id_to_function.length() == caller_inline_id.length()); |
| 765 Assembler assembler(use_far_branches); | 777 Assembler assembler(use_far_branches); |
| 766 FlowGraphCompiler graph_compiler(&assembler, flow_graph, | 778 FlowGraphCompiler graph_compiler(&assembler, flow_graph, |
| 767 *parsed_function, optimized, | 779 *parsed_function, optimized, |
| 768 inline_id_to_function, | 780 inline_id_to_function, |
| 769 caller_inline_id); | 781 caller_inline_id); |
| 770 { | 782 { |
| 771 CSTAT_TIMER_SCOPE(thread, graphcompiler_timer); | 783 CSTAT_TIMER_SCOPE(thread, graphcompiler_timer); |
| 784 TimelineDurationScope tds(thread, | |
| 785 compiler_timeline, | |
| 786 "CompileGraph"); | |
| 772 graph_compiler.CompileGraph(); | 787 graph_compiler.CompileGraph(); |
| 773 pipeline->FinalizeCompilation(); | 788 pipeline->FinalizeCompilation(); |
| 774 } | 789 } |
| 775 { | 790 { |
| 791 TimelineDurationScope tds(thread, | |
| 792 compiler_timeline, | |
| 793 "FinalizeCompilation"); | |
| 776 // This part of compilation must be at a safepoint. | 794 // This part of compilation must be at a safepoint. |
| 777 if (!Thread::Current()->IsMutatorThread()) { | 795 if (!Thread::Current()->IsMutatorThread()) { |
| 778 // Stop mutator thread before creating the instruction object and | 796 // Stop mutator thread before creating the instruction object and |
| 779 // installing code. | 797 // installing code. |
| 780 // Mutator thread may not run code while we are creating the | 798 // Mutator thread may not run code while we are creating the |
| 781 // instruction object, since the creation of instruction object | 799 // instruction object, since the creation of instruction object |
| 782 // changes code page access permissions (makes them temporary not | 800 // changes code page access permissions (makes them temporary not |
| 783 // executable). | 801 // executable). |
| 784 isolate->thread_registry()->SafepointThreads(); | 802 isolate->thread_registry()->SafepointThreads(); |
| 785 } | 803 } |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1888 } | 1906 } |
| 1889 | 1907 |
| 1890 | 1908 |
| 1891 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1909 void BackgroundCompiler::EnsureInit(Thread* thread) { |
| 1892 UNREACHABLE(); | 1910 UNREACHABLE(); |
| 1893 } | 1911 } |
| 1894 | 1912 |
| 1895 #endif // DART_PRECOMPILED | 1913 #endif // DART_PRECOMPILED |
| 1896 | 1914 |
| 1897 } // namespace dart | 1915 } // namespace dart |
| OLD | NEW |