| 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 663 } |
| 664 | 664 |
| 665 // Replace remaining constants with uses by constants in the caller's | 665 // Replace remaining constants with uses by constants in the caller's |
| 666 // initial definitions. | 666 // initial definitions. |
| 667 GrowableArray<Definition*>* defns = | 667 GrowableArray<Definition*>* defns = |
| 668 callee_graph->graph_entry()->initial_definitions(); | 668 callee_graph->graph_entry()->initial_definitions(); |
| 669 for (intptr_t i = 0; i < defns->length(); ++i) { | 669 for (intptr_t i = 0; i < defns->length(); ++i) { |
| 670 ConstantInstr* constant = (*defns)[i]->AsConstant(); | 670 ConstantInstr* constant = (*defns)[i]->AsConstant(); |
| 671 if ((constant != NULL) && constant->HasUses()) { | 671 if ((constant != NULL) && constant->HasUses()) { |
| 672 constant->ReplaceUsesWith( | 672 constant->ReplaceUsesWith( |
| 673 caller_graph_->AddConstantToInitialDefinitions( | 673 caller_graph_->GetConstant(constant->value())); |
| 674 constant->value())); | |
| 675 } | 674 } |
| 676 } | 675 } |
| 677 | 676 |
| 678 // Check that inlining maintains use lists. | 677 // Check that inlining maintains use lists. |
| 679 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists()); | 678 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists()); |
| 680 } | 679 } |
| 681 | 680 |
| 682 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) { | 681 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) { |
| 683 intptr_t count = 0; | 682 intptr_t count = 0; |
| 684 for (intptr_t i = 0; i < arguments.length(); i++) { | 683 for (intptr_t i = 0; i < arguments.length(); i++) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 stub = (*call_data.parameter_stubs)[i]; | 1019 stub = (*call_data.parameter_stubs)[i]; |
| 1021 stub->ReplaceUsesWith(actual->definition()); | 1020 stub->ReplaceUsesWith(actual->definition()); |
| 1022 } | 1021 } |
| 1023 } | 1022 } |
| 1024 GrowableArray<Definition*>* defns = | 1023 GrowableArray<Definition*>* defns = |
| 1025 callee_graph->graph_entry()->initial_definitions(); | 1024 callee_graph->graph_entry()->initial_definitions(); |
| 1026 for (intptr_t i = 0; i < defns->length(); ++i) { | 1025 for (intptr_t i = 0; i < defns->length(); ++i) { |
| 1027 ConstantInstr* constant = (*defns)[i]->AsConstant(); | 1026 ConstantInstr* constant = (*defns)[i]->AsConstant(); |
| 1028 if ((constant != NULL) && constant->HasUses()) { | 1027 if ((constant != NULL) && constant->HasUses()) { |
| 1029 constant->ReplaceUsesWith( | 1028 constant->ReplaceUsesWith( |
| 1030 owner_->caller_graph()->AddConstantToInitialDefinitions( | 1029 owner_->caller_graph()->GetConstant(constant->value())); |
| 1031 constant->value())); | |
| 1032 } | 1030 } |
| 1033 } | 1031 } |
| 1034 return true; | 1032 return true; |
| 1035 } | 1033 } |
| 1036 | 1034 |
| 1037 | 1035 |
| 1038 static Instruction* AppendInstruction(Instruction* first, | 1036 static Instruction* AppendInstruction(Instruction* first, |
| 1039 Instruction* second) { | 1037 Instruction* second) { |
| 1040 for (intptr_t i = second->InputCount() - 1; i >= 0; --i) { | 1038 for (intptr_t i = second->InputCount() - 1; i >= 0; --i) { |
| 1041 Value* input = second->InputAt(i); | 1039 Value* input = second->InputAt(i); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 OS::Print("After Inlining of %s\n", flow_graph_-> | 1327 OS::Print("After Inlining of %s\n", flow_graph_-> |
| 1330 parsed_function().function().ToFullyQualifiedCString()); | 1328 parsed_function().function().ToFullyQualifiedCString()); |
| 1331 FlowGraphPrinter printer(*flow_graph_); | 1329 FlowGraphPrinter printer(*flow_graph_); |
| 1332 printer.PrintBlocks(); | 1330 printer.PrintBlocks(); |
| 1333 } | 1331 } |
| 1334 } | 1332 } |
| 1335 } | 1333 } |
| 1336 } | 1334 } |
| 1337 | 1335 |
| 1338 } // namespace dart | 1336 } // namespace dart |
| OLD | NEW |