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

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: s/materialize/Materialize 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
« no previous file with comments | « runtime/vm/locations.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4928 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 4939 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
4940 friend class Array; 4940 friend class Array;
4941 friend class Class; 4941 friend class Class;
4942 }; 4942 };
4943 4943
4944 4944
4945 class Float32x4 : public Instance { 4945 class Float32x4 : public Instance {
4946 public: 4946 public:
4947 static RawFloat32x4* New(float value0, float value1, float value2, 4947 static RawFloat32x4* New(float value0, float value1, float value2,
4948 float value3, Heap::Space space = Heap::kNew); 4948 float value3, Heap::Space space = Heap::kNew);
4949 static RawFloat32x4* New(simd_value_t value, Heap::Space space = Heap::kNew); 4949 static RawFloat32x4* New(simd128_value_t value,
4950 Heap::Space space = Heap::kNew);
4950 4951
4951 float x() const; 4952 float x() const;
4952 float y() const; 4953 float y() const;
4953 float z() const; 4954 float z() const;
4954 float w() const; 4955 float w() const;
4955 4956
4956 void set_x(float x) const; 4957 void set_x(float x) const;
4957 void set_y(float y) const; 4958 void set_y(float y) const;
4958 void set_z(float z) const; 4959 void set_z(float z) const;
4959 void set_w(float w) const; 4960 void set_w(float w) const;
4960 4961
4961 simd_value_t value() const; 4962 simd128_value_t value() const;
4962 void set_value(simd_value_t value) const; 4963 void set_value(simd128_value_t value) const;
4963 4964
4964 static intptr_t InstanceSize() { 4965 static intptr_t InstanceSize() {
4965 return RoundedAllocationSize(sizeof(RawFloat32x4)); 4966 return RoundedAllocationSize(sizeof(RawFloat32x4));
4966 } 4967 }
4967 4968
4968 static intptr_t value_offset() { 4969 static intptr_t value_offset() {
4969 return OFFSET_OF(RawFloat32x4, value_); 4970 return OFFSET_OF(RawFloat32x4, value_);
4970 } 4971 }
4971 4972
4972 private: 4973 private:
4973 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance); 4974 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance);
4974 friend class Class; 4975 friend class Class;
4975 }; 4976 };
4976 4977
4977 4978
4978 class Uint32x4 : public Instance { 4979 class Uint32x4 : public Instance {
4979 public: 4980 public:
4980 static RawUint32x4* New(uint32_t value0, uint32_t value1, uint32_t value2, 4981 static RawUint32x4* New(uint32_t value0, uint32_t value1, uint32_t value2,
4981 uint32_t value3, Heap::Space space = Heap::kNew); 4982 uint32_t value3, Heap::Space space = Heap::kNew);
4982 static RawUint32x4* New(simd_value_t value, Heap::Space space = Heap::kNew); 4983 static RawUint32x4* New(simd128_value_t value,
4984 Heap::Space space = Heap::kNew);
4983 4985
4984 uint32_t x() const; 4986 uint32_t x() const;
4985 uint32_t y() const; 4987 uint32_t y() const;
4986 uint32_t z() const; 4988 uint32_t z() const;
4987 uint32_t w() const; 4989 uint32_t w() const;
4988 4990
4989 void set_x(uint32_t x) const; 4991 void set_x(uint32_t x) const;
4990 void set_y(uint32_t y) const; 4992 void set_y(uint32_t y) const;
4991 void set_z(uint32_t z) const; 4993 void set_z(uint32_t z) const;
4992 void set_w(uint32_t w) const; 4994 void set_w(uint32_t w) const;
4993 4995
4994 simd_value_t value() const; 4996 simd128_value_t value() const;
4995 void set_value(simd_value_t value) const; 4997 void set_value(simd128_value_t value) const;
4996 4998
4997 static intptr_t InstanceSize() { 4999 static intptr_t InstanceSize() {
4998 return RoundedAllocationSize(sizeof(RawUint32x4)); 5000 return RoundedAllocationSize(sizeof(RawUint32x4));
4999 } 5001 }
5000 5002
5001 static intptr_t value_offset() { 5003 static intptr_t value_offset() {
5002 return OFFSET_OF(RawUint32x4, value_); 5004 return OFFSET_OF(RawUint32x4, value_);
5003 } 5005 }
5004 5006
5005 private: 5007 private:
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
5738 friend class Class; 5740 friend class Class;
5739 }; 5741 };
5740 5742
5741 5743
5742 class Float32x4Array : public ByteArray { 5744 class Float32x4Array : public ByteArray {
5743 public: 5745 public:
5744 intptr_t ByteLength() const { 5746 intptr_t ByteLength() const {
5745 return Length() * kBytesPerElement; 5747 return Length() * kBytesPerElement;
5746 } 5748 }
5747 5749
5748 simd_value_t At(intptr_t index) const { 5750 simd128_value_t At(intptr_t index) const {
5749 ASSERT((index >= 0) && (index < Length())); 5751 ASSERT((index >= 0) && (index < Length()));
5750 simd_value_t* load_ptr = &raw_ptr()->data_[index]; 5752 return raw_ptr()->data_[index];
5751 return simd_value_safe_load(load_ptr);
5752 } 5753 }
5753 5754
5754 void SetAt(intptr_t index, simd_value_t value) const { 5755 void SetAt(intptr_t index, simd128_value_t value) const {
5755 ASSERT((index >= 0) && (index < Length())); 5756 ASSERT((index >= 0) && (index < Length()));
5756 simd_value_t* store_ptr = &raw_ptr()->data_[index]; 5757 raw_ptr()->data_[index] = value;
5757 simd_value_safe_store(store_ptr, value);
5758 } 5758 }
5759 5759
5760 static const intptr_t kBytesPerElement = 16; 5760 static const intptr_t kBytesPerElement = 16;
5761 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; 5761 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
5762 5762
5763 static intptr_t data_offset() { 5763 static intptr_t data_offset() {
5764 return OFFSET_OF(RawFloat32x4Array, data_); 5764 return OFFSET_OF(RawFloat32x4Array, data_);
5765 } 5765 }
5766 5766
5767 static intptr_t InstanceSize() { 5767 static intptr_t InstanceSize() {
5768 ASSERT(sizeof(RawFloat32x4Array) == 5768 ASSERT(sizeof(RawFloat32x4Array) ==
5769 OFFSET_OF(RawFloat32x4Array, data_)); 5769 OFFSET_OF(RawFloat32x4Array, data_));
5770 return 0; 5770 return 0;
5771 } 5771 }
5772 5772
5773 static intptr_t InstanceSize(intptr_t len) { 5773 static intptr_t InstanceSize(intptr_t len) {
5774 ASSERT(0 <= len && len <= kMaxElements); 5774 ASSERT(0 <= len && len <= kMaxElements);
5775 return RoundedAllocationSize( 5775 return RoundedAllocationSize(
5776 sizeof(RawFloat32x4Array) + (len * kBytesPerElement)); 5776 sizeof(RawFloat32x4Array) + (len * kBytesPerElement));
5777 } 5777 }
5778 5778
5779 static RawFloat32x4Array* New(intptr_t len, 5779 static RawFloat32x4Array* New(intptr_t len,
5780 Heap::Space space = Heap::kNew); 5780 Heap::Space space = Heap::kNew);
5781 static RawFloat32x4Array* New(const simd_value_t* data, 5781 static RawFloat32x4Array* New(const simd128_value_t* data,
5782 intptr_t len, 5782 intptr_t len,
5783 Heap::Space space = Heap::kNew); 5783 Heap::Space space = Heap::kNew);
5784 5784
5785 private: 5785 private:
5786 uint8_t* ByteAddr(intptr_t byte_offset) const { 5786 uint8_t* ByteAddr(intptr_t byte_offset) const {
5787 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); 5787 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
5788 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; 5788 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset;
5789 } 5789 }
5790 5790
5791 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4Array, ByteArray); 5791 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4Array, ByteArray);
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
6392 friend class Class; 6392 friend class Class;
6393 }; 6393 };
6394 6394
6395 6395
6396 class ExternalFloat32x4Array : public ByteArray { 6396 class ExternalFloat32x4Array : public ByteArray {
6397 public: 6397 public:
6398 intptr_t ByteLength() const { 6398 intptr_t ByteLength() const {
6399 return Length() * kBytesPerElement; 6399 return Length() * kBytesPerElement;
6400 } 6400 }
6401 6401
6402 simd_value_t At(intptr_t index) const { 6402 simd128_value_t At(intptr_t index) const {
6403 ASSERT((index >= 0) && (index < Length())); 6403 ASSERT((index >= 0) && (index < Length()));
6404 simd_value_t* load_ptr = &raw_ptr()->data_[index]; 6404 return raw_ptr()->data_[index];
6405 return simd_value_safe_load(load_ptr);
6406 } 6405 }
6407 6406
6408 void SetAt(intptr_t index, simd_value_t value) const { 6407 void SetAt(intptr_t index, simd128_value_t value) const {
6409 ASSERT((index >= 0) && (index < Length())); 6408 ASSERT((index >= 0) && (index < Length()));
6410 simd_value_t* store_ptr = &raw_ptr()->data_[index]; 6409 raw_ptr()->data_[index] = value;
6411 simd_value_safe_store(store_ptr, value);
6412 } 6410 }
6413 6411
6414 6412
6415 simd_value_t* GetData() const { 6413 simd128_value_t* GetData() const {
6416 return raw_ptr()->data_; 6414 return raw_ptr()->data_;
6417 } 6415 }
6418 6416
6419 void* GetPeer() const { 6417 void* GetPeer() const {
6420 return raw_ptr()->peer_; 6418 return raw_ptr()->peer_;
6421 } 6419 }
6422 6420
6423 static const intptr_t kBytesPerElement = 16; 6421 static const intptr_t kBytesPerElement = 16;
6424 6422
6425 // Since external arrays may be serialized to non-external ones, 6423 // Since external arrays may be serialized to non-external ones,
6426 // enforce the same maximum element count. 6424 // enforce the same maximum element count.
6427 static const intptr_t kMaxElements = Float32x4Array::kMaxElements; 6425 static const intptr_t kMaxElements = Float32x4Array::kMaxElements;
6428 6426
6429 static intptr_t InstanceSize() { 6427 static intptr_t InstanceSize() {
6430 return RoundedAllocationSize(sizeof(RawExternalFloat32x4Array)); 6428 return RoundedAllocationSize(sizeof(RawExternalFloat32x4Array));
6431 } 6429 }
6432 6430
6433 static RawExternalFloat32x4Array* New(simd_value_t* data, 6431 static RawExternalFloat32x4Array* New(simd128_value_t* data, intptr_t len,
6434 intptr_t len, 6432 Heap::Space space = Heap::kNew);
6435 Heap::Space space = Heap::kNew);
6436 6433
6437 private: 6434 private:
6438 uint8_t* ByteAddr(intptr_t byte_offset) const { 6435 uint8_t* ByteAddr(intptr_t byte_offset) const {
6439 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); 6436 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
6440 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_); 6437 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_);
6441 return data + byte_offset; 6438 return data + byte_offset;
6442 } 6439 }
6443 6440
6444 void SetData(simd_value_t* data) const { 6441 void SetData(simd128_value_t* data) const {
6445 raw_ptr()->data_ = data; 6442 raw_ptr()->data_ = data;
6446 } 6443 }
6447 6444
6448 void SetPeer(void* peer) const { 6445 void SetPeer(void* peer) const {
6449 raw_ptr()->peer_ = peer; 6446 raw_ptr()->peer_ = peer;
6450 } 6447 }
6451 6448
6452 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32x4Array, ByteArray); 6449 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32x4Array, ByteArray);
6453 friend class ByteArray; 6450 friend class ByteArray;
6454 friend class Class; 6451 friend class Class;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
6934 6931
6935 6932
6936 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6933 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6937 intptr_t index) { 6934 intptr_t index) {
6938 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6935 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6939 } 6936 }
6940 6937
6941 } // namespace dart 6938 } // namespace dart
6942 6939
6943 #endif // VM_OBJECT_H_ 6940 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/locations.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698