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

Side by Side Diff: runtime/vm/object.h

Issue 10578018: Fix type test elimination using static type propagation in new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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/flow_graph_builder.cc ('k') | runtime/vm/object.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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 static RawError* Init(Isolate* isolate); 330 static RawError* Init(Isolate* isolate);
331 static void InitFromSnapshot(Isolate* isolate); 331 static void InitFromSnapshot(Isolate* isolate);
332 static void InitOnce(); 332 static void InitOnce();
333 333
334 static intptr_t InstanceSize() { 334 static intptr_t InstanceSize() {
335 return RoundedAllocationSize(sizeof(RawObject)); 335 return RoundedAllocationSize(sizeof(RawObject));
336 } 336 }
337 337
338 static const ObjectKind kInstanceKind = kObject; 338 static const ObjectKind kInstanceKind = kObject;
339 339
340 // Different kinds of type tests.
341 enum TypeTestKind {
342 kIsSubtypeOf = 0,
343 kIsMoreSpecificThan
344 };
345
340 protected: 346 protected:
341 // Used for extracting the C++ vtable during bringup. 347 // Used for extracting the C++ vtable during bringup.
342 Object() : raw_(null_) {} 348 Object() : raw_(null_) {}
343 349
344 uword raw_value() const { 350 uword raw_value() const {
345 return reinterpret_cast<uword>(raw()); 351 return reinterpret_cast<uword>(raw());
346 } 352 }
347 353
348 inline void SetRaw(RawObject* value); 354 inline void SetRaw(RawObject* value);
349 355
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 601 }
596 602
597 // Check if this class represents a canonical signature class, i.e. not an 603 // Check if this class represents a canonical signature class, i.e. not an
598 // alias as defined in a typedef. 604 // alias as defined in a typedef.
599 bool IsCanonicalSignatureClass() const; 605 bool IsCanonicalSignatureClass() const;
600 606
601 // Check the subtype relationship. 607 // Check the subtype relationship.
602 bool IsSubtypeOf(const AbstractTypeArguments& type_arguments, 608 bool IsSubtypeOf(const AbstractTypeArguments& type_arguments,
603 const Class& other, 609 const Class& other,
604 const AbstractTypeArguments& other_type_arguments, 610 const AbstractTypeArguments& other_type_arguments,
605 Error* malformed_error) const; 611 Error* malformed_error) const {
612 return TypeTest(kIsSubtypeOf,
613 type_arguments,
614 other,
615 other_type_arguments,
616 malformed_error);
617 }
618
619 // Check the 'more specific' relationship.
620 bool IsMoreSpecificThan(const AbstractTypeArguments& type_arguments,
621 const Class& other,
622 const AbstractTypeArguments& other_type_arguments,
623 Error* malformed_error) const {
624 return TypeTest(kIsMoreSpecificThan,
625 type_arguments,
626 other,
627 other_type_arguments,
628 malformed_error);
629 }
606 630
607 // Check if this is the top level class. 631 // Check if this is the top level class.
608 bool IsTopLevel() const; 632 bool IsTopLevel() const;
609 633
610 RawArray* fields() const { return raw_ptr()->fields_; } 634 RawArray* fields() const { return raw_ptr()->fields_; }
611 void SetFields(const Array& value) const; 635 void SetFields(const Array& value) const;
612 636
613 // Returns true if non-static fields are defined. 637 // Returns true if non-static fields are defined.
614 bool HasInstanceFields() const; 638 bool HasInstanceFields() const;
615 639
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 RawFunction* LookupAccessorFunction(const char* prefix, 756 RawFunction* LookupAccessorFunction(const char* prefix,
733 intptr_t prefix_length, 757 intptr_t prefix_length,
734 const String& name) const; 758 const String& name) const;
735 759
736 // Allocate an instance class which has a VM implementation. 760 // Allocate an instance class which has a VM implementation.
737 template <class FakeInstance> static RawClass* New(intptr_t id); 761 template <class FakeInstance> static RawClass* New(intptr_t id);
738 template <class FakeInstance> static RawClass* New(const String& name, 762 template <class FakeInstance> static RawClass* New(const String& name,
739 const Script& script, 763 const Script& script,
740 intptr_t token_index); 764 intptr_t token_index);
741 765
766 // Check the subtype or 'more specific' relationship.
767 bool TypeTest(TypeTestKind test_kind,
768 const AbstractTypeArguments& type_arguments,
769 const Class& other,
770 const AbstractTypeArguments& other_type_arguments,
771 Error* malformed_error) const;
772
742 HEAP_OBJECT_IMPLEMENTATION(Class, Object); 773 HEAP_OBJECT_IMPLEMENTATION(Class, Object);
743 friend class Object; 774 friend class Object;
744 friend class Instance; 775 friend class Instance;
776 friend class AbstractType;
745 friend class Type; 777 friend class Type;
746 }; 778 };
747 779
748 780
749 // Unresolved class is used for storing unresolved names which will be resolved 781 // Unresolved class is used for storing unresolved names which will be resolved
750 // to a class after all classes have been loaded and finalized. 782 // to a class after all classes have been loaded and finalized.
751 class UnresolvedClass : public Object { 783 class UnresolvedClass : public Object {
752 public: 784 public:
753 RawLibraryPrefix* library_prefix() const { 785 RawLibraryPrefix* library_prefix() const {
754 return raw_ptr()->library_prefix_; 786 return raw_ptr()->library_prefix_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 // Check if this type is an interface type. 895 // Check if this type is an interface type.
864 bool IsInterfaceType() const { 896 bool IsInterfaceType() const {
865 if (!HasResolvedTypeClass()) { 897 if (!HasResolvedTypeClass()) {
866 return false; 898 return false;
867 } 899 }
868 const Class& cls = Class::Handle(type_class()); 900 const Class& cls = Class::Handle(type_class());
869 return !cls.IsNull() && cls.is_interface(); 901 return !cls.IsNull() && cls.is_interface();
870 } 902 }
871 903
872 // Check the subtype relationship. 904 // Check the subtype relationship.
873 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const; 905 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const {
906 return TypeTest(kIsSubtypeOf, other, malformed_error);
907 }
908
909 // Check the 'more specific' relationship.
910 bool IsMoreSpecificThan(const AbstractType& other,
911 Error* malformed_error) const {
912 return TypeTest(kIsMoreSpecificThan, other, malformed_error);
913 }
914
915 private:
916 // Check the subtype or 'more specific' relationship.
917 bool TypeTest(TypeTestKind test_kind,
918 const AbstractType& other,
919 Error* malformed_error) const;
874 920
875 protected: 921 protected:
876 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); 922 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object);
877 friend class Class; 923 friend class Class;
924 friend class AbstractTypeArguments;
878 }; 925 };
879 926
880 927
881 // A Type consists of a class, possibly parameterized with type 928 // A Type consists of a class, possibly parameterized with type
882 // arguments. Example: C<T1, T2>. 929 // arguments. Example: C<T1, T2>.
883 // An unresolved class is a String specifying the class name. 930 // An unresolved class is a String specifying the class name.
884 // 931 //
885 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as 932 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as
886 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not 933 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not
887 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. 934 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1123
1077 // Check that this type argument vector is within the declared bounds of the 1124 // Check that this type argument vector is within the declared bounds of the
1078 // given class or interface. If not, set malformed_error (if not yet set). 1125 // given class or interface. If not, set malformed_error (if not yet set).
1079 bool IsWithinBoundsOf(const Class& cls, 1126 bool IsWithinBoundsOf(const Class& cls,
1080 const AbstractTypeArguments& bounds_instantiator, 1127 const AbstractTypeArguments& bounds_instantiator,
1081 Error* malformed_error) const; 1128 Error* malformed_error) const;
1082 1129
1083 // Check the subtype relationship, considering only a prefix of length 'len'. 1130 // Check the subtype relationship, considering only a prefix of length 'len'.
1084 bool IsSubtypeOf(const AbstractTypeArguments& other, 1131 bool IsSubtypeOf(const AbstractTypeArguments& other,
1085 intptr_t len, 1132 intptr_t len,
1086 Error* malformed_error) const; 1133 Error* malformed_error) const {
1134 return TypeTest(kIsSubtypeOf, other, len, malformed_error);
1135 }
1136
1137 // Check the 'more specific' relationship, considering only a prefix of
1138 // length 'len'.
1139 bool IsMoreSpecificThan(const AbstractTypeArguments& other,
1140 intptr_t len,
1141 Error* malformed_error) const {
1142 return TypeTest(kIsMoreSpecificThan, other, len, malformed_error);
1143 }
1087 1144
1088 bool Equals(const AbstractTypeArguments& other) const; 1145 bool Equals(const AbstractTypeArguments& other) const;
1089 1146
1090 // UNREACHABLEs as AbstractTypeArguments is an abstract class. 1147 // UNREACHABLEs as AbstractTypeArguments is an abstract class.
1091 virtual intptr_t Length() const; 1148 virtual intptr_t Length() const;
1092 virtual RawAbstractType* TypeAt(intptr_t index) const; 1149 virtual RawAbstractType* TypeAt(intptr_t index) const;
1093 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1150 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1094 virtual bool IsResolved() const; 1151 virtual bool IsResolved() const;
1095 virtual bool IsInstantiated() const; 1152 virtual bool IsInstantiated() const;
1096 virtual bool IsUninstantiatedIdentity() const; 1153 virtual bool IsUninstantiatedIdentity() const;
1097 1154
1098 private: 1155 private:
1099 // Check if this type argument vector consists solely of DynamicType, 1156 // Check if this type argument vector consists solely of DynamicType,
1100 // considering only a prefix of length 'len'. 1157 // considering only a prefix of length 'len'.
1101 // If raw_instantiated is true, consider each type parameter to be first 1158 // If raw_instantiated is true, consider each type parameter to be first
1102 // instantiated from a vector of dynamic types. 1159 // instantiated from a vector of dynamic types.
1103 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const; 1160 bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const;
1104 1161
1162 // Check the subtype or 'more specific' relationship, considering only a
1163 // prefix of length 'len'.
1164 bool TypeTest(TypeTestKind test_kind,
1165 const AbstractTypeArguments& other,
1166 intptr_t len,
1167 Error* malformed_error) const;
1168
1105 protected: 1169 protected:
1106 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object); 1170 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
1107 friend class Class; 1171 friend class Class;
1108 }; 1172 };
1109 1173
1110 1174
1111 // A TypeArguments is an array of AbstractType. 1175 // A TypeArguments is an array of AbstractType.
1112 class TypeArguments : public AbstractTypeArguments { 1176 class TypeArguments : public AbstractTypeArguments {
1113 public: 1177 public:
1114 virtual intptr_t Length() const; 1178 virtual intptr_t Length() const;
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after
4972 } 5036 }
4973 5037
4974 5038
4975 intptr_t Stackmap::SizeInBits() const { 5039 intptr_t Stackmap::SizeInBits() const {
4976 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); 5040 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte);
4977 } 5041 }
4978 5042
4979 } // namespace dart 5043 } // namespace dart
4980 5044
4981 #endif // VM_OBJECT_H_ 5045 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698