Chromium Code Reviews| 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 5016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5027 intptr_t Length() const { | 5027 intptr_t Length() const { |
| 5028 ASSERT(!IsNull()); | 5028 ASSERT(!IsNull()); |
| 5029 return Smi::Value(raw_ptr()->length_); | 5029 return Smi::Value(raw_ptr()->length_); |
| 5030 } | 5030 } |
| 5031 | 5031 |
| 5032 intptr_t ElementSizeInBytes() const { | 5032 intptr_t ElementSizeInBytes() const { |
| 5033 intptr_t cid = raw()->GetClassId(); | 5033 intptr_t cid = raw()->GetClassId(); |
| 5034 return ElementSizeInBytes(cid); | 5034 return ElementSizeInBytes(cid); |
| 5035 } | 5035 } |
| 5036 | 5036 |
| 5037 intptr_t ElementType() const { | |
| 5038 intptr_t cid = raw()->GetClassId(); | |
| 5039 return ElementType(cid); | |
|
kustermann
2013/04/16 17:26:04
It is not the nicest thing that these functions re
Vyacheslav Egorov (Google)
2013/04/17 11:41:56
Why not introduce an enum:
enum TypeDataElementTy
Vyacheslav Egorov (Google)
2013/04/17 12:55:27
I meant:
enum TypeDataElementType {
#define V(nam
kustermann
2013/04/18 13:57:57
Done.
| |
| 5040 } | |
| 5041 | |
| 5037 intptr_t LengthInBytes() const { | 5042 intptr_t LengthInBytes() const { |
| 5038 intptr_t cid = raw()->GetClassId(); | 5043 intptr_t cid = raw()->GetClassId(); |
| 5039 return (ElementSizeInBytes(cid) * Length()); | 5044 return (ElementSizeInBytes(cid) * Length()); |
| 5040 } | 5045 } |
| 5041 | 5046 |
| 5042 void* DataAddr(intptr_t byte_offset) const { | 5047 void* DataAddr(intptr_t byte_offset) const { |
| 5043 ASSERT((byte_offset >= 0) && (byte_offset < LengthInBytes())); | 5048 ASSERT((byte_offset >= 0) && (byte_offset < LengthInBytes())); |
| 5044 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); | 5049 return reinterpret_cast<void*>(raw_ptr()->data_ + byte_offset); |
| 5045 } | 5050 } |
| 5046 | 5051 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5079 static intptr_t InstanceSize(intptr_t lengthInBytes) { | 5084 static intptr_t InstanceSize(intptr_t lengthInBytes) { |
| 5080 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); | 5085 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); |
| 5081 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); | 5086 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); |
| 5082 } | 5087 } |
| 5083 | 5088 |
| 5084 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5089 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 5085 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 5090 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 5086 return element_size[class_id - kTypedDataInt8ArrayCid]; | 5091 return element_size[class_id - kTypedDataInt8ArrayCid]; |
| 5087 } | 5092 } |
| 5088 | 5093 |
| 5094 static intptr_t ElementType(intptr_t class_id) { | |
| 5095 ASSERT(RawObject::IsTypedDataClassId(class_id)); | |
| 5096 return class_id - kTypedDataInt8ArrayCid; | |
| 5097 } | |
| 5098 | |
| 5089 static intptr_t MaxElements(intptr_t class_id) { | 5099 static intptr_t MaxElements(intptr_t class_id) { |
| 5090 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 5100 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 5091 return (kSmiMax / ElementSizeInBytes(class_id)); | 5101 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 5092 } | 5102 } |
| 5093 | 5103 |
| 5094 static RawTypedData* New(intptr_t class_id, | 5104 static RawTypedData* New(intptr_t class_id, |
| 5095 intptr_t len, | 5105 intptr_t len, |
| 5096 Heap::Space space = Heap::kNew); | 5106 Heap::Space space = Heap::kNew); |
| 5097 | 5107 |
| 5098 static void Copy(const TypedData& dst, | 5108 static void Copy(const TypedData& dst, |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 5127 intptr_t Length() const { | 5137 intptr_t Length() const { |
| 5128 ASSERT(!IsNull()); | 5138 ASSERT(!IsNull()); |
| 5129 return Smi::Value(raw_ptr()->length_); | 5139 return Smi::Value(raw_ptr()->length_); |
| 5130 } | 5140 } |
| 5131 | 5141 |
| 5132 intptr_t ElementSizeInBytes() const { | 5142 intptr_t ElementSizeInBytes() const { |
| 5133 intptr_t cid = raw()->GetClassId(); | 5143 intptr_t cid = raw()->GetClassId(); |
| 5134 return ElementSizeInBytes(cid); | 5144 return ElementSizeInBytes(cid); |
| 5135 } | 5145 } |
| 5136 | 5146 |
| 5147 intptr_t ElementType() const { | |
| 5148 intptr_t cid = raw()->GetClassId(); | |
| 5149 return ElementType(cid); | |
| 5150 } | |
| 5151 | |
| 5137 intptr_t LengthInBytes() const { | 5152 intptr_t LengthInBytes() const { |
| 5138 intptr_t cid = raw()->GetClassId(); | 5153 intptr_t cid = raw()->GetClassId(); |
| 5139 return (ElementSizeInBytes(cid) * Length()); | 5154 return (ElementSizeInBytes(cid) * Length()); |
| 5140 } | 5155 } |
| 5141 | 5156 |
| 5142 void* GetPeer() const { | 5157 void* GetPeer() const { |
| 5143 return raw_ptr()->peer_; | 5158 return raw_ptr()->peer_; |
| 5144 } | 5159 } |
| 5145 | 5160 |
| 5146 void* DataAddr(intptr_t byte_offset) const { | 5161 void* DataAddr(intptr_t byte_offset) const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5180 | 5195 |
| 5181 static intptr_t InstanceSize() { | 5196 static intptr_t InstanceSize() { |
| 5182 return RoundedAllocationSize(sizeof(RawExternalTypedData)); | 5197 return RoundedAllocationSize(sizeof(RawExternalTypedData)); |
| 5183 } | 5198 } |
| 5184 | 5199 |
| 5185 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5200 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 5186 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5201 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5187 return TypedData::element_size[class_id - kExternalTypedDataInt8ArrayCid]; | 5202 return TypedData::element_size[class_id - kExternalTypedDataInt8ArrayCid]; |
| 5188 } | 5203 } |
| 5189 | 5204 |
| 5205 static intptr_t ElementType(intptr_t class_id) { | |
| 5206 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | |
| 5207 return class_id - kExternalTypedDataInt8ArrayCid; | |
| 5208 } | |
| 5209 | |
| 5190 static intptr_t MaxElements(intptr_t class_id) { | 5210 static intptr_t MaxElements(intptr_t class_id) { |
| 5191 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5211 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5192 return (kSmiMax / ElementSizeInBytes(class_id)); | 5212 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 5193 } | 5213 } |
| 5194 | 5214 |
| 5195 static RawExternalTypedData* New(intptr_t class_id, | 5215 static RawExternalTypedData* New(intptr_t class_id, |
| 5196 uint8_t* data, | 5216 uint8_t* data, |
| 5197 intptr_t len, | 5217 intptr_t len, |
| 5198 Heap::Space space = Heap::kNew); | 5218 Heap::Space space = Heap::kNew); |
| 5199 | 5219 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5656 | 5676 |
| 5657 | 5677 |
| 5658 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 5678 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 5659 intptr_t index) { | 5679 intptr_t index) { |
| 5660 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 5680 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 5661 } | 5681 } |
| 5662 | 5682 |
| 5663 } // namespace dart | 5683 } // namespace dart |
| 5664 | 5684 |
| 5665 #endif // VM_OBJECT_H_ | 5685 #endif // VM_OBJECT_H_ |
| OLD | NEW |