Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
dart::FullSnapshotWriter Class Reference

#include <app_snapshot.h>

Public Member Functions

 FullSnapshotWriter (Snapshot::Kind kind, NonStreamingWriteStream *vm_snapshot_data, NonStreamingWriteStream *isolate_snapshot_data, ImageWriter *vm_image_writer, ImageWriter *iso_image_writer)
 
 ~FullSnapshotWriter ()
 
void WriteFullSnapshot (GrowableArray< LoadingUnitSerializationData * > *data=nullptr)
 
void WriteUnitSnapshot (GrowableArray< LoadingUnitSerializationData * > *units, LoadingUnitSerializationData *unit, uint32_t program_hash)
 
intptr_t VmIsolateSnapshotSize () const
 
intptr_t IsolateSnapshotSize () const
 

Static Public Attributes

static constexpr intptr_t kInitialSize = 64 * KB
 

Detailed Description

Definition at line 108 of file app_snapshot.h.

Constructor & Destructor Documentation

◆ FullSnapshotWriter()

dart::FullSnapshotWriter::FullSnapshotWriter ( Snapshot::Kind  kind,
NonStreamingWriteStream vm_snapshot_data,
NonStreamingWriteStream isolate_snapshot_data,
ImageWriter vm_image_writer,
ImageWriter iso_image_writer 
)

Definition at line 9644 of file app_snapshot.cc.

9650 : thread_(Thread::Current()),
9651 kind_(kind),
9652 vm_snapshot_data_(vm_snapshot_data),
9653 isolate_snapshot_data_(isolate_snapshot_data),
9654 vm_isolate_snapshot_size_(0),
9655 isolate_snapshot_size_(0),
9656 vm_image_writer_(vm_image_writer),
9657 isolate_image_writer_(isolate_image_writer) {
9658 ASSERT(isolate_group() != nullptr);
9659 ASSERT(heap() != nullptr);
9660 ObjectStore* object_store = isolate_group()->object_store();
9661 ASSERT(object_store != nullptr);
9662
9663#if defined(DEBUG)
9664 isolate_group()->ValidateClassTable();
9665#endif // DEBUG
9666
9667#if defined(DART_PRECOMPILER)
9668 if (FLAG_write_v8_snapshot_profile_to != nullptr) {
9669 profile_writer_ = new (zone()) V8SnapshotProfileWriter(zone());
9670 }
9671#endif
9672}
ObjectStore * object_store() const
Definition: isolate.h:510
static Thread * Current()
Definition: thread.h:362
#define ASSERT(E)
const uint8_t * isolate_snapshot_data
Definition: gen_snapshot.cc:69
const uint8_t * vm_snapshot_data
Definition: main_impl.cc:52

◆ ~FullSnapshotWriter()

dart::FullSnapshotWriter::~FullSnapshotWriter ( )

Definition at line 9674 of file app_snapshot.cc.

9674{}

Member Function Documentation

◆ IsolateSnapshotSize()

intptr_t dart::FullSnapshotWriter::IsolateSnapshotSize ( ) const
inline

Definition at line 126 of file app_snapshot.h.

126{ return isolate_snapshot_size_; }

◆ VmIsolateSnapshotSize()

intptr_t dart::FullSnapshotWriter::VmIsolateSnapshotSize ( ) const
inline

Definition at line 125 of file app_snapshot.h.

125{ return vm_isolate_snapshot_size_; }

◆ WriteFullSnapshot()

void dart::FullSnapshotWriter::WriteFullSnapshot ( GrowableArray< LoadingUnitSerializationData * > *  data = nullptr)

Definition at line 9794 of file app_snapshot.cc.

