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

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

Issue 12303013: Simd128Float32, Simd128Mask, and Simd128Float32List additions for dart:scalarlist (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporating Kasper's review Created 7 years, 10 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 4739 matching lines...) Expand 10 before | Expand all | Expand 10 after
4750 } 4750 }
4751 4751
4752 static const int kDefaultInitialCapacity = 4; 4752 static const int kDefaultInitialCapacity = 4;
4753 4753
4754 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 4754 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
4755 friend class Array; 4755 friend class Array;
4756 friend class Class; 4756 friend class Class;
4757 }; 4757 };
4758 4758
4759 4759
4760 class Simd128Float32 : public Instance {
4761 public:
4762 static RawSimd128Float32* New(float value0, float value1, float value2,
4763 float value3, Heap::Space space = Heap::kNew);
4764 static RawSimd128Float32* New(simd_value_t value,
4765 Heap::Space space = Heap::kNew);
4766 float x() const;
4767 float y() const;
4768 float z() const;
4769 float w() const;
4770
4771 void set_x(float x) const;
4772 void set_y(float y) const;
4773 void set_z(float z) const;
4774 void set_w(float w) const;
4775
4776 simd_value_t value() const;
4777 void set_value(simd_value_t value) const;
4778
4779 static intptr_t InstanceSize() {
4780 return RoundedAllocationSize(sizeof(RawSimd128Float32));
4781 }
4782
4783 static intptr_t value_offset() {
4784 return OFFSET_OF(RawSimd128Float32, value_);
4785 }
4786
4787 private:
4788 HEAP_OBJECT_IMPLEMENTATION(Simd128Float32, Instance);
srdjan 2013/02/21 21:43:25 FINAL_HEAP_OBJECT_IMPLEMENTATION
Cutch 2013/02/22 03:30:55 Done.
4789 friend class Class;
4790 };
4791
4792
4793 class Simd128Mask : public Instance {
4794 public:
4795 static RawSimd128Mask* New(uint32_t value0, uint32_t value1, uint32_t value2,
4796 uint32_t value3, Heap::Space space = Heap::kNew);
4797 uint32_t x() const;
4798 uint32_t y() const;
4799 uint32_t z() const;
4800 uint32_t w() const;
4801
4802 void set_x(uint32_t x) const;
4803 void set_y(uint32_t y) const;
4804 void set_z(uint32_t z) const;
4805 void set_w(uint32_t w) const;
4806
4807 static intptr_t InstanceSize() {
4808 return RoundedAllocationSize(sizeof(RawSimd128Mask));
4809 }
4810
4811 static intptr_t value_offset() {
4812 return OFFSET_OF(RawSimd128Mask, value_);
4813 }
4814
4815 private:
4816 HEAP_OBJECT_IMPLEMENTATION(Simd128Mask, Instance);
srdjan 2013/02/21 21:43:25 FINAL_HEAP_OBJECT_IMPLEMENTATION
Cutch 2013/02/22 03:30:55 Done.
4817 friend class Class;
4818 };
4819
4820
4760 class ByteArray : public Instance { 4821 class ByteArray : public Instance {
4761 public: 4822 public:
4762 intptr_t Length() const { 4823 intptr_t Length() const {
4763 ASSERT(!IsNull()); 4824 ASSERT(!IsNull());
4764 return Smi::Value(raw_ptr()->length_); 4825 return Smi::Value(raw_ptr()->length_);
4765 } 4826 }
4766 4827
4767 static intptr_t length_offset() { 4828 static intptr_t length_offset() {
4768 return OFFSET_OF(RawByteArray, length_); 4829 return OFFSET_OF(RawByteArray, length_);
4769 } 4830 }
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
5290 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); 5351 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
5291 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; 5352 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset;
5292 } 5353 }
5293 5354
5294 FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint64Array, ByteArray); 5355 FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint64Array, ByteArray);
5295 friend class ByteArray; 5356 friend class ByteArray;
5296 friend class Class; 5357 friend class Class;
5297 }; 5358 };
5298 5359
5299 5360
5361 class Simd128Float32Array : public ByteArray {
5362 public:
5363 intptr_t ByteLength() const {
5364 return Length() * kBytesPerElement;
5365 }
5366
5367 simd_value_t At(intptr_t index) const {
5368 ASSERT((index >= 0) && (index < Length()));
5369 simd_value_t* load_ptr = &raw_ptr()->data_[index];
5370 return simd_value_safe_load(load_ptr);
5371 }
5372
5373 void SetAt(intptr_t index, simd_value_t value) const {
5374 ASSERT((index >= 0) && (index < Length()));
5375 simd_value_t* store_ptr = &raw_ptr()->data_[index];
5376 simd_value_safe_store(store_ptr, value);
5377 }
5378
5379 static const intptr_t kBytesPerElement = 16;
5380 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
5381
5382 static intptr_t data_offset() {
5383 return OFFSET_OF(RawSimd128Float32Array, data_);
5384 }
5385
5386 static intptr_t InstanceSize() {
5387 ASSERT(sizeof(RawSimd128Float32Array) ==
5388 OFFSET_OF(RawSimd128Float32Array, data_));
5389 return 0;
5390 }
5391
5392 static intptr_t InstanceSize(intptr_t len) {
5393 ASSERT(0 <= len && len <= kMaxElements);
5394 return RoundedAllocationSize(
5395 sizeof(RawSimd128Float32Array) + (len * kBytesPerElement));
5396 }
5397
5398 static RawSimd128Float32Array* New(intptr_t len,
5399 Heap::Space space = Heap::kNew);
5400 static RawSimd128Float32Array* New(const simd_value_t* data,
5401 intptr_t len,
5402 Heap::Space space = Heap::kNew);
5403
5404 private:
5405 uint8_t* ByteAddr(intptr_t byte_offset) const {
5406 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
5407 return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset;
5408 }
5409
5410 FINAL_HEAP_OBJECT_IMPLEMENTATION(Simd128Float32Array, ByteArray);
5411 friend class ByteArray;
5412 friend class Class;
5413 };
5414
5415
5300 class Float32Array : public ByteArray { 5416 class Float32Array : public ByteArray {
5301 public: 5417 public:
5302 intptr_t ByteLength() const { 5418 intptr_t ByteLength() const {
5303 return Length() * kBytesPerElement; 5419 return Length() * kBytesPerElement;
5304 } 5420 }
5305 5421
5306 float At(intptr_t index) const { 5422 float At(intptr_t index) const {
5307 ASSERT((index >= 0) && (index < Length())); 5423 ASSERT((index >= 0) && (index < Length()));
5308 return raw_ptr()->data_[index]; 5424 return raw_ptr()->data_[index];
5309 } 5425 }
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
5889 void SetPeer(void* peer) const { 6005 void SetPeer(void* peer) const {
5890 raw_ptr()->peer_ = peer; 6006 raw_ptr()->peer_ = peer;
5891 } 6007 }
5892 6008
5893 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array, ByteArray); 6009 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array, ByteArray);
5894 friend class ByteArray; 6010 friend class ByteArray;
5895 friend class Class; 6011 friend class Class;
5896 }; 6012 };
5897 6013
5898 6014
6015 class ExternalSimd128Float32Array : public ByteArray {
6016 public:
6017 intptr_t ByteLength() const {
6018 return Length() * kBytesPerElement;
6019 }
6020
6021 simd_value_t At(intptr_t index) const {
6022 ASSERT((index >= 0) && (index < Length()));
6023 simd_value_t* load_ptr = &raw_ptr()->data_[index];
6024 return simd_value_safe_load(load_ptr);
6025 }
6026
6027 void SetAt(intptr_t index, simd_value_t value) const {
6028 ASSERT((index >= 0) && (index < Length()));
6029 simd_value_t* store_ptr = &raw_ptr()->data_[index];
6030 simd_value_safe_store(store_ptr, value);
6031 }
6032
6033
6034 simd_value_t* GetData() const {
6035 return raw_ptr()->data_;
6036 }
6037
6038 void* GetPeer() const {
6039 return raw_ptr()->peer_;
6040 }
6041
6042 static const intptr_t kBytesPerElement = 16;
6043
6044 // Since external arrays may be serialized to non-external ones,
6045 // enforce the same maximum element count.
6046 static const intptr_t kMaxElements = Simd128Float32Array::kMaxElements;
6047
6048 static intptr_t InstanceSize() {
6049 return RoundedAllocationSize(sizeof(RawExternalSimd128Float32Array));
6050 }
6051
6052 static RawExternalSimd128Float32Array* New(simd_value_t* data,
6053 intptr_t len,
6054 Heap::Space space = Heap::kNew);
6055
6056 private:
6057 uint8_t* ByteAddr(intptr_t byte_offset) const {
6058 ASSERT((byte_offset >= 0) && (byte_offset < ByteLength()));
6059 uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_);
6060 return data + byte_offset;
6061 }
6062
6063 void SetData(simd_value_t* data) const {
6064 raw_ptr()->data_ = data;
6065 }
6066
6067 void SetPeer(void* peer) const {
6068 raw_ptr()->peer_ = peer;
6069 }
6070
6071 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalSimd128Float32Array, ByteArray);
6072 friend class ByteArray;
6073 friend class Class;
6074 };
6075
6076
5899 class ExternalFloat32Array : public ByteArray { 6077 class ExternalFloat32Array : public ByteArray {
5900 public: 6078 public:
5901 intptr_t ByteLength() const { 6079 intptr_t ByteLength() const {
5902 return Length() * kBytesPerElement; 6080 return Length() * kBytesPerElement;
5903 } 6081 }
5904 6082
5905 float At(intptr_t index) const { 6083 float At(intptr_t index) const {
5906 ASSERT((index >= 0) && (index < Length())); 6084 ASSERT((index >= 0) && (index < Length()));
5907 return raw_ptr()->data_[index]; 6085 return raw_ptr()->data_[index];
5908 } 6086 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 6537
6360 6538
6361 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6539 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6362 intptr_t index) { 6540 intptr_t index) {
6363 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6541 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6364 } 6542 }
6365 6543
6366 } // namespace dart 6544 } // namespace dart
6367 6545
6368 #endif // VM_OBJECT_H_ 6546 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698