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

#include <datastream.h>

Inheritance diagram for dart::ReadStream:
dart::ValueObject dart::Deserializer::Local

Classes

class  Raw
 
class  Raw< 1, T >
 
class  Raw< 2, T >
 
class  Raw< 4, T >
 
class  Raw< 8, T >
 

Public Member Functions

 ReadStream (const uint8_t *buffer, intptr_t size)
 
 ReadStream (const uint8_t *buffer, intptr_t size, intptr_t pos)
 
void ReadBytes (void *addr, intptr_t len)
 
template<typename T = intptr_t>
T ReadUnsigned ()
 
intptr_t ReadRefId ()
 
intptr_t Position () const
 
void SetPosition (intptr_t value)
 
void Align (intptr_t alignment, intptr_t offset=0)
 
const uint8_t * AddressOfCurrentPosition () const
 
void Advance (intptr_t value)
 
intptr_t PendingBytes () const
 
template<typename T >
T Read ()
 
uword ReadWordWith32BitReads ()
 
template<typename T = uintptr_t>
C::only_if_unsigned< T, TReadLEB128 ()
 
template<typename T >
C::only_if_signed< T, TReadLEB128 ()
 
template<typename T >
C::only_if_unsigned< T, TReadSLEB128 ()
 
template<typename T = intptr_t>
C::only_if_signed< T, TReadSLEB128 ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Friends

class Deserializer
 

Detailed Description

Definition at line 51 of file datastream.h.

Constructor & Destructor Documentation

◆ ReadStream() [1/2]

dart::ReadStream::ReadStream ( const uint8_t *  buffer,
intptr_t  size 
)
inline

Definition at line 53 of file datastream.h.

54 : buffer_(buffer), current_(buffer), end_(buffer + size) {}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
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

◆ ReadStream() [2/2]

dart::ReadStream::ReadStream ( const uint8_t *  buffer,
intptr_t  size,
intptr_t  pos 
)
inline

Definition at line 57 of file datastream.h.

60 }
SkPoint pos
ReadStream(const uint8_t *buffer, intptr_t size)
Definition: datastream.h:53
void SetPosition(intptr_t value)
Definition: datastream.h:128

Member Function Documentation

◆ AddressOfCurrentPosition()

const uint8_t * dart::ReadStream::AddressOfCurrentPosition ( ) const
inline

Definition at line 140 of file datastream.h.

140{ return current_; }

◆ Advance()

void dart::ReadStream::Advance ( intptr_t  value)
inline

Definition at line 142 of file datastream.h.

142 {
143 ASSERT((end_ - current_) >= value);
144 current_ = current_ + value;
145 }
#define ASSERT(E)
uint8_t value

◆ Align()

void dart::ReadStream::Align ( intptr_t  alignment,
intptr_t  offset = 0 
)
inline

Definition at line 133 of file datastream.h.

133 {
134 intptr_t position_before = Position();
135 intptr_t position_after =
136 Utils::RoundUp(position_before, alignment, offset);
137 Advance(position_after - position_before);
138 }
intptr_t Position() const
Definition: datastream.h:127
void Advance(intptr_t value)
Definition: datastream.h:142
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120
SeparatedVector2 offset

◆ PendingBytes()

intptr_t dart::ReadStream::PendingBytes ( ) const
inline

Definition at line 147 of file datastream.h.

147 {
148 ASSERT(end_ >= current_);
149 return (end_ - current_);
150 }

◆ Position()

intptr_t dart::ReadStream::Position ( ) const
inline

Definition at line 127 of file datastream.h.

127{ return current_ - buffer_; }

◆ Read()

template<typename T >
T dart::ReadStream::Read ( )
inline

Definition at line 153 of file datastream.h.

153 {
154 return Read<T>(kEndByteMarker);
155 }
static constexpr uint8_t kEndByteMarker
Definition: datastream.h:24

◆ ReadBytes()

void dart::ReadStream::ReadBytes ( void *  addr,
intptr_t  len 
)
inline

Definition at line 90 of file datastream.h.

90 {
91 ASSERT((end_ - current_) >= len);
92 if (len != 0) {
93 memmove(addr, current_, len);
94 }
95 current_ += len;
96 }

◆ ReadLEB128() [1/2]

template<typename T = uintptr_t>
C::only_if_unsigned< T, T > dart::ReadStream::ReadLEB128 ( )
inline

Definition at line 173 of file datastream.h.

173 {
174 constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
175 T r = 0;
176 uint8_t s = 0;
177 uint8_t b;
178 do {
179 ASSERT(s < kBitsPerT);
180 b = ReadByte();
181 r |= static_cast<T>(b & C::kDataByteMask) << s;
183 } while ((b & C::kMoreDataMask) != 0);
184 ASSERT(s < C::kDataBitsPerByte + kBitsPerT);
185 return r;
186 }
static bool b
struct MyStruct s
constexpr intptr_t kBitsPerByte
Definition: globals.h:463
#define T
Definition: precompiler.cc:65
static constexpr uint8_t kDataBitsPerByte
Definition: datastream.h:40
static constexpr uint8_t kDataByteMask
Definition: datastream.h:41
static constexpr uint8_t kMoreDataMask
Definition: datastream.h:43

