Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
dart::Image Class Reference

#include <image_snapshot.h>

Inheritance diagram for dart::Image:
dart::ValueObject

Public Member Functions

 Image (const void *raw_memory)
 
 Image (const uword raw_memory)
 
void * object_start () const
 
uword object_size () const
 
bool contains (uword address) const
 
uwordbss () const
 
uword instructions_relocated_address () const
 
const uint8_t * build_id () const
 
intptr_t build_id_length () const
 
bool compiled_to_elf () const
 

Friends

class AssemblyImageWriter
 
class BitsContainer
 
class BlobImageWriter
 
class ImageWriter
 

Detailed Description

Definition at line 39 of file image_snapshot.h.

Constructor & Destructor Documentation

◆ Image() [1/2]

dart::Image::Image ( const void *  raw_memory)
inlineexplicit

Definition at line 41 of file image_snapshot.h.

42 : Image(reinterpret_cast<uword>(raw_memory)) {}
Image(const void *raw_memory)
uintptr_t uword
Definition: globals.h:501

◆ Image() [2/2]

dart::Image::Image ( const uword  raw_memory)
inlineexplicit

Definition at line 43 of file image_snapshot.h.

44 : raw_memory_(raw_memory),
45 snapshot_size_(FieldValue(raw_memory, HeaderField::ImageSize)),
46 extra_info_(ExtraInfo(raw_memory_, snapshot_size_)) {
48 }
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:92
#define ASSERT(E)
static constexpr intptr_t kObjectStartAlignment

Member Function Documentation

◆ bss()

uword * dart::Image::bss ( ) const

Definition at line 68 of file image_snapshot.cc.

68 {
69#if defined(DART_PRECOMPILED_RUNTIME)
70 ASSERT(extra_info_ != nullptr);
71 // There should always be a non-zero BSS offset.
72 ASSERT(extra_info_->bss_offset_ != 0);
73 // Returning a non-const uword* is safe because we're translating from
74 // the start of the instructions (read-only) to the start of the BSS
75 // (read-write).
76 return reinterpret_cast<uword*>(raw_memory_ + extra_info_->bss_offset_);
77#else
78 return nullptr;
79#endif
80}

◆ build_id()

const uint8_t * dart::Image::build_id ( ) const

Definition at line 91 of file image_snapshot.cc.

91 {
92#if defined(DART_PRECOMPILED_RUNTIME)
93 ASSERT(extra_info_ != nullptr);
94 if (extra_info_->build_id_offset_ != kNoBuildId) {
95 auto const note = reinterpret_cast<elf::Note*>(
96 raw_memory_ + extra_info_->build_id_offset_);
97 return note->data + note->name_size;
98 }
99#endif
100 return nullptr;
101}

◆ build_id_length()

intptr_t dart::Image::build_id_length ( ) const

Definition at line 103 of file image_snapshot.cc.

103 {
104#if defined(DART_PRECOMPILED_RUNTIME)
105 ASSERT(extra_info_ != nullptr);
106 if (extra_info_->build_id_offset_ != kNoBuildId) {
107 auto const note = reinterpret_cast<elf::Note*>(
108 raw_memory_ + extra_info_->build_id_offset_);
109 return note->description_size;
110 }
111#endif
112 return 0;
113}

◆ compiled_to_elf()

bool dart::Image::compiled_to_elf ( ) const

Definition at line 115 of file image_snapshot.cc.

115 {
116#if defined(DART_PRECOMPILED_RUNTIME)
117 ASSERT(extra_info_ != nullptr);
118 // Since assembly snapshots can't set up this field correctly (instead,
119 // it's initialized in BSS at snapshot load time), we use it to detect
120 // direct-to-ELF snapshots.
121 return extra_info_->instructions_relocated_address_ != kNoRelocatedAddress;
122#else
123 return false;
124#endif
125}

◆ contains()

bool dart::Image::contains ( uword  address) const
inline

Definition at line 59 of file image_snapshot.h.

59 {
60 uword start = reinterpret_cast<uword>(object_start());
61 return address >= start && (address - start < object_size());
62 }
uword object_size() const
void * object_start() const

◆ instructions_relocated_address()

uword dart::Image::instructions_relocated_address ( ) const

Definition at line 82 of file image_snapshot.cc.

82 {
83#if defined(DART_PRECOMPILED_RUNTIME)
84 ASSERT(extra_info_ != nullptr);
85 return extra_info_->instructions_relocated_address_;
86#else
87 return kNoRelocatedAddress;
88#endif
89}

◆ object_size()

uword dart::Image::object_size ( ) const
inline

Definition at line 57 of file image_snapshot.h.

57{ return snapshot_size_ - kHeaderSize; }

◆ object_start()

void * dart::Image::object_start ( ) const
inline

Definition at line 53 of file image_snapshot.h.

53 {
54 return reinterpret_cast<void*>(raw_memory_ + kHeaderSize);
55 }

Friends And Related Function Documentation

◆ AssemblyImageWriter

friend class AssemblyImageWriter
friend

Definition at line 144 of file image_snapshot.h.

◆ BitsContainer

friend class BitsContainer
friend

Definition at line 145 of file image_snapshot.h.

◆ BlobImageWriter

friend class BlobImageWriter
friend

Definition at line 146 of file image_snapshot.h.

◆ ImageWriter

friend class ImageWriter
friend

Definition at line 147 of file image_snapshot.h.


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