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 #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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 return ZoneHandle(zone, Object::null()); | 894 return ZoneHandle(zone, Object::null()); |
895 } | 895 } |
896 | 896 |
897 private: | 897 private: |
898 PassiveObject() : Object() {} | 898 PassiveObject() : Object() {} |
899 DISALLOW_ALLOCATION(); | 899 DISALLOW_ALLOCATION(); |
900 DISALLOW_COPY_AND_ASSIGN(PassiveObject); | 900 DISALLOW_COPY_AND_ASSIGN(PassiveObject); |
901 }; | 901 }; |
902 | 902 |
903 | 903 |
| 904 typedef ZoneGrowableHandlePtrArray<const AbstractType> Trail; |
| 905 typedef ZoneGrowableHandlePtrArray<const AbstractType>* TrailPtr; |
| 906 |
| 907 |
904 class Class : public Object { | 908 class Class : public Object { |
905 public: | 909 public: |
906 intptr_t instance_size() const { | 910 intptr_t instance_size() const { |
907 ASSERT(is_finalized() || is_prefinalized()); | 911 ASSERT(is_finalized() || is_prefinalized()); |
908 return (raw_ptr()->instance_size_in_words_ * kWordSize); | 912 return (raw_ptr()->instance_size_in_words_ * kWordSize); |
909 } | 913 } |
910 void set_instance_size(intptr_t value_in_bytes) const { | 914 void set_instance_size(intptr_t value_in_bytes) const { |
911 ASSERT(kWordSize != 0); | 915 ASSERT(kWordSize != 0); |
912 set_instance_size_in_words(value_in_bytes / kWordSize); | 916 set_instance_size_in_words(value_in_bytes / kWordSize); |
913 } | 917 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 static bool IsInFullSnapshot(RawClass* cls) { | 1119 static bool IsInFullSnapshot(RawClass* cls) { |
1116 NoSafepointScope no_safepoint; | 1120 NoSafepointScope no_safepoint; |
1117 return cls->ptr()->library_->ptr()->is_in_fullsnapshot_; | 1121 return cls->ptr()->library_->ptr()->is_in_fullsnapshot_; |
1118 } | 1122 } |
1119 | 1123 |
1120 // Check the subtype relationship. | 1124 // Check the subtype relationship. |
1121 bool IsSubtypeOf(const TypeArguments& type_arguments, | 1125 bool IsSubtypeOf(const TypeArguments& type_arguments, |
1122 const Class& other, | 1126 const Class& other, |
1123 const TypeArguments& other_type_arguments, | 1127 const TypeArguments& other_type_arguments, |
1124 Error* bound_error, | 1128 Error* bound_error, |
| 1129 TrailPtr bound_trail = NULL, |
1125 Heap::Space space = Heap::kNew) const { | 1130 Heap::Space space = Heap::kNew) const { |
1126 return TypeTest(kIsSubtypeOf, | 1131 return TypeTest(kIsSubtypeOf, |
1127 type_arguments, | 1132 type_arguments, |
1128 other, | 1133 other, |
1129 other_type_arguments, | 1134 other_type_arguments, |
1130 bound_error, | 1135 bound_error, |
| 1136 bound_trail, |
1131 space); | 1137 space); |
1132 } | 1138 } |
1133 | 1139 |
1134 // Check the 'more specific' relationship. | 1140 // Check the 'more specific' relationship. |
1135 bool IsMoreSpecificThan(const TypeArguments& type_arguments, | 1141 bool IsMoreSpecificThan(const TypeArguments& type_arguments, |
1136 const Class& other, | 1142 const Class& other, |
1137 const TypeArguments& other_type_arguments, | 1143 const TypeArguments& other_type_arguments, |
1138 Error* bound_error, | 1144 Error* bound_error, |
| 1145 TrailPtr bound_trail = NULL, |
1139 Heap::Space space = Heap::kNew) const { | 1146 Heap::Space space = Heap::kNew) const { |
1140 return TypeTest(kIsMoreSpecificThan, | 1147 return TypeTest(kIsMoreSpecificThan, |
1141 type_arguments, | 1148 type_arguments, |
1142 other, | 1149 other, |
1143 other_type_arguments, | 1150 other_type_arguments, |
1144 bound_error, | 1151 bound_error, |
| 1152 bound_trail, |
1145 space); | 1153 space); |
1146 } | 1154 } |
1147 | 1155 |
1148 // Check if this is the top level class. | 1156 // Check if this is the top level class. |
1149 bool IsTopLevel() const; | 1157 bool IsTopLevel() const; |
1150 | 1158 |
1151 bool IsPrivate() const; | 1159 bool IsPrivate() const; |
1152 | 1160 |
1153 RawArray* fields() const { return raw_ptr()->fields_; } | 1161 RawArray* fields() const { return raw_ptr()->fields_; } |
1154 void SetFields(const Array& value) const; | 1162 void SetFields(const Array& value) const; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 | 1465 |
1458 // Allocate an instance class which has a VM implementation. | 1466 // Allocate an instance class which has a VM implementation. |
1459 template <class FakeInstance> static RawClass* New(intptr_t id); | 1467 template <class FakeInstance> static RawClass* New(intptr_t id); |
1460 | 1468 |
1461 // Check the subtype or 'more specific' relationship. | 1469 // Check the subtype or 'more specific' relationship. |
1462 bool TypeTest(TypeTestKind test_kind, | 1470 bool TypeTest(TypeTestKind test_kind, |
1463 const TypeArguments& type_arguments, | 1471 const TypeArguments& type_arguments, |
1464 const Class& other, | 1472 const Class& other, |
1465 const TypeArguments& other_type_arguments, | 1473 const TypeArguments& other_type_arguments, |
1466 Error* bound_error, | 1474 Error* bound_error, |
| 1475 TrailPtr bound_trail, |
1467 Heap::Space space) const; | 1476 Heap::Space space) const; |
1468 | 1477 |
1469 static bool TypeTestNonRecursive( | 1478 static bool TypeTestNonRecursive( |
1470 const Class& cls, | 1479 const Class& cls, |
1471 TypeTestKind test_kind, | 1480 TypeTestKind test_kind, |
1472 const TypeArguments& type_arguments, | 1481 const TypeArguments& type_arguments, |
1473 const Class& other, | 1482 const Class& other, |
1474 const TypeArguments& other_type_arguments, | 1483 const TypeArguments& other_type_arguments, |
1475 Error* bound_error, | 1484 Error* bound_error, |
| 1485 TrailPtr bound_trail, |
1476 Heap::Space space); | 1486 Heap::Space space); |
1477 | 1487 |
1478 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 1488 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
1479 friend class AbstractType; | 1489 friend class AbstractType; |
1480 friend class Instance; | 1490 friend class Instance; |
1481 friend class Object; | 1491 friend class Object; |
1482 friend class Type; | 1492 friend class Type; |
1483 friend class FunctionType; | 1493 friend class FunctionType; |
1484 friend class Intrinsifier; | 1494 friend class Intrinsifier; |
1485 friend class Precompiler; | 1495 friend class Precompiler; |
(...skipping 25 matching lines...) Expand all Loading... |
1511 void set_ident(const String& ident) const; | 1521 void set_ident(const String& ident) const; |
1512 void set_token_pos(TokenPosition token_pos) const; | 1522 void set_token_pos(TokenPosition token_pos) const; |
1513 | 1523 |
1514 static RawUnresolvedClass* New(); | 1524 static RawUnresolvedClass* New(); |
1515 | 1525 |
1516 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 1526 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
1517 friend class Class; | 1527 friend class Class; |
1518 }; | 1528 }; |
1519 | 1529 |
1520 | 1530 |
1521 typedef ZoneGrowableHandlePtrArray<const AbstractType> Trail; | |
1522 typedef ZoneGrowableHandlePtrArray<const AbstractType>* TrailPtr; | |
1523 | |
1524 // A TypeArguments is an array of AbstractType. | 1531 // A TypeArguments is an array of AbstractType. |
1525 class TypeArguments : public Object { | 1532 class TypeArguments : public Object { |
1526 public: | 1533 public: |
1527 intptr_t Length() const; | 1534 intptr_t Length() const; |
1528 RawAbstractType* TypeAt(intptr_t index) const; | 1535 RawAbstractType* TypeAt(intptr_t index) const; |
1529 static intptr_t type_at_offset(intptr_t index) { | 1536 static intptr_t type_at_offset(intptr_t index) { |
1530 return OFFSET_OF_RETURNED_VALUE( | 1537 return OFFSET_OF_RETURNED_VALUE( |
1531 RawTypeArguments, types) + index * kWordSize; | 1538 RawTypeArguments, types) + index * kWordSize; |
1532 } | 1539 } |
1533 void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1540 void SetTypeAt(intptr_t index, const AbstractType& value) const; |
(...skipping 28 matching lines...) Expand all Loading... |
1562 bool IsRawInstantiatedRaw(intptr_t len) const { | 1569 bool IsRawInstantiatedRaw(intptr_t len) const { |
1563 return IsDynamicTypes(true, 0, len); | 1570 return IsDynamicTypes(true, 0, len); |
1564 } | 1571 } |
1565 | 1572 |
1566 // Check the subtype relationship, considering only a subvector of length | 1573 // Check the subtype relationship, considering only a subvector of length |
1567 // 'len' starting at 'from_index'. | 1574 // 'len' starting at 'from_index'. |
1568 bool IsSubtypeOf(const TypeArguments& other, | 1575 bool IsSubtypeOf(const TypeArguments& other, |
1569 intptr_t from_index, | 1576 intptr_t from_index, |
1570 intptr_t len, | 1577 intptr_t len, |
1571 Error* bound_error, | 1578 Error* bound_error, |
| 1579 TrailPtr bound_trail = NULL, |
1572 Heap::Space space = Heap::kNew) const { | 1580 Heap::Space space = Heap::kNew) const { |
1573 return TypeTest(kIsSubtypeOf, other, from_index, len, bound_error, space); | 1581 return TypeTest(kIsSubtypeOf, other, from_index, len, |
| 1582 bound_error, bound_trail, space); |
1574 } | 1583 } |
1575 | 1584 |
1576 // Check the 'more specific' relationship, considering only a subvector of | 1585 // Check the 'more specific' relationship, considering only a subvector of |
1577 // length 'len' starting at 'from_index'. | 1586 // length 'len' starting at 'from_index'. |
1578 bool IsMoreSpecificThan(const TypeArguments& other, | 1587 bool IsMoreSpecificThan(const TypeArguments& other, |
1579 intptr_t from_index, | 1588 intptr_t from_index, |
1580 intptr_t len, | 1589 intptr_t len, |
1581 Error* bound_error, | 1590 Error* bound_error, |
| 1591 TrailPtr bound_trail = NULL, |
1582 Heap::Space space = Heap::kNew) const { | 1592 Heap::Space space = Heap::kNew) const { |
1583 return TypeTest(kIsMoreSpecificThan, | 1593 return TypeTest(kIsMoreSpecificThan, other, from_index, len, |
1584 other, from_index, len, bound_error, space); | 1594 bound_error, bound_trail, space); |
1585 } | 1595 } |
1586 | 1596 |
1587 // Check if the vectors are equal (they may be null). | 1597 // Check if the vectors are equal (they may be null). |
1588 bool Equals(const TypeArguments& other) const { | 1598 bool Equals(const TypeArguments& other) const { |
1589 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length()); | 1599 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length()); |
1590 } | 1600 } |
1591 | 1601 |
1592 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const { | 1602 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const { |
1593 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail); | 1603 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail); |
1594 } | 1604 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; | 1640 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; |
1631 | 1641 |
1632 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1642 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
1633 // not refer to type parameters. Otherwise, return a new type argument vector | 1643 // not refer to type parameters. Otherwise, return a new type argument vector |
1634 // where each reference to a type parameter is replaced with the corresponding | 1644 // where each reference to a type parameter is replaced with the corresponding |
1635 // type of the instantiator type argument vector. | 1645 // type of the instantiator type argument vector. |
1636 // If bound_error is not NULL, it may be set to reflect a bound error. | 1646 // If bound_error is not NULL, it may be set to reflect a bound error. |
1637 RawTypeArguments* InstantiateFrom( | 1647 RawTypeArguments* InstantiateFrom( |
1638 const TypeArguments& instantiator_type_arguments, | 1648 const TypeArguments& instantiator_type_arguments, |
1639 Error* bound_error, | 1649 Error* bound_error, |
1640 TrailPtr trail = NULL, | 1650 TrailPtr instantiation_trail = NULL, |
| 1651 TrailPtr bound_trail = NULL, |
1641 Heap::Space space = Heap::kNew) const; | 1652 Heap::Space space = Heap::kNew) const; |
1642 | 1653 |
1643 // Runtime instantiation with canonicalization. Not to be used during type | 1654 // Runtime instantiation with canonicalization. Not to be used during type |
1644 // finalization at compile time. | 1655 // finalization at compile time. |
1645 RawTypeArguments* InstantiateAndCanonicalizeFrom( | 1656 RawTypeArguments* InstantiateAndCanonicalizeFrom( |
1646 const TypeArguments& instantiator_type_arguments, | 1657 const TypeArguments& instantiator_type_arguments, |
1647 Error* bound_error) const; | 1658 Error* bound_error) const; |
1648 | 1659 |
1649 // Return true if this type argument vector has cached instantiations. | 1660 // Return true if this type argument vector has cached instantiations. |
1650 bool HasInstantiations() const; | 1661 bool HasInstantiations() const; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1687 intptr_t from_index, | 1698 intptr_t from_index, |
1688 intptr_t len) const; | 1699 intptr_t len) const; |
1689 | 1700 |
1690 // Check the subtype or 'more specific' relationship, considering only a | 1701 // Check the subtype or 'more specific' relationship, considering only a |
1691 // subvector of length 'len' starting at 'from_index'. | 1702 // subvector of length 'len' starting at 'from_index'. |
1692 bool TypeTest(TypeTestKind test_kind, | 1703 bool TypeTest(TypeTestKind test_kind, |
1693 const TypeArguments& other, | 1704 const TypeArguments& other, |
1694 intptr_t from_index, | 1705 intptr_t from_index, |
1695 intptr_t len, | 1706 intptr_t len, |
1696 Error* bound_error, | 1707 Error* bound_error, |
| 1708 TrailPtr bound_trail, |
1697 Heap::Space space) const; | 1709 Heap::Space space) const; |
1698 | 1710 |
1699 // Return the internal or public name of a subvector of this type argument | 1711 // Return the internal or public name of a subvector of this type argument |
1700 // vector, e.g. "<T, dynamic, List<T>, int>". | 1712 // vector, e.g. "<T, dynamic, List<T>, int>". |
1701 RawString* SubvectorName(intptr_t from_index, | 1713 RawString* SubvectorName(intptr_t from_index, |
1702 intptr_t len, | 1714 intptr_t len, |
1703 NameVisibility name_visibility) const; | 1715 NameVisibility name_visibility) const; |
1704 | 1716 |
1705 RawArray* instantiations() const; | 1717 RawArray* instantiations() const; |
1706 void set_instantiations(const Array& value) const; | 1718 void set_instantiations(const Array& value) const; |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 bound_error, | 2503 bound_error, |
2492 space); | 2504 space); |
2493 } | 2505 } |
2494 | 2506 |
2495 // Returns true if the type of this function is more specific than the type of | 2507 // Returns true if the type of this function is more specific than the type of |
2496 // the other function. | 2508 // the other function. |
2497 bool IsMoreSpecificThan(const TypeArguments& type_arguments, | 2509 bool IsMoreSpecificThan(const TypeArguments& type_arguments, |
2498 const Function& other, | 2510 const Function& other, |
2499 const TypeArguments& other_type_arguments, | 2511 const TypeArguments& other_type_arguments, |
2500 Error* bound_error, | 2512 Error* bound_error, |
2501 Heap::Space space = Heap::kNew) const { | 2513 Heap::Space space = Heap::kNew) const { |
2502 return TypeTest(kIsMoreSpecificThan, | 2514 return TypeTest(kIsMoreSpecificThan, |
2503 type_arguments, | 2515 type_arguments, |
2504 other, | 2516 other, |
2505 other_type_arguments, | 2517 other_type_arguments, |
2506 bound_error, | 2518 bound_error, |
2507 space); | 2519 space); |
2508 } | 2520 } |
2509 | 2521 |
2510 // Check the subtype or 'more specific' relationship. | 2522 // Check the subtype or 'more specific' relationship. |
2511 bool TypeTest(TypeTestKind test_kind, | 2523 bool TypeTest(TypeTestKind test_kind, |
(...skipping 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5259 } | 5271 } |
5260 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5272 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5261 virtual bool IsRecursive() const; | 5273 virtual bool IsRecursive() const; |
5262 | 5274 |
5263 // Instantiate this type using the given type argument vector. | 5275 // Instantiate this type using the given type argument vector. |
5264 // Return a new type, or return 'this' if it is already instantiated. | 5276 // Return a new type, or return 'this' if it is already instantiated. |
5265 // If bound_error is not NULL, it may be set to reflect a bound error. | 5277 // If bound_error is not NULL, it may be set to reflect a bound error. |
5266 virtual RawAbstractType* InstantiateFrom( | 5278 virtual RawAbstractType* InstantiateFrom( |
5267 const TypeArguments& instantiator_type_arguments, | 5279 const TypeArguments& instantiator_type_arguments, |
5268 Error* bound_error, | 5280 Error* bound_error, |
5269 TrailPtr trail = NULL, | 5281 TrailPtr instantiation_trail = NULL, |
| 5282 TrailPtr bound_trail = NULL, |
5270 Heap::Space space = Heap::kNew) const; | 5283 Heap::Space space = Heap::kNew) const; |
5271 | 5284 |
5272 // Return a clone of this unfinalized type or the type itself if it is | 5285 // Return a clone of this unfinalized type or the type itself if it is |
5273 // already finalized. Apply recursively to type arguments, i.e. finalized | 5286 // already finalized. Apply recursively to type arguments, i.e. finalized |
5274 // type arguments of an unfinalized type are not cloned, but shared. | 5287 // type arguments of an unfinalized type are not cloned, but shared. |
5275 virtual RawAbstractType* CloneUnfinalized() const; | 5288 virtual RawAbstractType* CloneUnfinalized() const; |
5276 | 5289 |
5277 // Return a clone of this uninstantiated type where all references to type | 5290 // Return a clone of this uninstantiated type where all references to type |
5278 // parameters are replaced with references to type parameters of the same name | 5291 // parameters are replaced with references to type parameters of the same name |
5279 // but belonging to the new owner class. | 5292 // but belonging to the new owner class. |
(...skipping 10 matching lines...) Expand all Loading... |
5290 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5303 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
5291 | 5304 |
5292 // Return the object associated with the receiver in the trail or | 5305 // Return the object associated with the receiver in the trail or |
5293 // AbstractType::null() if the receiver is not contained in the trail. | 5306 // AbstractType::null() if the receiver is not contained in the trail. |
5294 RawAbstractType* OnlyBuddyInTrail(TrailPtr trail) const; | 5307 RawAbstractType* OnlyBuddyInTrail(TrailPtr trail) const; |
5295 | 5308 |
5296 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to | 5309 // If the trail is null, allocate a trail, add the pair <receiver, buddy> to |
5297 // the trail. The receiver may only be added once with its only buddy. | 5310 // the trail. The receiver may only be added once with its only buddy. |
5298 void AddOnlyBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; | 5311 void AddOnlyBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; |
5299 | 5312 |
| 5313 // Return true if the receiver is contained in the trail. |
| 5314 // Otherwise, if the trail is null, allocate a trail, then add the receiver to |
| 5315 // the trail and return false. |
| 5316 bool TestAndAddToTrail(TrailPtr* trail) const; |
| 5317 |
| 5318 // Return true if the pair <receiver, buddy> is contained in the trail. |
| 5319 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, |
| 5320 // buddy> to the trail and return false. |
| 5321 // The receiver may be added several times, each time with a different buddy. |
| 5322 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; |
| 5323 |
5300 // The name of this type, including the names of its type arguments, if any. | 5324 // The name of this type, including the names of its type arguments, if any. |
5301 virtual RawString* Name() const { | 5325 virtual RawString* Name() const { |
5302 return BuildName(kInternalName); | 5326 return BuildName(kInternalName); |
5303 } | 5327 } |
5304 | 5328 |
5305 virtual RawString* PrettyName() const { | 5329 virtual RawString* PrettyName() const { |
5306 return BuildName(kPrettyName); | 5330 return BuildName(kPrettyName); |
5307 } | 5331 } |
5308 | 5332 |
5309 // The name of this type, including the names of its type arguments, if any. | 5333 // The name of this type, including the names of its type arguments, if any. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5362 | 5386 |
5363 // Check if this type represents the 'String' type. | 5387 // Check if this type represents the 'String' type. |
5364 bool IsStringType() const; | 5388 bool IsStringType() const; |
5365 | 5389 |
5366 // Check if this type represents the Dart 'Function' type. | 5390 // Check if this type represents the Dart 'Function' type. |
5367 bool IsDartFunctionType() const; | 5391 bool IsDartFunctionType() const; |
5368 | 5392 |
5369 // Check the subtype relationship. | 5393 // Check the subtype relationship. |
5370 bool IsSubtypeOf(const AbstractType& other, | 5394 bool IsSubtypeOf(const AbstractType& other, |
5371 Error* bound_error, | 5395 Error* bound_error, |
| 5396 TrailPtr bound_trail = NULL, |
5372 Heap::Space space = Heap::kNew) const { | 5397 Heap::Space space = Heap::kNew) const { |
5373 return TypeTest(kIsSubtypeOf, other, bound_error, space); | 5398 return TypeTest(kIsSubtypeOf, other, bound_error, bound_trail, space); |
5374 } | 5399 } |
5375 | 5400 |
5376 // Check the 'more specific' relationship. | 5401 // Check the 'more specific' relationship. |
5377 bool IsMoreSpecificThan(const AbstractType& other, | 5402 bool IsMoreSpecificThan(const AbstractType& other, |
5378 Error* bound_error, | 5403 Error* bound_error, |
| 5404 TrailPtr bound_trail = NULL, |
5379 Heap::Space space = Heap::kNew) const { | 5405 Heap::Space space = Heap::kNew) const { |
5380 return TypeTest(kIsMoreSpecificThan, other, bound_error, space); | 5406 return TypeTest(kIsMoreSpecificThan, other, |
| 5407 bound_error, bound_trail, space); |
5381 } | 5408 } |
5382 | 5409 |
5383 private: | 5410 private: |
5384 // Check the subtype or 'more specific' relationship. | 5411 // Check the subtype or 'more specific' relationship. |
5385 bool TypeTest(TypeTestKind test_kind, | 5412 bool TypeTest(TypeTestKind test_kind, |
5386 const AbstractType& other, | 5413 const AbstractType& other, |
5387 Error* bound_error, | 5414 Error* bound_error, |
| 5415 TrailPtr bound_trail, |
5388 Heap::Space space) const; | 5416 Heap::Space space) const; |
5389 | 5417 |
5390 // Return the internal or public name of this type, including the names of its | 5418 // Return the internal or public name of this type, including the names of its |
5391 // type arguments, if any. | 5419 // type arguments, if any. |
5392 RawString* BuildName(NameVisibility visibility) const; | 5420 RawString* BuildName(NameVisibility visibility) const; |
5393 | 5421 |
5394 protected: | 5422 protected: |
5395 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Instance); | 5423 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Instance); |
5396 friend class Class; | 5424 friend class Class; |
5397 friend class Function; | 5425 friend class Function; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5436 virtual RawUnresolvedClass* unresolved_class() const; | 5464 virtual RawUnresolvedClass* unresolved_class() const; |
5437 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } | 5465 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } |
5438 virtual void set_arguments(const TypeArguments& value) const; | 5466 virtual void set_arguments(const TypeArguments& value) const; |
5439 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 5467 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
5440 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5468 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
5441 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5469 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5442 virtual bool IsRecursive() const; | 5470 virtual bool IsRecursive() const; |
5443 virtual RawAbstractType* InstantiateFrom( | 5471 virtual RawAbstractType* InstantiateFrom( |
5444 const TypeArguments& instantiator_type_arguments, | 5472 const TypeArguments& instantiator_type_arguments, |
5445 Error* bound_error, | 5473 Error* bound_error, |
5446 TrailPtr trail = NULL, | 5474 TrailPtr instantiation_trail = NULL, |
| 5475 TrailPtr bound_trail = NULL, |
5447 Heap::Space space = Heap::kNew) const; | 5476 Heap::Space space = Heap::kNew) const; |
5448 virtual RawAbstractType* CloneUnfinalized() const; | 5477 virtual RawAbstractType* CloneUnfinalized() const; |
5449 virtual RawAbstractType* CloneUninstantiated( | 5478 virtual RawAbstractType* CloneUninstantiated( |
5450 const Class& new_owner, | 5479 const Class& new_owner, |
5451 TrailPtr trail = NULL) const; | 5480 TrailPtr trail = NULL) const; |
5452 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5481 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
5453 | 5482 |
5454 virtual intptr_t Hash() const; | 5483 virtual intptr_t Hash() const; |
5455 | 5484 |
5456 static intptr_t InstanceSize() { | 5485 static intptr_t InstanceSize() { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5583 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } | 5612 virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; } |
5584 virtual void set_arguments(const TypeArguments& value) const; | 5613 virtual void set_arguments(const TypeArguments& value) const; |
5585 RawFunction* signature() const { return raw_ptr()->signature_; } | 5614 RawFunction* signature() const { return raw_ptr()->signature_; } |
5586 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 5615 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
5587 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5616 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
5588 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5617 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5589 virtual bool IsRecursive() const; | 5618 virtual bool IsRecursive() const; |
5590 virtual RawAbstractType* InstantiateFrom( | 5619 virtual RawAbstractType* InstantiateFrom( |
5591 const TypeArguments& instantiator_type_arguments, | 5620 const TypeArguments& instantiator_type_arguments, |
5592 Error* malformed_error, | 5621 Error* malformed_error, |
5593 TrailPtr trail = NULL, | 5622 TrailPtr instantiation_trail = NULL, |
| 5623 TrailPtr bound_trail = NULL, |
5594 Heap::Space space = Heap::kNew) const; | 5624 Heap::Space space = Heap::kNew) const; |
5595 virtual RawAbstractType* CloneUnfinalized() const; | 5625 virtual RawAbstractType* CloneUnfinalized() const; |
5596 virtual RawAbstractType* CloneUninstantiated( | 5626 virtual RawAbstractType* CloneUninstantiated( |
5597 const Class& new_owner, | 5627 const Class& new_owner, |
5598 TrailPtr trail = NULL) const; | 5628 TrailPtr trail = NULL) const; |
5599 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5629 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
5600 | 5630 |
5601 virtual intptr_t Hash() const; | 5631 virtual intptr_t Hash() const; |
5602 | 5632 |
5603 static intptr_t InstanceSize() { | 5633 static intptr_t InstanceSize() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5659 virtual TokenPosition token_pos() const { | 5689 virtual TokenPosition token_pos() const { |
5660 return AbstractType::Handle(type()).token_pos(); | 5690 return AbstractType::Handle(type()).token_pos(); |
5661 } | 5691 } |
5662 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5692 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
5663 virtual bool IsEquivalent(const Instance& other, | 5693 virtual bool IsEquivalent(const Instance& other, |
5664 TrailPtr trail = NULL) const; | 5694 TrailPtr trail = NULL) const; |
5665 virtual bool IsRecursive() const { return true; } | 5695 virtual bool IsRecursive() const { return true; } |
5666 virtual RawTypeRef* InstantiateFrom( | 5696 virtual RawTypeRef* InstantiateFrom( |
5667 const TypeArguments& instantiator_type_arguments, | 5697 const TypeArguments& instantiator_type_arguments, |
5668 Error* bound_error, | 5698 Error* bound_error, |
5669 TrailPtr trail = NULL, | 5699 TrailPtr instantiation_trail = NULL, |
| 5700 TrailPtr bound_trail = NULL, |
5670 Heap::Space space = Heap::kNew) const; | 5701 Heap::Space space = Heap::kNew) const; |
5671 virtual RawTypeRef* CloneUninstantiated( | 5702 virtual RawTypeRef* CloneUninstantiated( |
5672 const Class& new_owner, | 5703 const Class& new_owner, |
5673 TrailPtr trail = NULL) const; | 5704 TrailPtr trail = NULL) const; |
5674 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5705 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
5675 | 5706 |
5676 virtual intptr_t Hash() const; | 5707 virtual intptr_t Hash() const; |
5677 | 5708 |
5678 // Return true if the receiver is contained in the trail. | |
5679 // Otherwise, if the trail is null, allocate a trail, then add the receiver to | |
5680 // the trail and return false. | |
5681 bool TestAndAddToTrail(TrailPtr* trail) const; | |
5682 | |
5683 // Return true if the pair <receiver, buddy> is contained in the trail. | |
5684 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, | |
5685 // buddy> to the trail and return false. | |
5686 // The receiver may be added several times, each time with a different buddy. | |
5687 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; | |
5688 | |
5689 static intptr_t InstanceSize() { | 5709 static intptr_t InstanceSize() { |
5690 return RoundedAllocationSize(sizeof(RawTypeRef)); | 5710 return RoundedAllocationSize(sizeof(RawTypeRef)); |
5691 } | 5711 } |
5692 | 5712 |
5693 static RawTypeRef* New(const AbstractType& type); | 5713 static RawTypeRef* New(const AbstractType& type); |
5694 | 5714 |
5695 private: | 5715 private: |
5696 static RawTypeRef* New(); | 5716 static RawTypeRef* New(); |
5697 | 5717 |
5698 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); | 5718 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5731 void set_index(intptr_t value) const; | 5751 void set_index(intptr_t value) const; |
5732 RawAbstractType* bound() const { return raw_ptr()->bound_; } | 5752 RawAbstractType* bound() const { return raw_ptr()->bound_; } |
5733 void set_bound(const AbstractType& value) const; | 5753 void set_bound(const AbstractType& value) const; |
5734 // Returns true if bounded_type is below upper_bound, otherwise return false | 5754 // Returns true if bounded_type is below upper_bound, otherwise return false |
5735 // and set bound_error if both bounded_type and upper_bound are instantiated. | 5755 // and set bound_error if both bounded_type and upper_bound are instantiated. |
5736 // If one or both are not instantiated, returning false only means that the | 5756 // If one or both are not instantiated, returning false only means that the |
5737 // bound cannot be checked yet and this is not an error. | 5757 // bound cannot be checked yet and this is not an error. |
5738 bool CheckBound(const AbstractType& bounded_type, | 5758 bool CheckBound(const AbstractType& bounded_type, |
5739 const AbstractType& upper_bound, | 5759 const AbstractType& upper_bound, |
5740 Error* bound_error, | 5760 Error* bound_error, |
| 5761 TrailPtr bound_trail = NULL, |
5741 Heap::Space space = Heap::kNew) const; | 5762 Heap::Space space = Heap::kNew) const; |
5742 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 5763 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
5743 virtual bool IsInstantiated(TrailPtr trail = NULL) const { | 5764 virtual bool IsInstantiated(TrailPtr trail = NULL) const { |
5744 return false; | 5765 return false; |
5745 } | 5766 } |
5746 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5767 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5747 virtual bool IsRecursive() const { return false; } | 5768 virtual bool IsRecursive() const { return false; } |
5748 virtual RawAbstractType* InstantiateFrom( | 5769 virtual RawAbstractType* InstantiateFrom( |
5749 const TypeArguments& instantiator_type_arguments, | 5770 const TypeArguments& instantiator_type_arguments, |
5750 Error* bound_error, | 5771 Error* bound_error, |
5751 TrailPtr trail = NULL, | 5772 TrailPtr instantiation_trail = NULL, |
| 5773 TrailPtr bound_trail = NULL, |
5752 Heap::Space space = Heap::kNew) const; | 5774 Heap::Space space = Heap::kNew) const; |
5753 virtual RawAbstractType* CloneUnfinalized() const; | 5775 virtual RawAbstractType* CloneUnfinalized() const; |
5754 virtual RawAbstractType* CloneUninstantiated( | 5776 virtual RawAbstractType* CloneUninstantiated( |
5755 const Class& new_owner, TrailPtr trail = NULL) const; | 5777 const Class& new_owner, TrailPtr trail = NULL) const; |
5756 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5778 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
5757 return raw(); | 5779 return raw(); |
5758 } | 5780 } |
5759 | 5781 |
5760 virtual intptr_t Hash() const; | 5782 virtual intptr_t Hash() const; |
5761 | 5783 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5826 // uninstantiated upper bound. Therefore, we do not need to check if the | 5848 // uninstantiated upper bound. Therefore, we do not need to check if the |
5827 // bound is instantiated. Moreover, doing so could lead into cycles, as in | 5849 // bound is instantiated. Moreover, doing so could lead into cycles, as in |
5828 // class C<T extends C<C>> { }. | 5850 // class C<T extends C<C>> { }. |
5829 return AbstractType::Handle(type()).IsInstantiated(); | 5851 return AbstractType::Handle(type()).IsInstantiated(); |
5830 } | 5852 } |
5831 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5853 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
5832 virtual bool IsRecursive() const; | 5854 virtual bool IsRecursive() const; |
5833 virtual RawAbstractType* InstantiateFrom( | 5855 virtual RawAbstractType* InstantiateFrom( |
5834 const TypeArguments& instantiator_type_arguments, | 5856 const TypeArguments& instantiator_type_arguments, |
5835 Error* bound_error, | 5857 Error* bound_error, |
5836 TrailPtr trail = NULL, | 5858 TrailPtr instantiation_trail = NULL, |
| 5859 TrailPtr bound_trail = NULL, |
5837 Heap::Space space = Heap::kNew) const; | 5860 Heap::Space space = Heap::kNew) const; |
5838 virtual RawAbstractType* CloneUnfinalized() const; | 5861 virtual RawAbstractType* CloneUnfinalized() const; |
5839 virtual RawAbstractType* CloneUninstantiated( | 5862 virtual RawAbstractType* CloneUninstantiated( |
5840 const Class& new_owner, TrailPtr trail = NULL) const; | 5863 const Class& new_owner, TrailPtr trail = NULL) const; |
5841 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5864 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
5842 return raw(); | 5865 return raw(); |
5843 } | 5866 } |
5844 | 5867 |
5845 virtual intptr_t Hash() const; | 5868 virtual intptr_t Hash() const; |
5846 | 5869 |
(...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8417 | 8440 |
8418 | 8441 |
8419 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8442 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8420 intptr_t index) { | 8443 intptr_t index) { |
8421 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8444 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8422 } | 8445 } |
8423 | 8446 |
8424 } // namespace dart | 8447 } // namespace dart |
8425 | 8448 |
8426 #endif // VM_OBJECT_H_ | 8449 #endif // VM_OBJECT_H_ |
OLD | NEW |