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

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

Issue 10830339: Propagate class ids using existing type propagation framework. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « no previous file | runtime/vm/il_printer.cc » ('j') | runtime/vm/intermediate_language.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/flow_graph_builder.h" 7 #include "vm/flow_graph_builder.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // No need to propagate the input types of the bound computation, as long as 665 // No need to propagate the input types of the bound computation, as long as
666 // PhiInstr's are handled as part of JoinEntryInstr. 666 // PhiInstr's are handled as part of JoinEntryInstr.
667 // Visit computation and possibly eliminate type check. 667 // Visit computation and possibly eliminate type check.
668 bind->computation()->Accept(this, bind); 668 bind->computation()->Accept(this, bind);
669 // Cache propagated computation type. 669 // Cache propagated computation type.
670 AbstractType& type = AbstractType::Handle(bind->computation()->CompileType()); 670 AbstractType& type = AbstractType::Handle(bind->computation()->CompileType());
671 bool changed = bind->SetPropagatedType(type); 671 bool changed = bind->SetPropagatedType(type);
672 if (changed) { 672 if (changed) {
673 still_changing_ = true; 673 still_changing_ = true;
674 } 674 }
675 // Propagate class ids.
676 intptr_t cid = bind->computation()->ResultCid();
677 changed = bind->SetPropagatedCid(cid);
678 if (changed) {
679 still_changing_ = true;
680 }
675 } 681 }
676 682
677 683
678 void FlowGraphTypePropagator::VisitPhi(PhiInstr* phi) { 684 void FlowGraphTypePropagator::VisitPhi(PhiInstr* phi) {
679 // We could set the propagated type of the phi to the least upper bound of its 685 // We could set the propagated type of the phi to the least upper bound of its
680 // input propagated types. However, keeping all propagated types allows us to 686 // input propagated types. However, keeping all propagated types allows us to
681 // optimize method dispatch. 687 // optimize method dispatch.
682 // TODO(regis): Support a set of propagated types. For now, we compute the 688 // TODO(regis): Support a set of propagated types. For now, we compute the
683 // least specific of the input propagated types. 689 // least specific of the input propagated types.
684 AbstractType& type = AbstractType::Handle(phi->LeastSpecificInputType()); 690 AbstractType& type = AbstractType::Handle(phi->LeastSpecificInputType());
685 bool changed = phi->SetPropagatedType(type); 691 bool changed = phi->SetPropagatedType(type);
686 if (changed) { 692 if (changed) {
687 still_changing_ = true; 693 still_changing_ = true;
688 } 694 }
695 if (phi->propagated_cid() == kDynamicCid) {
regis 2012/08/15 22:46:54 So far, I have tried not to depend on the type of
srdjan 2012/08/16 00:34:46 Done.
696 return;
697 }
698 // Merge class ids: if any two inputs have different class ids than result
regis 2012/08/15 22:46:54 s/than/then/
srdjan 2012/08/16 00:34:46 Done.
699 // is kDynamicCid.
700 for (intptr_t i = 0; i < phi->InputCount(); i++) {
701 intptr_t cid = phi->InputAt(i)->ResultCid();
702 ASSERT(cid != kIllegalCid);
703 changed = phi->SetPropagatedCid(cid);
regis 2012/08/15 22:46:54 This does not look right. You are not merging, but
srdjan 2012/08/16 00:34:46 Done.
704 if (changed) {
705 still_changing_ = true;
706 }
707 }
689 } 708 }
690 709
691 710
692 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) { 711 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) {
693 // TODO(regis): Once we inline functions, the propagated type of the formal 712 // TODO(regis): Once we inline functions, the propagated type of the formal
694 // parameter will reflect the compile type of the passed-in argument. 713 // parameter will reflect the compile type of the passed-in argument.
695 // For now, we do not know anything about the argument type and therefore set 714 // For now, we do not know anything about the argument type and therefore set
696 // it to the DynamicType, unless the argument is a compiler generated value, 715 // it to the DynamicType, unless the argument is a compiler generated value,
697 // i.e. the receiver argument or the constructor phase argument. 716 // i.e. the receiver argument or the constructor phase argument.
698 AbstractType& param_type = AbstractType::Handle(Type::DynamicType()); 717 AbstractType& param_type = AbstractType::Handle(Type::DynamicType());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 LocationSummary* locs = it.Current()->locs(); 749 LocationSummary* locs = it.Current()->locs();
731 if ((locs != NULL) && locs->can_call()) { 750 if ((locs != NULL) && locs->can_call()) {
732 is_leaf_ = false; 751 is_leaf_ = false;
733 return; 752 return;
734 } 753 }
735 } 754 }
736 } 755 }
737 } 756 }
738 757
739 } // namespace dart 758 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/il_printer.cc » ('j') | runtime/vm/intermediate_language.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698