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

#include <snapshot.h>

Public Types

enum  Kind {
  kFull , kFullCore , kFullJIT , kFullAOT ,
  kNone , kInvalid
}
 

Public Member Functions

bool check_magic () const
 
void set_magic ()
 
int64_t large_length () const
 
intptr_t length () const
 
void set_length (intptr_t value)
 
Kind kind () const
 
void set_kind (Kind value)
 
const uint8_t * Addr () const
 
const uint8_t * DataImage () const
 

Static Public Member Functions

static const char * KindToCString (Kind kind)
 
static const SnapshotSetupFromBuffer (const void *raw_memory)
 
static bool IsFull (Kind kind)
 
static bool IncludesCode (Kind kind)
 
static bool IncludesStringsInROData (Kind kind)
 

Static Public Attributes

static constexpr int32_t kMagicValue = 0xdcdcf5f5
 
static constexpr intptr_t kMagicOffset = 0
 
static constexpr intptr_t kMagicSize = sizeof(int32_t)
 
static constexpr intptr_t kLengthOffset = kMagicOffset + kMagicSize
 
static constexpr intptr_t kLengthSize = sizeof(int64_t)
 
static constexpr intptr_t kKindOffset = kLengthOffset + kLengthSize
 
static constexpr intptr_t kKindSize = sizeof(int64_t)
 
static constexpr intptr_t kHeaderSize = kKindOffset + kKindSize
 

Detailed Description

Definition at line 22 of file snapshot.h.

Member Enumeration Documentation

◆ Kind

Enumerator
kFull 
kFullCore 
kFullJIT 
kFullAOT 
kNone 
kInvalid 

Definition at line 24 of file snapshot.h.

24 {
25 kFull, // Full snapshot of an application.
26 kFullCore, // Full snapshot of core libraries.
27 kFullJIT, // Full + JIT code
28 kFullAOT, // Full + AOT code
29 kNone, // gen_snapshot
31 };

Member Function Documentation

◆ Addr()

const uint8_t * dart::Snapshot::Addr ( ) const
inline

Definition at line 79 of file snapshot.h.

79{ return reinterpret_cast<const uint8_t*>(this); }

◆ check_magic()

bool dart::Snapshot::check_magic ( ) const
inline

Definition at line 46 of file snapshot.h.

46 {
47 return Read<int32_t>(kMagicOffset) == kMagicValue;
48 }
static constexpr int32_t kMagicValue
Definition: snapshot.h:36
static constexpr intptr_t kMagicOffset
Definition: snapshot.h:37

◆ DataImage()

const uint8_t * dart::Snapshot::DataImage ( ) const
inline

Definition at line 81 of file snapshot.h.

81 {
82 if (!IncludesCode(kind())) {
83 return nullptr;
84 }
86 return Addr() + offset;
87 }
Kind kind() const
Definition: snapshot.h:60
const uint8_t * Addr() const
Definition: snapshot.h:79
intptr_t length() const
Definition: snapshot.h:56
static bool IncludesCode(Kind kind)
Definition: snapshot.h:67
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120
static constexpr intptr_t kObjectStartAlignment
uintptr_t uword
Definition: globals.h:501
SeparatedVector2 offset

◆ IncludesCode()

static bool dart::Snapshot::IncludesCode ( Kind  kind)
inlinestatic

Definition at line 67 of file snapshot.h.

67 {
68 return (kind == kFullJIT) || (kind == kFullAOT);
69 }

◆ IncludesStringsInROData()

static bool dart::Snapshot::IncludesStringsInROData ( Kind  kind)
inlinestatic

Definition at line 71 of file snapshot.h.

71 {
72#if !defined(DART_COMPRESSED_POINTERS)
73 return IncludesCode(kind);
74#else
75 return false;
76#endif
77 }

◆ IsFull()

static bool dart::Snapshot::IsFull ( Kind  kind)
inlinestatic

Definition at line 63 of file snapshot.h.

63 {
64 return (kind == kFull) || (kind == kFullCore) || (kind == kFullJIT) ||
65 (kind == kFullAOT);
66 }

◆ kind()

Kind dart::Snapshot::kind ( ) const
inline