◆ ReadLEB128() [2/2]

template<typename T >
C::only_if_signed< T, T > dart::ReadStream::ReadLEB128 ( )
inline

Definition at line 189 of file datastream.h.

189 {
190 return bit_cast<T>(ReadLEB128<typename std::make_unsigned<T>::type>());
191 }
GLenum type
C::only_if_unsigned< T, T > ReadLEB128()
Definition: datastream.h:173

◆ ReadRefId()

intptr_t dart::ReadStream::ReadRefId ( )
inline

Definition at line 103 of file datastream.h.

103 {
104 const int8_t* cursor = reinterpret_cast<const int8_t*>(current_);
105 intptr_t result = 0;
106 intptr_t byte;
107 // clang-format off
108#define STAGE \
109 byte = *cursor++; /* ldrsb byte, [result], 1 */ \
110 result = byte + (result << 7); /* add result, byte, result lsl 7 */ \
111 if (byte < 0) goto done; /* tbnz byte, 63, done */
112 STAGE // 0-7
113 STAGE // 8-14
114 STAGE // 15-21
115 STAGE // 22-28
116#undef STAGE
117 ASSERT(byte < 0); // 256MB is enough for anyone...
118 // clang-format on
119 done:
120 current_ = reinterpret_cast<const uint8_t*>(cursor);
121 // With big-endian order and the has-more marker being 0, the correction
122 // factor to remove the last-byte marker is a constant, which can be folded
123 // into subsequent load offsets.
124 return result + 128;
125 }
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition: DM.cpp:263
#define STAGE
GAsyncResult * result

◆ ReadSLEB128() [1/2]

template<typename T >
C::only_if_unsigned< T, T > dart::ReadStream::ReadSLEB128 ( )
inline

Definition at line 194 of file datastream.h.

194 {
195 constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
196 T r = 0;
197 uint8_t s = 0;
198 uint8_t b;
199 do {
200 ASSERT(s < kBitsPerT);
201 b = ReadByte();
202 r |= static_cast<T>(b & C::kDataByteMask) << s;
204 } while ((b & C::kMoreDataMask) != 0);
205 ASSERT(s < C::kDataBitsPerByte + kBitsPerT);
206 // At this point, [s] contains how many data bits have made it into the
207 // value. If the value is negative and the count of data bits is less than
208 // the size of the value, then we need to extend the sign by setting the
209 // remaining (unset) most significant bits (MSBs).
210 T sign_bits = 0;
211 if ((b & C::kSignMask) != 0 && s < kBitsPerT) {
212 // Create a bitmask for the current data bits and invert it.
213 sign_bits = ~((static_cast<T>(1) << s) - 1);
214 }
215 return r | sign_bits;
216 }
static constexpr uint8_t kSignMask
Definition: datastream.h:45

◆ ReadSLEB128() [2/2]

template<typename T = intptr_t>
C::only_if_signed< T, T > dart::ReadStream::ReadSLEB128 ( )
inline

Definition at line 219 of file datastream.h.

219 {
220 return bit_cast<T>(ReadSLEB128<typename std::make_unsigned<T>::type>());
221 }
C::only_if_unsigned< T, T > ReadSLEB128()
Definition: datastream.h:194

◆ ReadUnsigned()

template<typename T = intptr_t>
T dart::ReadStream::ReadUnsigned ( )
inline

Definition at line 99 of file datastream.h.

99 {
100 return Read<T>(kEndUnsignedByteMarker);
101 }
static constexpr uint8_t kEndUnsignedByteMarker
Definition: datastream.h:25

◆ ReadWordWith32BitReads()

uword dart::ReadStream::ReadWordWith32BitReads ( )
inline

Definition at line 157 of file datastream.h.

157 {
158 constexpr intptr_t kNumRead32PerWord = kBitsPerWord / kBitsPerInt32;
159
160 uword value = 0;
161 for (intptr_t j = 0; j < kNumRead32PerWord; j++) {
162 const auto partial_value = Raw<kInt32Size, uint32_t>::Read(this);
163 value |= (static_cast<uword>(partial_value) << (j * kBitsPerInt32));
164 }
165 return value;
166 }
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
constexpr intptr_t kBitsPerWord
Definition: globals.h:514
uintptr_t uword
Definition: globals.h:501
constexpr intptr_t kBitsPerInt32
Definition: globals.h:466

◆ SetPosition()

void dart::ReadStream::SetPosition ( intptr_t  value)
inline

Definition at line 128 of file datastream.h.

128 {
129 ASSERT((end_ - buffer_) >= value);
130 current_ = buffer_ + value;
131 }

Friends And Related Function Documentation

◆ Deserializer

friend class Deserializer
friend

Definition at line 326 of file datastream.h.


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