Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 Value* PhiInstr::InputAt(intptr_t i) const { | 312 Value* PhiInstr::InputAt(intptr_t i) const { |
| 313 return inputs_[i]; | 313 return inputs_[i]; |
| 314 } | 314 } |
| 315 | 315 |
| 316 | 316 |
| 317 void PhiInstr::SetInputAt(intptr_t i, Value* value) { | 317 void PhiInstr::SetInputAt(intptr_t i, Value* value) { |
| 318 inputs_[i] = value; | 318 inputs_[i] = value; |
| 319 } | 319 } |
| 320 | 320 |
| 321 | 321 |
| 322 RawAbstractType* PhiInstr::StaticType() const { | |
| 323 // TODO(regis): Return the least upper bound of the input static types. | |
| 324 return Type::DynamicType(); | |
| 325 } | |
| 326 | |
| 327 | |
| 322 intptr_t ParameterInstr::InputCount() const { | 328 intptr_t ParameterInstr::InputCount() const { |
| 323 return 0; | 329 return 0; |
| 324 } | 330 } |
| 325 | 331 |
| 326 | 332 |
| 327 Value* ParameterInstr::InputAt(intptr_t i) const { | 333 Value* ParameterInstr::InputAt(intptr_t i) const { |
| 328 UNREACHABLE(); | 334 UNREACHABLE(); |
| 329 return NULL; | 335 return NULL; |
| 330 } | 336 } |
| 331 | 337 |
| 332 | 338 |
| 333 void ParameterInstr::SetInputAt(intptr_t i, Value* value) { | 339 void ParameterInstr::SetInputAt(intptr_t i, Value* value) { |
| 334 UNREACHABLE(); | 340 UNREACHABLE(); |
| 335 } | 341 } |
| 336 | 342 |
| 337 | 343 |
| 344 RawAbstractType* ParameterInstr::StaticType() const { | |
| 345 // TODO(regis): Can type feedback provide information about the static type | |
| 346 // of a passed-in parameter? | |
|
srdjan
2012/07/25 21:50:06
I guess with FLAG_enable_type_checks we can use th
regis
2012/07/26 15:08:50
Good point. You probably mean the type of the form
| |
| 347 return Type::DynamicType(); | |
| 348 } | |
| 349 | |
| 350 | |
| 338 intptr_t GraphEntryInstr::InputCount() const { | 351 intptr_t GraphEntryInstr::InputCount() const { |
| 339 return 0; | 352 return 0; |
| 340 } | 353 } |
| 341 | 354 |
| 342 | 355 |
| 343 Value* GraphEntryInstr::InputAt(intptr_t i) const { | 356 Value* GraphEntryInstr::InputAt(intptr_t i) const { |
| 344 UNREACHABLE(); | 357 UNREACHABLE(); |
| 345 return NULL; | 358 return NULL; |
| 346 } | 359 } |
| 347 | 360 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 } | 634 } |
| 622 } | 635 } |
| 623 | 636 |
| 624 | 637 |
| 625 RawAbstractType* UseVal::StaticType() const { | 638 RawAbstractType* UseVal::StaticType() const { |
| 626 return definition()->StaticType(); | 639 return definition()->StaticType(); |
| 627 } | 640 } |
| 628 | 641 |
| 629 | 642 |
| 630 RawAbstractType* AssertAssignableComp::StaticType() const { | 643 RawAbstractType* AssertAssignableComp::StaticType() const { |
| 644 const AbstractType& value_static_type = | |
| 645 AbstractType::Handle(value()->StaticType()); | |
| 646 if (value_static_type.IsMoreSpecificThan(dst_type(), NULL)) { | |
| 647 return value_static_type.raw(); | |
| 648 } | |
| 631 return dst_type().raw(); | 649 return dst_type().raw(); |
| 632 } | 650 } |
| 633 | 651 |
| 634 | 652 |
| 635 RawAbstractType* AssertBooleanComp::StaticType() const { | 653 RawAbstractType* AssertBooleanComp::StaticType() const { |
| 636 return Type::BoolInterface(); | 654 return Type::BoolInterface(); |
| 637 } | 655 } |
| 638 | 656 |
| 639 | 657 |
| 640 RawAbstractType* CurrentContextComp::StaticType() const { | 658 RawAbstractType* CurrentContextComp::StaticType() const { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 652 RawAbstractType* ClosureCallComp::StaticType() const { | 670 RawAbstractType* ClosureCallComp::StaticType() const { |
| 653 // Because of function subtyping rules, the static return type of a closure | 671 // Because of function subtyping rules, the static return type of a closure |
| 654 // call cannot be relied upon for static type analysis. For example, a | 672 // call cannot be relied upon for static type analysis. For example, a |
| 655 // function returning Dynamic can be assigned to a closure variable declared | 673 // function returning Dynamic can be assigned to a closure variable declared |
| 656 // to return int and may actually return a double at run-time. | 674 // to return int and may actually return a double at run-time. |
| 657 return Type::DynamicType(); | 675 return Type::DynamicType(); |
| 658 } | 676 } |
| 659 | 677 |
| 660 | 678 |
| 661 RawAbstractType* InstanceCallComp::StaticType() const { | 679 RawAbstractType* InstanceCallComp::StaticType() const { |
| 680 // TODO(regis): Return a more specific type than Dynamic for recognized | |
| 681 // combinations of receiver static type and method name. | |
| 662 return Type::DynamicType(); | 682 return Type::DynamicType(); |
| 663 } | 683 } |
| 664 | 684 |
| 665 | 685 |
| 666 RawAbstractType* PolymorphicInstanceCallComp::StaticType() const { | 686 RawAbstractType* PolymorphicInstanceCallComp::StaticType() const { |
| 667 return Type::DynamicType(); | 687 return Type::DynamicType(); |
| 668 } | 688 } |
| 669 | 689 |
| 670 | 690 |
| 671 RawAbstractType* StaticCallComp::StaticType() const { | 691 RawAbstractType* StaticCallComp::StaticType() const { |
| 672 return function().result_type(); | 692 return function().result_type(); |
| 673 } | 693 } |
| 674 | 694 |
| 675 | 695 |
| 676 RawAbstractType* LoadLocalComp::StaticType() const { | 696 RawAbstractType* LoadLocalComp::StaticType() const { |
| 677 return local().type().raw(); | 697 return local().type().raw(); |
|
srdjan
2012/07/25 21:50:06
Is the type of the receiver setup correctly in loc
regis
2012/07/26 15:08:50
Good question. I have added a todo to verify.
I al
| |
| 678 } | 698 } |
| 679 | 699 |
| 680 | 700 |
| 681 RawAbstractType* StoreLocalComp::StaticType() const { | 701 RawAbstractType* StoreLocalComp::StaticType() const { |
| 682 const AbstractType& assigned_value_type = | 702 return value()->StaticType(); |
| 683 AbstractType::Handle(value()->StaticType()); | |
| 684 if (assigned_value_type.IsDynamicType()) { | |
| 685 // Static type of assigned value is unknown, return static type of local. | |
| 686 return local().type().raw(); | |
| 687 } | |
| 688 return assigned_value_type.raw(); | |
| 689 } | 703 } |
| 690 | 704 |
| 691 | 705 |
| 692 RawAbstractType* StrictCompareComp::StaticType() const { | 706 RawAbstractType* StrictCompareComp::StaticType() const { |
| 693 return Type::BoolInterface(); | 707 return Type::BoolInterface(); |
| 694 } | 708 } |
| 695 | 709 |
| 696 | 710 |
| 697 RawAbstractType* EqualityCompareComp::StaticType() const { | 711 RawAbstractType* EqualityCompareComp::StaticType() const { |
| 698 return Type::BoolInterface(); | 712 return Type::BoolInterface(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 722 return AbstractType::null(); | 736 return AbstractType::null(); |
| 723 } | 737 } |
| 724 | 738 |
| 725 | 739 |
| 726 RawAbstractType* InstanceSetterComp::StaticType() const { | 740 RawAbstractType* InstanceSetterComp::StaticType() const { |
| 727 return value()->StaticType(); | 741 return value()->StaticType(); |
| 728 } | 742 } |
| 729 | 743 |
| 730 | 744 |
| 731 RawAbstractType* StaticSetterComp::StaticType() const { | 745 RawAbstractType* StaticSetterComp::StaticType() const { |
| 732 const AbstractType& assigned_value_type = | 746 return value()->StaticType(); |
| 733 AbstractType::Handle(value()->StaticType()); | |
| 734 if (assigned_value_type.IsDynamicType()) { | |
| 735 // Static type of assigned value is unknown, return static type of setter | |
| 736 // value parameter. | |
| 737 return setter_function().ParameterTypeAt(0); | |
| 738 } | |
| 739 return assigned_value_type.raw(); | |
| 740 } | 747 } |
| 741 | 748 |
| 742 | 749 |
| 743 RawAbstractType* LoadInstanceFieldComp::StaticType() const { | 750 RawAbstractType* LoadInstanceFieldComp::StaticType() const { |
| 744 return field().type(); | 751 return field().type(); |
| 745 } | 752 } |
| 746 | 753 |
| 747 | 754 |
| 748 RawAbstractType* StoreInstanceFieldComp::StaticType() const { | 755 RawAbstractType* StoreInstanceFieldComp::StaticType() const { |
| 749 const AbstractType& assigned_value_type = | 756 return value()->StaticType(); |
| 750 AbstractType::Handle(value()->StaticType()); | |
| 751 if (assigned_value_type.IsDynamicType()) { | |
| 752 // Static type of assigned value is unknown, return static type of field. | |
| 753 return field().type(); | |
| 754 } | |
| 755 return assigned_value_type.raw(); | |
| 756 } | 757 } |
| 757 | 758 |
| 758 | 759 |
| 759 RawAbstractType* LoadStaticFieldComp::StaticType() const { | 760 RawAbstractType* LoadStaticFieldComp::StaticType() const { |
| 760 return field().type(); | 761 return field().type(); |
| 761 } | 762 } |
| 762 | 763 |
| 763 | 764 |
| 764 RawAbstractType* StoreStaticFieldComp::StaticType() const { | 765 RawAbstractType* StoreStaticFieldComp::StaticType() const { |
| 765 const AbstractType& assigned_value_type = | 766 return value()->StaticType(); |
| 766 AbstractType::Handle(value()->StaticType()); | |
| 767 if (assigned_value_type.IsDynamicType()) { | |
| 768 // Static type of assigned value is unknown, return static type of field. | |
| 769 return field().type(); | |
| 770 } | |
| 771 return assigned_value_type.raw(); | |
| 772 } | 767 } |
| 773 | 768 |
| 774 | 769 |
| 775 RawAbstractType* BooleanNegateComp::StaticType() const { | 770 RawAbstractType* BooleanNegateComp::StaticType() const { |
| 776 return Type::BoolInterface(); | 771 return Type::BoolInterface(); |
| 777 } | 772 } |
| 778 | 773 |
| 779 | 774 |
| 780 RawAbstractType* InstanceOfComp::StaticType() const { | 775 RawAbstractType* InstanceOfComp::StaticType() const { |
| 781 return Type::BoolInterface(); | 776 return Type::BoolInterface(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 807 } | 802 } |
| 808 | 803 |
| 809 | 804 |
| 810 RawAbstractType* LoadVMFieldComp::StaticType() const { | 805 RawAbstractType* LoadVMFieldComp::StaticType() const { |
| 811 ASSERT(!type().IsNull()); | 806 ASSERT(!type().IsNull()); |
| 812 return type().raw(); | 807 return type().raw(); |
| 813 } | 808 } |
| 814 | 809 |
| 815 | 810 |
| 816 RawAbstractType* StoreVMFieldComp::StaticType() const { | 811 RawAbstractType* StoreVMFieldComp::StaticType() const { |
| 817 ASSERT(!type().IsNull()); | 812 return value()->StaticType(); |
| 818 const AbstractType& assigned_value_type = | |
| 819 AbstractType::Handle(value()->StaticType()); | |
| 820 if (assigned_value_type.IsDynamicType()) { | |
| 821 // Static type of assigned value is unknown, return static type of field. | |
| 822 return type().raw(); | |
| 823 } | |
| 824 return assigned_value_type.raw(); | |
| 825 } | 813 } |
| 826 | 814 |
| 827 | 815 |
| 828 RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const { | 816 RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const { |
| 829 UNREACHABLE(); | 817 UNREACHABLE(); |
| 830 return AbstractType::null(); | 818 return AbstractType::null(); |
| 831 } | 819 } |
| 832 | 820 |
| 833 | 821 |
| 834 RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const { | 822 RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const { |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1300 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 1288 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
| 1301 compiler->GenerateCall(token_pos(), try_index(), &label, | 1289 compiler->GenerateCall(token_pos(), try_index(), &label, |
| 1302 PcDescriptors::kOther); | 1290 PcDescriptors::kOther); |
| 1303 __ Drop(2); // Discard type arguments and receiver. | 1291 __ Drop(2); // Discard type arguments and receiver. |
| 1304 } | 1292 } |
| 1305 | 1293 |
| 1306 | 1294 |
| 1307 #undef __ | 1295 #undef __ |
| 1308 | 1296 |
| 1309 } // namespace dart | 1297 } // namespace dart |
| OLD | NEW |