| 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 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; | 1643 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; |
| 1644 | 1644 |
| 1645 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1645 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
| 1646 // not refer to type parameters. Otherwise, return a new type argument vector | 1646 // not refer to type parameters. Otherwise, return a new type argument vector |
| 1647 // where each reference to a type parameter is replaced with the corresponding | 1647 // where each reference to a type parameter is replaced with the corresponding |
| 1648 // type of the instantiator type argument vector. | 1648 // type of the instantiator type argument vector. |
| 1649 // If bound_error is not NULL, it may be set to reflect a bound error. | 1649 // If bound_error is not NULL, it may be set to reflect a bound error. |
| 1650 RawTypeArguments* InstantiateFrom( | 1650 RawTypeArguments* InstantiateFrom( |
| 1651 const TypeArguments& instantiator_type_arguments, | 1651 const TypeArguments& instantiator_type_arguments, |
| 1652 Error* bound_error, | 1652 Error* bound_error, |
| 1653 TrailPtr trail = NULL) const; | 1653 TrailPtr trail = NULL, |
| 1654 Heap::Space space = Heap::kNew) const; |
| 1654 | 1655 |
| 1655 // Runtime instantiation with canonicalization. Not to be used during type | 1656 // Runtime instantiation with canonicalization. Not to be used during type |
| 1656 // finalization at compile time. | 1657 // finalization at compile time. |
| 1657 RawTypeArguments* InstantiateAndCanonicalizeFrom( | 1658 RawTypeArguments* InstantiateAndCanonicalizeFrom( |
| 1658 const TypeArguments& instantiator_type_arguments, | 1659 const TypeArguments& instantiator_type_arguments, |
| 1659 Error* bound_error) const; | 1660 Error* bound_error) const; |
| 1660 | 1661 |
| 1661 // Return true if this type argument vector has cached instantiations. | 1662 // Return true if this type argument vector has cached instantiations. |
| 1662 bool HasInstantiations() const; | 1663 bool HasInstantiations() const; |
| 1663 | 1664 |
| (...skipping 3335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4999 } | 5000 } |
| 5000 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5001 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 5001 virtual bool IsRecursive() const; | 5002 virtual bool IsRecursive() const; |
| 5002 | 5003 |
| 5003 // Instantiate this type using the given type argument vector. | 5004 // Instantiate this type using the given type argument vector. |
| 5004 // Return a new type, or return 'this' if it is already instantiated. | 5005 // Return a new type, or return 'this' if it is already instantiated. |
| 5005 // If bound_error is not NULL, it may be set to reflect a bound error. | 5006 // If bound_error is not NULL, it may be set to reflect a bound error. |
| 5006 virtual RawAbstractType* InstantiateFrom( | 5007 virtual RawAbstractType* InstantiateFrom( |
| 5007 const TypeArguments& instantiator_type_arguments, | 5008 const TypeArguments& instantiator_type_arguments, |
| 5008 Error* bound_error, | 5009 Error* bound_error, |
| 5009 TrailPtr trail = NULL) const; | 5010 TrailPtr trail = NULL, |
| 5011 Heap::Space space = Heap::kNew) const; |
| 5010 | 5012 |
| 5011 // Return a clone of this unfinalized type or the type itself if it is | 5013 // Return a clone of this unfinalized type or the type itself if it is |
| 5012 // already finalized. Apply recursively to type arguments, i.e. finalized | 5014 // already finalized. Apply recursively to type arguments, i.e. finalized |
| 5013 // type arguments of an unfinalized type are not cloned, but shared. | 5015 // type arguments of an unfinalized type are not cloned, but shared. |
| 5014 virtual RawAbstractType* CloneUnfinalized() const; | 5016 virtual RawAbstractType* CloneUnfinalized() const; |
| 5015 | 5017 |
| 5016 // Return a clone of this uninstantiated type where all references to type | 5018 // Return a clone of this uninstantiated type where all references to type |
| 5017 // parameters are replaced with references to type parameters of the same name | 5019 // parameters are replaced with references to type parameters of the same name |
| 5018 // but belonging to the new owner class. | 5020 // but belonging to the new owner class. |
| 5019 // Apply recursively to type arguments, i.e. instantiated type arguments of | 5021 // Apply recursively to type arguments, i.e. instantiated type arguments of |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5172 virtual RawUnresolvedClass* unresolved_class() const; | 5174 virtual RawUnresolvedClass* unresolved_class() const; |
| 5173 virtual RawTypeArguments* arguments() const; | 5175 virtual RawTypeArguments* arguments() const; |
| 5174 void set_arguments(const TypeArguments& value) const; | 5176 void set_arguments(const TypeArguments& value) const; |
| 5175 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 5177 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 5176 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5178 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
| 5177 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5179 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 5178 virtual bool IsRecursive() const; | 5180 virtual bool IsRecursive() const; |
| 5179 virtual RawAbstractType* InstantiateFrom( | 5181 virtual RawAbstractType* InstantiateFrom( |
| 5180 const TypeArguments& instantiator_type_arguments, | 5182 const TypeArguments& instantiator_type_arguments, |
| 5181 Error* malformed_error, | 5183 Error* malformed_error, |
| 5182 TrailPtr trail = NULL) const; | 5184 TrailPtr trail = NULL, |
| 5185 Heap::Space space = Heap::kNew) const; |
| 5183 virtual RawAbstractType* CloneUnfinalized() const; | 5186 virtual RawAbstractType* CloneUnfinalized() const; |
| 5184 virtual RawAbstractType* CloneUninstantiated( | 5187 virtual RawAbstractType* CloneUninstantiated( |
| 5185 const Class& new_owner, | 5188 const Class& new_owner, |
| 5186 TrailPtr trail = NULL) const; | 5189 TrailPtr trail = NULL) const; |
| 5187 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5190 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5188 | 5191 |
| 5189 virtual intptr_t Hash() const; | 5192 virtual intptr_t Hash() const; |
| 5190 | 5193 |
| 5191 static intptr_t InstanceSize() { | 5194 static intptr_t InstanceSize() { |
| 5192 return RoundedAllocationSize(sizeof(RawType)); | 5195 return RoundedAllocationSize(sizeof(RawType)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5293 virtual intptr_t token_pos() const { | 5296 virtual intptr_t token_pos() const { |
| 5294 return AbstractType::Handle(type()).token_pos(); | 5297 return AbstractType::Handle(type()).token_pos(); |
| 5295 } | 5298 } |
| 5296 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5299 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
| 5297 virtual bool IsEquivalent(const Instance& other, | 5300 virtual bool IsEquivalent(const Instance& other, |
| 5298 TrailPtr trail = NULL) const; | 5301 TrailPtr trail = NULL) const; |
| 5299 virtual bool IsRecursive() const { return true; } | 5302 virtual bool IsRecursive() const { return true; } |
| 5300 virtual RawTypeRef* InstantiateFrom( | 5303 virtual RawTypeRef* InstantiateFrom( |
| 5301 const TypeArguments& instantiator_type_arguments, | 5304 const TypeArguments& instantiator_type_arguments, |
| 5302 Error* bound_error, | 5305 Error* bound_error, |
| 5303 TrailPtr trail = NULL) const; | 5306 TrailPtr trail = NULL, |
| 5307 Heap::Space space = Heap::kNew) const; |
| 5304 virtual RawTypeRef* CloneUninstantiated( | 5308 virtual RawTypeRef* CloneUninstantiated( |
| 5305 const Class& new_owner, | 5309 const Class& new_owner, |
| 5306 TrailPtr trail = NULL) const; | 5310 TrailPtr trail = NULL) const; |
| 5307 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5311 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5308 | 5312 |
| 5309 virtual intptr_t Hash() const; | 5313 virtual intptr_t Hash() const; |
| 5310 | 5314 |
| 5311 // Return true if the receiver is contained in the trail. | 5315 // Return true if the receiver is contained in the trail. |
| 5312 // Otherwise, if the trail is null, allocate a trail, then add the receiver to | 5316 // Otherwise, if the trail is null, allocate a trail, then add the receiver to |
| 5313 // the trail and return false. | 5317 // the trail and return false. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5373 Error* bound_error) const; | 5377 Error* bound_error) const; |
| 5374 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 5378 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 5375 virtual bool IsInstantiated(TrailPtr trail = NULL) const { | 5379 virtual bool IsInstantiated(TrailPtr trail = NULL) const { |
| 5376 return false; | 5380 return false; |
| 5377 } | 5381 } |
| 5378 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5382 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 5379 virtual bool IsRecursive() const { return false; } | 5383 virtual bool IsRecursive() const { return false; } |
| 5380 virtual RawAbstractType* InstantiateFrom( | 5384 virtual RawAbstractType* InstantiateFrom( |
| 5381 const TypeArguments& instantiator_type_arguments, | 5385 const TypeArguments& instantiator_type_arguments, |
| 5382 Error* bound_error, | 5386 Error* bound_error, |
| 5383 TrailPtr trail = NULL) const; | 5387 TrailPtr trail = NULL, |
| 5388 Heap::Space space = Heap::kNew) const; |
| 5384 virtual RawAbstractType* CloneUnfinalized() const; | 5389 virtual RawAbstractType* CloneUnfinalized() const; |
| 5385 virtual RawAbstractType* CloneUninstantiated( | 5390 virtual RawAbstractType* CloneUninstantiated( |
| 5386 const Class& new_owner, TrailPtr trail = NULL) const; | 5391 const Class& new_owner, TrailPtr trail = NULL) const; |
| 5387 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5392 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 5388 return raw(); | 5393 return raw(); |
| 5389 } | 5394 } |
| 5390 | 5395 |
| 5391 virtual intptr_t Hash() const; | 5396 virtual intptr_t Hash() const; |
| 5392 | 5397 |
| 5393 static intptr_t InstanceSize() { | 5398 static intptr_t InstanceSize() { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5457 // uninstantiated upper bound. Therefore, we do not need to check if the | 5462 // uninstantiated upper bound. Therefore, we do not need to check if the |
| 5458 // bound is instantiated. Moreover, doing so could lead into cycles, as in | 5463 // bound is instantiated. Moreover, doing so could lead into cycles, as in |
| 5459 // class C<T extends C<C>> { }. | 5464 // class C<T extends C<C>> { }. |
| 5460 return AbstractType::Handle(type()).IsInstantiated(); | 5465 return AbstractType::Handle(type()).IsInstantiated(); |
| 5461 } | 5466 } |
| 5462 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 5467 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 5463 virtual bool IsRecursive() const; | 5468 virtual bool IsRecursive() const; |
| 5464 virtual RawAbstractType* InstantiateFrom( | 5469 virtual RawAbstractType* InstantiateFrom( |
| 5465 const TypeArguments& instantiator_type_arguments, | 5470 const TypeArguments& instantiator_type_arguments, |
| 5466 Error* bound_error, | 5471 Error* bound_error, |
| 5467 TrailPtr trail = NULL) const; | 5472 TrailPtr trail = NULL, |
| 5473 Heap::Space space = Heap::kNew) const; |
| 5468 virtual RawAbstractType* CloneUnfinalized() const; | 5474 virtual RawAbstractType* CloneUnfinalized() const; |
| 5469 virtual RawAbstractType* CloneUninstantiated( | 5475 virtual RawAbstractType* CloneUninstantiated( |
| 5470 const Class& new_owner, TrailPtr trail = NULL) const; | 5476 const Class& new_owner, TrailPtr trail = NULL) const; |
| 5471 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5477 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 5472 return raw(); | 5478 return raw(); |
| 5473 } | 5479 } |
| 5474 | 5480 |
| 5475 virtual intptr_t Hash() const; | 5481 virtual intptr_t Hash() const; |
| 5476 | 5482 |
| 5477 static intptr_t InstanceSize() { | 5483 static intptr_t InstanceSize() { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5593 | 5599 |
| 5594 virtual bool FitsIntoSmi() const; | 5600 virtual bool FitsIntoSmi() const; |
| 5595 | 5601 |
| 5596 // Returns 0, -1 or 1. | 5602 // Returns 0, -1 or 1. |
| 5597 virtual int CompareWith(const Integer& other) const; | 5603 virtual int CompareWith(const Integer& other) const; |
| 5598 | 5604 |
| 5599 // Return the most compact presentation of an integer. | 5605 // Return the most compact presentation of an integer. |
| 5600 RawInteger* AsValidInteger() const; | 5606 RawInteger* AsValidInteger() const; |
| 5601 | 5607 |
| 5602 // Returns null to indicate that a bigint operation is required. | 5608 // Returns null to indicate that a bigint operation is required. |
| 5603 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; | 5609 RawInteger* ArithmeticOp(Token::Kind operation, |
| 5610 const Integer& other, |
| 5611 Heap::Space space = Heap::kNew) const; |
| 5604 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; | 5612 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; |
| 5605 | 5613 |
| 5606 // Returns true if the Integer does not fit in a Javascript integer. | 5614 // Returns true if the Integer does not fit in a Javascript integer. |
| 5607 bool CheckJavascriptIntegerOverflow() const; | 5615 bool CheckJavascriptIntegerOverflow() const; |
| 5608 | 5616 |
| 5609 private: | 5617 private: |
| 5610 OBJECT_IMPLEMENTATION(Integer, Number); | 5618 OBJECT_IMPLEMENTATION(Integer, Number); |
| 5611 friend class Class; | 5619 friend class Class; |
| 5612 }; | 5620 }; |
| 5613 | 5621 |
| (...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8053 | 8061 |
| 8054 | 8062 |
| 8055 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8063 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8056 intptr_t index) { | 8064 intptr_t index) { |
| 8057 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8065 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8058 } | 8066 } |
| 8059 | 8067 |
| 8060 } // namespace dart | 8068 } // namespace dart |
| 8061 | 8069 |
| 8062 #endif // VM_OBJECT_H_ | 8070 #endif // VM_OBJECT_H_ |
| OLD | NEW |