Definition at line 60 of file snapshot.h.

60{ return static_cast<Kind>(Read<int64_t>(kKindOffset)); }
static constexpr intptr_t kKindOffset
Definition: snapshot.h:41

◆ KindToCString()

const char * dart::Snapshot::KindToCString ( Kind  kind)
static

Definition at line 12 of file snapshot.cc.

12 {
13 switch (kind) {
14 case kFull:
15 return "full";
16 case kFullCore:
17 return "full-core";
18 case kFullJIT:
19 return "full-jit";
20 case kFullAOT:
21 return "full-aot";
22 case kNone:
23 return "none";
24 case kInvalid:
25 default:
26 return "invalid";
27 }
28}

◆ large_length()

int64_t dart::Snapshot::large_length ( ) const
inline

Definition at line 53 of file snapshot.h.

53 {
54 return Read<int64_t>(kLengthOffset) + kMagicSize;
55 }
static constexpr intptr_t kMagicSize
Definition: snapshot.h:38
static constexpr intptr_t kLengthOffset
Definition: snapshot.h:39

◆ length()

intptr_t dart::Snapshot::length ( ) const
inline

Definition at line 56 of file snapshot.h.

56{ return static_cast<intptr_t>(large_length()); }
int64_t large_length() const
Definition: snapshot.h:53

◆ set_kind()

void dart::Snapshot::set_kind ( Kind  value)
inline

Definition at line 61 of file snapshot.h.

61{ return Write<int64_t>(kKindOffset, value); }
uint8_t value

◆ set_length()

void dart::Snapshot::set_length ( intptr_t  value)
inline

Definition at line 57 of file snapshot.h.

57 {
58 return Write<int64_t>(kLengthOffset, value - kMagicSize);
59 }

◆ set_magic()

void dart::Snapshot::set_magic ( )
inline

Definition at line 49 of file snapshot.h.

49{ return Write<int32_t>(kMagicOffset, kMagicValue); }

◆ SetupFromBuffer()

const Snapshot * dart::Snapshot::SetupFromBuffer ( const void *  raw_memory)
static

Definition at line 30 of file snapshot.cc.

30 {
31 ASSERT(raw_memory != nullptr);
32 const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
33 if (!snapshot->check_magic()) {
34 return nullptr;
35 }
36 // If the raw length is negative or greater than what the local machine can
37 // handle, then signal an error.
38 int64_t length = snapshot->large_length();
39 if ((length < 0) || (length > kIntptrMax)) {
40 return nullptr;
41 }
42 return snapshot;
43}
#define ASSERT(E)
constexpr intptr_t kIntptrMax
Definition: globals.h:557

Member Data Documentation

◆ kHeaderSize

constexpr intptr_t dart::Snapshot::kHeaderSize = kKindOffset + kKindSize
staticconstexpr

Definition at line 43 of file snapshot.h.

◆ kKindOffset

constexpr intptr_t dart::Snapshot::kKindOffset = kLengthOffset + kLengthSize
staticconstexpr

Definition at line 41 of file snapshot.h.

◆ kKindSize

constexpr intptr_t dart::Snapshot::kKindSize = sizeof(int64_t)
staticconstexpr

Definition at line 42 of file snapshot.h.

◆ kLengthOffset

constexpr intptr_t dart::Snapshot::kLengthOffset = kMagicOffset + kMagicSize
staticconstexpr

Definition at line 39 of file snapshot.h.

◆ kLengthSize

constexpr intptr_t dart::Snapshot::kLengthSize = sizeof(int64_t)
staticconstexpr

Definition at line 40 of file snapshot.h.

◆ kMagicOffset

constexpr intptr_t dart::Snapshot::kMagicOffset = 0
staticconstexpr

Definition at line 37 of file snapshot.h.

◆ kMagicSize

constexpr intptr_t dart::Snapshot::kMagicSize = sizeof(int32_t)
staticconstexpr

Definition at line 38 of file snapshot.h.

◆ kMagicValue

constexpr int32_t dart::Snapshot::kMagicValue = 0xdcdcf5f5
staticconstexpr

Definition at line 36 of file snapshot.h.


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