| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
| 6 | 6 |
| 7 #include "vm/block_scheduler.h" | 7 #include "vm/block_scheduler.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/flow_graph.h" | 10 #include "vm/flow_graph.h" |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 bool TryInlining(const Function& function, | 587 bool TryInlining(const Function& function, |
| 588 const Array& argument_names, | 588 const Array& argument_names, |
| 589 InlinedCallData* call_data) { | 589 InlinedCallData* call_data) { |
| 590 TRACE_INLINING(OS::Print(" => %s (deopt count %d)\n", | 590 TRACE_INLINING(OS::Print(" => %s (deopt count %d)\n", |
| 591 function.ToCString(), | 591 function.ToCString(), |
| 592 function.deoptimization_counter())); | 592 function.deoptimization_counter())); |
| 593 | 593 |
| 594 // TODO(fschneider): Enable inlining inside try-blocks. | |
| 595 if (call_data->call->GetBlock()->try_index() != | |
| 596 CatchClauseNode::kInvalidTryIndex) { | |
| 597 TRACE_INLINING(OS::Print(" Bailout: inside try-block\n")); | |
| 598 PRINT_INLINING_TREE("Inside try-block", | |
| 599 &call_data->caller, &function, call_data->call); | |
| 600 return false; | |
| 601 } | |
| 602 | |
| 603 // Make a handle for the unoptimized code so that it is not disconnected | 594 // Make a handle for the unoptimized code so that it is not disconnected |
| 604 // from the function while we are trying to inline it. | 595 // from the function while we are trying to inline it. |
| 605 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); | 596 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); |
| 606 // Abort if the inlinable bit on the function is low. | 597 // Abort if the inlinable bit on the function is low. |
| 607 if (!function.CanBeInlined()) { | 598 if (!function.CanBeInlined()) { |
| 608 TRACE_INLINING(OS::Print(" Bailout: not inlinable\n")); | 599 TRACE_INLINING(OS::Print(" Bailout: not inlinable\n")); |
| 609 PRINT_INLINING_TREE("Not inlinable", | 600 PRINT_INLINING_TREE("Not inlinable", |
| 610 &call_data->caller, &function, call_data->call); | 601 &call_data->caller, &function, call_data->call); |
| 611 return false; | 602 return false; |
| 612 } | 603 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 PRINT_INLINING_TREE("Optional arg mismatch", | 714 PRINT_INLINING_TREE("Optional arg mismatch", |
| 724 &call_data->caller, &function, call_data->call); | 715 &call_data->caller, &function, call_data->call); |
| 725 return false; | 716 return false; |
| 726 } | 717 } |
| 727 } | 718 } |
| 728 | 719 |
| 729 // After treating optional parameters the actual/formal count must match. | 720 // After treating optional parameters the actual/formal count must match. |
| 730 ASSERT(arguments->length() == function.NumParameters()); | 721 ASSERT(arguments->length() == function.NumParameters()); |
| 731 ASSERT(param_stubs->length() == callee_graph->parameter_count()); | 722 ASSERT(param_stubs->length() == callee_graph->parameter_count()); |
| 732 | 723 |
| 724 // Update try-index of the callee graph. |
| 725 BlockEntryInstr* call_block = call_data->call->GetBlock(); |
| 726 if (call_block->InsideTryBlock()) { |
| 727 intptr_t try_index = call_block->try_index(); |
| 728 for (BlockIterator it = callee_graph->reverse_postorder_iterator(); |
| 729 !it.Done(); it.Advance()) { |
| 730 BlockEntryInstr* block = it.Current(); |
| 731 block->set_try_index(try_index); |
| 732 } |
| 733 } |
| 734 |
| 733 BlockScheduler block_scheduler(callee_graph); | 735 BlockScheduler block_scheduler(callee_graph); |
| 734 block_scheduler.AssignEdgeWeights(); | 736 block_scheduler.AssignEdgeWeights(); |
| 735 | 737 |
| 736 { | 738 { |
| 737 TimerScope timer(FLAG_compiler_stats, | 739 TimerScope timer(FLAG_compiler_stats, |
| 738 &CompilerStats::graphinliner_ssa_timer, | 740 &CompilerStats::graphinliner_ssa_timer, |
| 739 isolate()); | 741 isolate()); |
| 740 // Compute SSA on the callee graph, catching bailouts. | 742 // Compute SSA on the callee graph, catching bailouts. |
| 741 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 743 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
| 742 param_stubs); | 744 param_stubs); |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 OS::Print("After Inlining of %s\n", flow_graph_-> | 1775 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1774 parsed_function()->function().ToFullyQualifiedCString()); | 1776 parsed_function()->function().ToFullyQualifiedCString()); |
| 1775 FlowGraphPrinter printer(*flow_graph_); | 1777 FlowGraphPrinter printer(*flow_graph_); |
| 1776 printer.PrintBlocks(); | 1778 printer.PrintBlocks(); |
| 1777 } | 1779 } |
| 1778 } | 1780 } |
| 1779 } | 1781 } |
| 1780 } | 1782 } |
| 1781 | 1783 |
| 1782 } // namespace dart | 1784 } // namespace dart |
| OLD | NEW |