| 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/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 } | 429 } |
| 430 | 430 |
| 431 // Load IC data for the callee. | 431 // Load IC data for the callee. |
| 432 if (function.HasCode()) { | 432 if (function.HasCode()) { |
| 433 const Code& unoptimized_code = | 433 const Code& unoptimized_code = |
| 434 Code::Handle(function.unoptimized_code()); | 434 Code::Handle(function.unoptimized_code()); |
| 435 isolate->set_ic_data_array(unoptimized_code.ExtractTypeFeedbackArray()); | 435 isolate->set_ic_data_array(unoptimized_code.ExtractTypeFeedbackArray()); |
| 436 } | 436 } |
| 437 | 437 |
| 438 // Build the callee graph. | 438 // Build the callee graph. |
| 439 InliningContext* inlining_context = InliningContext::Create(call); | 439 InliningContext inlining_context; |
| 440 FlowGraphBuilder builder(*parsed_function, inlining_context); | 440 FlowGraphBuilder builder(*parsed_function, &inlining_context); |
| 441 builder.SetInitialBlockId(caller_graph_->max_block_id()); | 441 builder.SetInitialBlockId(caller_graph_->max_block_id()); |
| 442 FlowGraph* callee_graph; | 442 FlowGraph* callee_graph; |
| 443 { | 443 { |
| 444 TimerScope timer(FLAG_compiler_stats, | 444 TimerScope timer(FLAG_compiler_stats, |
| 445 &CompilerStats::graphinliner_build_timer, | 445 &CompilerStats::graphinliner_build_timer, |
| 446 isolate); | 446 isolate); |
| 447 callee_graph = builder.BuildGraph(); | 447 callee_graph = builder.BuildGraph(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 // The parameter stubs are a copy of the actual arguments providing | 450 // The parameter stubs are a copy of the actual arguments providing |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if (inlining_depth_ < FLAG_inlining_depth_threshold) { | 552 if (inlining_depth_ < FLAG_inlining_depth_threshold) { |
| 553 collected_call_sites_->FindCallSites(callee_graph); | 553 collected_call_sites_->FindCallSites(callee_graph); |
| 554 } | 554 } |
| 555 | 555 |
| 556 { | 556 { |
| 557 TimerScope timer(FLAG_compiler_stats, | 557 TimerScope timer(FLAG_compiler_stats, |
| 558 &CompilerStats::graphinliner_subst_timer, | 558 &CompilerStats::graphinliner_subst_timer, |
| 559 isolate); | 559 isolate); |
| 560 | 560 |
| 561 // Plug result in the caller graph. | 561 // Plug result in the caller graph. |
| 562 inlining_context->ReplaceCall(caller_graph_, call, callee_graph); | 562 inlining_context.ReplaceCall(caller_graph_, call, callee_graph); |
| 563 | 563 |
| 564 // Replace each stub with the actual argument or the caller's constant. | 564 // Replace each stub with the actual argument or the caller's constant. |
| 565 // Nulls denote optional parameters for which no actual was given. | 565 // Nulls denote optional parameters for which no actual was given. |
| 566 for (intptr_t i = 0; i < arguments->length(); ++i) { | 566 for (intptr_t i = 0; i < arguments->length(); ++i) { |
| 567 Definition* stub = param_stubs[i]; | 567 Definition* stub = param_stubs[i]; |
| 568 Value* actual = (*arguments)[i]; | 568 Value* actual = (*arguments)[i]; |
| 569 if (actual != NULL) stub->ReplaceUsesWith(actual->definition()); | 569 if (actual != NULL) stub->ReplaceUsesWith(actual->definition()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 // Remove push arguments of the call. | 572 // Remove push arguments of the call. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 OS::Print("After Inlining of %s\n", flow_graph_-> | 883 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 884 parsed_function().function().ToFullyQualifiedCString()); | 884 parsed_function().function().ToFullyQualifiedCString()); |
| 885 FlowGraphPrinter printer(*flow_graph_); | 885 FlowGraphPrinter printer(*flow_graph_); |
| 886 printer.PrintBlocks(); | 886 printer.PrintBlocks(); |
| 887 } | 887 } |
| 888 } | 888 } |
| 889 } | 889 } |
| 890 } | 890 } |
| 891 | 891 |
| 892 } // namespace dart | 892 } // namespace dart |
| OLD | NEW |