5#ifndef RUNTIME_VM_DATASTREAM_H_
6#define RUNTIME_VM_DATASTREAM_H_
30 template <
typename T,
typename S>
35 template <
typename T,
typename S>
62 template <
int N,
typename T>
98 template <
typename T =
intptr_t>
104 const int8_t* cursor =
reinterpret_cast<const int8_t*
>(current_);
110 result = byte + (result << 7); \
111 if (byte < 0) goto done;
120 current_ =
reinterpret_cast<const uint8_t*
>(cursor);
127 intptr_t
Position()
const {
return current_ - buffer_; }
130 current_ = buffer_ +
value;
134 intptr_t position_before =
Position();
135 intptr_t position_after =
137 Advance(position_after - position_before);
144 current_ = current_ +
value;
149 return (end_ - current_);
152 template <
typename T>
161 for (intptr_t j = 0; j < kNumRead32PerWord; j++) {
172 template <
typename T = u
intptr_t>
188 template <
typename T>
193 template <
typename T>
213 sign_bits = ~((
static_cast<T>(1) <<
s) - 1);
215 return r | sign_bits;
218 template <
typename T =
intptr_t>
230 template <
typename T>
231 T Read(uint8_t end_byte_marker) {
233 Unsigned
b = ReadByte();
235 return b - end_byte_marker;
240 r |=
static_cast<Unsigned
>(
b) <<
s;
244 return r | (
static_cast<Unsigned
>(
b - end_byte_marker) <<
s);
248#define UNROLLED_INIT() \
249 using Unsigned = typename std::make_unsigned<T>::type; \
250 Unsigned b = ReadByte(); \
251 if (b > kMaxUnsignedDataPerByte) { \
252 return b - end_byte_marker; \
258#define UNROLLED_BODY(bit_start) \
259 static_assert(bit_start % kDataBitsPerByte == 0, \
260 "Bit start must be a multiple of the data bits per byte"); \
261 static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T), \
262 "Starting unrolled body at invalid bit position"); \
263 static_assert(bit_start + kDataBitsPerByte < kBitsPerByte * sizeof(T), \
264 "Unrolled body should not contain final bits in value"); \
266 if (b > kMaxUnsignedDataPerByte) { \
267 return r | (static_cast<T>(b - end_byte_marker) << bit_start); \
272#define UNROLLED_END(bit_start) \
273 static_assert(bit_start % kDataBitsPerByte == 0, \
274 "Bit start must be a multiple of the data bits per byte"); \
275 static_assert(bit_start >= 0 && bit_start < kBitsPerByte * sizeof(T), \
276 "Starting unrolled end at invalid bit position"); \
277 static_assert(bit_start + kDataBitsPerByte >= kBitsPerByte * sizeof(T), \
278 "Unrolled end does not contain final bits in value"); \
280 ASSERT(b > kMaxUnsignedDataPerByte); \
281 return r | (static_cast<T>(b - end_byte_marker) << bit_start);
283 uint16_t Read16(uint8_t end_byte_marker) {
290 uint32_t Read32(uint8_t end_byte_marker) {
299 uint64_t Read64(uint8_t end_byte_marker) {
313 DART_FORCE_INLINE uint8_t ReadByte() {
319 ReadStream(
const uint8_t*
buffer,
const uint8_t* current,
const uint8_t* end)
320 : buffer_(
buffer), current_(current), end_(
end) {}
322 const uint8_t* buffer_;
323 const uint8_t* current_;
342 const intptr_t position_before =
Position();
343 const intptr_t position_after =
345 const intptr_t
length = position_after - position_before;
354 template <
int N,
typename T>
357 template <
typename T>
365 template <
typename T>
373 template <
typename T>
381 template <
typename T>
393 for (intptr_t j = 0; j < kNumWrite32PerWord; j++) {
399 template <
typename T>
412 if ((
value >> 21) != 0) {
415 if ((
value >> 14) != 0) {
418 if ((
value >> 7) != 0) {
445 va_list measure_args;
446 va_copy(measure_args,
args);
455 va_copy(print_args,
args);
462 template <
typename T>
472 template <
typename T>
488 template <
typename T>
496 is_last_part = remainder ==
static_cast<T>(0);
502 }
while (!is_last_part);
505 template <
typename T>
513 template <
typename T>
518 const bool is_negative =
value < 0;
538 ~static_cast<T>((
static_cast<Unsigned
>(1) << preserved_bits) - 1);
544 remainder == ~static_cast<T>(0) && (part &
C::kSignMask) != 0;
548 (remainder ==
static_cast<T>(0) && (part &
C::kSignMask) == 0);
555 }
while (!is_last_part);
558 template <
typename T>
567 if (size_needed > increment_size) {
570 intptr_t new_size =
capacity_ + increment_size;
595 virtual void Realloc(intptr_t new_capacity) = 0;
636 uint8_t*
const old_buffer =
buffer_;
645 virtual void Realloc(intptr_t new_size);
657 virtual void Realloc(intptr_t new_size);
676 callback_data_(callback_data) {}
682 virtual void Flush();
684 virtual void Realloc(intptr_t new_size);
697 void*
const callback_data_;
698 intptr_t flushed_size_ = 0;
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
static void Write(BaseWriteStream *st, T value)
static void Write(BaseWriteStream *st, T value)
static void Write(BaseWriteStream *st, T value)
static void Write(BaseWriteStream *st, T value)
C::only_if_signed< T, void > WriteSLEB128(T value)
DISALLOW_COPY_AND_ASSIGN(BaseWriteStream)
void Printf(const char *format,...) PRINTF_ATTRIBUTE(2
void WriteBytes(const void *addr, intptr_t len)
virtual void SetPosition(intptr_t value)
void va_start(args, format)
void WriteString(const char *cstr)
void EnsureSpace(intptr_t size_needed)
BaseWriteStream(intptr_t initial_size)
void WriteWord(uword value)
void WriteWordWith32BitWrites(uword value)
intptr_t Align(intptr_t alignment, intptr_t offset=0)
C::only_if_unsigned< T, void > WriteSLEB128(T value)
virtual ~BaseWriteStream()
virtual void Realloc(intptr_t new_capacity)=0
DART_FORCE_INLINE void WriteByte(uint8_t value)
void WriteUnsigned(T value)
DART_FORCE_INLINE intptr_t bytes_written() const
C::only_if_signed< T, void > WriteLEB128(T value)
void VPrintf(const char *format, va_list args)
virtual intptr_t Position() const
void WriteTargetWord(word value)
C::only_if_unsigned< T, void > WriteLEB128(T value)
void WriteRefId(intptr_t value)
DART_FORCE_INLINE intptr_t Remaining() const
const intptr_t initial_size_
static DART_NORETURN void ThrowOOM()
uint8_t * Steal(intptr_t *length)
virtual void Realloc(intptr_t new_size)
MallocWriteStream(intptr_t initial_size)
NonStreamingWriteStream(intptr_t initial_size)
DART_FORCE_INLINE void SetPosition(intptr_t value)
static T Read(ReadStream *st)
static T Read(ReadStream *st)
static T Read(ReadStream *st)
static T Read(ReadStream *st)
uword ReadWordWith32BitReads()
C::only_if_unsigned< T, T > ReadSLEB128()
ReadStream(const uint8_t *buffer, intptr_t size, intptr_t pos)
void Align(intptr_t alignment, intptr_t offset=0)
C::only_if_signed< T, T > ReadLEB128()
C::only_if_signed< T, T > ReadSLEB128()
ReadStream(const uint8_t *buffer, intptr_t size)
C::only_if_unsigned< T, T > ReadLEB128()
intptr_t Position() const
intptr_t PendingBytes() const
const uint8_t * AddressOfCurrentPosition() const
void Advance(intptr_t value)
void SetPosition(intptr_t value)
void ReadBytes(void *addr, intptr_t len)
virtual void Realloc(intptr_t new_size)
StreamingWriteStream(intptr_t initial_capacity, Dart_StreamingWriteCallback callback, void *callback_data)
virtual void SetPosition(intptr_t value)
virtual intptr_t Position() const
static constexpr T NBitMask(size_t n)
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
static bool IsUint(intptr_t N, T value)
ZoneWriteStream(Zone *zone, intptr_t initial_size)
virtual void Realloc(intptr_t new_size)
void(* Dart_StreamingWriteCallback)(void *callback_data, const uint8_t *buffer, intptr_t size)
#define UNROLLED_BODY(bit_start)
#define UNROLLED_END(bit_start)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint32_t uint32_t * format
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
DART_FORCE_INLINE D bit_cast(const S &source)
constexpr intptr_t kBitsPerWord
constexpr intptr_t kBitsPerByte
static constexpr int8_t kMaxUnsignedDataPerByte
static constexpr uint8_t kEndUnsignedByteMarker
static constexpr int8_t kByteMask
intx_t sign_extend(int32_t x)
constexpr intptr_t kBitsPerInt32
static constexpr int8_t kMinDataPerByte
static constexpr int8_t kMaxDataPerByte
static constexpr int8_t kDataBitsPerByte
static constexpr uint8_t kEndByteMarker
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
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
static constexpr uint8_t kSignMask
static constexpr uint8_t kDataBitsPerByte
static constexpr uint8_t kDataByteMask
typename std::enable_if< std::is_unsigned< T >::value, S >::type only_if_unsigned
static constexpr uint8_t kMoreDataMask
typename std::enable_if< std::is_signed< T >::value, S >::type only_if_signed