| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 // Different kinds of name visibility. | 578 // Different kinds of name visibility. |
| 579 enum NameVisibility { | 579 enum NameVisibility { |
| 580 // Internal names are the true names of classes, fields, | 580 // Internal names are the true names of classes, fields, |
| 581 // etc. inside the vm. These names include privacy suffixes, | 581 // etc. inside the vm. These names include privacy suffixes, |
| 582 // getter prefixes, and trailing dots on unnamed constructors. | 582 // getter prefixes, and trailing dots on unnamed constructors. |
| 583 // | 583 // |
| 584 // The names of core implementation classes (like _OneByteString) | 584 // The names of core implementation classes (like _OneByteString) |
| 585 // are preserved as well. | 585 // are preserved as well. |
| 586 // | 586 // |
| 587 // e.g. | 587 // e.g. |
| 588 // private getter - get:foo@6be832b | 588 // private getter -> get:foo@6be832b |
| 589 // private constructor - _MyClass@6b3832b. | 589 // private constructor -> _MyClass@6b3832b. |
| 590 // private named constructor - _MyClass@6b3832b.named | 590 // private named constructor -> _MyClass@6b3832b.named |
| 591 // core impl class name shown - _OneByteString | 591 // core impl class name shown -> _OneByteString |
| 592 kInternalName = 0, | 592 kInternalName = 0, |
| 593 | 593 |
| 594 // Scrubbed names drop privacy suffixes, getter prefixes, and | 594 // Scrubbed names drop privacy suffixes, getter prefixes, and |
| 595 // trailing dots on unnamed constructors. These names are used in | 595 // trailing dots on unnamed constructors. These names are used in |
| 596 // the vm service. | 596 // the vm service. |
| 597 // | 597 // |
| 598 // e.g. | 598 // e.g. |
| 599 // get:foo@6be832b -> foo | 599 // get:foo@6be832b -> foo |
| 600 // _MyClass@6b3832b. -> _MyClass | 600 // _MyClass@6b3832b. -> _MyClass |
| 601 // _MyClass@6b3832b.named -> _MyClass.named | 601 // _MyClass@6b3832b.named -> _MyClass.named |
| 602 // _OneByteString -> _OneByteString (not remapped) | 602 // _OneByteString -> _OneByteString (not remapped) |
| 603 kScrubbedName, | 603 kScrubbedName, |
| 604 | 604 |
| 605 // User visible names are appropriate for reporting type errors | 605 // User visible names are appropriate for reporting type errors |
| 606 // directly to programmers. The names have been scrubbed and | 606 // directly to programmers. The names have been scrubbed and |
| 607 // the names of core implementation classes are remapped to their | 607 // the names of core implementation classes are remapped to their |
| 608 // public interface names. | 608 // public interface names. |
| 609 // | 609 // |
| 610 // e.g. | 610 // e.g. |
| 611 // get:foo@6be832b -> foo | 611 // get:foo@6be832b -> foo |
| 612 // _MyClass@6b3832b. -> _MyClass | 612 // _MyClass@6b3832b. -> _MyClass |
| 613 // _MyClass@6b3832b.named -> _MyClass.named | 613 // _MyClass@6b3832b.named -> _MyClass.named |
| 614 // _OneByteString -> String (remapped) | 614 // _OneByteString -> String (remapped) |
| 615 kUserVisibleName | 615 kUserVisibleName |
| 616 }; | 616 }; |
| 617 | 617 |
| 618 protected: | 618 protected: |
| 619 // Used for extracting the C++ vtable during bringup. | 619 // Used for extracting the C++ vtable during bringup. |
| 620 Object() : raw_(null_) {} | 620 Object() : raw_(null_) {} |
| 621 | 621 |
| 622 uword raw_value() const { | 622 uword raw_value() const { |
| 623 return reinterpret_cast<uword>(raw()); | 623 return reinterpret_cast<uword>(raw()); |
| 624 } | 624 } |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1629 | 1629 |
| 1630 // Clone this type argument vector and clone all uninstantiated type | 1630 // Clone this type argument vector and clone all uninstantiated type |
| 1631 // arguments, changing the class owner of type parameters. | 1631 // arguments, changing the class owner of type parameters. |
| 1632 // Instantiated type arguments are shared. | 1632 // Instantiated type arguments are shared. |
| 1633 RawTypeArguments* CloneUninstantiated( | 1633 RawTypeArguments* CloneUninstantiated( |
| 1634 const Class& new_owner, TrailPtr trail = NULL) const; | 1634 const Class& new_owner, TrailPtr trail = NULL) const; |
| 1635 | 1635 |
| 1636 // Canonicalize only if instantiated, otherwise returns 'this'. | 1636 // Canonicalize only if instantiated, otherwise returns 'this'. |
| 1637 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; | 1637 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; |
| 1638 | 1638 |
| 1639 // Returns a formatted list of occuring type arguments with their URI. |
| 1640 RawString* EnumerateURIs() const; |
| 1641 |
| 1639 // 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 |
| 1640 // 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 |
| 1641 // 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 |
| 1642 // type of the instantiator type argument vector. | 1645 // type of the instantiator type argument vector. |
| 1643 // 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. |
| 1644 RawTypeArguments* InstantiateFrom( | 1647 RawTypeArguments* InstantiateFrom( |
| 1645 const TypeArguments& instantiator_type_arguments, | 1648 const TypeArguments& instantiator_type_arguments, |
| 1646 Error* bound_error, | 1649 Error* bound_error, |
| 1647 TrailPtr instantiation_trail, | 1650 TrailPtr instantiation_trail, |
| 1648 TrailPtr bound_trail, | 1651 TrailPtr bound_trail, |
| (...skipping 3694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5343 virtual RawString* Name() const { | 5346 virtual RawString* Name() const { |
| 5344 return BuildName(kInternalName); | 5347 return BuildName(kInternalName); |
| 5345 } | 5348 } |
| 5346 | 5349 |
| 5347 // The name of this type, including the names of its type arguments, if any. | 5350 // The name of this type, including the names of its type arguments, if any. |
| 5348 // Names of internal classes are mapped to their public interfaces. | 5351 // Names of internal classes are mapped to their public interfaces. |
| 5349 virtual RawString* UserVisibleName() const { | 5352 virtual RawString* UserVisibleName() const { |
| 5350 return BuildName(kUserVisibleName); | 5353 return BuildName(kUserVisibleName); |
| 5351 } | 5354 } |
| 5352 | 5355 |
| 5356 // Same as user visible name, but including the URI of each occuring type. |
| 5357 // Used to report errors involving types with identical names. |
| 5358 virtual RawString* UserVisibleNameWithURI() const; |
| 5359 |
| 5360 // Returns a formatted list of occuring types with their URI. |
| 5361 virtual RawString* EnumerateURIs() const; |
| 5362 |
| 5353 virtual intptr_t Hash() const; | 5363 virtual intptr_t Hash() const; |
| 5354 | 5364 |
| 5355 // The name of this type's class, i.e. without the type argument names of this | 5365 // The name of this type's class, i.e. without the type argument names of this |
| 5356 // type. | 5366 // type. |
| 5357 RawString* ClassName() const; | 5367 RawString* ClassName() const; |
| 5358 | 5368 |
| 5359 // Check if this type represents the 'dynamic' type. | 5369 // Check if this type represents the 'dynamic' type. |
| 5360 bool IsDynamicType() const { | 5370 bool IsDynamicType() const { |
| 5361 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); | 5371 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); |
| 5362 } | 5372 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5486 const TypeArguments& instantiator_type_arguments, | 5496 const TypeArguments& instantiator_type_arguments, |
| 5487 Error* bound_error, | 5497 Error* bound_error, |
| 5488 TrailPtr instantiation_trail, | 5498 TrailPtr instantiation_trail, |
| 5489 TrailPtr bound_trail, | 5499 TrailPtr bound_trail, |
| 5490 Heap::Space space) const; | 5500 Heap::Space space) const; |
| 5491 virtual RawAbstractType* CloneUnfinalized() const; | 5501 virtual RawAbstractType* CloneUnfinalized() const; |
| 5492 virtual RawAbstractType* CloneUninstantiated( | 5502 virtual RawAbstractType* CloneUninstantiated( |
| 5493 const Class& new_owner, | 5503 const Class& new_owner, |
| 5494 TrailPtr trail = NULL) const; | 5504 TrailPtr trail = NULL) const; |
| 5495 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5505 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5506 virtual RawString* EnumerateURIs() const; |
| 5496 | 5507 |
| 5497 virtual intptr_t Hash() const; | 5508 virtual intptr_t Hash() const; |
| 5498 | 5509 |
| 5499 static intptr_t InstanceSize() { | 5510 static intptr_t InstanceSize() { |
| 5500 return RoundedAllocationSize(sizeof(RawType)); | 5511 return RoundedAllocationSize(sizeof(RawType)); |
| 5501 } | 5512 } |
| 5502 | 5513 |
| 5503 // The type of the literal 'null'. | 5514 // The type of the literal 'null'. |
| 5504 static RawType* NullType(); | 5515 static RawType* NullType(); |
| 5505 | 5516 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5634 const TypeArguments& instantiator_type_arguments, | 5645 const TypeArguments& instantiator_type_arguments, |
| 5635 Error* malformed_error, | 5646 Error* malformed_error, |
| 5636 TrailPtr instantiation_trail, | 5647 TrailPtr instantiation_trail, |
| 5637 TrailPtr bound_trail, | 5648 TrailPtr bound_trail, |
| 5638 Heap::Space space) const; | 5649 Heap::Space space) const; |
| 5639 virtual RawAbstractType* CloneUnfinalized() const; | 5650 virtual RawAbstractType* CloneUnfinalized() const; |
| 5640 virtual RawAbstractType* CloneUninstantiated( | 5651 virtual RawAbstractType* CloneUninstantiated( |
| 5641 const Class& new_owner, | 5652 const Class& new_owner, |
| 5642 TrailPtr trail = NULL) const; | 5653 TrailPtr trail = NULL) const; |
| 5643 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5654 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5655 virtual RawString* EnumerateURIs() const; |
| 5644 | 5656 |
| 5645 virtual intptr_t Hash() const; | 5657 virtual intptr_t Hash() const; |
| 5646 | 5658 |
| 5647 static intptr_t InstanceSize() { | 5659 static intptr_t InstanceSize() { |
| 5648 return RoundedAllocationSize(sizeof(RawFunctionType)); | 5660 return RoundedAllocationSize(sizeof(RawFunctionType)); |
| 5649 } | 5661 } |
| 5650 | 5662 |
| 5651 static RawFunctionType* New(const Class& scope_class, | 5663 static RawFunctionType* New(const Class& scope_class, |
| 5652 const TypeArguments& arguments, | 5664 const TypeArguments& arguments, |
| 5653 const Function& signature, | 5665 const Function& signature, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5710 virtual RawTypeRef* InstantiateFrom( | 5722 virtual RawTypeRef* InstantiateFrom( |
| 5711 const TypeArguments& instantiator_type_arguments, | 5723 const TypeArguments& instantiator_type_arguments, |
| 5712 Error* bound_error, | 5724 Error* bound_error, |
| 5713 TrailPtr instantiation_trail, | 5725 TrailPtr instantiation_trail, |
| 5714 TrailPtr bound_trail, | 5726 TrailPtr bound_trail, |
| 5715 Heap::Space space) const; | 5727 Heap::Space space) const; |
| 5716 virtual RawTypeRef* CloneUninstantiated( | 5728 virtual RawTypeRef* CloneUninstantiated( |
| 5717 const Class& new_owner, | 5729 const Class& new_owner, |
| 5718 TrailPtr trail = NULL) const; | 5730 TrailPtr trail = NULL) const; |
| 5719 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5731 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5732 virtual RawString* EnumerateURIs() const; |
| 5720 | 5733 |
| 5721 virtual intptr_t Hash() const; | 5734 virtual intptr_t Hash() const; |
| 5722 | 5735 |
| 5723 static intptr_t InstanceSize() { | 5736 static intptr_t InstanceSize() { |
| 5724 return RoundedAllocationSize(sizeof(RawTypeRef)); | 5737 return RoundedAllocationSize(sizeof(RawTypeRef)); |
| 5725 } | 5738 } |
| 5726 | 5739 |
| 5727 static RawTypeRef* New(const AbstractType& type); | 5740 static RawTypeRef* New(const AbstractType& type); |
| 5728 | 5741 |
| 5729 private: | 5742 private: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5785 Error* bound_error, | 5798 Error* bound_error, |
| 5786 TrailPtr instantiation_trail, | 5799 TrailPtr instantiation_trail, |
| 5787 TrailPtr bound_trail, | 5800 TrailPtr bound_trail, |
| 5788 Heap::Space space) const; | 5801 Heap::Space space) const; |
| 5789 virtual RawAbstractType* CloneUnfinalized() const; | 5802 virtual RawAbstractType* CloneUnfinalized() const; |
| 5790 virtual RawAbstractType* CloneUninstantiated( | 5803 virtual RawAbstractType* CloneUninstantiated( |
| 5791 const Class& new_owner, TrailPtr trail = NULL) const; | 5804 const Class& new_owner, TrailPtr trail = NULL) const; |
| 5792 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5805 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 5793 return raw(); | 5806 return raw(); |
| 5794 } | 5807 } |
| 5808 virtual RawString* EnumerateURIs() const; |
| 5795 | 5809 |
| 5796 virtual intptr_t Hash() const; | 5810 virtual intptr_t Hash() const; |
| 5797 | 5811 |
| 5798 static intptr_t InstanceSize() { | 5812 static intptr_t InstanceSize() { |
| 5799 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 5813 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
| 5800 } | 5814 } |
| 5801 | 5815 |
| 5802 static RawTypeParameter* New(const Class& parameterized_class, | 5816 static RawTypeParameter* New(const Class& parameterized_class, |
| 5803 intptr_t index, | 5817 intptr_t index, |
| 5804 const String& name, | 5818 const String& name, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5871 Error* bound_error, | 5885 Error* bound_error, |
| 5872 TrailPtr instantiation_trail, | 5886 TrailPtr instantiation_trail, |
| 5873 TrailPtr bound_trail, | 5887 TrailPtr bound_trail, |
| 5874 Heap::Space space) const; | 5888 Heap::Space space) const; |
| 5875 virtual RawAbstractType* CloneUnfinalized() const; | 5889 virtual RawAbstractType* CloneUnfinalized() const; |
| 5876 virtual RawAbstractType* CloneUninstantiated( | 5890 virtual RawAbstractType* CloneUninstantiated( |
| 5877 const Class& new_owner, TrailPtr trail = NULL) const; | 5891 const Class& new_owner, TrailPtr trail = NULL) const; |
| 5878 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 5892 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 5879 return raw(); | 5893 return raw(); |
| 5880 } | 5894 } |
| 5895 virtual RawString* EnumerateURIs() const; |
| 5881 | 5896 |
| 5882 virtual intptr_t Hash() const; | 5897 virtual intptr_t Hash() const; |
| 5883 | 5898 |
| 5884 static intptr_t InstanceSize() { | 5899 static intptr_t InstanceSize() { |
| 5885 return RoundedAllocationSize(sizeof(RawBoundedType)); | 5900 return RoundedAllocationSize(sizeof(RawBoundedType)); |
| 5886 } | 5901 } |
| 5887 | 5902 |
| 5888 static RawBoundedType* New(const AbstractType& type, | 5903 static RawBoundedType* New(const AbstractType& type, |
| 5889 const AbstractType& bound, | 5904 const AbstractType& bound, |
| 5890 const TypeParameter& type_parameter); | 5905 const TypeParameter& type_parameter); |
| (...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8448 | 8463 |
| 8449 | 8464 |
| 8450 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8465 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8451 intptr_t index) { | 8466 intptr_t index) { |
| 8452 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8467 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8453 } | 8468 } |
| 8454 | 8469 |
| 8455 } // namespace dart | 8470 } // namespace dart |
| 8456 | 8471 |
| 8457 #endif // VM_OBJECT_H_ | 8472 #endif // VM_OBJECT_H_ |
| OLD | NEW |