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

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

Issue 10407026: Address a few TODOs related to type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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/intermediate_language.h ('k') | 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/object.h" 8 #include "vm/object.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 #include "vm/scopes.h" 10 #include "vm/scopes.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const AbstractType& function_type = 333 const AbstractType& function_type =
334 AbstractType::Handle(ArgumentAt(0)->StaticType()); 334 AbstractType::Handle(ArgumentAt(0)->StaticType());
335 if (function_type.IsDynamicType() || function_type.IsFunctionInterface()) { 335 if (function_type.IsDynamicType() || function_type.IsFunctionInterface()) {
336 // The function type is not statically known or simply Function. 336 // The function type is not statically known or simply Function.
337 return Type::DynamicType(); 337 return Type::DynamicType();
338 } 338 }
339 const Class& signature_class = Class::Handle(function_type.type_class()); 339 const Class& signature_class = Class::Handle(function_type.type_class());
340 ASSERT(signature_class.IsSignatureClass()); 340 ASSERT(signature_class.IsSignatureClass());
341 const Function& signature_function = 341 const Function& signature_function =
342 Function::Handle(signature_class.signature_function()); 342 Function::Handle(signature_class.signature_function());
343 // TODO(regis): The result type may be generic. 343 // TODO(regis): The result type may be generic. Consider upper bounds.
344 return signature_function.result_type(); 344 return signature_function.result_type();
345 } 345 }
346 346
347 347
348 RawAbstractType* InstanceCallComp::StaticType() const { 348 RawAbstractType* InstanceCallComp::StaticType() const {
349 return Type::DynamicType(); 349 return Type::DynamicType();
350 } 350 }
351 351
352 352
353 RawAbstractType* StaticCallComp::StaticType() const { 353 RawAbstractType* StaticCallComp::StaticType() const {
(...skipping 22 matching lines...) Expand all
376 } 376 }
377 377
378 378
379 RawAbstractType* EqualityCompareComp::StaticType() const { 379 RawAbstractType* EqualityCompareComp::StaticType() const {
380 return Type::BoolInterface(); 380 return Type::BoolInterface();
381 } 381 }
382 382
383 383
384 RawAbstractType* NativeCallComp::StaticType() const { 384 RawAbstractType* NativeCallComp::StaticType() const {
385 // The result type of the native function is identical to the result type of 385 // The result type of the native function is identical to the result type of
386 // the enclosing native Dart function. 386 // the enclosing native Dart function. However, we prefer to check the type
387 // TODO(regis): Can we trust it or should we check anyway? Check for now. 387 // of the value returned from the native call.
388 return Type::DynamicType(); 388 return Type::DynamicType();
389 } 389 }
390 390
391 391
392 RawAbstractType* StoreIndexedComp::StaticType() const { 392 RawAbstractType* StoreIndexedComp::StaticType() const {
393 return value()->StaticType(); 393 return value()->StaticType();
394 } 394 }
395 395
396 396
397 RawAbstractType* InstanceSetterComp::StaticType() const { 397 RawAbstractType* InstanceSetterComp::StaticType() const {
398 // TODO(regis): Would it be correct to return value()->StaticType()? 398 return value()->StaticType();
399 return Type::DynamicType();
400 } 399 }
401 400
402 401
403 RawAbstractType* StaticSetterComp::StaticType() const { 402 RawAbstractType* StaticSetterComp::StaticType() const {
404 // TODO(regis): Would it be correct/better to return value()->StaticType()? 403 const AbstractType& assigned_value_type =
405 return setter_function().result_type(); 404 AbstractType::Handle(value()->StaticType());
405 if (assigned_value_type.IsDynamicType()) {
406 // Static type of assigned value is unknown, return static type of setter
407 // value parameter.
408 return setter_function().ParameterTypeAt(0);
409 }
410 return assigned_value_type.raw();
406 } 411 }
407 412
408 413
409 RawAbstractType* LoadInstanceFieldComp::StaticType() const { 414 RawAbstractType* LoadInstanceFieldComp::StaticType() const {
410 return field().type(); 415 return field().type();
411 } 416 }
412 417
413 418
414 RawAbstractType* StoreInstanceFieldComp::StaticType() const { 419 RawAbstractType* StoreInstanceFieldComp::StaticType() const {
415 const AbstractType& assigned_value_type = 420 const AbstractType& assigned_value_type =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 455
451 RawAbstractType* CreateArrayComp::StaticType() const { 456 RawAbstractType* CreateArrayComp::StaticType() const {
452 UNREACHABLE(); 457 UNREACHABLE();
453 return AbstractType::null(); 458 return AbstractType::null();
454 } 459 }
455 460
456 461
457 RawAbstractType* CreateClosureComp::StaticType() const { 462 RawAbstractType* CreateClosureComp::StaticType() const {
458 const Function& fun = function(); 463 const Function& fun = function();
459 const Class& signature_class = Class::Handle(fun.signature_class()); 464 const Class& signature_class = Class::Handle(fun.signature_class());
460 // TODO(regis): Can we take (constant) type_arguments() into consideration? 465 // TODO(regis): The signature type may be generic. Consider upper bounds.
461 // For now, we return Dynamic (no type test elimination) if the signature 466 // For now, we return Dynamic (no type test elimination) if the signature
462 // class is parameterized, or a non-parameterized finalized type otherwise. 467 // class is parameterized, or a non-parameterized finalized type otherwise.
463 if (signature_class.HasTypeArguments()) { 468 if (signature_class.HasTypeArguments()) {
464 return Type::DynamicType(); 469 return Type::DynamicType();
465 } 470 }
466 // Make sure we use the canonical signature class. 471 // Make sure we use the canonical signature class.
467 const Type& type = Type::Handle(signature_class.SignatureType()); 472 const Type& type = Type::Handle(signature_class.SignatureType());
468 const Class& canonical_signature_class = Class::Handle(type.type_class()); 473 const Class& canonical_signature_class = Class::Handle(type.type_class());
469 return Type::NewNonParameterizedType(canonical_signature_class); 474 return Type::NewNonParameterizedType(canonical_signature_class);
470 } 475 }
(...skipping 11 matching lines...) Expand all
482 } 487 }
483 488
484 489
485 RawAbstractType* NativeLoadFieldComp::StaticType() const { 490 RawAbstractType* NativeLoadFieldComp::StaticType() const {
486 ASSERT(!type().IsNull()); 491 ASSERT(!type().IsNull());
487 return type().raw(); 492 return type().raw();
488 } 493 }
489 494
490 495
491 RawAbstractType* NativeStoreFieldComp::StaticType() const { 496 RawAbstractType* NativeStoreFieldComp::StaticType() const {
492 return value()->StaticType(); 497 ASSERT(!type().IsNull());
498 const AbstractType& assigned_value_type =
499 AbstractType::Handle(value()->StaticType());
500 if (assigned_value_type.IsDynamicType()) {
501 // Static type of assigned value is unknown, return static type of field.
502 return type().raw();
503 }
504 return assigned_value_type.raw();
493 } 505 }
494 506
495 507
496 RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const { 508 RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const {
497 UNREACHABLE(); 509 UNREACHABLE();
498 return AbstractType::null(); 510 return AbstractType::null();
499 } 511 }
500 512
501 513
502 RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const { 514 RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const {
(...skipping 26 matching lines...) Expand all
529 } 541 }
530 542
531 543
532 RawAbstractType* CatchEntryComp::StaticType() const { 544 RawAbstractType* CatchEntryComp::StaticType() const {
533 UNREACHABLE(); 545 UNREACHABLE();
534 return AbstractType::null(); 546 return AbstractType::null();
535 } 547 }
536 548
537 549
538 } // namespace dart 550 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698