Flutter Engine
The Flutter Engine
Public Member Functions | Private Member Functions | List of all members
dart::BlobImageWriter Class Reference

#include <image_snapshot.h>

Inheritance diagram for dart::BlobImageWriter:
dart::ImageWriter dart::ValueObject

Public Member Functions

 BlobImageWriter (Thread *thread, NonStreamingWriteStream *vm_instructions, NonStreamingWriteStream *isolate_instructions, Elf *debug_elf=nullptr, Elf *elf=nullptr)
 
- Public Member Functions inherited from dart::ImageWriter
 ImageWriter (Thread *thread, bool generates_assembly)
 
virtual ~ImageWriter ()
 
void ResetOffsets ()
 
void PrepareForSerialization (GrowableArray< ImageWriterCommand > *commands)
 
bool IsROSpace () const
 
int32_t GetTextOffsetFor (InstructionsPtr instructions, CodePtr code)
 
uint32_t GetDataOffsetFor (ObjectPtr raw_object)
 
uint32_t AddBytesToData (uint8_t *bytes, intptr_t length)
 
void Write (NonStreamingWriteStream *clustered_stream, bool vm)
 
intptr_t data_size () const
 
intptr_t text_size () const
 
intptr_t GetTextObjectCount () const
 
void GetTrampolineInfo (intptr_t *count, intptr_t *size) const
 
void DumpStatistics ()
 
void SetProfileWriter (V8SnapshotProfileWriter *profile_writer)
 
void ClearProfileWriter ()
 
void TraceInstructions (const Instructions &instructions)
 
const char * ObjectTypeForProfile (const Object &object) const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Private Member Functions

virtual void WriteBss (bool vm)
 
virtual void WriteROData (NonStreamingWriteStream *clustered_stream, bool vm)
 
virtual bool EnterSection (ProgramSection section, bool vm, intptr_t alignment, intptr_t *alignment_padding=nullptr)
 
virtual void ExitSection (ProgramSection name, bool vm, intptr_t size)
 
virtual intptr_t WriteTargetWord (word value)
 
virtual intptr_t WriteBytes (const void *bytes, intptr_t size)
 
virtual intptr_t Align (intptr_t alignment, intptr_t offset, intptr_t position)
 
virtual void FrameUnwindPrologue ()
 
virtual void FrameUnwindEpilogue ()
 

Additional Inherited Members

- Public Types inherited from dart::ImageWriter
enum class  ProgramSection { Text , Data , Bss , BuildId }
 
- Static Public Member Functions inherited from dart::ImageWriter
static intptr_t SizeInSnapshot (ObjectPtr object)
 
static intptr_t SizeInSnapshot (const Object &object)
 
static const char * TagObjectTypeAsReadOnly (Zone *zone, const char *type)
 
- Static Public Attributes inherited from dart::ImageWriter
static constexpr intptr_t kBssAlignment = compiler::target::kWordSize
 
static constexpr intptr_t kRODataAlignment = kObjectStartAlignment
 
static constexpr intptr_t kTextAlignment = kObjectStartAlignment
 
static constexpr intptr_t kNumProgramSections
 
- Protected Member Functions inherited from dart::ImageWriter
virtual void WriteBss (bool vm)=0
 
virtual void WriteROData (NonStreamingWriteStream *clustered_stream, bool vm)
 
void WriteText (bool vm)
 
void DumpInstructionStats ()
 
void DumpInstructionsSizes ()
 
virtual bool EnterSection (ProgramSection name, bool vm, intptr_t alignment, intptr_t *alignment_padding=nullptr)=0
 
virtual void ExitSection (ProgramSection name, bool vm, intptr_t size)=0
 
virtual void FrameUnwindPrologue ()=0
 
virtual void FrameUnwindEpilogue ()=0
 
virtual intptr_t WriteTargetWord (word value)=0
 
virtual intptr_t WriteBytes (const void *bytes, intptr_t size)=0
 
virtual intptr_t Align (intptr_t alignment, intptr_t offset, intptr_t position)=0
 
template<typename T >
intptr_t WriteFixed (T value)
 
intptr_t AlignWithBreakInstructions (intptr_t alignment, intptr_t offset)
 
- Static Protected Member Functions inherited from dart::ImageWriter
static const char * SectionSymbol (ProgramSection section, bool vm)
 
static uword GetMarkedTags (classid_t cid, intptr_t size, bool is_canonical=false)
 
