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

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

Issue 12212093: Convert some compiler passes to preserve valid def-use chains. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 7 years, 10 months 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
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Remove push arguments of the call. 564 // Remove push arguments of the call.
565 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { 565 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) {
566 PushArgumentInstr* push = call->ArgumentAt(i); 566 PushArgumentInstr* push = call->PushArgumentAt(i);
567 push->ReplaceUsesWith(push->value()->definition()); 567 push->ReplaceUsesWith(push->value()->definition());
568 push->RemoveFromGraph(); 568 push->RemoveFromGraph();
569 } 569 }
570 570
571 // Replace each stub with the actual argument or the caller's constant. 571 // Replace each stub with the actual argument or the caller's constant.
572 // Nulls denote optional parameters for which no actual was given. 572 // Nulls denote optional parameters for which no actual was given.
573 for (intptr_t i = 0; i < arguments->length(); ++i) { 573 for (intptr_t i = 0; i < arguments->length(); ++i) {
574 Definition* stub = param_stubs[i]; 574 Definition* stub = param_stubs[i];
575 Value* actual = (*arguments)[i]; 575 Value* actual = (*arguments)[i];
576 if (actual != NULL) stub->ReplaceUsesWith(actual->definition()); 576 if (actual != NULL) stub->ReplaceUsesWith(actual->definition());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 645 }
646 646
647 void InlineStaticCalls() { 647 void InlineStaticCalls() {
648 const GrowableArray<StaticCallInstr*>& calls = 648 const GrowableArray<StaticCallInstr*>& calls =
649 inlining_call_sites_->static_calls(); 649 inlining_call_sites_->static_calls();
650 TRACE_INLINING(OS::Print(" Static Calls (%d)\n", calls.length())); 650 TRACE_INLINING(OS::Print(" Static Calls (%d)\n", calls.length()));
651 for (intptr_t i = 0; i < calls.length(); ++i) { 651 for (intptr_t i = 0; i < calls.length(); ++i) {
652 StaticCallInstr* call = calls[i]; 652 StaticCallInstr* call = calls[i];
653 GrowableArray<Value*> arguments(call->ArgumentCount()); 653 GrowableArray<Value*> arguments(call->ArgumentCount());
654 for (int i = 0; i < call->ArgumentCount(); ++i) { 654 for (int i = 0; i < call->ArgumentCount(); ++i) {
655 arguments.Add(call->ArgumentAt(i)->value()); 655 arguments.Add(call->PushArgumentAt(i)->value());
656 } 656 }
657 TryInlining(call->function(), call->argument_names(), &arguments, call); 657 TryInlining(call->function(), call->argument_names(), &arguments, call);
658 } 658 }
659 } 659 }
660 660
661 void InlineClosureCalls() { 661 void InlineClosureCalls() {
662 const GrowableArray<ClosureCallInstr*>& calls = 662 const GrowableArray<ClosureCallInstr*>& calls =
663 inlining_call_sites_->closure_calls(); 663 inlining_call_sites_->closure_calls();
664 TRACE_INLINING(OS::Print(" Closure Calls (%d)\n", calls.length())); 664 TRACE_INLINING(OS::Print(" Closure Calls (%d)\n", calls.length()));
665 for (intptr_t i = 0; i < calls.length(); ++i) { 665 for (intptr_t i = 0; i < calls.length(); ++i) {
666 ClosureCallInstr* call = calls[i]; 666 ClosureCallInstr* call = calls[i];
667 // Find the closure of the callee. 667 // Find the closure of the callee.
668 ASSERT(call->ArgumentCount() > 0); 668 ASSERT(call->ArgumentCount() > 0);
669 const CreateClosureInstr* closure = 669 const CreateClosureInstr* closure =
670 call->ArgumentAt(0)->value()->definition()->AsCreateClosure(); 670 call->ArgumentAt(0)->AsCreateClosure();
671 if (closure == NULL) { 671 if (closure == NULL) {
672 TRACE_INLINING(OS::Print(" Bailout: non-closure operator\n")); 672 TRACE_INLINING(OS::Print(" Bailout: non-closure operator\n"));
673 continue; 673 continue;
674 } 674 }
675 GrowableArray<Value*> arguments(call->ArgumentCount()); 675 GrowableArray<Value*> arguments(call->ArgumentCount());
676 for (int i = 0; i < call->ArgumentCount(); ++i) { 676 for (int i = 0; i < call->ArgumentCount(); ++i) {
677 arguments.Add(call->ArgumentAt(i)->value()); 677 arguments.Add(call->PushArgumentAt(i)->value());
678 } 678 }
679 TryInlining(closure->function(), 679 TryInlining(closure->function(),
680 call->argument_names(), 680 call->argument_names(),
681 &arguments, 681 &arguments,
682 call); 682 call);
683 } 683 }
684 } 684 }
685 685
686 void InlineInstanceCalls() { 686 void InlineInstanceCalls() {
687 const GrowableArray<CallSites::InstanceCallInfo>& call_info = 687 const GrowableArray<CallSites::InstanceCallInfo>& call_info =
(...skipping 15 matching lines...) Expand all
703 if ((call_info[i].ratio * 100) < FLAG_inlining_hotness) { 703 if ((call_info[i].ratio * 100) < FLAG_inlining_hotness) {
704 TRACE_INLINING(OS::Print( 704 TRACE_INLINING(OS::Print(
705 " => %s (deopt count %d)\n Bailout: cold %f\n", 705 " => %s (deopt count %d)\n Bailout: cold %f\n",
706 target.ToCString(), 706 target.ToCString(),
707 target.deoptimization_counter(), 707 target.deoptimization_counter(),
708 call_info[i].ratio)); 708 call_info[i].ratio));
709 continue; 709 continue;
710 } 710 }
711 GrowableArray<Value*> arguments(instr->ArgumentCount()); 711 GrowableArray<Value*> arguments(instr->ArgumentCount());
712 for (int arg_i = 0; arg_i < instr->ArgumentCount(); ++arg_i) { 712 for (int arg_i = 0; arg_i < instr->ArgumentCount(); ++arg_i) {
713 arguments.Add(instr->ArgumentAt(arg_i)->value()); 713 arguments.Add(instr->PushArgumentAt(arg_i)->value());
714 } 714 }
715 TryInlining(target, 715 TryInlining(target,
716 instr->instance_call()->argument_names(), 716 instr->instance_call()->argument_names(),
717 &arguments, 717 &arguments,
718 instr); 718 instr);
719 } 719 }
720 } 720 }
721 721
722 void AdjustForOptionalParameters(const ParsedFunction& parsed_function, 722 void AdjustForOptionalParameters(const ParsedFunction& parsed_function,
723 const Array& argument_names, 723 const Array& argument_names,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 OS::Print("After Inlining of %s\n", flow_graph_-> 868 OS::Print("After Inlining of %s\n", flow_graph_->
869 parsed_function().function().ToFullyQualifiedCString()); 869 parsed_function().function().ToFullyQualifiedCString());
870 FlowGraphPrinter printer(*flow_graph_); 870 FlowGraphPrinter printer(*flow_graph_);
871 printer.PrintBlocks(); 871 printer.PrintBlocks();
872 } 872 }
873 } 873 }
874 } 874 }
875 } 875 }
876 876
877 } // namespace dart 877 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph.cc ('k') | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698