| Index: runtime/vm/raw_object.h
|
| ===================================================================
|
| --- runtime/vm/raw_object.h (revision 19594)
|
| +++ runtime/vm/raw_object.h (working copy)
|
| @@ -87,6 +87,8 @@
|
| V(ExternalFloat32x4Array) \
|
| V(ExternalFloat32Array) \
|
| V(ExternalFloat64Array) \
|
| + V(TypedData) \
|
| + V(ExternalTypedData) \
|
| V(Stacktrace) \
|
| V(JSRegExp) \
|
| V(WeakProperty) \
|
| @@ -102,6 +104,19 @@
|
| V(ExternalOneByteString) \
|
| V(ExternalTwoByteString)
|
|
|
| +#define CLASS_LIST_TYPED_DATA(V) \
|
| + V(Int8Array) \
|
| + V(Uint8Array) \
|
| + V(Uint8ClampedArray) \
|
| + V(Int16Array) \
|
| + V(Uint16Array) \
|
| + V(Int32Array) \
|
| + V(Uint32Array) \
|
| + V(Int64Array) \
|
| + V(Uint64Array) \
|
| + V(Float32Array) \
|
| + V(Float64Array) \
|
| +
|
| #define CLASS_LIST_FOR_HANDLES(V) \
|
| CLASS_LIST_NO_OBJECT_OR_STRING(V) \
|
| V(String)
|
| @@ -133,6 +148,16 @@
|
| CLASS_LIST(DEFINE_OBJECT_KIND)
|
| #undef DEFINE_OBJECT_KIND
|
|
|
| +#define DEFINE_OBJECT_KIND(clazz) \
|
| + kTypedData##clazz##Cid,
|
| +CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND)
|
| +#undef DEFINE_OBJECT_KIND
|
| +
|
| +#define DEFINE_OBJECT_KIND(clazz) \
|
| + kExternalTypedData##clazz##Cid,
|
| +CLASS_LIST_TYPED_DATA(DEFINE_OBJECT_KIND)
|
| +#undef DEFINE_OBJECT_KIND
|
| +
|
| // The following entries do not describe a predefined class, but instead
|
| // are class indexes for pre-allocated instance (Null, dynamic and Void).
|
| kNullCid,
|
| @@ -361,7 +386,11 @@
|
| static bool IsBuiltinListClassId(intptr_t index);
|
| static bool IsByteArrayClassId(intptr_t index);
|
| static bool IsExternalByteArrayClassId(intptr_t index);
|
| + static bool IsTypedDataClassId(intptr_t index);
|
| + static bool IsExternalTypedDataClassId(intptr_t index);
|
|
|
| + static intptr_t NumberOfTypedDataClasses();
|
| +
|
| private:
|
| uword tags_; // Various object tags (bits).
|
|
|
| @@ -396,6 +425,7 @@
|
| friend class Array;
|
| friend class FreeListElement;
|
| friend class GCMarker;
|
| + friend class ExternalTypedData;
|
| friend class Heap;
|
| friend class HeapProfiler;
|
| friend class HeapProfilerRootVisitor;
|
| @@ -405,12 +435,15 @@
|
| friend class HeapTraceVisitor;
|
| friend class MarkingVisitor;
|
| friend class Object;
|
| + friend class RawExternalTypedData;
|
| friend class RawInstructions;
|
| friend class RawInstance;
|
| + friend class RawTypedData;
|
| friend class Scavenger;
|
| friend class SnapshotReader;
|
| friend class SnapshotWriter;
|
| friend class String;
|
| + friend class TypedData;
|
|
|
| DISALLOW_ALLOCATION();
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
|
| @@ -1354,6 +1387,32 @@
|
| #endif // ARCH_IS_32_BIT
|
|
|
|
|
| +class RawTypedData : public RawInstance {
|
| + RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData);
|
| +
|
| + protected:
|
| + RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
|
| + RawSmi* length_;
|
| + RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
|
| +
|
| + // Variable length data follows here.
|
| + uint8_t data_[0];
|
| +};
|
| +
|
| +
|
| +class RawExternalTypedData : public RawInstance {
|
| + RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData);
|
| +
|
| + protected:
|
| + RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
|
| + RawSmi* length_;
|
| + RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
|
| +
|
| + uint8_t* data_;
|
| + void* peer_;
|
| +};
|
| +
|
| +
|
| class RawByteArray : public RawInstance {
|
| RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray);
|
|
|
| @@ -1744,10 +1803,11 @@
|
| kExternalFloat32x4ArrayCid == kByteArrayCid + 22 &&
|
| kExternalFloat32ArrayCid == kByteArrayCid + 23 &&
|
| kExternalFloat64ArrayCid == kByteArrayCid + 24 &&
|
| - kStacktraceCid == kByteArrayCid + 25);
|
| + kTypedDataCid == kByteArrayCid + 25);
|
| return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid);
|
| }
|
|
|
| +
|
| inline bool RawObject::IsExternalByteArrayClassId(intptr_t index) {
|
| // Make sure this function is updated when new ByteArray types are added.
|
| ASSERT(kExternalUint8ArrayCid == kExternalInt8ArrayCid + 1 &&
|
| @@ -1761,10 +1821,64 @@
|
| kExternalFloat32x4ArrayCid == kExternalInt8ArrayCid + 9 &&
|
| kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 10 &&
|
| kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 11 &&
|
| - kStacktraceCid == kExternalInt8ArrayCid + 12);
|
| + kTypedDataCid == kExternalInt8ArrayCid + 12);
|
| return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid);
|
| }
|
|
|
| +
|
| +inline bool RawObject::IsTypedDataClassId(intptr_t index) {
|
| + // Make sure this is updated when new TypedData types are added.
|
| + ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 &&
|
| + kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 &&
|
| + kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 &&
|
| + kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 &&
|
| + kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 &&
|
| + kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 &&
|
| + kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 &&
|
| + kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 &&
|
| + kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 &&
|
| + kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 &&
|
| + kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11);
|
| + return (index >= kTypedDataInt8ArrayCid &&
|
| + index <= kTypedDataFloat64ArrayCid);
|
| +}
|
| +
|
| +
|
| +inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) {
|
| + // Make sure this is updated when new ExternalTypedData types are added.
|
| + ASSERT((kExternalTypedDataUint8ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 1) &&
|
| + (kExternalTypedDataUint8ClampedArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 2) &&
|
| + (kExternalTypedDataInt16ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 3) &&
|
| + (kExternalTypedDataUint16ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 4) &&
|
| + (kExternalTypedDataInt32ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 5) &&
|
| + (kExternalTypedDataUint32ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 6) &&
|
| + (kExternalTypedDataInt64ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 7) &&
|
| + (kExternalTypedDataUint64ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 8) &&
|
| + (kExternalTypedDataFloat32ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 9) &&
|
| + (kExternalTypedDataFloat64ArrayCid ==
|
| + kExternalTypedDataInt8ArrayCid + 10) &&
|
| + (kNullCid == kExternalTypedDataInt8ArrayCid + 11));
|
| + return (index >= kExternalTypedDataInt8ArrayCid &&
|
| + index <= kExternalTypedDataFloat64ArrayCid);
|
| +}
|
| +
|
| +
|
| +inline intptr_t RawObject::NumberOfTypedDataClasses() {
|
| + // Make sure this is updated when new TypedData types are added.
|
| + ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayCid + 11);
|
| + ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 11);
|
| + return (kNullCid - kTypedDataInt8ArrayCid);
|
| +}
|
| +
|
| } // namespace dart
|
|
|
| #endif // VM_RAW_OBJECT_H_
|
|
|