static uword GetMarkedTags (const Object &obj)
 
- Protected Attributes inherited from dart::ImageWriter
Thread *const thread_
 
Zone *const zone_
 
intptr_t next_data_offset_
 
intptr_t next_text_offset_
 
GrowableArray< ObjectDataobjects_
 
GrowableArray< InstructionsDatainstructions_
 
IdSpace offset_space_ = IdSpace::kSnapshot
 
V8SnapshotProfileWriterprofile_writer_ = nullptr
 
const char *const image_type_
 
const char *const instructions_section_type_
 
const char *const instructions_type_
 
const char *const trampoline_type_
 
const char *const padding_type_
 

Detailed Description

Definition at line 845 of file image_snapshot.h.

Constructor & Destructor Documentation

◆ BlobImageWriter()

dart::BlobImageWriter::BlobImageWriter ( Thread thread,
NonStreamingWriteStream vm_instructions,
NonStreamingWriteStream isolate_instructions,
Elf *  debug_elf = nullptr,
Elf *  elf = nullptr 
)

Definition at line 1758 of file image_snapshot.cc.

1763 : ImageWriter(thread, /*generates_assembly=*/false),
1764#endif
1765 vm_instructions_(vm_instructions),
1766 isolate_instructions_(isolate_instructions),
1767 elf_(elf),
1768 debug_elf_(debug_elf) {
1769#if defined(DART_PRECOMPILER)
1770 ASSERT_EQUAL(FLAG_precompiled_mode, elf_ != nullptr);
1771 ASSERT(debug_elf_ == nullptr || debug_elf_->dwarf() != nullptr);
1772#else
1773 RELEASE_ASSERT(elf_ == nullptr);
1774#endif
1775}
#define ASSERT_EQUAL(expected, actual)
Definition: assert.h:309
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
ImageWriter(Thread *thread, bool generates_assembly)
#define ASSERT(E)

Member Function Documentation

◆ Align()

intptr_t dart::BlobImageWriter::Align ( intptr_t  alignment,
intptr_t  offset,
intptr_t  position 
)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1878 of file image_snapshot.cc.

1880 {
1881 const intptr_t stream_padding =
1882 current_section_stream_->Align(alignment, offset);
1883 // Double-check that the position has the same alignment.
1884 ASSERT_EQUAL(Utils::RoundUp(position, alignment, offset) - position,
1885 stream_padding);
1886 return stream_padding;
1887}
intptr_t Align(intptr_t alignment, intptr_t offset=0)
Definition: datastream.h:341
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120
SeparatedVector2 offset

◆ EnterSection()

bool dart::BlobImageWriter::EnterSection ( ProgramSection  section,
bool  vm,
intptr_t  alignment,
intptr_t *  alignment_padding = nullptr 
)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1810 of file image_snapshot.cc.

1813 {
1814#if defined(DART_PRECOMPILER)
1815 ASSERT_EQUAL(elf_ != nullptr, FLAG_precompiled_mode);
1816 ASSERT(current_relocations_ == nullptr);
1817 ASSERT(current_symbols_ == nullptr);
1818#endif
1819 ASSERT(section == ProgramSection::Data || current_section_stream_ == nullptr);
1820 switch (section) {
1822 current_section_stream_ =
1823 ASSERT_NOTNULL(vm ? vm_instructions_ : isolate_instructions_);
1824#if defined(DART_PRECOMPILER)
1825 current_relocations_ =
1826 new (zone_) ZoneGrowableArray<Elf::Relocation>(zone_, 0);
1827 current_symbols_ =
1828 new (zone_) ZoneGrowableArray<Elf::SymbolData>(zone_, 0);
1829#endif
1830 break;
1832 // The stream to use is passed into WriteROData and set there.
1833 ASSERT(current_section_stream_ != nullptr);
1834#if defined(DART_PRECOMPILER)
1835 current_relocations_ =
1836 new (zone_) ZoneGrowableArray<Elf::Relocation>(zone_, 0);
1837 current_symbols_ =
1838 new (zone_) ZoneGrowableArray<Elf::SymbolData>(zone_, 0);
1839#endif
1840 break;
1842 // The BSS section is pre-made in the Elf object for precompiled snapshots
1843 // and unused otherwise, so there's no work that needs doing here.
1844 return false;
1846 // The GNU build ID is handled specially in the Elf object, and does not
1847 // get used for non-precompiled snapshots.
1848 return false;
1849 }
1850 intptr_t padding = current_section_stream_->Align(alignment);
1851 if (alignment_padding != nullptr) {
1852 *alignment_padding = padding;
1853 }
1854 return true;
1855}
#define ASSERT_NOTNULL(ptr)
Definition: assert.h:323

