Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: runtime/vm/flow_graph_inliner.cc

Issue 678763004: Make CTX allocatable by the register allocator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 // Replace remaining constants with uses by constants in the caller's 919 // Replace remaining constants with uses by constants in the caller's
920 // initial definitions. 920 // initial definitions.
921 GrowableArray<Definition*>* defns = 921 GrowableArray<Definition*>* defns =
922 callee_graph->graph_entry()->initial_definitions(); 922 callee_graph->graph_entry()->initial_definitions();
923 for (intptr_t i = 0; i < defns->length(); ++i) { 923 for (intptr_t i = 0; i < defns->length(); ++i) {
924 ConstantInstr* constant = (*defns)[i]->AsConstant(); 924 ConstantInstr* constant = (*defns)[i]->AsConstant();
925 if ((constant != NULL) && constant->HasUses()) { 925 if ((constant != NULL) && constant->HasUses()) {
926 constant->ReplaceUsesWith( 926 constant->ReplaceUsesWith(
927 caller_graph_->GetConstant(constant->value())); 927 caller_graph_->GetConstant(constant->value()));
928 } 928 }
929 CurrentContextInstr* context = (*defns)[i]->AsCurrentContext();
930 if ((context != NULL) && context->HasUses()) {
931 if (call->IsClosureCall()) {
932 context->ReplaceUsesWith(
933 call->AsClosureCall()->context()->definition());
934 } else {
935 context->ReplaceUsesWith(caller_graph_->CurrentContext(call->env()));
Vyacheslav Egorov (Google) 2014/10/28 13:44:58 Just use the empty one here. If it's not a closure
Florian Schneider 2014/10/28 19:04:31 Done.
936 }
937 }
929 } 938 }
930 939
931 // Check that inlining maintains use lists. 940 // Check that inlining maintains use lists.
932 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists()); 941 DEBUG_ASSERT(!FLAG_verify_compiler || caller_graph_->VerifyUseLists());
933 } 942 }
934 943
935 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) { 944 static intptr_t CountConstants(const GrowableArray<Value*>& arguments) {
936 intptr_t count = 0; 945 intptr_t count = 0;
937 for (intptr_t i = 0; i < arguments.length(); i++) { 946 for (intptr_t i = 0; i < arguments.length(); i++) {
938 if (arguments[i]->BindsToConstant()) count++; 947 if (arguments[i]->BindsToConstant()) count++;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 } 1337 }
1329 } 1338 }
1330 GrowableArray<Definition*>* defns = 1339 GrowableArray<Definition*>* defns =
1331 callee_graph->graph_entry()->initial_definitions(); 1340 callee_graph->graph_entry()->initial_definitions();
1332 for (intptr_t i = 0; i < defns->length(); ++i) { 1341 for (intptr_t i = 0; i < defns->length(); ++i) {
1333 ConstantInstr* constant = (*defns)[i]->AsConstant(); 1342 ConstantInstr* constant = (*defns)[i]->AsConstant();
1334 if ((constant != NULL) && constant->HasUses()) { 1343 if ((constant != NULL) && constant->HasUses()) {
1335 constant->ReplaceUsesWith( 1344 constant->ReplaceUsesWith(
1336 owner_->caller_graph()->GetConstant(constant->value())); 1345 owner_->caller_graph()->GetConstant(constant->value()));
1337 } 1346 }
1347 CurrentContextInstr* context = (*defns)[i]->AsCurrentContext();
1348 if ((context != NULL) && context->HasUses()) {
1349 if (call_data.call->IsClosureCall()) {
1350 context->ReplaceUsesWith(
1351 call_data.call->AsClosureCall()->context()->definition());
1352 } else {
1353 context->ReplaceUsesWith(
1354 owner_->caller_graph()->CurrentContext(call_data.call->env()));
Vyacheslav Egorov (Google) 2014/10/28 13:44:58 Ditto.
Florian Schneider 2014/10/28 19:04:31 Done.
1355 }
1356 }
1338 } 1357 }
1339 return true; 1358 return true;
1340 } 1359 }
1341 1360
1342 1361
1343 static Instruction* AppendInstruction(Instruction* first, 1362 static Instruction* AppendInstruction(Instruction* first,
1344 Instruction* second) { 1363 Instruction* second) {
1345 for (intptr_t i = second->InputCount() - 1; i >= 0; --i) { 1364 for (intptr_t i = second->InputCount() - 1; i >= 0; --i) {
1346 Value* input = second->InputAt(i); 1365 Value* input = second->InputAt(i);
1347 input->definition()->AddInputUse(input); 1366 input->definition()->AddInputUse(input);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 OS::Print("After Inlining of %s\n", flow_graph_-> 1722 OS::Print("After Inlining of %s\n", flow_graph_->
1704 parsed_function().function().ToFullyQualifiedCString()); 1723 parsed_function().function().ToFullyQualifiedCString());
1705 FlowGraphPrinter printer(*flow_graph_); 1724 FlowGraphPrinter printer(*flow_graph_);
1706 printer.PrintBlocks(); 1725 printer.PrintBlocks();
1707 } 1726 }
1708 } 1727 }
1709 } 1728 }
1710 } 1729 }
1711 1730
1712 } // namespace dart 1731 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698