Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: runtime/vm/object.h

Issue 12871015: SIMD plumbing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix FPU register move instruction on x64 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 4882 matching lines...) Expand 10 before | Expand all | Expand 10 after
4893 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 4893 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
4894 friend class Array; 4894 friend class Array;
4895 friend class Class; 4895 friend class Class;
4896 }; 4896 };
4897 4897
4898 4898
4899 class Float32x4 : public Instance { 4899 class Float32x4 : public Instance {
4900 public: 4900 public:
4901 static RawFloat32x4* New(float value0, float value1, float value2, 4901 static RawFloat32x4* New(float value0, float value1, float value2,
4902 float value3, Heap::Space space = Heap::kNew); 4902 float value3, Heap::Space space = Heap::kNew);
4903 static RawFloat32x4* New(simd_value_t value, Heap::Space space = Heap::kNew); 4903 static RawFloat32x4* New(simd128_value_t value,
4904 Heap::Space space = Heap::kNew);
4904 4905
4905 float x() const; 4906 float x() const;
4906 float y() const; 4907 float y() const;
4907 float z() const; 4908 float z() const;
4908 float w() const; 4909 float w() const;
4909 4910
4910 void set_x(float x) const; 4911 void set_x(float x) const;
4911 void set_y(float y) const; 4912 void set_y(float y) const;
4912 void set_z(float z) const; 4913 void set_z(float z) const;
4913 void set_w(float w) const; 4914 void set_w(float w) const;
4914 4915
4915 simd_value_t value() const; 4916 simd128_value_t value() const;
4916 void set_value(simd_value_t value) const; 4917 void set_value(simd128_value_t value) const;
4917 4918
4918 static intptr_t InstanceSize() { 4919 static intptr_t InstanceSize() {
4919 return RoundedAllocationSize(sizeof(RawFloat32x4)); 4920 return RoundedAllocationSize(sizeof(RawFloat32x4));
4920 } 4921 }
4921 4922
4922 static intptr_t value_offset() { 4923 static intptr_t value_offset() {
4923 return OFFSET_OF(RawFloat32x4, value_); 4924 return OFFSET_OF(RawFloat32x4, value_);
4924 } 4925 }
4925 4926
4926 private: 4927 private:
4927 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance); 4928 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance);
4928 friend class Class; 4929 friend class Class;
4929 }; 4930 };
4930 4931
4931 4932
4932 class Uint32x4 : public Instance { 4933 class Uint32x4 : public Instance {
4933 public: 4934 public:
4934 static RawUint32x4* New(uint32_t value0, uint32_t value1, uint32_t value2, 4935 static RawUint32x4* New(uint32_t value0, uint32_t value1, uint32_t value2,
4935 uint32_t value3, Heap::Space space = Heap::kNew); 4936 uint32_t value3, Heap::Space space = Heap::kNew);
4936 static RawUint32x4* New(simd_value_t value, Heap::Space space = Heap::kNew); 4937 static RawUint32x4* New(simd128_value_t value,
4938 Heap::Space space = Heap::kNew);
4937 4939
4938 uint32_t x() const; 4940 uint32_t x() const;
4939 uint32_t y() const; 4941 uint32_t y() const;
4940 uint32_t z() const; 4942 uint32_t z() const;
4941 uint32_t w() const; 4943 uint32_t w() const;
4942 4944
4943 void set_x(uint32_t x) const; 4945 void set_x(uint32_t x) const;
4944 void set_y(uint32_t y) const; 4946 void set_y(uint32_t y) const;
4945 void set_z(uint32_t z) const; 4947 void set_z(uint32_t z) const;
4946 void set_w(uint32_t w) const; 4948 void set_w(uint32_t w) const;
4947 4949
4948 simd_value_t value() const; 4950 simd128_value_t value() const;
4949 void set_value(simd_value_t value) const; 4951 void set_value(simd128_value_t value) const;
4950 4952
4951 static intptr_t InstanceSize() { 4953 static intptr_t InstanceSize() {
4952 return RoundedAllocationSize(sizeof(RawUint32x4)); 4954 return RoundedAllocationSize(sizeof(RawUint32x4));
4953 } 4955 }
4954 4956
4955 static intptr_t value_offset() { 4957 static intptr_t value_offset() {
4956 return OFFSET_OF(RawUint32x4, value_); 4958 return OFFSET_OF(RawUint32x4, value_);
4957 } 4959 }
4958 4960
4959 private: 4961 private:
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
5692 friend class Class; 5694 friend class Class;
5693 }; 5695 };
5694 5696
5695 5697
5696 class Float32x4Array : public ByteArray { 5698 class Float32x4Array : public ByteArray {
5697 public: 5699 public:
5698 intptr_t ByteLength() const { 5700 intptr_t ByteLength() const {
5699 return Length() * kBytesPerElement; 5701 return Length() * kBytesPerElement;
5700 } 5702 }
5701 5703
5702 simd_value_t At(intptr_t index) const { 5704 simd128_value_t At(intptr_t index) const {
5703 ASSERT((index >= 0) && (index < Length())); 5705 ASSERT((index >= 0) && (index < Length()));
5704 simd_value_t* load_ptr = &raw_ptr()->data_[index]; 5706 return raw_ptr()->data_[index];
5705 return simd_value_safe_load(load_ptr);
5706 } 5707 }
5707 5708
5708 void SetAt(intptr_t index, simd_value_t value) const { 5709 void SetAt(intptr_t index, simd128_value_t value) const {
5709 ASSERT((index >= 0) && (index < Length())); 5710 ASSERT((index >= 0) && (index < Length()));
5710 simd_value_t* store_ptr = &raw_ptr()->data_[index]; 5711 raw_ptr()->data_[index] = value;
5711 simd_value_safe_store(store_ptr, value);
5712 } 5712 }
5713 5713
5714 static const intptr_t kBytesPerElement = 16; 5714 static const intptr_t kBytesPerElement = 16;
5715 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 5715 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
5716 5716
5717 static intptr_t data_offset() { 5717 static intptr_t data_offset() {
5718 return OFFSET_OF(RawFloat32x4Array, data_); 5718 return OFFSET_OF(RawFloat32x4Array, data_);
5719 } 5719 }
5720 5720
5721 static intptr_t InstanceSize() { 5721 static intptr_t InstanceSize() {
5722 ASSERT(sizeof(RawFloat32x4Array) == 5722 ASSERT(sizeof(RawFloat32x4Array) ==
5723 OFFSET_OF(RawFloat32x4Array, data_)); 5723 OFFSET_OF(RawFloat32x4Array, data_));
5724 return 0; 5724 return 0;
5725 } 5725 }
5726 5726
5727 static intptr_t InstanceSize(intptr_t len) { 5727 static intptr_t InstanceSize(intptr_t len) {
5728 ASSERT(0 <= len && len <= kMaxElements); 5728 ASSERT(0 <= len && len <= kMaxElements);
5729 return RoundedAllocationSize( 5729 return RoundedAllocationSize(
5730 sizeof(RawFloat32x4Array) + (len * kBytesPerElement)); 5730 sizeof(RawFloat32x4Array) + (len * kBytesPerElement));
5731 } 5731 }
5732 5732
5733 static RawFloat32x4Array* New(intptr_t len, 5733 static RawFloat32x4Array* New(intptr_t len,
5734 Heap::Space space = Heap::kNew); 5734 Heap::Space space = Heap::kNew);
5735 static RawFloat32x4Array* New(const simd_value_t* data, 5735 static RawFloat32x4Array* New(const simd128_value_t* data,
5736 intptr_t len, 5736 intptr_t len,
5737 Heap::Space space = Heap::kNew); 5737 Heap::Space space = Heap::kNew);
5738 5738
5739 private: 5739 private:
5740 uint8_t* ByteAddr(intptr_t byte_offset) const { 5740 uint8_t* ByteAddr(intptr_t byte_offset) const {
5741 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); 5741 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
5742 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; 5742 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset;
5743 } 5743 }
5744 5744
5745 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4Array, ByteArray); 5745 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4Array, ByteArray);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
6346 friend class Class; 6346 friend class Class;
6347 }; 6347 };
6348 6348
6349 6349
6350 class ExternalFloat32x4Array : public ByteArray { 6350 class ExternalFloat32x4Array : public ByteArray {
6351 public: 6351 public:
6352 intptr_t ByteLength() const { 6352 intptr_t ByteLength() const {
6353 return Length() * kBytesPerElement; 6353 return Length() * kBytesPerElement;
6354 } 6354 }
6355 6355
6356 simd_value_t At(intptr_t index) const { 6356 simd128_value_t At(intptr_t index) const {
6357 ASSERT((index >= 0) && (index < Length())); 6357 ASSERT((index >= 0) && (index < Length()));
6358 simd_value_t* load_ptr = &raw_ptr()->data_[index]; 6358 return raw_ptr()->data_[index];
6359 return simd_value_safe_load(load_ptr);
6360 } 6359 }
6361 6360
6362 void SetAt(intptr_t index, simd_value_t value) const { 6361 void SetAt(intptr_t index, simd128_value_t value) const {
6363 ASSERT((index >= 0) && (index < Length())); 6362 ASSERT((index >= 0) && (index < Length()));
6364 simd_value_t* store_ptr = &raw_ptr()->data_[index]; 6363 raw_ptr()->data_[index] = value;
6365 simd_value_safe_store(store_ptr, value);
6366 } 6364 }
6367 6365
6368 6366
6369 simd_value_t* GetData() const { 6367 simd128_value_t* GetData() const {
6370 return raw_ptr()->data_; 6368 return raw_ptr()->data_;
6371 } 6369 }
6372 6370
6373 void* GetPeer() const { 6371 void* GetPeer() const {
6374 return raw_ptr()->peer_; 6372 return raw_ptr()->peer_;
6375 } 6373 }
6376 6374
6377 static const intptr_t kBytesPerElement = 16; 6375 static const intptr_t kBytesPerElement = 16;
6378 6376
6379 // Since external arrays may be serialized to non-external ones, 6377 // Since external arrays may be serialized to non-external ones,
6380 // enforce the same maximum element count. 6378 // enforce the same maximum element count.
6381 static const intptr_t kMaxElements = Float32x4Array::kMaxElements; 6379 static const intptr_t kMaxElements = Float32x4Array::kMaxElements;
6382 6380
6383 static intptr_t InstanceSize() { 6381 static intptr_t InstanceSize() {
6384 return RoundedAllocationSize(sizeof(RawExternalFloat32x4Array)); 6382 return RoundedAllocationSize(sizeof(RawExternalFloat32x4Array));
6385 } 6383 }
6386 6384
6387 static RawExternalFloat32x4Array* New(simd_value_t* data, 6385 static RawExternalFloat32x4Array* New(simd128_value_t* data, intptr_t len,
6388 intptr_t len, 6386 Heap::Space space = Heap::kNew);
6389 Heap::Space space = Heap::kNew);
6390 6387
6391 private: 6388 private:
6392 uint8_t* ByteAddr(intptr_t byte_offset) const { 6389 uint8_t* ByteAddr(intptr_t byte_offset) const {
6393 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); 6390 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
6394 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_); 6391 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_);
6395 return data + byte_offset; 6392 return data + byte_offset;
6396 } 6393 }
6397 6394
6398 void SetData(simd_value_t* data) const { 6395 void SetData(simd128_value_t* data) const {
6399 raw_ptr()->data_ = data; 6396 raw_ptr()->data_ = data;
6400 } 6397 }
6401 6398
6402 void SetPeer(void* peer) const { 6399 void SetPeer(void* peer) const {
6403 raw_ptr()->peer_ = peer; 6400 raw_ptr()->peer_ = peer;
6404 } 6401 }
6405 6402
6406 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32x4Array, ByteArray); 6403 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32x4Array, ByteArray);
6407 friend class ByteArray; 6404 friend class ByteArray;
6408 friend class Class; 6405 friend class Class;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
6888 6885
6889 6886
6890 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6887 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6891 intptr_t index) { 6888 intptr_t index) {
6892 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6889 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6893 } 6890 }
6894 6891
6895 } // namespace dart 6892 } // namespace dart
6896 6893
6897 #endif // VM_OBJECT_H_ 6894 #endif // VM_OBJECT_H_
OLDNEW
« runtime/vm/locations.h ('K') | « runtime/vm/locations.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698