Index: runtime/vm/object.h |
=================================================================== |
--- runtime/vm/object.h (revision 20600) |
+++ runtime/vm/object.h (working copy) |
@@ -2182,7 +2182,6 @@ |
static RawLibrary* MathLibrary(); |
static RawLibrary* MirrorsLibrary(); |
static RawLibrary* NativeWrappersLibrary(); |
- static RawLibrary* ScalarlistLibrary(); |
static RawLibrary* TypedDataLibrary(); |
static RawLibrary* UriLibrary(); |
static RawLibrary* UtfLibrary(); |
@@ -5205,1263 +5204,6 @@ |
}; |
-class ByteArray : public Instance { |
- public: |
- intptr_t Length() const { |
- ASSERT(!IsNull()); |
- return Smi::Value(raw_ptr()->length_); |
- } |
- |
- static intptr_t length_offset() { |
- return OFFSET_OF(RawByteArray, length_); |
- } |
- |
- virtual intptr_t ByteLength() const; |
- |
- virtual void* GetPeer() const { return NULL; } |
- virtual uint8_t* ByteAddr(intptr_t byte_offset) const; |
- |
- FinalizablePersistentHandle* AddFinalizer( |
- void* peer, Dart_WeakPersistentHandleFinalizer callback) const; |
- |
- static void Copy(void* dst, |
- const ByteArray& src, |
- intptr_t src_offset, |
- intptr_t length); |
- |
- static void Copy(const ByteArray& dst, |
- intptr_t dst_offset, |
- const void* src, |
- intptr_t length); |
- |
- static void Copy(const ByteArray& dst, |
- intptr_t dst_offset, |
- const ByteArray& src, |
- intptr_t src_offset, |
- intptr_t length); |
- |
- protected: |
- virtual void SetPeer(void* peer) const { } |
- |
- template<typename HandleT, typename RawT> |
- static RawT* NewImpl(intptr_t class_id, |
- intptr_t len, |
- Heap::Space space); |
- |
- template<typename HandleT, typename RawT, typename ElementT> |
- static RawT* NewImpl(intptr_t class_id, |
- const ElementT* data, |
- intptr_t len, |
- Heap::Space space); |
- |
- template<typename HandleT, typename RawT, typename ElementT> |
- static RawT* NewExternalImpl(intptr_t class_id, |
- ElementT* data, |
- intptr_t len, |
- Heap::Space space); |
- |
- template<typename HandleT, typename RawT, typename ElementT> |
- static RawT* ReadFromImpl(SnapshotReader* reader, |
- intptr_t object_id, |
- intptr_t tags, |
- Snapshot::Kind kind); |
- |
- void SetLength(intptr_t value) const { |
- raw_ptr()->length_ = Smi::New(value); |
- } |
- |
- private: |
- HEAP_OBJECT_IMPLEMENTATION(ByteArray, Instance); |
- friend class Class; |
-}; |
- |
- |
-class Int8Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length(); |
- } |
- |
- int8_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int8_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 1; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawInt8Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawInt8Array) == OFFSET_OF(RawInt8Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawInt8Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawInt8Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawInt8Array* New(const int8_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(Int8Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Uint8Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length(); |
- } |
- |
- uint8_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint8_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 1; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawUint8Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawUint8Array) == OFFSET_OF(RawUint8Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawUint8Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawUint8Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawUint8Array* New(const uint8_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(Uint8Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Uint8ClampedArray : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length(); |
- } |
- |
- uint8_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint8_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 1; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawUint8ClampedArray, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawUint8ClampedArray) == |
- OFFSET_OF(RawUint8ClampedArray, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawUint8ClampedArray) + (len * kBytesPerElement)); |
- } |
- |
- static RawUint8ClampedArray* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawUint8ClampedArray* New(const uint8_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(Uint8ClampedArray, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Int16Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int16_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int16_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 2; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawInt16Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawInt16Array) == OFFSET_OF(RawInt16Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawInt16Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawInt16Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawInt16Array* New(const int16_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(Int16Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Uint16Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- uint16_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint16_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 2; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawUint16Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawUint16Array) == OFFSET_OF(RawUint16Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawUint16Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawUint16Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawUint16Array* New(const uint16_t* data, |
- intptr_t len, |
- Heap::Space space = Heap::kNew); |
- |
- 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; |
- } |
- |
- private: |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint16Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Int32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int32_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int32_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawInt32Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawInt32Array) == OFFSET_OF(RawInt32Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawInt32Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawInt32Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawInt32Array* New(const int32_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(Int32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Uint32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- uint32_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint32_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawUint32Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawUint32Array) == OFFSET_OF(RawUint32Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawUint32Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawUint32Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawUint32Array* New(const uint32_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(Uint32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Int64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int64_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int64_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawInt64Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawInt64Array) == OFFSET_OF(RawInt64Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawInt64Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawInt64Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawInt64Array* New(const int64_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(Int64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Uint64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * sizeof(uint64_t); |
- } |
- |
- uint64_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint64_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawUint64Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawUint64Array) == OFFSET_OF(RawUint64Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawUint64Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawUint64Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawUint64Array* New(const uint64_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(Uint64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Float32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- float At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, float value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawFloat32Array, data_); |
- } |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawFloat32Array) == OFFSET_OF(RawFloat32Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawFloat32Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawFloat32Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawFloat32Array* New(const float* 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(Float32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class Float64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- double At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, double value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
- |
- static intptr_t InstanceSize() { |
- ASSERT(sizeof(RawFloat64Array) == OFFSET_OF(RawFloat64Array, data_)); |
- return 0; |
- } |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawFloat64Array, data_); |
- } |
- |
- static intptr_t InstanceSize(intptr_t len) { |
- ASSERT(0 <= len && len <= kMaxElements); |
- return RoundedAllocationSize( |
- sizeof(RawFloat64Array) + (len * kBytesPerElement)); |
- } |
- |
- static RawFloat64Array* New(intptr_t len, |
- Heap::Space space = Heap::kNew); |
- static RawFloat64Array* New(const double* 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(Float64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalInt8Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int8_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int8_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- int8_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 1; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Int8Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalInt8Array)); |
- } |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawExternalInt8Array, data_); |
- } |
- |
- static RawExternalInt8Array* New(int8_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(int8_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalUint8Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- uint8_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, uint8_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- uint8_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 1; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Uint8Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalUint8Array)); |
- } |
- |
- static intptr_t data_offset() { |
- return OFFSET_OF(RawExternalUint8Array, data_); |
- } |
- |
- static RawExternalUint8Array* New(uint8_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(uint8_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
- friend class TokenStream; |
-}; |
- |
- |
-class ExternalUint8ClampedArray : public ExternalUint8Array { |
- public: |
- static RawExternalUint8ClampedArray* New(uint8_t* data, |
- intptr_t len, |
- Heap::Space space = Heap::kNew); |
- |
- private: |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8ClampedArray, |
- ExternalUint8Array); |
- friend class Class; |
-}; |
- |
- |
-class ExternalInt16Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int16_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int16_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- int16_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 2; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Int16Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalInt16Array)); |
- } |
- |
- static RawExternalInt16Array* New(int16_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(int16_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalUint16Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int16_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int16_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- uint16_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 2; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Uint16Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalUint16Array)); |
- } |
- |
- static RawExternalUint16Array* New(uint16_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(uint16_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalInt32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int32_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int32_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- int32_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Int32Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalInt32Array)); |
- } |
- |
- static RawExternalInt32Array* New(int32_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(int32_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalInt32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalUint32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int32_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int32_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- uint32_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Uint32Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalUint32Array)); |
- } |
- |
- static RawExternalUint32Array* New(uint32_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(uint32_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalInt64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int64_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int64_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- int64_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Int64Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalInt64Array)); |
- } |
- |
- static RawExternalInt64Array* New(int64_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(int64_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalInt64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalUint64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- int64_t At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, int64_t value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- uint64_t* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Uint64Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalUint64Array)); |
- } |
- |
- static RawExternalUint64Array* New(uint64_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(uint64_t* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalFloat32Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- float At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, float value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- float* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 4; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Float32Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalFloat32Array)); |
- } |
- |
- static RawExternalFloat32Array* New(float* 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(float* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
-class ExternalFloat64Array : public ByteArray { |
- public: |
- intptr_t ByteLength() const { |
- return Length() * kBytesPerElement; |
- } |
- |
- double At(intptr_t index) const { |
- ASSERT((index >= 0) && (index < Length())); |
- return raw_ptr()->data_[index]; |
- } |
- |
- void SetAt(intptr_t index, double value) const { |
- ASSERT((index >= 0) && (index < Length())); |
- raw_ptr()->data_[index] = value; |
- } |
- |
- double* GetData() const { |
- return raw_ptr()->data_; |
- } |
- |
- void* GetPeer() const { |
- return raw_ptr()->peer_; |
- } |
- |
- static const intptr_t kBytesPerElement = 8; |
- |
- // Since external arrays may be serialized to non-external ones, |
- // enforce the same maximum element count. |
- static const intptr_t kMaxElements = Float64Array::kMaxElements; |
- |
- static intptr_t InstanceSize() { |
- return RoundedAllocationSize(sizeof(RawExternalFloat64Array)); |
- } |
- |
- static RawExternalFloat64Array* New(double* 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(double* data) const { |
- raw_ptr()->data_ = data; |
- } |
- |
- void SetPeer(void* peer) const { |
- raw_ptr()->peer_ = peer; |
- } |
- |
- FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat64Array, ByteArray); |
- friend class ByteArray; |
- friend class Class; |
-}; |
- |
- |
// DartFunction represents the abstract Dart class 'Function'. |
class DartFunction : public Instance { |
private: |
@@ -6769,12 +5511,14 @@ |
intptr_t Instance::GetNativeField(Isolate* isolate, int index) const { |
ASSERT(IsValidNativeIndex(index)); |
NoGCScope no_gc; |
- RawIntPtrArray* native_fields = |
- reinterpret_cast<RawIntPtrArray*>(*NativeFieldsAddr()); |
- if (native_fields == IntPtrArray::null()) { |
+ RawTypedData* native_fields = |
+ reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
+ if (native_fields == TypedData::null()) { |
return 0; |
} |
- return native_fields->ptr()->data_[index]; |
+ intptr_t byte_offset = index * sizeof(intptr_t); |
+ return *reinterpret_cast<intptr_t*>(native_fields->ptr()->data_ + |
+ byte_offset); |
} |