Chromium Code Reviews| Index: runtime/vm/object.h |
| diff --git a/runtime/vm/object.h b/runtime/vm/object.h |
| index c5e6aae2a8c87e712acc1b0f8dc2ddb9a6965085..7530029aef27c3569a9e801badc7678f78dfa5fb 100644 |
| --- a/runtime/vm/object.h |
| +++ b/runtime/vm/object.h |
| @@ -4757,6 +4757,67 @@ class GrowableObjectArray : public Instance { |
| }; |
| +class Simd128Float32 : public Instance { |
| + public: |
| + static RawSimd128Float32* New(float value0, float value1, float value2, |
| + float value3, Heap::Space space = Heap::kNew); |
| + static RawSimd128Float32* New(simd_value_t value, |
| + Heap::Space space = Heap::kNew); |
| + float x() const; |
| + float y() const; |
| + float z() const; |
| + float w() const; |
| + |
| + void set_x(float x) const; |
| + void set_y(float y) const; |
| + void set_z(float z) const; |
| + void set_w(float w) const; |
| + |
| + simd_value_t value() const; |
| + void set_value(simd_value_t value) const; |
| + |
| + static intptr_t InstanceSize() { |
| + return RoundedAllocationSize(sizeof(RawSimd128Float32)); |
| + } |
| + |
| + static intptr_t value_offset() { |
| + return OFFSET_OF(RawSimd128Float32, value_); |
| + } |
| + |
| + private: |
| + HEAP_OBJECT_IMPLEMENTATION(Simd128Float32, Instance); |
|
srdjan
2013/02/21 21:43:25
FINAL_HEAP_OBJECT_IMPLEMENTATION
Cutch
2013/02/22 03:30:55
Done.
|
| + friend class Class; |
| +}; |
| + |
| + |
| +class Simd128Mask : public Instance { |
| + public: |
| + static RawSimd128Mask* New(uint32_t value0, uint32_t value1, uint32_t value2, |
| + uint32_t value3, Heap::Space space = Heap::kNew); |
| + uint32_t x() const; |
| + uint32_t y() const; |
| + uint32_t z() const; |
| + uint32_t w() const; |
| + |
| + void set_x(uint32_t x) const; |
| + void set_y(uint32_t y) const; |
| + void set_z(uint32_t z) const; |
| + void set_w(uint32_t w) const; |
| + |
| + static intptr_t InstanceSize() { |
| + return RoundedAllocationSize(sizeof(RawSimd128Mask)); |
| + } |
| + |
| + static intptr_t value_offset() { |
| + return OFFSET_OF(RawSimd128Mask, value_); |
| + } |
| + |
| + private: |
| + HEAP_OBJECT_IMPLEMENTATION(Simd128Mask, Instance); |
|
srdjan
2013/02/21 21:43:25
FINAL_HEAP_OBJECT_IMPLEMENTATION
Cutch
2013/02/22 03:30:55
Done.
|
| + friend class Class; |
| +}; |
| + |
| + |
| class ByteArray : public Instance { |
| public: |
| intptr_t Length() const { |
| @@ -5297,6 +5358,61 @@ class Uint64Array : public ByteArray { |
| }; |
| +class Simd128Float32Array : public ByteArray { |
| + public: |
| + intptr_t ByteLength() const { |
| + return Length() * kBytesPerElement; |
| + } |
| + |
| + simd_value_t At(intptr_t index) const { |
| + ASSERT((index >= 0) && (index < Length())); |
| + simd_value_t* load_ptr = &raw_ptr()->data_[index]; |
| + return simd_value_safe_load(load_ptr); |
| + } |
| + |
| + void SetAt(intptr_t index, simd_value_t value) const { |
| + ASSERT((index >= 0) && (index < Length())); |
| + simd_value_t* store_ptr = &raw_ptr()->data_[index]; |
| + simd_value_safe_store(store_ptr, value); |
| + } |
| + |
| + static const intptr_t kBytesPerElement = 16; |
| + static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| + |
| + static intptr_t data_offset() { |
| + return OFFSET_OF(RawSimd128Float32Array, data_); |
| + } |
| + |
| + static intptr_t InstanceSize() { |
| + ASSERT(sizeof(RawSimd128Float32Array) == |
| + OFFSET_OF(RawSimd128Float32Array, data_)); |
| + return 0; |
| + } |
| + |
| + static intptr_t InstanceSize(intptr_t len) { |
| + ASSERT(0 <= len && len <= kMaxElements); |
| + return RoundedAllocationSize( |
| + sizeof(RawSimd128Float32Array) + (len * kBytesPerElement)); |
| + } |
| + |
| + static RawSimd128Float32Array* New(intptr_t len, |
| + Heap::Space space = Heap::kNew); |
| + static RawSimd128Float32Array* New(const simd_value_t* data, |
| + intptr_t len, |
| + Heap::Space space = Heap::kNew); |
| + |
| + private: |
| + uint8_t* ByteAddr(intptr_t byte_offset) const { |
| + ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); |
| + return reinterpret_cast<uint8_t*>(&raw_ptr()->data_) + byte_offset; |
| + } |
| + |
| + FINAL_HEAP_OBJECT_IMPLEMENTATION(Simd128Float32Array, ByteArray); |
| + friend class ByteArray; |
| + friend class Class; |
| +}; |
| + |
| + |
| class Float32Array : public ByteArray { |
| public: |
| intptr_t ByteLength() const { |
| @@ -5896,6 +6012,68 @@ class ExternalUint64Array : public ByteArray { |
| }; |
| +class ExternalSimd128Float32Array : public ByteArray { |
| + public: |
| + intptr_t ByteLength() const { |
| + return Length() * kBytesPerElement; |
| + } |
| + |
| + simd_value_t At(intptr_t index) const { |
| + ASSERT((index >= 0) && (index < Length())); |
| + simd_value_t* load_ptr = &raw_ptr()->data_[index]; |
| + return simd_value_safe_load(load_ptr); |
| + } |
| + |
| + void SetAt(intptr_t index, simd_value_t value) const { |
| + ASSERT((index >= 0) && (index < Length())); |
| + simd_value_t* store_ptr = &raw_ptr()->data_[index]; |
| + simd_value_safe_store(store_ptr, value); |
| + } |
| + |
| + |
| + simd_value_t* GetData() const { |
| + return raw_ptr()->data_; |
| + } |
| + |
| + void* GetPeer() const { |
| + return raw_ptr()->peer_; |
| + } |
| + |
| + static const intptr_t kBytesPerElement = 16; |
| + |
| + // Since external arrays may be serialized to non-external ones, |
| + // enforce the same maximum element count. |
| + static const intptr_t kMaxElements = Simd128Float32Array::kMaxElements; |
| + |
| + static intptr_t InstanceSize() { |
| + return RoundedAllocationSize(sizeof(RawExternalSimd128Float32Array)); |
| + } |
| + |
| + static RawExternalSimd128Float32Array* New(simd_value_t* data, |
| + intptr_t len, |
| + Heap::Space space = Heap::kNew); |
| + |
| + private: |
| + uint8_t* ByteAddr(intptr_t byte_offset) const { |
| + ASSERT((byte_offset >= 0) && (byte_offset < ByteLength())); |
| + uint8_t* data = reinterpret_cast<uint8_t*>(raw_ptr()->data_); |
| + return data + byte_offset; |
| + } |
| + |
| + void SetData(simd_value_t* data) const { |
| + raw_ptr()->data_ = data; |
| + } |
| + |
| + void SetPeer(void* peer) const { |
| + raw_ptr()->peer_ = peer; |
| + } |
| + |
| + FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalSimd128Float32Array, ByteArray); |
| + friend class ByteArray; |
| + friend class Class; |
| +}; |
| + |
| + |
| class ExternalFloat32Array : public ByteArray { |
| public: |
| intptr_t ByteLength() const { |