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

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

Issue 10825483: Add --use_cha (default true, switch to false if you use dynamic class loading). Use CHA to specify … (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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('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) 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/cha.h"
7 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
8 #include "vm/hash_map.h" 9 #include "vm/hash_map.h"
9 #include "vm/il_printer.h" 10 #include "vm/il_printer.h"
10 #include "vm/object_store.h" 11 #include "vm/object_store.h"
11 #include "vm/parser.h" 12 #include "vm/parser.h"
12 #include "vm/scopes.h" 13 #include "vm/scopes.h"
13 #include "vm/symbols.h" 14 #include "vm/symbols.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 DECLARE_FLAG(bool, eliminate_type_checks); 18 DECLARE_FLAG(bool, eliminate_type_checks);
18 DECLARE_FLAG(bool, enable_type_checks); 19 DECLARE_FLAG(bool, enable_type_checks);
19 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); 20 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details.");
20 DECLARE_FLAG(bool, trace_type_check_elimination); 21 DECLARE_FLAG(bool, trace_type_check_elimination);
22 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis.");
21 23
22 void FlowGraphOptimizer::ApplyICData() { 24 void FlowGraphOptimizer::ApplyICData() {
23 VisitBlocks(); 25 VisitBlocks();
24 } 26 }
25 27
26 28
27 void FlowGraphOptimizer::OptimizeComputations() { 29 void FlowGraphOptimizer::OptimizeComputations() {
28 for (intptr_t i = 0; i < block_order_.length(); ++i) { 30 for (intptr_t i = 0; i < block_order_.length(); ++i) {
29 BlockEntryInstr* entry = block_order_[i]; 31 BlockEntryInstr* entry = block_order_[i];
30 entry->Accept(this); 32 entry->Accept(this);
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 } 863 }
862 864
863 865
864 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) { 866 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) {
865 // TODO(regis): Once we inline functions, the propagated type of the formal 867 // TODO(regis): Once we inline functions, the propagated type of the formal
866 // parameter will reflect the compile type of the passed-in argument. 868 // parameter will reflect the compile type of the passed-in argument.
867 // For now, we do not know anything about the argument type and therefore set 869 // For now, we do not know anything about the argument type and therefore set
868 // it to the DynamicType, unless the argument is a compiler generated value, 870 // it to the DynamicType, unless the argument is a compiler generated value,
869 // i.e. the receiver argument or the constructor phase argument. 871 // i.e. the receiver argument or the constructor phase argument.
870 AbstractType& param_type = AbstractType::Handle(Type::DynamicType()); 872 AbstractType& param_type = AbstractType::Handle(Type::DynamicType());
873 param->SetPropagatedCid(kDynamicCid);
871 if (param->index() < 2) { 874 if (param->index() < 2) {
872 const Function& function = parsed_function().function(); 875 const Function& function = parsed_function().function();
873 if (((param->index() == 0) && function.IsDynamicFunction()) || 876 if (((param->index() == 0) && function.IsDynamicFunction()) ||
874 ((param->index() == 1) && function.IsConstructor())) { 877 ((param->index() == 1) && function.IsConstructor())) {
875 // Parameter is the receiver or the constructor phase. 878 // Parameter is the receiver or the constructor phase.
876 LocalScope* scope = parsed_function().node_sequence()->scope(); 879 LocalScope* scope = parsed_function().node_sequence()->scope();
877 param_type = scope->VariableAt(param->index())->type().raw(); 880 param_type = scope->VariableAt(param->index())->type().raw();
881 if (FLAG_use_cha) {
882 const intptr_t cid = Class::Handle(param_type.type_class()).id();
883 if (!CHA::HasSubclasses(cid)) {
884 // Receiver's class has no subclasses.
885 param->SetPropagatedCid(cid);
886 }
887 }
878 } 888 }
879 } 889 }
880 bool changed = param->SetPropagatedType(param_type); 890 bool changed = param->SetPropagatedType(param_type);
881 if (changed) { 891 if (changed) {
882 still_changing_ = true; 892 still_changing_ = true;
883 } 893 }
884 param->SetPropagatedCid(kDynamicCid);
885 } 894 }
886 895
887 896
888 void FlowGraphTypePropagator::PropagateTypes() { 897 void FlowGraphTypePropagator::PropagateTypes() {
889 // TODO(regis): Is there a way to make this more efficient, e.g. by visiting 898 // TODO(regis): Is there a way to make this more efficient, e.g. by visiting
890 // only blocks depending on blocks that have changed and not the whole graph. 899 // only blocks depending on blocks that have changed and not the whole graph.
891 do { 900 do {
892 still_changing_ = false; 901 still_changing_ = false;
893 VisitBlocks(); 902 VisitBlocks();
894 } while (still_changing_); 903 } while (still_changing_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 OS::Print("Replacing v%d with v%d\n", 939 OS::Print("Replacing v%d with v%d\n",
931 instr->ssa_temp_index(), 940 instr->ssa_temp_index(),
932 result->ssa_temp_index()); 941 result->ssa_temp_index());
933 } 942 }
934 } 943 }
935 } 944 }
936 } 945 }
937 946
938 947
939 } // namespace dart 948 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698