| 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 4954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4965 static intptr_t InstanceSize(intptr_t lengthInBytes) { | 4965 static intptr_t InstanceSize(intptr_t lengthInBytes) { |
| 4966 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); | 4966 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); |
| 4967 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); | 4967 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); |
| 4968 } | 4968 } |
| 4969 | 4969 |
| 4970 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 4970 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 4971 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 4971 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 4972 return element_size[class_id - kTypedDataInt8ArrayCid]; | 4972 return element_size[class_id - kTypedDataInt8ArrayCid]; |
| 4973 } | 4973 } |
| 4974 | 4974 |
| 4975 static intptr_t MaxElements(intptr_t class_id) { |
| 4976 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 4977 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 4978 } |
| 4979 |
| 4975 static RawTypedData* New(intptr_t class_id, | 4980 static RawTypedData* New(intptr_t class_id, |
| 4976 intptr_t len, | 4981 intptr_t len, |
| 4977 Heap::Space space = Heap::kNew); | 4982 Heap::Space space = Heap::kNew); |
| 4978 | 4983 |
| 4979 protected: | 4984 protected: |
| 4980 void SetLength(intptr_t value) const { | 4985 void SetLength(intptr_t value) const { |
| 4981 raw_ptr()->length_ = Smi::New(value); | 4986 raw_ptr()->length_ = Smi::New(value); |
| 4982 } | 4987 } |
| 4983 | 4988 |
| 4984 private: | 4989 private: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5043 | 5048 |
| 5044 static intptr_t InstanceSize() { | 5049 static intptr_t InstanceSize() { |
| 5045 return RoundedAllocationSize(sizeof(RawExternalTypedData)); | 5050 return RoundedAllocationSize(sizeof(RawExternalTypedData)); |
| 5046 } | 5051 } |
| 5047 | 5052 |
| 5048 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5053 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 5049 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5054 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5050 return TypedData::element_size[class_id - kExternalTypedDataInt8ArrayCid]; | 5055 return TypedData::element_size[class_id - kExternalTypedDataInt8ArrayCid]; |
| 5051 } | 5056 } |
| 5052 | 5057 |
| 5058 static intptr_t MaxElements(intptr_t class_id) { |
| 5059 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5060 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 5061 } |
| 5062 |
| 5053 static RawExternalTypedData* New(intptr_t class_id, | 5063 static RawExternalTypedData* New(intptr_t class_id, |
| 5054 uint8_t* data, | 5064 uint8_t* data, |
| 5055 intptr_t len, | 5065 intptr_t len, |
| 5056 Heap::Space space = Heap::kNew); | 5066 Heap::Space space = Heap::kNew); |
| 5057 | 5067 |
| 5058 protected: | 5068 protected: |
| 5059 void SetLength(intptr_t value) const { | 5069 void SetLength(intptr_t value) const { |
| 5060 raw_ptr()->length_ = Smi::New(value); | 5070 raw_ptr()->length_ = Smi::New(value); |
| 5061 } | 5071 } |
| 5062 | 5072 |
| (...skipping 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6814 | 6824 |
| 6815 | 6825 |
| 6816 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6826 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6817 intptr_t index) { | 6827 intptr_t index) { |
| 6818 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6828 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6819 } | 6829 } |
| 6820 | 6830 |
| 6821 } // namespace dart | 6831 } // namespace dart |
| 6822 | 6832 |
| 6823 #endif // VM_OBJECT_H_ | 6833 #endif // VM_OBJECT_H_ |
| OLD | NEW |