| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. | 415 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. |
| 416 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. | 416 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. |
| 417 static RawClass* context_class_; // Class of the Context vm object. | 417 static RawClass* context_class_; // Class of the Context vm object. |
| 418 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 418 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
| 419 static RawClass* icdata_class_; // Class of ICData. | 419 static RawClass* icdata_class_; // Class of ICData. |
| 420 static RawClass* api_error_class_; // Class of ApiError. | 420 static RawClass* api_error_class_; // Class of ApiError. |
| 421 static RawClass* language_error_class_; // Class of LanguageError. | 421 static RawClass* language_error_class_; // Class of LanguageError. |
| 422 static RawClass* unhandled_exception_class_; // Class of UnhandledException. | 422 static RawClass* unhandled_exception_class_; // Class of UnhandledException. |
| 423 static RawClass* unwind_error_class_; // Class of UnwindError. | 423 static RawClass* unwind_error_class_; // Class of UnwindError. |
| 424 | 424 |
| 425 friend void RawObject::Validate() const; | 425 friend void RawObject::Validate(Isolate* isolate) const; |
| 426 friend class SnapshotReader; | 426 friend class SnapshotReader; |
| 427 | 427 |
| 428 // Disallow allocation. | 428 // Disallow allocation. |
| 429 void* operator new(size_t size); | 429 void* operator new(size_t size); |
| 430 // Disallow copy constructor. | 430 // Disallow copy constructor. |
| 431 DISALLOW_COPY_AND_ASSIGN(Object); | 431 DISALLOW_COPY_AND_ASSIGN(Object); |
| 432 }; | 432 }; |
| 433 | 433 |
| 434 | 434 |
| 435 class Class : public Object { | 435 class Class : public Object { |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 ASSERT(sizeof(RawTypeArguments) == (sizeof(RawObject) + (1 * kWordSize))); | 1189 ASSERT(sizeof(RawTypeArguments) == (sizeof(RawObject) + (1 * kWordSize))); |
| 1190 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize)); | 1190 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize)); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 static RawTypeArguments* New(intptr_t len); | 1193 static RawTypeArguments* New(intptr_t len); |
| 1194 | 1194 |
| 1195 private: | 1195 private: |
| 1196 // Make sure that the array size cannot wrap around. | 1196 // Make sure that the array size cannot wrap around. |
| 1197 static const intptr_t kMaxTypes = 512 * 1024 * 1024; | 1197 static const intptr_t kMaxTypes = 512 * 1024 * 1024; |
| 1198 RawAbstractType** TypeAddr(intptr_t index) const; | 1198 RawAbstractType** TypeAddr(intptr_t index) const; |
| 1199 void SetLength(intptr_t value); | 1199 void SetLength(intptr_t value) const; |
| 1200 | 1200 |
| 1201 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments); | 1201 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments); |
| 1202 friend class Class; | 1202 friend class Class; |
| 1203 }; | 1203 }; |
| 1204 | 1204 |
| 1205 | 1205 |
| 1206 // An instance of InstantiatedTypeArguments is never encountered at compile | 1206 // An instance of InstantiatedTypeArguments is never encountered at compile |
| 1207 // time, but only at run time, when type parameters can be matched to actual | 1207 // time, but only at run time, when type parameters can be matched to actual |
| 1208 // types. | 1208 // types. |
| 1209 // An instance of InstantiatedTypeArguments consists of a pair of | 1209 // An instance of InstantiatedTypeArguments consists of a pair of |
| (...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3493 private: | 3493 private: |
| 3494 // Make sure that the array size cannot wrap around. | 3494 // Make sure that the array size cannot wrap around. |
| 3495 static const intptr_t kMaxArrayElements = 512 * 1024 * 1024; | 3495 static const intptr_t kMaxArrayElements = 512 * 1024 * 1024; |
| 3496 | 3496 |
| 3497 RawObject** ObjectAddr(intptr_t index) const { | 3497 RawObject** ObjectAddr(intptr_t index) const { |
| 3498 // TODO(iposva): Determine if we should throw an exception here. | 3498 // TODO(iposva): Determine if we should throw an exception here. |
| 3499 ASSERT((index >= 0) && (index < Length())); | 3499 ASSERT((index >= 0) && (index < Length())); |
| 3500 return &raw_ptr()->data()[index]; | 3500 return &raw_ptr()->data()[index]; |
| 3501 } | 3501 } |
| 3502 | 3502 |
| 3503 void SetLength(intptr_t value) { | 3503 void SetLength(intptr_t value) const { |
| 3504 // This is only safe because we create a new Smi, which does not cause | 3504 // This is only safe because we create a new Smi, which does not cause |
| 3505 // heap allocation. | 3505 // heap allocation. |
| 3506 raw_ptr()->length_ = Smi::New(value); | 3506 raw_ptr()->length_ = Smi::New(value); |
| 3507 } | 3507 } |
| 3508 | 3508 |
| 3509 HEAP_OBJECT_IMPLEMENTATION(Array, Instance); | 3509 HEAP_OBJECT_IMPLEMENTATION(Array, Instance); |
| 3510 friend class Class; | 3510 friend class Class; |
| 3511 }; | 3511 }; |
| 3512 | 3512 |
| 3513 | 3513 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3702 | 3702 |
| 3703 template<typename T> | 3703 template<typename T> |
| 3704 T* Addr(intptr_t byte_offset) const { | 3704 T* Addr(intptr_t byte_offset) const { |
| 3705 intptr_t limit = byte_offset + sizeof(T); | 3705 intptr_t limit = byte_offset + sizeof(T); |
| 3706 // TODO(iposva): Determine if we should throw an exception here. | 3706 // TODO(iposva): Determine if we should throw an exception here. |
| 3707 ASSERT((byte_offset >= 0) && (limit <= Length())); | 3707 ASSERT((byte_offset >= 0) && (limit <= Length())); |
| 3708 uint8_t* addr = &raw_ptr()->data()[byte_offset]; | 3708 uint8_t* addr = &raw_ptr()->data()[byte_offset]; |
| 3709 return reinterpret_cast<T*>(addr); | 3709 return reinterpret_cast<T*>(addr); |
| 3710 } | 3710 } |
| 3711 | 3711 |
| 3712 void SetLength(intptr_t value) { | 3712 void SetLength(intptr_t value) const { |
| 3713 raw_ptr()->length_ = Smi::New(value); | 3713 raw_ptr()->length_ = Smi::New(value); |
| 3714 } | 3714 } |
| 3715 | 3715 |
| 3716 HEAP_OBJECT_IMPLEMENTATION(InternalByteArray, ByteArray); | 3716 HEAP_OBJECT_IMPLEMENTATION(InternalByteArray, ByteArray); |
| 3717 friend class Class; | 3717 friend class Class; |
| 3718 }; | 3718 }; |
| 3719 | 3719 |
| 3720 | 3720 |
| 3721 class ExternalByteArray : public ByteArray { | 3721 class ExternalByteArray : public ByteArray { |
| 3722 public: | 3722 public: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3772 | 3772 |
| 3773 template<typename T> | 3773 template<typename T> |
| 3774 T* Addr(intptr_t byte_offset) const { | 3774 T* Addr(intptr_t byte_offset) const { |
| 3775 intptr_t limit = byte_offset + sizeof(T); | 3775 intptr_t limit = byte_offset + sizeof(T); |
| 3776 // TODO(iposva): Determine if we should throw an exception here. | 3776 // TODO(iposva): Determine if we should throw an exception here. |
| 3777 ASSERT((byte_offset >= 0) && (limit <= Length())); | 3777 ASSERT((byte_offset >= 0) && (limit <= Length())); |
| 3778 uint8_t* addr = &raw_ptr()->external_data_->data()[byte_offset]; | 3778 uint8_t* addr = &raw_ptr()->external_data_->data()[byte_offset]; |
| 3779 return reinterpret_cast<T*>(addr); | 3779 return reinterpret_cast<T*>(addr); |
| 3780 } | 3780 } |
| 3781 | 3781 |
| 3782 void SetLength(intptr_t value) { | 3782 void SetLength(intptr_t value) const { |
| 3783 raw_ptr()->length_ = Smi::New(value); | 3783 raw_ptr()->length_ = Smi::New(value); |
| 3784 } | 3784 } |
| 3785 | 3785 |
| 3786 void SetExternalData(ExternalByteArrayData* data) { | 3786 void SetExternalData(ExternalByteArrayData* data) const { |
| 3787 raw_ptr()->external_data_ = data; | 3787 raw_ptr()->external_data_ = data; |
| 3788 } | 3788 } |
| 3789 | 3789 |
| 3790 static void Finalize(Dart_Handle handle, void* peer); | 3790 static void Finalize(Dart_Handle handle, void* peer); |
| 3791 | 3791 |
| 3792 HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray, ByteArray); | 3792 HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray, ByteArray); |
| 3793 friend class Class; | 3793 friend class Class; |
| 3794 }; | 3794 }; |
| 3795 | 3795 |
| 3796 | 3796 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 static intptr_t InstanceSize(intptr_t len) { | 3924 static intptr_t InstanceSize(intptr_t len) { |
| 3925 return RoundedAllocationSize(sizeof(RawJSRegExp) + len); | 3925 return RoundedAllocationSize(sizeof(RawJSRegExp) + len); |
| 3926 } | 3926 } |
| 3927 | 3927 |
| 3928 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 3928 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
| 3929 | 3929 |
| 3930 private: | 3930 private: |
| 3931 void set_type(RegExType type) const { raw_ptr()->type_ = type; } | 3931 void set_type(RegExType type) const { raw_ptr()->type_ = type; } |
| 3932 void set_flags(intptr_t value) const { raw_ptr()->flags_ = value; } | 3932 void set_flags(intptr_t value) const { raw_ptr()->flags_ = value; } |
| 3933 | 3933 |
| 3934 void SetLength(intptr_t value) { | 3934 void SetLength(intptr_t value) const { |
| 3935 // This is only safe because we create a new Smi, which does not cause | 3935 // This is only safe because we create a new Smi, which does not cause |
| 3936 // heap allocation. | 3936 // heap allocation. |
| 3937 raw_ptr()->data_length_ = Smi::New(value); | 3937 raw_ptr()->data_length_ = Smi::New(value); |
| 3938 } | 3938 } |
| 3939 | 3939 |
| 3940 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 3940 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
| 3941 friend class Class; | 3941 friend class Class; |
| 3942 }; | 3942 }; |
| 3943 | 3943 |
| 3944 | 3944 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 } | 4019 } |
| 4020 | 4020 |
| 4021 | 4021 |
| 4022 intptr_t Stackmap::SizeInBits() const { | 4022 intptr_t Stackmap::SizeInBits() const { |
| 4023 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 4023 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 4024 } | 4024 } |
| 4025 | 4025 |
| 4026 } // namespace dart | 4026 } // namespace dart |
| 4027 | 4027 |
| 4028 #endif // VM_OBJECT_H_ | 4028 #endif // VM_OBJECT_H_ |
| OLD | NEW |