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

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

Issue 11187003: Fix receiver's type for constructors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | no next file » | 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/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 2124
2125 2125
2126 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) { 2126 void FlowGraphTypePropagator::VisitParameter(ParameterInstr* param) {
2127 // TODO(regis): Once we inline functions, the propagated type of the formal 2127 // TODO(regis): Once we inline functions, the propagated type of the formal
2128 // parameter will reflect the compile type of the passed-in argument. 2128 // parameter will reflect the compile type of the passed-in argument.
2129 // For now, we do not know anything about the argument type and therefore set 2129 // For now, we do not know anything about the argument type and therefore set
2130 // it to the DynamicType, unless the argument is a compiler generated value, 2130 // it to the DynamicType, unless the argument is a compiler generated value,
2131 // i.e. the receiver argument or the constructor phase argument. 2131 // i.e. the receiver argument or the constructor phase argument.
2132 AbstractType& param_type = AbstractType::Handle(Type::DynamicType()); 2132 AbstractType& param_type = AbstractType::Handle(Type::DynamicType());
2133 param->SetPropagatedCid(kDynamicCid); 2133 param->SetPropagatedCid(kDynamicCid);
2134 if (param->index() < 2) { 2134 bool param_type_is_known = false;
2135 if (param->index() == 0) {
2135 const Function& function = parsed_function().function(); 2136 const Function& function = parsed_function().function();
2136 if (((param->index() == 0) && function.IsDynamicFunction()) || 2137 if ((function.IsDynamicFunction() || function.IsConstructor())) {
regis 2012/10/16 16:10:11 It looks like your change is only inserting || fun
srdjan 2012/10/16 16:18:19 Yes. IMO, it was hard to read and I thought that w
2137 ((param->index() == 1) && function.IsConstructor())) { 2138 // Parameter is the receiver .
2138 // Parameter is the receiver or the constructor phase. 2139 param_type_is_known = true;
2139 LocalScope* scope = parsed_function().node_sequence()->scope(); 2140 }
2140 param_type = scope->VariableAt(param->index())->type().raw(); 2141 }
2141 if (FLAG_use_cha) { 2142 if ((param->index() == 1) && parsed_function().function().IsConstructor()) {
regis 2012/10/16 16:10:11 How about an else here?
srdjan 2012/10/16 16:18:19 Done.
2142 const intptr_t cid = Class::Handle(param_type.type_class()).id(); 2143 // Parameter is the constructor phase.
2143 if (!CHA::HasSubclasses(cid)) { 2144 param_type_is_known = true;
2144 // Receiver's class has no subclasses. 2145 }
2145 param->SetPropagatedCid(cid); 2146 if (param_type_is_known) {
2146 } 2147 LocalScope* scope = parsed_function().node_sequence()->scope();
2148 param_type = scope->VariableAt(param->index())->type().raw();
2149 if (FLAG_use_cha) {
2150 const intptr_t cid = Class::Handle(param_type.type_class()).id();
2151 if (!CHA::HasSubclasses(cid)) {
2152 // Receiver's class has no subclasses.
2153 param->SetPropagatedCid(cid);
2147 } 2154 }
2148 } 2155 }
2149 } 2156 }
2150 bool changed = param->SetPropagatedType(param_type); 2157 bool changed = param->SetPropagatedType(param_type);
2151 if (changed) { 2158 if (changed) {
2152 still_changing_ = true; 2159 still_changing_ = true;
2153 } 2160 }
2154 } 2161 }
2155 2162
2156 2163
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 3285
3279 if (FLAG_trace_constant_propagation) { 3286 if (FLAG_trace_constant_propagation) {
3280 OS::Print("\n==== After constant propagation ====\n"); 3287 OS::Print("\n==== After constant propagation ====\n");
3281 FlowGraphPrinter printer(*graph_); 3288 FlowGraphPrinter printer(*graph_);
3282 printer.PrintBlocks(); 3289 printer.PrintBlocks();
3283 } 3290 }
3284 } 3291 }
3285 3292
3286 3293
3287 } // namespace dart 3294 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698