| Index: runtime/vm/raw_object_snapshot.cc
|
| diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
|
| index affe4d8c780c68ff1697d94d7ff5a504cbc28070..348ca6d2844bc717bb4d731d9eb65fdeda7649be 100644
|
| --- a/runtime/vm/raw_object_snapshot.cc
|
| +++ b/runtime/vm/raw_object_snapshot.cc
|
| @@ -1816,37 +1816,227 @@ RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader,
|
| }
|
|
|
|
|
| -RawInternalByteArray* InternalByteArray::ReadFrom(SnapshotReader* reader,
|
| - intptr_t object_id,
|
| - intptr_t tags,
|
| - Snapshot::Kind kind) {
|
| +template<typename HandleT, typename RawT, typename ElementT>
|
| +RawT* ByteArray::ReadFromImpl(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;
|
| - InternalByteArray& result =
|
| - InternalByteArray::ZoneHandle(reader->isolate(),
|
| - InternalByteArray::New(len, space));
|
| + HandleT& result =
|
| + HandleT::ZoneHandle(reader->isolate(), HandleT::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<uint8_t>(i, reader->Read<uint8_t>());
|
| + for (intptr_t i = 0; i < len; ++i) {
|
| + result.SetAt(i, reader->Read<ElementT>());
|
| }
|
| return result.raw();
|
| }
|
|
|
|
|
| -RawExternalByteArray* ExternalByteArray::ReadFrom(SnapshotReader* reader,
|
| +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,
|
| intptr_t object_id,
|
| intptr_t tags,
|
| Snapshot::Kind kind) {
|
| UNREACHABLE();
|
| - return ExternalByteArray::null();
|
| + 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();
|
| }
|
|
|
|
|
| @@ -1883,30 +2073,272 @@ void RawByteArray::WriteTo(SnapshotWriter* writer,
|
| }
|
|
|
|
|
| -void RawInternalByteArray::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,
|
| intptr_t object_id,
|
| Snapshot::Kind kind) {
|
| ByteArrayWriteTo(writer,
|
| object_id,
|
| kind,
|
| - ObjectStore::kInternalByteArrayClass,
|
| + ObjectStore::kUint8ArrayClass,
|
| ptr()->tags_,
|
| ptr()->length_,
|
| - ptr()->data());
|
| + reinterpret_cast<uint8_t*>(ptr()->data_));
|
| }
|
|
|
|
|
| -void RawExternalByteArray::WriteTo(SnapshotWriter* writer,
|
| +void RawInt16Array::WriteTo(SnapshotWriter* writer,
|
| intptr_t object_id,
|
| Snapshot::Kind kind) {
|
| - // Serialize as an internal byte array.
|
| ByteArrayWriteTo(writer,
|
| object_id,
|
| kind,
|
| - ObjectStore::kInternalByteArrayClass,
|
| + 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,
|
| ptr()->tags_,
|
| ptr()->length_,
|
| - ptr()->external_data_->data());
|
| + reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
|
| }
|
|
|
|
|
|
|