| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Filter stores based on source and target. | 365 // Filter stores based on source and target. |
| 366 if (value->IsNewObject() && raw()->IsOldObject()) { | 366 if (value->IsNewObject() && raw()->IsOldObject()) { |
| 367 uword ptr = reinterpret_cast<uword>(addr); | 367 uword ptr = reinterpret_cast<uword>(addr); |
| 368 Isolate::Current()->store_buffer()->AddPointer(ptr); | 368 Isolate::Current()->store_buffer()->AddPointer(ptr); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 | 371 |
| 372 RawObject* raw_; // The raw object reference. | 372 RawObject* raw_; // The raw object reference. |
| 373 | 373 |
| 374 private: | 374 private: |
| 375 static void InitializeObject(uword address, intptr_t index, intptr_t size); | 375 static void InitializeObject(uword address, intptr_t id, intptr_t size); |
| 376 | 376 |
| 377 cpp_vtable* vtable_address() const { | 377 cpp_vtable* vtable_address() const { |
| 378 uword vtable_addr = reinterpret_cast<uword>(this); | 378 uword vtable_addr = reinterpret_cast<uword>(this); |
| 379 return reinterpret_cast<cpp_vtable*>(vtable_addr); | 379 return reinterpret_cast<cpp_vtable*>(vtable_addr); |
| 380 } | 380 } |
| 381 | 381 |
| 382 static cpp_vtable handle_vtable_; | 382 static cpp_vtable handle_vtable_; |
| 383 | 383 |
| 384 // The static values below are singletons shared between the different | 384 // The static values below are singletons shared between the different |
| 385 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 385 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } | 457 cpp_vtable handle_vtable() const { return raw_ptr()->handle_vtable_; } |
| 458 void set_handle_vtable(cpp_vtable value) const { | 458 void set_handle_vtable(cpp_vtable value) const { |
| 459 raw_ptr()->handle_vtable_ = value; | 459 raw_ptr()->handle_vtable_ = value; |
| 460 } | 460 } |
| 461 | 461 |
| 462 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } | 462 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } |
| 463 void set_instance_kind(ObjectKind value) const { | 463 void set_instance_kind(ObjectKind value) const { |
| 464 raw_ptr()->instance_kind_ = value; | 464 raw_ptr()->instance_kind_ = value; |
| 465 } | 465 } |
| 466 | 466 |
| 467 intptr_t index() const { return raw_ptr()->index_; } | 467 intptr_t id() const { return raw_ptr()->id_; } |
| 468 void set_index(intptr_t value) const { | 468 void set_id(intptr_t value) const { |
| 469 raw_ptr()->index_ = value; | 469 raw_ptr()->id_ = value; |
| 470 } | 470 } |
| 471 | 471 |
| 472 RawString* Name() const; | 472 RawString* Name() const; |
| 473 | 473 |
| 474 RawScript* script() const { return raw_ptr()->script_; } | 474 RawScript* script() const { return raw_ptr()->script_; } |
| 475 | 475 |
| 476 intptr_t token_index() const { return raw_ptr()->token_index_; } | 476 intptr_t token_index() const { return raw_ptr()->token_index_; } |
| 477 | 477 |
| 478 // This class represents the signature class of a closure function if | 478 // This class represents the signature class of a closure function if |
| 479 // signature_function() is not null. | 479 // signature_function() is not null. |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 void CalculateFieldOffsets() const; | 726 void CalculateFieldOffsets() const; |
| 727 | 727 |
| 728 // Assigns empty array to all raw class array fields. | 728 // Assigns empty array to all raw class array fields. |
| 729 void InitEmptyFields(); | 729 void InitEmptyFields(); |
| 730 | 730 |
| 731 RawFunction* LookupAccessorFunction(const char* prefix, | 731 RawFunction* LookupAccessorFunction(const char* prefix, |
| 732 intptr_t prefix_length, | 732 intptr_t prefix_length, |
| 733 const String& name) const; | 733 const String& name) const; |
| 734 | 734 |
| 735 // Allocate an instance class which has a VM implementation. | 735 // Allocate an instance class which has a VM implementation. |
| 736 template <class FakeInstance> static RawClass* New(intptr_t index); | 736 template <class FakeInstance> static RawClass* New(intptr_t id); |
| 737 template <class FakeInstance> static RawClass* New(const String& name, | 737 template <class FakeInstance> static RawClass* New(const String& name, |
| 738 const Script& script, | 738 const Script& script, |
| 739 intptr_t token_index); | 739 intptr_t token_index); |
| 740 | 740 |
| 741 HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 741 HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
| 742 friend class Object; | 742 friend class Object; |
| 743 friend class Instance; | 743 friend class Instance; |
| 744 friend class Type; | 744 friend class Type; |
| 745 }; | 745 }; |
| 746 | 746 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 if (!HasResolvedTypeClass()) { | 864 if (!HasResolvedTypeClass()) { |
| 865 return false; | 865 return false; |
| 866 } | 866 } |
| 867 const Class& cls = Class::Handle(type_class()); | 867 const Class& cls = Class::Handle(type_class()); |
| 868 return !cls.IsNull() && cls.is_interface(); | 868 return !cls.IsNull() && cls.is_interface(); |
| 869 } | 869 } |
| 870 | 870 |
| 871 // Check the subtype relationship. | 871 // Check the subtype relationship. |
| 872 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const; | 872 bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const; |
| 873 | 873 |
| 874 static RawAbstractType* NewTypeParameter(const Class& parameterized_class, | |
| 875 intptr_t index, | |
| 876 const String& name, | |
| 877 intptr_t token_index); | |
| 878 | |
| 879 protected: | 874 protected: |
| 880 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); | 875 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); |
| 881 friend class Class; | 876 friend class Class; |
| 882 }; | 877 }; |
| 883 | 878 |
| 884 | 879 |
| 885 // A Type consists of a class, possibly parameterized with type | 880 // A Type consists of a class, possibly parameterized with type |
| 886 // arguments. Example: C<T1, T2>. | 881 // arguments. Example: C<T1, T2>. |
| 887 // An unresolved class is a String specifying the class name. | 882 // An unresolved class is a String specifying the class name. |
| 888 // | 883 // |
| (...skipping 3991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4880 }; | 4875 }; |
| 4881 | 4876 |
| 4882 | 4877 |
| 4883 // Breaking cycles and loops. | 4878 // Breaking cycles and loops. |
| 4884 RawClass* Object::clazz() const { | 4879 RawClass* Object::clazz() const { |
| 4885 uword raw_value = reinterpret_cast<uword>(raw_); | 4880 uword raw_value = reinterpret_cast<uword>(raw_); |
| 4886 if ((raw_value & kSmiTagMask) == kSmiTag) { | 4881 if ((raw_value & kSmiTagMask) == kSmiTag) { |
| 4887 return Smi::Class(); | 4882 return Smi::Class(); |
| 4888 } | 4883 } |
| 4889 RawClass* result = raw_->ptr()->class_; | 4884 RawClass* result = raw_->ptr()->class_; |
| 4890 ASSERT(result->ptr()->index_ == | 4885 ASSERT(result->ptr()->id_ == |
| 4891 RawObject::ClassTag::decode(raw_->ptr()->tags_)); | 4886 RawObject::ClassIdTag::decode(raw_->ptr()->tags_)); |
| 4892 ASSERT(Isolate::Current()->class_table()->At( | 4887 ASSERT(Isolate::Current()->class_table()->At( |
| 4893 RawObject::ClassTag::decode(raw_->ptr()->tags_)) == result); | 4888 RawObject::ClassIdTag::decode(raw_->ptr()->tags_)) == result); |
| 4894 return result; | 4889 return result; |
| 4895 } | 4890 } |
| 4896 | 4891 |
| 4897 | 4892 |
| 4898 void Object::SetRaw(RawObject* value) { | 4893 void Object::SetRaw(RawObject* value) { |
| 4899 // NOTE: The assignment "raw_ = value" should be the first statement in | 4894 // NOTE: The assignment "raw_ = value" should be the first statement in |
| 4900 // this function. Also do not use 'value' in this function after the | 4895 // this function. Also do not use 'value' in this function after the |
| 4901 // assignment (use 'raw_' instead). | 4896 // assignment (use 'raw_' instead). |
| 4902 raw_ = value; | 4897 raw_ = value; |
| 4903 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { | 4898 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4957 } | 4952 } |
| 4958 | 4953 |
| 4959 | 4954 |
| 4960 intptr_t Stackmap::SizeInBits() const { | 4955 intptr_t Stackmap::SizeInBits() const { |
| 4961 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 4956 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 4962 } | 4957 } |
| 4963 | 4958 |
| 4964 } // namespace dart | 4959 } // namespace dart |
| 4965 | 4960 |
| 4966 #endif // VM_OBJECT_H_ | 4961 #endif // VM_OBJECT_H_ |
| OLD | NEW |