◆ ExitSection()

void dart::BlobImageWriter::ExitSection ( ProgramSection  name,
bool  vm,
intptr_t  size 
)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1857 of file image_snapshot.cc.

1857 {
1858#if defined(DART_PRECOMPILER)
1859 ElfAddSection(elf_, name, SectionSymbol(name, vm), SectionLabel(name, vm),
1860 current_section_stream_->buffer(), size, current_symbols_,
1861 current_relocations_);
1862 // We create the corresponding segment in the debugging information as well,
1863 // since it needs the contents to create the correct build ID.
1864 ElfAddSection(debug_elf_, name, SectionSymbol(name, vm),
1865 SectionLabel(name, vm), current_section_stream_->buffer(), size,
1866 current_symbols_, current_relocations_);
1867 current_relocations_ = nullptr;
1868 current_symbols_ = nullptr;
1869#endif
1870 current_section_stream_ = nullptr;
1871}
static const char * SectionSymbol(ProgramSection section, bool vm)
uint8_t * buffer() const
Definition: datastream.h:615
const char *const name
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ FrameUnwindEpilogue()

virtual void dart::BlobImageWriter::FrameUnwindEpilogue ( )
inlineprivatevirtual

Implements dart::ImageWriter.

Definition at line 879 of file image_snapshot.h.

879{}

◆ FrameUnwindPrologue()

virtual void dart::BlobImageWriter::FrameUnwindPrologue ( )
inlineprivatevirtual

Implements dart::ImageWriter.

Definition at line 878 of file image_snapshot.h.

878{}

◆ WriteBss()

void dart::BlobImageWriter::WriteBss ( bool  vm)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1782 of file image_snapshot.cc.

1782 {
1783#if defined(DART_PRECOMPILER)
1784 // We don't actually write a BSS segment, it's created as part of the
1785 // Elf constructor.
1786#endif
1787}

◆ WriteBytes()

intptr_t dart::BlobImageWriter::WriteBytes ( const void *  bytes,
intptr_t  size 
)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1777 of file image_snapshot.cc.

1777 {
1778 current_section_stream_->WriteBytes(bytes, size);
1779 return size;
1780}
void WriteBytes(const void *addr, intptr_t len)
Definition: datastream.h:424

◆ WriteROData()

void dart::BlobImageWriter::WriteROData ( NonStreamingWriteStream clustered_stream,
bool  vm 
)
privatevirtual

Reimplemented from dart::ImageWriter.

Definition at line 1789 of file image_snapshot.cc.

1790 {
1791#if defined(DART_PRECOMPILER)
1792 const intptr_t start_position = clustered_stream->Position();
1793#endif
1794 current_section_stream_ = ASSERT_NOTNULL(clustered_stream);
1796 return;
1797 }
1798#if defined(DART_PRECOMPILER)
1799 if (profile_writer_ != nullptr) {
1800 // Attribute any padding needed to the artificial root.
1801 const intptr_t padding = clustered_stream->Position() - start_position;
1804 }
1805#endif
1806 ImageWriter::WriteROData(clustered_stream, vm);
1807 ExitSection(ProgramSection::Data, vm, clustered_stream->bytes_written());
1808}
virtual bool EnterSection(ProgramSection section, bool vm, intptr_t alignment, intptr_t *alignment_padding=nullptr)
virtual void ExitSection(ProgramSection name, bool vm, intptr_t size)
V8SnapshotProfileWriter * profile_writer_
static constexpr intptr_t kRODataAlignment
virtual void WriteROData(NonStreamingWriteStream *clustered_stream, bool vm)
static const ObjectId kArtificialRootId
void AttributeBytesTo(const ObjectId &object_id, size_t num_bytes)

◆ WriteTargetWord()

intptr_t dart::BlobImageWriter::WriteTargetWord ( word  value)
privatevirtual

Implements dart::ImageWriter.

Definition at line 1873 of file image_snapshot.cc.

1873 {
1874 current_section_stream_->WriteTargetWord(value);
1876}
void WriteTargetWord(word value)
Definition: datastream.cc:12
uint8_t value
static constexpr intptr_t kWordSize
Definition: runtime_api.h:274

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