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

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

Issue 10823279: Cache the first evaluation of the compile time type of a definition as the (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 | 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // here. In other words, if the compile type of the value is more specific 215 // here. In other words, if the compile type of the value is more specific
216 // than the destination type, the run time type of the value, which is 216 // than the destination type, the run time type of the value, which is
217 // guaranteed to be a subtype of the compile type, is also guaranteed to be 217 // guaranteed to be a subtype of the compile type, is also guaranteed to be
218 // a subtype of the destination type and the type check can therefore be 218 // a subtype of the destination type and the type check can therefore be
219 // eliminated. 219 // eliminated.
220 return compile_type.IsMoreSpecificThan(dst_type, NULL); 220 return compile_type.IsMoreSpecificThan(dst_type, NULL);
221 } 221 }
222 222
223 223
224 RawAbstractType* PhiInstr::CompileType() const { 224 RawAbstractType* PhiInstr::CompileType() const {
225 if (HasPropagatedType()) { 225 ASSERT(!HasPropagatedType());
226 return PropagatedType(); 226 // Since type propagation has not yet occured, we are reaching this phi via a
227 }
228 // If type propagation has not yet occured, we are reaching this phi via a
229 // back edge phi input. Return null as compile type so that this input is 227 // back edge phi input. Return null as compile type so that this input is
230 // ignored in the first iteration of type propagation. 228 // ignored in the first iteration of type propagation.
231 return AbstractType::null(); 229 return AbstractType::null();
232 } 230 }
233 231
234 232
235 RawAbstractType* PhiInstr::LeastSpecificInputType() const { 233 RawAbstractType* PhiInstr::LeastSpecificInputType() const {
236 AbstractType& least_specific_type = AbstractType::Handle(); 234 AbstractType& least_specific_type = AbstractType::Handle();
237 AbstractType& input_type = AbstractType::Handle(); 235 AbstractType& input_type = AbstractType::Handle();
238 for (intptr_t i = 0; i < InputCount(); i++) { 236 for (intptr_t i = 0; i < InputCount(); i++) {
(...skipping 14 matching lines...) Expand all
253 // The types are unrelated. No need to continue. 251 // The types are unrelated. No need to continue.
254 least_specific_type = Type::ObjectType(); 252 least_specific_type = Type::ObjectType();
255 break; 253 break;
256 } 254 }
257 } 255 }
258 return least_specific_type.raw(); 256 return least_specific_type.raw();
259 } 257 }
260 258
261 259
262 RawAbstractType* ParameterInstr::CompileType() const { 260 RawAbstractType* ParameterInstr::CompileType() const {
263 // TODO(regis): Can type feedback provide information about the compile type 261 ASSERT(!HasPropagatedType());
264 // of a passed-in parameter? In that case, it would be stored in the
265 // propagated_type_ field.
266 if (HasPropagatedType()) {
267 return PropagatedType();
268 }
269 // Note that returning the declared type of the formal parameter would be 262 // Note that returning the declared type of the formal parameter would be
270 // incorrect, because ParameterInstr is used as input to the type check 263 // incorrect, because ParameterInstr is used as input to the type check
271 // verifying the run time type of the passed-in parameter and this check would 264 // verifying the run time type of the passed-in parameter and this check would
272 // always be wrongly eliminated. 265 // always be wrongly eliminated.
273 return Type::DynamicType(); 266 return Type::DynamicType();
274 } 267 }
275 268
276 269
277 RawAbstractType* PushArgumentInstr::CompileType() const { 270 RawAbstractType* PushArgumentInstr::CompileType() const {
278 return AbstractType::null(); 271 return AbstractType::null();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 312 }
320 current->definition_ = other; 313 current->definition_ = other;
321 314
322 current->next_use_ = other->use_list(); 315 current->next_use_ = other->use_list();
323 other->use_list()->previous_use_ = current; 316 other->use_list()->previous_use_ = current;
324 other->set_use_list(head); 317 other->set_use_list(head);
325 } 318 }
326 319
327 320
328 RawAbstractType* BindInstr::CompileType() const { 321 RawAbstractType* BindInstr::CompileType() const {
329 if (HasPropagatedType()) { 322 ASSERT(!HasPropagatedType());
330 return PropagatedType();
331 }
332 // The compile type may be requested when building the flow graph, i.e. before 323 // The compile type may be requested when building the flow graph, i.e. before
333 // type propagation has occurred. 324 // type propagation has occurred.
334 return computation()->CompileType(); 325 return computation()->CompileType();
335 } 326 }
336 327
337 328
338 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, 329 void BindInstr::RecordAssignedVars(BitVector* assigned_vars,
339 intptr_t fixed_parameter_count) { 330 intptr_t fixed_parameter_count) {
340 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); 331 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count);
341 } 332 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 if (value().IsInstance()) { 559 if (value().IsInstance()) {
569 return Instance::Cast(value()).GetType(); 560 return Instance::Cast(value()).GetType();
570 } else { 561 } else {
571 ASSERT(value().IsAbstractTypeArguments()); 562 ASSERT(value().IsAbstractTypeArguments());
572 return AbstractType::null(); 563 return AbstractType::null();
573 } 564 }
574 } 565 }
575 566
576 567
577 RawAbstractType* UseVal::CompileType() const { 568 RawAbstractType* UseVal::CompileType() const {
578 return definition()->CompileType(); 569 if (definition()->HasPropagatedType()) {
570 return definition()->PropagatedType();
571 }
572 // The compile type may be requested when building the flow graph, i.e. before
573 // type propagation has occurred. To avoid repeatedly computing the compile
574 // type of the definition, we store it as initial propagated type.
575 AbstractType& type = AbstractType::Handle(definition()->CompileType());
576 definition()->SetPropagatedType(type);
577 return type.raw();
579 } 578 }
580 579
581 580
582 RawAbstractType* AssertAssignableComp::CompileType() const { 581 RawAbstractType* AssertAssignableComp::CompileType() const {
583 const AbstractType& value_compile_type = 582 const AbstractType& value_compile_type =
584 AbstractType::Handle(value()->CompileType()); 583 AbstractType::Handle(value()->CompileType());
585 if (!value_compile_type.IsNull() && 584 if (!value_compile_type.IsNull() &&
586 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { 585 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) {
587 return value_compile_type.raw(); 586 return value_compile_type.raw();
588 } 587 }
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 if (compiler->is_ssa()) { 1293 if (compiler->is_ssa()) {
1295 ASSERT(locs()->in(0).IsRegister()); 1294 ASSERT(locs()->in(0).IsRegister());
1296 __ PushRegister(locs()->in(0).reg()); 1295 __ PushRegister(locs()->in(0).reg());
1297 } 1296 }
1298 } 1297 }
1299 1298
1300 1299
1301 #undef __ 1300 #undef __
1302 1301
1303 } // namespace dart 1302 } // 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