9795 {
9796 ZoneGrowableArray<Object*>* objects;
9797 if (vm_snapshot_data_ != nullptr) {
9798 objects = WriteVMSnapshot();
9799 } else {
9800 objects = nullptr;
9801 }
9802
9803 if (isolate_snapshot_data_ != nullptr) {
9804 WriteProgramSnapshot(objects, data);
9805 }
9806
9807 if (FLAG_print_snapshot_sizes) {
9808 OS::Print("VMIsolate(CodeSize): %" Pd "\n", clustered_vm_size_);
9809 OS::Print("Isolate(CodeSize): %" Pd "\n", clustered_isolate_size_);
9810 OS::Print("ReadOnlyData(CodeSize): %" Pd "\n", mapped_data_size_);
9811 OS::Print("Instructions(CodeSize): %" Pd "\n", mapped_text_size_);
9812 OS::Print("Total(CodeSize): %" Pd "\n",
9813 clustered_vm_size_ + clustered_isolate_size_ + mapped_data_size_ +
9814 mapped_text_size_);
9815 OS::Print("VMIsolate(HeapSize): %" Pd "\n", heap_vm_size_);
9816 OS::Print("Isolate(HeapSize): %" Pd "\n", heap_isolate_size_);
9817 OS::Print("Total(HeapSize): %" Pd "\n", heap_vm_size_ + heap_isolate_size_);
9818 }
9819
9820#if defined(DART_PRECOMPILER)
9821 if (FLAG_write_v8_snapshot_profile_to != nullptr) {
9822 profile_writer_->Write(FLAG_write_v8_snapshot_profile_to);
9823 }
9824#endif
9825}
static void Print(const char *format,...) PRINTF_ATTRIBUTE(1
static int8_t data[kExtLength]
#define Pd
Definition: globals.h:408

◆ WriteUnitSnapshot()

void dart::FullSnapshotWriter::WriteUnitSnapshot ( GrowableArray< LoadingUnitSerializationData * > *  units,
LoadingUnitSerializationData unit,
uint32_t  program_hash 
)

Definition at line 9756 of file app_snapshot.cc.

9759 {
9760 TIMELINE_DURATION(thread(), Isolate, "WriteUnitSnapshot");
9761
9762 Serializer serializer(thread(), kind_, isolate_snapshot_data_,
9763 isolate_image_writer_, /*vm=*/false, profile_writer_);
9764 serializer.set_loading_units(units);
9765 serializer.set_current_loading_unit_id(unit->id());
9766
9767 serializer.ReserveHeader();
9768 serializer.WriteVersionAndFeatures(false);
9769 serializer.Write(program_hash);
9770
9771 UnitSerializationRoots roots(unit);
9772 unit->set_objects(serializer.Serialize(&roots));
9773
9774 serializer.FillHeader(serializer.kind());
9775 clustered_isolate_size_ = serializer.bytes_written();
9776
9777 if (Snapshot::IncludesCode(kind_)) {
9778 isolate_image_writer_->SetProfileWriter(profile_writer_);
9779 isolate_image_writer_->Write(serializer.stream(), false);
9780#if defined(DART_PRECOMPILER)
9781 isolate_image_writer_->DumpStatistics();
9782#endif
9783
9784 mapped_data_size_ += isolate_image_writer_->data_size();
9785 mapped_text_size_ += isolate_image_writer_->text_size();
9786 isolate_image_writer_->ResetOffsets();
9787 isolate_image_writer_->ClearProfileWriter();
9788 }
9789
9790 // The clustered part + the direct mapped data part.
9791 isolate_snapshot_size_ = serializer.bytes_written();
9792}
void Write(NonStreamingWriteStream *clustered_stream, bool vm)
void SetProfileWriter(V8SnapshotProfileWriter *profile_writer)
intptr_t text_size() const
intptr_t data_size() const
static bool IncludesCode(Kind kind)
Definition: snapshot.h:67
#define TIMELINE_DURATION(thread, stream, name)
Definition: timeline.h:39

Member Data Documentation

◆ kInitialSize

constexpr intptr_t dart::FullSnapshotWriter::kInitialSize = 64 * KB
staticconstexpr

Definition at line 110 of file app_snapshot.h.


The documentation for this class was generated from the following files: