| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 for (intptr_t i = 0; i < num_instance_calls; ++i) { | 262 for (intptr_t i = 0; i < num_instance_calls; ++i) { |
| 263 const intptr_t aggregate_count = | 263 const intptr_t aggregate_count = |
| 264 instance_calls_[i + instance_call_start_ix]. | 264 instance_calls_[i + instance_call_start_ix]. |
| 265 call->ic_data().AggregateCount(); | 265 call->ic_data().AggregateCount(); |
| 266 instance_call_counts.Add(aggregate_count); | 266 instance_call_counts.Add(aggregate_count); |
| 267 if (aggregate_count > max_count) max_count = aggregate_count; | 267 if (aggregate_count > max_count) max_count = aggregate_count; |
| 268 } | 268 } |
| 269 | 269 |
| 270 GrowableArray<intptr_t> static_call_counts(num_static_calls); | 270 GrowableArray<intptr_t> static_call_counts(num_static_calls); |
| 271 for (intptr_t i = 0; i < num_static_calls; ++i) { | 271 for (intptr_t i = 0; i < num_static_calls; ++i) { |
| 272 const intptr_t aggregate_count = | 272 intptr_t aggregate_count = 0; |
| 273 static_calls_[i + static_call_start_ix]. | 273 if (static_calls_[i + static_call_start_ix].call->ic_data() == NULL) { |
| 274 call->ic_data()->AggregateCount(); | 274 aggregate_count = 0; |
| 275 } else { |
| 276 aggregate_count = |
| 277 static_calls_[i + static_call_start_ix]. |
| 278 call->ic_data()->AggregateCount(); |
| 279 } |
| 275 static_call_counts.Add(aggregate_count); | 280 static_call_counts.Add(aggregate_count); |
| 276 if (aggregate_count > max_count) max_count = aggregate_count; | 281 if (aggregate_count > max_count) max_count = aggregate_count; |
| 277 } | 282 } |
| 278 | 283 |
| 279 // max_count can be 0 if none of the calls was executed. | 284 // max_count can be 0 if none of the calls was executed. |
| 280 for (intptr_t i = 0; i < num_instance_calls; ++i) { | 285 for (intptr_t i = 0; i < num_instance_calls; ++i) { |
| 281 const double ratio = (max_count == 0) ? | 286 const double ratio = (max_count == 0) ? |
| 282 0.0 : static_cast<double>(instance_call_counts[i]) / max_count; | 287 0.0 : static_cast<double>(instance_call_counts[i]) / max_count; |
| 283 instance_calls_[i + instance_call_start_ix].ratio = ratio; | 288 instance_calls_[i + instance_call_start_ix].ratio = ratio; |
| 284 } | 289 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 const intptr_t prev_deopt_id = isolate()->deopt_id(); | 680 const intptr_t prev_deopt_id = isolate()->deopt_id(); |
| 676 isolate()->set_deopt_id(0); | 681 isolate()->set_deopt_id(0); |
| 677 // Install bailout jump. | 682 // Install bailout jump. |
| 678 LongJumpScope jump; | 683 LongJumpScope jump; |
| 679 if (setjmp(*jump.Set()) == 0) { | 684 if (setjmp(*jump.Set()) == 0) { |
| 680 // Parse the callee function. | 685 // Parse the callee function. |
| 681 bool in_cache; | 686 bool in_cache; |
| 682 ParsedFunction* parsed_function; | 687 ParsedFunction* parsed_function; |
| 683 { | 688 { |
| 684 CSTAT_TIMER_SCOPE(isolate(), graphinliner_parse_timer); | 689 CSTAT_TIMER_SCOPE(isolate(), graphinliner_parse_timer); |
| 685 const Error& error = Error::Handle(Z, | 690 if (!Compiler::always_optimize()) { |
| 686 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); | 691 const Error& error = Error::Handle(Z, |
| 687 if (!error.IsNull()) { | 692 Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); |
| 688 Exceptions::PropagateError(error); | 693 if (!error.IsNull()) { |
| 694 Exceptions::PropagateError(error); |
| 695 } |
| 689 } | 696 } |
| 690 parsed_function = GetParsedFunction(function, &in_cache); | 697 parsed_function = GetParsedFunction(function, &in_cache); |
| 691 } | 698 } |
| 692 | 699 |
| 693 // Load IC data for the callee. | 700 // Load IC data for the callee. |
| 694 ZoneGrowableArray<const ICData*>* ic_data_array = | 701 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 695 new(Z) ZoneGrowableArray<const ICData*>(); | 702 new(Z) ZoneGrowableArray<const ICData*>(); |
| 696 function.RestoreICDataMap(ic_data_array); | 703 function.RestoreICDataMap(ic_data_array); |
| 697 | 704 |
| 698 // Build the callee graph. | 705 // Build the callee graph. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 // Compute SSA on the callee graph, catching bailouts. | 770 // Compute SSA on the callee graph, catching bailouts. |
| 764 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), | 771 callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(), |
| 765 param_stubs); | 772 param_stubs); |
| 766 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 773 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 767 } | 774 } |
| 768 | 775 |
| 769 { | 776 { |
| 770 CSTAT_TIMER_SCOPE(isolate(), graphinliner_opt_timer); | 777 CSTAT_TIMER_SCOPE(isolate(), graphinliner_opt_timer); |
| 771 // TODO(zerny): Do more optimization passes on the callee graph. | 778 // TODO(zerny): Do more optimization passes on the callee graph. |
| 772 FlowGraphOptimizer optimizer(callee_graph); | 779 FlowGraphOptimizer optimizer(callee_graph); |
| 780 if (Compiler::always_optimize()) { |
| 781 optimizer.PopulateWithICData(); |
| 782 } |
| 773 optimizer.ApplyICData(); | 783 optimizer.ApplyICData(); |
| 774 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 784 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 775 | 785 |
| 776 // Optimize (a << b) & c patterns, merge instructions. Must occur before | 786 // Optimize (a << b) & c patterns, merge instructions. Must occur before |
| 777 // 'SelectRepresentations' which inserts conversion nodes. | 787 // 'SelectRepresentations' which inserts conversion nodes. |
| 778 optimizer.TryOptimizePatterns(); | 788 optimizer.TryOptimizePatterns(); |
| 779 DEBUG_ASSERT(callee_graph->VerifyUseLists()); | 789 DEBUG_ASSERT(callee_graph->VerifyUseLists()); |
| 780 } | 790 } |
| 781 | 791 |
| 782 if (FLAG_trace_inlining && | 792 if (FLAG_trace_inlining && |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 intptr_t FlowGraphInliner::NextInlineId(const Function& function, | 1880 intptr_t FlowGraphInliner::NextInlineId(const Function& function, |
| 1871 intptr_t parent_id) { | 1881 intptr_t parent_id) { |
| 1872 const intptr_t id = inline_id_to_function_->length(); | 1882 const intptr_t id = inline_id_to_function_->length(); |
| 1873 inline_id_to_function_->Add(&function); | 1883 inline_id_to_function_->Add(&function); |
| 1874 caller_inline_id_->Add(parent_id); | 1884 caller_inline_id_->Add(parent_id); |
| 1875 return id; | 1885 return id; |
| 1876 } | 1886 } |
| 1877 | 1887 |
| 1878 | 1888 |
| 1879 } // namespace dart | 1889 } // namespace dart |
| OLD | NEW |