| Index: runtime/vm/raw_object_snapshot.cc
|
| diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
|
| index eb04e7ddda4a4eefe54535e34b4cb16d6b45d25f..627412782a9478bdda8ac5ae119e8e7a9f4aa802 100644
|
| --- a/runtime/vm/raw_object_snapshot.cc
|
| +++ b/runtime/vm/raw_object_snapshot.cc
|
| @@ -1813,227 +1813,37 @@ RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader,
|
| }
|
|
|
|
|
| -template<typename HandleT, typename RawT, typename ElementT>
|
| -RawT* ByteArray::ReadFromImpl(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| +RawInternalByteArray* InternalByteArray::ReadFrom(SnapshotReader* reader,
|
| + intptr_t object_id,
|
| + intptr_t tags,
|
| + Snapshot::Kind kind) {
|
| ASSERT(reader != NULL);
|
|
|
| + // Read the length so that we can determine instance size to allocate.
|
| intptr_t len = reader->ReadSmiValue();
|
| Heap::Space space = (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew;
|
| - HandleT& result =
|
| - HandleT::ZoneHandle(reader->isolate(), HandleT::New(len, space));
|
| + InternalByteArray& result =
|
| + InternalByteArray::ZoneHandle(reader->isolate(),
|
| + InternalByteArray::New(len, space));
|
| reader->AddBackwardReference(object_id, &result);
|
|
|
| // Set the object tags.
|
| result.set_tags(tags);
|
|
|
| // Setup the array elements.
|
| - for (intptr_t i = 0; i < len; ++i) {
|
| - result.SetAt(i, reader->Read<ElementT>());
|
| + for (intptr_t i = 0; i < len; i++) {
|
| + result.SetAt<uint8_t>(i, reader->Read<uint8_t>());
|
| }
|
| return result.raw();
|
| }
|
|
|
|
|
| -RawInt8Array* Int8Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Int8Array, RawInt8Array, int8_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawUint8Array* Uint8Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Uint8Array, RawUint8Array, uint8_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawInt16Array* Int16Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Int16Array, RawInt16Array, int16_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawUint16Array* Uint16Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Uint16Array, RawUint16Array, uint16_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawInt32Array* Int32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Int32Array, RawInt32Array, int32_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawUint32Array* Uint32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Uint32Array, RawUint32Array, uint32_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawInt64Array* Int64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Int64Array, RawInt64Array, int64_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawUint64Array* Uint64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Uint64Array, RawUint64Array, uint64_t>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawFloat32Array* Float32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Float32Array, RawFloat32Array, float>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawFloat64Array* Float64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - return ReadFromImpl<Float64Array, RawFloat64Array, double>(reader,
|
| - object_id,
|
| - tags,
|
| - kind);
|
| -}
|
| -
|
| -
|
| -RawExternalInt8Array* ExternalInt8Array::ReadFrom(SnapshotReader* reader,
|
| +RawExternalByteArray* ExternalByteArray::ReadFrom(SnapshotReader* reader,
|
| intptr_t object_id,
|
| intptr_t tags,
|
| Snapshot::Kind kind) {
|
| UNREACHABLE();
|
| - return ExternalInt8Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalUint8Array* ExternalUint8Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalUint8Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalInt16Array* ExternalInt16Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalInt16Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalUint16Array* ExternalUint16Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalUint16Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalInt32Array* ExternalInt32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalInt32Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalUint32Array* ExternalUint32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalUint32Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalInt64Array* ExternalInt64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalInt64Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalUint64Array* ExternalUint64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalUint64Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalFloat32Array* ExternalFloat32Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalFloat32Array::null();
|
| -}
|
| -
|
| -
|
| -RawExternalFloat64Array* ExternalFloat64Array::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| - UNREACHABLE();
|
| - return ExternalFloat64Array::null();
|
| + return ExternalByteArray::null();
|
| }
|
|
|
|
|
| @@ -2070,272 +1880,30 @@ void RawByteArray::WriteTo(SnapshotWriter* writer,
|
| }
|
|
|
|
|
| -void RawInt8Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt8ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawUint8Array::WriteTo(SnapshotWriter* writer,
|
| +void RawInternalByteArray::WriteTo(SnapshotWriter* writer,
|
| intptr_t object_id,
|
| Snapshot::Kind kind) {
|
| ByteArrayWriteTo(writer,
|
| object_id,
|
| kind,
|
| - ObjectStore::kUint8ArrayClass,
|
| + ObjectStore::kInternalByteArrayClass,
|
| ptr()->tags_,
|
| ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| + ptr()->data());
|
| }
|
|
|
|
|
| -void RawInt16Array::WriteTo(SnapshotWriter* writer,
|
| +void RawExternalByteArray::WriteTo(SnapshotWriter* writer,
|
| intptr_t object_id,
|
| Snapshot::Kind kind) {
|
| + // Serialize as an internal byte array.
|
| ByteArrayWriteTo(writer,
|
| object_id,
|
| kind,
|
| - ObjectStore::kInt16ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawUint16Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint16ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawInt32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawUint32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawInt64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt64ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawUint64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint64ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawFloat32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kFloat32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawFloat64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kFloat64ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->data_));
|
| -}
|
| -
|
| -
|
| -void RawExternalInt8Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt8ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalUint8Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external int8 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint8ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalInt16Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external int16 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt16ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalUint16Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external uint16 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint16ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalInt32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external int32 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalUint32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external uint32 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalInt64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external int64 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kInt64ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalUint64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external uint64 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kUint64ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalFloat32Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external float32 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kFloat32ArrayClass,
|
| - ptr()->tags_,
|
| - ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| -}
|
| -
|
| -
|
| -void RawExternalFloat64Array::WriteTo(SnapshotWriter* writer,
|
| - intptr_t object_id,
|
| - Snapshot::Kind kind) {
|
| - // Serialize as a non-external float64 array.
|
| - ByteArrayWriteTo(writer,
|
| - object_id,
|
| - kind,
|
| - ObjectStore::kFloat64ArrayClass,
|
| + ObjectStore::kInternalByteArrayClass,
|
| ptr()->tags_,
|
| ptr()->length_,
|
| - reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| + ptr()->external_data_->data());
|
| }
|
|
|
|
|
|
|