| 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 5727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5738 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); | 5738 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); |
| 5739 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; | 5739 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; |
| 5740 } | 5740 } |
| 5741 | 5741 |
| 5742 FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint64Array, ByteArray); | 5742 FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint64Array, ByteArray); |
| 5743 friend class ByteArray; | 5743 friend class ByteArray; |
| 5744 friend class Class; | 5744 friend class Class; |
| 5745 }; | 5745 }; |
| 5746 | 5746 |
| 5747 | 5747 |
| 5748 class Float32x4Array : public ByteArray { | |
| 5749 public: | |
| 5750 intptr_t ByteLength() const { | |
| 5751 return Length() * kBytesPerElement; | |
| 5752 } | |
| 5753 | |
| 5754 simd128_value_t At(intptr_t index) const { | |
| 5755 ASSERT((index >= 0) && (index < Length())); | |
| 5756 return raw_ptr()->data_[index]; | |
| 5757 } | |
| 5758 | |
| 5759 void SetAt(intptr_t index, simd128_value_t value) const { | |
| 5760 ASSERT((index >= 0) && (index < Length())); | |
| 5761 raw_ptr()->data_[index] = value; | |
| 5762 } | |
| 5763 | |
| 5764 static const intptr_t kBytesPerElement = 16; | |
| 5765 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | |
| 5766 | |
| 5767 static intptr_t data_offset() { | |
| 5768 return OFFSET_OF(RawFloat32x4Array, data_); | |
| 5769 } | |
| 5770 | |
| 5771 static intptr_t InstanceSize() { | |
| 5772 ASSERT(sizeof(RawFloat32x4Array) == | |
| 5773 OFFSET_OF(RawFloat32x4Array, data_)); | |
| 5774 return 0; | |
| 5775 } | |
| 5776 | |
| 5777 static intptr_t InstanceSize(intptr_t len) { | |
| 5778 ASSERT(0 <= len && len <= kMaxElements); | |
| 5779 return RoundedAllocationSize( | |
| 5780 sizeof(RawFloat32x4Array) + (len * kBytesPerElement)); | |
| 5781 } | |
| 5782 | |
| 5783 static RawFloat32x4Array* New(intptr_t len, | |
| 5784 Heap::Space space = Heap::kNew); | |
| 5785 static RawFloat32x4Array* New(const simd128_value_t* data, | |
| 5786 intptr_t len, | |
| 5787 Heap::Space space = Heap::kNew); | |
| 5788 | |
| 5789 private: | |
| 5790 uint8_t* ByteAddr(intptr_t byte_offset) const { | |
| 5791 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); | |
| 5792 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; | |
| 5793 } | |
| 5794 | |
| 5795 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4Array, ByteArray); | |
| 5796 friend class ByteArray; | |
| 5797 friend class Class; | |
| 5798 }; | |
| 5799 | |
| 5800 | |
| 5801 class Float32Array : public ByteArray { | 5748 class Float32Array : public ByteArray { |
| 5802 public: | 5749 public: |
| 5803 intptr_t ByteLength() const { | 5750 intptr_t ByteLength() const { |
| 5804 return Length() * kBytesPerElement; | 5751 return Length() * kBytesPerElement; |
| 5805 } | 5752 } |
| 5806 | 5753 |
| 5807 float At(intptr_t index) const { | 5754 float At(intptr_t index) const { |
| 5808 ASSERT((index >= 0) && (index < Length())); | 5755 ASSERT((index >= 0) && (index < Length())); |
| 5809 return raw_ptr()->data_[index]; | 5756 return raw_ptr()->data_[index]; |
| 5810 } | 5757 } |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6390 void SetPeer(void* peer) const { | 6337 void SetPeer(void* peer) const { |
| 6391 raw_ptr()->peer_ = peer; | 6338 raw_ptr()->peer_ = peer; |
| 6392 } | 6339 } |
| 6393 | 6340 |
| 6394 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array, ByteArray); | 6341 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array, ByteArray); |
| 6395 friend class ByteArray; | 6342 friend class ByteArray; |
| 6396 friend class Class; | 6343 friend class Class; |
| 6397 }; | 6344 }; |
| 6398 | 6345 |
| 6399 | 6346 |
| 6400 class ExternalFloat32x4Array : public ByteArray { | |
| 6401 public: | |
| 6402 intptr_t ByteLength() const { | |
| 6403 return Length() * kBytesPerElement; | |
| 6404 } | |
| 6405 | |
| 6406 simd128_value_t At(intptr_t index) const { | |
| 6407 ASSERT((index >= 0) && (index < Length())); | |
| 6408 return raw_ptr()->data_[index]; | |
| 6409 } | |
| 6410 | |
| 6411 void SetAt(intptr_t index, simd128_value_t value) const { | |
| 6412 ASSERT((index >= 0) && (index < Length())); | |
| 6413 raw_ptr()->data_[index] = value; | |
| 6414 } | |
| 6415 | |
| 6416 | |
| 6417 simd128_value_t* GetData() const { | |
| 6418 return raw_ptr()->data_; | |
| 6419 } | |
| 6420 | |
| 6421 void* GetPeer() const { | |
| 6422 return raw_ptr()->peer_; | |
| 6423 } | |
| 6424 | |
| 6425 static const intptr_t kBytesPerElement = 16; | |
| 6426 | |
| 6427 // Since external arrays may be serialized to non-external ones, | |
| 6428 // enforce the same maximum element count. | |
| 6429 static const intptr_t kMaxElements = Float32x4Array::kMaxElements; | |
| 6430 | |
| 6431 static intptr_t InstanceSize() { | |
| 6432 return RoundedAllocationSize(sizeof(RawExternalFloat32x4Array)); | |
| 6433 } | |
| 6434 | |
| 6435 static RawExternalFloat32x4Array* New(simd128_value_t* data, intptr_t len, | |
| 6436 Heap::Space space = Heap::kNew); | |
| 6437 | |
| 6438 private: | |
| 6439 uint8_t* ByteAddr(intptr_t byte_offset) const { | |
| 6440 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); | |
| 6441 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_); | |
| 6442 return data + byte_offset; | |
| 6443 } | |
| 6444 | |
| 6445 void SetData(simd128_value_t* data) const { | |
| 6446 raw_ptr()->data_ = data; | |
| 6447 } | |
| 6448 | |
| 6449 void SetPeer(void* peer) const { | |
| 6450 raw_ptr()->peer_ = peer; | |
| 6451 } | |
| 6452 | |
| 6453 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32x4Array, ByteArray); | |
| 6454 friend class ByteArray; | |
| 6455 friend class Class; | |
| 6456 }; | |
| 6457 | |
| 6458 | |
| 6459 class ExternalFloat32Array : public ByteArray { | 6347 class ExternalFloat32Array : public ByteArray { |
| 6460 public: | 6348 public: |
| 6461 intptr_t ByteLength() const { | 6349 intptr_t ByteLength() const { |
| 6462 return Length() * kBytesPerElement; | 6350 return Length() * kBytesPerElement; |
| 6463 } | 6351 } |
| 6464 | 6352 |
| 6465 float At(intptr_t index) const { | 6353 float At(intptr_t index) const { |
| 6466 ASSERT((index >= 0) && (index < Length())); | 6354 ASSERT((index >= 0) && (index < Length())); |
| 6467 return raw_ptr()->data_[index]; | 6355 return raw_ptr()->data_[index]; |
| 6468 } | 6356 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6935 | 6823 |
| 6936 | 6824 |
| 6937 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6825 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6938 intptr_t index) { | 6826 intptr_t index) { |
| 6939 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6827 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6940 } | 6828 } |
| 6941 | 6829 |
| 6942 } // namespace dart | 6830 } // namespace dart |
| 6943 | 6831 |
| 6944 #endif // VM_OBJECT_H_ | 6832 #endif // VM_OBJECT_H_ |
| OLD | NEW |