Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
datastream.h
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_DATASTREAM_H_
6#define RUNTIME_VM_DATASTREAM_H_
7
8#include "platform/assert.h"
9#include "platform/utils.h"
10#include "vm/allocation.h"
11#include "vm/exceptions.h"
12#include "vm/globals.h"
13#include "vm/os.h"
14#include "vm/zone.h"
15
16namespace dart {
17
18static constexpr int8_t kDataBitsPerByte = 7;
19static constexpr int8_t kByteMask = (1 << kDataBitsPerByte) - 1;
20static constexpr int8_t kMaxUnsignedDataPerByte = kByteMask;
21static constexpr int8_t kMinDataPerByte = -(1 << (kDataBitsPerByte - 1));
22static constexpr int8_t kMaxDataPerByte =
23 (~kMinDataPerByte & kByteMask); // NOLINT
24static constexpr uint8_t kEndByteMarker = (255 - kMaxDataPerByte);
25static constexpr uint8_t kEndUnsignedByteMarker =
27
29 // Convenience template for ensuring non-signed types trigger SFINAE.
30 template <typename T, typename S>
33
34 // Convenience template for ensuring signed types trigger SFINAE.
35 template <typename T, typename S>
38
39 // (S)LEB128 encodes 7 bits of data per byte (hence 128).
40 static constexpr uint8_t kDataBitsPerByte = 7;
41 static constexpr uint8_t kDataByteMask = (1 << kDataBitsPerByte) - 1;
42 // If more data follows a given data byte, the high bit is set.
43 static constexpr uint8_t kMoreDataMask = (1 << kDataBitsPerByte);
44 // For SLEB128, the high bit in the data of the last byte is the sign bit.
45 static constexpr uint8_t kSignMask = (1 << (kDataBitsPerByte - 1));
46};
47
49
50// Stream for reading various types from a buffer.
51class ReadStream : public ValueObject {
52 public:
53 ReadStream(const uint8_t* buffer, intptr_t size)
54 : buffer_(buffer), current_(buffer), end_(buffer + size) {}
55
56 // Creates a ReadStream that starts at a given position in the buffer.
57 ReadStream(const uint8_t* buffer, intptr_t size, intptr_t pos)
60 }
61
62 template <int N, typename T>
63 class Raw {};
64
65 template <typename T>
66 class Raw<1, T> {
67 public:
68 static T Read(ReadStream* st) { return bit_cast<T>(st->ReadByte()); }
69 };
70
71 template <typename T>
72 class Raw<2, T> {
73 public:
74 static T Read(ReadStream* st) { return bit_cast<T>(st->Read16()); }
75 };
76
77 template <typename T>
78 class Raw<4, T> {
79 public:
80 static T Read(ReadStream* st) { return bit_cast<T>(st->Read32()); }
81 };
82
83 template <typename T>
84 class Raw<8, T> {
85 public:
86 static T Read(ReadStream* st) { return bit_cast<T>(st->Read64()); }
87 };
88
89 // Reads 'len' bytes from the stream.
90 void ReadBytes(void* addr, intptr_t len) {
91 ASSERT((end_ - current_) >= len);
92 if (len != 0) {
93 memmove(addr, current_, len);
94 }
95 current_ += len;
96 }
97
98 template <typename T = intptr_t>
100 return Read<T>(kEndUnsignedByteMarker);
101 }
102
103 intptr_t ReadRefId() {
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 }
126
127 intptr_t Position() const { return current_ - buffer_; }
128 void SetPosition(intptr_t value) {
129 ASSERT((end_ - buffer_) >= value);
130 current_ = buffer_ + value;
131 }
132
133 void Align(intptr_t alignment, intptr_t offset = 0) {
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 }
139
140 const uint8_t* AddressOfCurrentPosition() const { return current_; }
141
142 void Advance(intptr_t value) {
143 ASSERT((end_ - current_) >= value);
144 current_ = current_ + value;
145 }
146
147 intptr_t PendingBytes() const {
148 ASSERT(end_ >= current_);
149 return (end_ - current_);
150 }
151
152 template <typename T>
153 T Read() {
154 return Read<T>(kEndByteMarker);
155 }
156
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 }
167
168 private:
169 using C = LEB128Constants;
170
171 public:
172 template <typename T = uintptr_t>
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 }
187
188 template <typename T>
190 return bit_cast<T>(ReadLEB128<typename std::make_unsigned<T>::type>());
191 }
192
193 template <typename T>
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 }
217
218 template <typename T = intptr_t>
220 return bit_cast<T>(ReadSLEB128<typename std::make_unsigned<T>::type>());
221 }
222
223 private:
224 uint16_t Read16() { return Read16(kEndByteMarker); }
225
226 uint32_t Read32() { return Read32(kEndByteMarker); }
227
228 uint64_t Read64() { return Read64(kEndByteMarker); }
229
230 template <typename T>
231 T Read(uint8_t end_byte_marker) {
232 using Unsigned = typename std::make_unsigned<T>::type;
233 Unsigned b = ReadByte();
235 return b - end_byte_marker;
236 }
237 T r = 0;
238 uint8_t s = 0;
239 do {
240 r |= static_cast<Unsigned>(b) << s;
242 b = ReadByte();
243 } while (b <= kMaxUnsignedDataPerByte);
244 return r | (static_cast<Unsigned>(b - end_byte_marker) << s);
245 }
246
247// Setting up needed variables for the unrolled loop sections below.
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; \
253 } \
254 T r = b;
255
256// Part of the unrolled loop where the loop may stop, having read the last part,
257// or continue reading.
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"); \
265 b = ReadByte(); \
266 if (b > kMaxUnsignedDataPerByte) { \
267 return r | (static_cast<T>(b - end_byte_marker) << bit_start); \
268 } \
269 r |= b << bit_start;
270
271// The end of the unrolled loop.
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"); \
279 b = ReadByte(); \
280 ASSERT(b > kMaxUnsignedDataPerByte); \
281 return r | (static_cast<T>(b - end_byte_marker) << bit_start);
282
283 uint16_t Read16(uint8_t end_byte_marker) {
284 using T = uint16_t;
286 UNROLLED_BODY(7);
287 UNROLLED_END(14);
288 }
289
290 uint32_t Read32(uint8_t end_byte_marker) {
291 using T = uint32_t;
293 UNROLLED_BODY(7);
294 UNROLLED_BODY(14);
295 UNROLLED_BODY(21);
296 UNROLLED_END(28);
297 }
298
299 uint64_t Read64(uint8_t end_byte_marker) {
300 using T = uint64_t;
302 UNROLLED_BODY(7);
303 UNROLLED_BODY(14);
304 UNROLLED_BODY(21);
305 UNROLLED_BODY(28);
306 UNROLLED_BODY(35);
307 UNROLLED_BODY(42);
308 UNROLLED_BODY(49);
309 UNROLLED_BODY(56);
310 UNROLLED_END(63);
311 }
312
313 DART_FORCE_INLINE uint8_t ReadByte() {
314 ASSERT(current_ < end_);
315 return *current_++;
316 }
317
318 private:
319 ReadStream(const uint8_t* buffer, const uint8_t* current, const uint8_t* end)
320 : buffer_(buffer), current_(current), end_(end) {}
321
322 const uint8_t* buffer_;
323 const uint8_t* current_;
324 const uint8_t* end_;
325
326 friend class Deserializer;
328};
329
330// Base class for streams that writing various types into a buffer, possibly
331// flushing data out periodically to a more permanent store.
333 public:
334 explicit BaseWriteStream(intptr_t initial_size)
335 : initial_size_(Utils::RoundUpToPowerOfTwo(initial_size)) {}
336 virtual ~BaseWriteStream() {}
337
338 DART_FORCE_INLINE intptr_t bytes_written() const { return Position(); }
339 virtual intptr_t Position() const { return current_ - buffer_; }
340
341 intptr_t Align(intptr_t alignment, intptr_t offset = 0) {
342 const intptr_t position_before = Position();
343 const intptr_t position_after =
344 Utils::RoundUp(position_before, alignment, offset);
345 const intptr_t length = position_after - position_before;
346 if (length != 0) {
348 memset(current_, 0, length);
349 SetPosition(position_after);
350 }
351 return length;
352 }
353
354 template <int N, typename T>
355 class Raw {};
356
357 template <typename T>
358 class Raw<1, T> {
359 public:
360 static void Write(BaseWriteStream* st, T value) {
361 st->WriteByte(bit_cast<uint8_t>(value));
362 }
363 };
364
365 template <typename T>
366 class Raw<2, T> {
367 public:
368 static void Write(BaseWriteStream* st, T value) {
369 st->Write<int16_t>(bit_cast<int16_t>(value));
370 }
371 };
372
373 template <typename T>
374 class Raw<4, T> {
375 public:
376 static void Write(BaseWriteStream* st, T value) {
377 st->Write<int32_t>(bit_cast<int32_t>(value));
378 }
379 };
380
381 template <typename T>
382 class Raw<8, T> {
383 public:
384 static void Write(BaseWriteStream* st, T value) {
385 st->Write<int64_t>(bit_cast<int64_t>(value));
386 }
387 };
388
390 constexpr intptr_t kNumWrite32PerWord = kBitsPerWord / kBitsPerInt32;
391
392 const uint32_t mask = Utils::NBitMask(kBitsPerInt32);
393 for (intptr_t j = 0; j < kNumWrite32PerWord; j++) {
394 const uint32_t shifted_value = (value >> (j * kBitsPerInt32));
395 Raw<kInt32Size, uint32_t>::Write(this, shifted_value & mask);
396 }
397 }
398
399 template <typename T>
401 ASSERT(value >= 0);
403 WriteByte(static_cast<uint8_t>(value & kByteMask));
405 }
406 WriteByte(static_cast<uint8_t>(value + kEndUnsignedByteMarker));
407 }
408
409 void WriteRefId(intptr_t value) {
410 ASSERT(Utils::IsUint(28, value)); // 256MB is enough for anyone...
411 EnsureSpace(4);
412 if ((value >> 21) != 0) {
413 *current_++ = (value >> 21) & 127;
414 }
415 if ((value >> 14) != 0) {
416 *current_++ = (value >> 14) & 127;
417 }
418 if ((value >> 7) != 0) {
419 *current_++ = (value >> 7) & 127;
420 }
421 *current_++ = ((value >> 0) & 127) | 128;
422 }
423
424 void WriteBytes(const void* addr, intptr_t len) {
425 if (len != 0) {
427 memmove(current_, addr, len);
428 current_ += len;
429 }
430 }
431
433
435
436 void Printf(const char* format, ...) PRINTF_ATTRIBUTE(2, 3) {
437 va_list args;
441 }
442
443 void VPrintf(const char* format, va_list args) {
444 // Measure.
445 va_list measure_args;
446 va_copy(measure_args, args);
447 intptr_t len = Utils::VSNPrint(nullptr, 0, format, measure_args);
448 va_end(measure_args);
449
450 // Alloc.
451 EnsureSpace(len + 1);
452
453 // Print.
454 va_list print_args;
455 va_copy(print_args, args);
456 Utils::VSNPrint(reinterpret_cast<char*>(current_), len + 1, format,
457 print_args);
458 va_end(print_args);
459 current_ += len; // Not len + 1 to swallow the terminating NUL.
460 }
461
462 template <typename T>
463 void Write(T value) {
464 T v = value;
465 while (v < kMinDataPerByte || v > kMaxDataPerByte) {
466 WriteByte(static_cast<uint8_t>(v & kByteMask));
467 v = v >> kDataBitsPerByte;
468 }
469 WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
470 }
471
472 template <typename T>
474 WriteBytes(&value, sizeof(value));
475 }
476
477 DART_FORCE_INLINE void WriteByte(uint8_t value) {
478 EnsureSpace(1);
479 *current_++ = value;
480 }
481
482 void WriteString(const char* cstr) { WriteBytes(cstr, strlen(cstr)); }
483
484 private:
485 using C = LEB128Constants;
486
487 public:
488 template <typename T>
490 T remainder = value;
491 bool is_last_part;
492 do {
493 uint8_t part = static_cast<uint8_t>(remainder & C::kDataByteMask);
494 remainder >>= C::kDataBitsPerByte;
495 // For unsigned types, we're done when the remainder has no bits set.
496 is_last_part = remainder == static_cast<T>(0);
497 if (!is_last_part) {
498 // Mark this part as a non-final part for this value.
499 part |= C::kMoreDataMask;
500 }
501 WriteByte(part);
502 } while (!is_last_part);
503 }
504
505 template <typename T>
507 // If we're trying to LEB128 encode a negative value, chances are we should
508 // be using SLEB128 instead.
509 ASSERT(value >= 0);
511 }
512
513 template <typename T>
515 constexpr intptr_t kBitsPerT = kBitsPerByte * sizeof(T);
516 using Unsigned = typename std::make_unsigned<T>::type;
517 // Record whether the original value was negative.
518 const bool is_negative = value < 0;
519 T remainder = value;
520 bool is_last_part;
521 do {
522 uint8_t part = static_cast<uint8_t>(remainder & C::kDataByteMask);
523 remainder >>= C::kDataBitsPerByte;
524 // For signed types, we're done when either:
525 // - the remainder has all bits set and the part's sign bit is set
526 // for negative values, or
527 // - the remainder has no bits set and the part's sign bit is unset for
528 // non-negative values.
529 // If the remainder matches but the sign bit does not, we need one more
530 // part to set the sign bit correctly when decoding.
531 if (is_negative) {
532 // Right shifts of negative values in C are not guaranteed to be
533 // arithmetic. For negative values, set the [kDataBitsPerByte] most
534 // significant bits after shifting to ensure the value stays negative.
535 constexpr intptr_t preserved_bits = kBitsPerT - C::kDataBitsPerByte;
536 // The sign extension mask is the inverse of the preserved bits mask.
537 constexpr T sign_extend =
538 ~static_cast<T>((static_cast<Unsigned>(1) << preserved_bits) - 1);
539 // Sign extend for negative values just in case a non-arithmetic right
540 // shift is used by the compiler.
541 remainder |= sign_extend;
542 ASSERT(remainder < 0); // Remainder should still be negative.
543 is_last_part =
544 remainder == ~static_cast<T>(0) && (part & C::kSignMask) != 0;
545 } else {
546 ASSERT(remainder >= 0); // Remainder should still be non-negative.
547 is_last_part =
548 (remainder == static_cast<T>(0) && (part & C::kSignMask) == 0);
549 }
550 if (!is_last_part) {
551 // Mark this part as a non-final part for this value.
552 part |= C::kMoreDataMask;
553 }
554 WriteByte(part);
555 } while (!is_last_part);
556 }
557
558 template <typename T>
561 }
562
563 protected:
564 void EnsureSpace(intptr_t size_needed) {
565 if (Remaining() >= size_needed) return;
566 intptr_t increment_size = capacity_;
567 if (size_needed > increment_size) {
568 increment_size = Utils::RoundUp(size_needed, initial_size_);
569 }
570 intptr_t new_size = capacity_ + increment_size;
571 ASSERT(new_size > capacity_);
572 Realloc(new_size);
573 if (buffer_ == nullptr) {
575 }
576 ASSERT(Remaining() >= size_needed);
577 }
578
579 virtual void SetPosition(intptr_t value) {
582 }
583
584 DART_FORCE_INLINE intptr_t Remaining() const {
586 }
587
588 // Resizes the internal buffer to the requested new capacity. Should set
589 // buffer_, capacity_, and current_ appropriately.
590 //
591 // Instead of templating over an Allocator (which would then cause users
592 // of the templated class to need to be templated, etc.), we just add an
593 // Realloc method to override appropriately in subclasses. Less flexible,
594 // but requires less changes throughout the codebase.
595 virtual void Realloc(intptr_t new_capacity) = 0;
596
597 const intptr_t initial_size_;
598 uint8_t* buffer_ = nullptr;
599 uint8_t* current_ = nullptr;
600 intptr_t capacity_ = 0;
601
603};
604
605// A base class for non-streaming write streams. Since these streams are
606// not flushed periodically, the internal buffer contains all written data
607// and can be retrieved via buffer(). NonStreamingWriteStream also provides
608// SetPosition as part of its public API for non-sequential writing.
610 public:
611 explicit NonStreamingWriteStream(intptr_t initial_size)
612 : BaseWriteStream(initial_size) {}
613
614 public:
615 uint8_t* buffer() const { return buffer_; }
616
617 // Sets the position of the buffer
618 DART_FORCE_INLINE void SetPosition(intptr_t value) {
620 }
621};
622
623// A non-streaming write stream that uses realloc for reallocation, and frees
624// the buffer when destructed unless ownership is transferred using Steal().
626 public:
627 explicit MallocWriteStream(intptr_t initial_size)
628 : NonStreamingWriteStream(initial_size) {}
630
631 // Resets the stream and returns the original buffer, which is now considered
632 // owned by the caller. Sets [*length] to the length of the returned buffer.
633 uint8_t* Steal(intptr_t* length) {
634 ASSERT(length != nullptr);
636 uint8_t* const old_buffer = buffer_;
637 // We don't immediately reallocate a new space just in case this steal
638 // is the last use of this stream.
639 current_ = buffer_ = nullptr;
640 capacity_ = 0;
641 return old_buffer;
642 }
643
644 private:
645 virtual void Realloc(intptr_t new_size);
646
647 DISALLOW_COPY_AND_ASSIGN(MallocWriteStream);
648};
649
650// A non-streaming write stream that uses a zone for reallocation.
652 public:
653 ZoneWriteStream(Zone* zone, intptr_t initial_size)
654 : NonStreamingWriteStream(initial_size), zone_(zone) {}
655
656 private:
657 virtual void Realloc(intptr_t new_size);
658
659 Zone* const zone_;
660
661 DISALLOW_COPY_AND_ASSIGN(ZoneWriteStream);
662};
663
664// A streaming write stream that uses the internal buffer only for non-flushed
665// data. Like MallocWriteStream, uses realloc for reallocation, and flushes and
666// frees the internal buffer when destructed. Since part or all of the written
667// data may be flushed and no longer in the internal buffer, it does not provide
668// a way to retrieve the written contents.
670 public:
671 explicit StreamingWriteStream(intptr_t initial_capacity,
673 void* callback_data)
674 : BaseWriteStream(initial_capacity),
675 callback_(callback),
676 callback_data_(callback_data) {}
678
679 private:
680 // Flushes any unflushed data to callback_data and resets the internal
681 // buffer. Changes current_ and flushed_size_ accordingly.
682 virtual void Flush();
683
684 virtual void Realloc(intptr_t new_size);
685
686 virtual intptr_t Position() const {
687 return flushed_size_ + BaseWriteStream::Position();
688 }
689
690 virtual void SetPosition(intptr_t value) {
691 // Make sure we're not trying to set the position to already-flushed data.
692 ASSERT(value >= flushed_size_);
693 BaseWriteStream::SetPosition(value - flushed_size_);
694 }
695
696 const Dart_StreamingWriteCallback callback_;
697 void* const callback_data_;
698 intptr_t flushed_size_ = 0;
699
700 DISALLOW_COPY_AND_ASSIGN(StreamingWriteStream);
701};
702
703} // namespace dart
704
705#endif // RUNTIME_VM_DATASTREAM_H_
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition: DM.cpp:263
SkPoint pos
GLenum type
static void Write(BaseWriteStream *st, T value)
Definition: datastream.h:360
static void Write(BaseWriteStream *st, T value)
Definition: datastream.h:368
static void Write(BaseWriteStream *st, T value)
Definition: datastream.h:376
static void Write(BaseWriteStream *st, T value)
Definition: datastream.h:384
C::only_if_signed< T, void > WriteSLEB128(T value)
Definition: datastream.h:514
DISALLOW_COPY_AND_ASSIGN(BaseWriteStream)
void Printf(const char *format,...) PRINTF_ATTRIBUTE(2
void WriteBytes(const void *addr, intptr_t len)
Definition: datastream.h:424
virtual void SetPosition(intptr_t value)
Definition: datastream.h:579
void va_start(args, format)
void WriteString(const char *cstr)
Definition: datastream.h:482
void WriteFixed(T value)
Definition: datastream.h:473
void EnsureSpace(intptr_t size_needed)
Definition: datastream.h:564
BaseWriteStream(intptr_t initial_size)
Definition: datastream.h:334
void WriteWord(uword value)
Definition: datastream.h:432
void WriteWordWith32BitWrites(uword value)
Definition: datastream.h:389
intptr_t Align(intptr_t alignment, intptr_t offset=0)
Definition: datastream.h:341
C::only_if_unsigned< T, void > WriteSLEB128(T value)
Definition: datastream.h:559
virtual ~BaseWriteStream()
Definition: datastream.h:336
virtual void Realloc(intptr_t new_capacity)=0
DART_FORCE_INLINE void WriteByte(uint8_t value)
Definition: datastream.h:477
VPrintf(format, args)
void WriteUnsigned(T value)
Definition: datastream.h:400
DART_FORCE_INLINE intptr_t bytes_written() const
Definition: datastream.h:338
C::only_if_signed< T, void > WriteLEB128(T value)
Definition: datastream.h:506
void VPrintf(const char *format, va_list args)
Definition: datastream.h:443
virtual intptr_t Position() const
Definition: datastream.h:339
void WriteTargetWord(word value)
Definition: datastream.cc:12
void Write(T value)
Definition: datastream.h:463
C::only_if_unsigned< T, void > WriteLEB128(T value)
Definition: datastream.h:489
void WriteRefId(intptr_t value)
Definition: datastream.h:409
DART_FORCE_INLINE intptr_t Remaining() const
Definition: datastream.h:584
const intptr_t initial_size_
Definition: datastream.h:597
static DART_NORETURN void ThrowOOM()
Definition: exceptions.cc:1066
uint8_t * Steal(intptr_t *length)
Definition: datastream.h:633
virtual void Realloc(intptr_t new_size)
Definition: datastream.cc:21
MallocWriteStream(intptr_t initial_size)
Definition: datastream.h:627
NonStreamingWriteStream(intptr_t initial_size)
Definition: datastream.h:611
DART_FORCE_INLINE void SetPosition(intptr_t value)
Definition: datastream.h:618
uint8_t * buffer() const
Definition: datastream.h:615
static T Read(ReadStream *st)
Definition: datastream.h:68
static T Read(ReadStream *st)
Definition: datastream.h:74
static T Read(ReadStream *st)
Definition: datastream.h:80
static T Read(ReadStream *st)
Definition: datastream.h:86
uword ReadWordWith32BitReads()
Definition: datastream.h:157
C::only_if_unsigned< T, T > ReadSLEB128()
Definition: datastream.h:194
ReadStream(const uint8_t *buffer, intptr_t size, intptr_t pos)
Definition: datastream.h:57
void Align(intptr_t alignment, intptr_t offset=0)
Definition: datastream.h:133
C::only_if_signed< T, T > ReadLEB128()
Definition: datastream.h:189
intptr_t ReadRefId()
Definition: datastream.h:103
C::only_if_signed< T, T > ReadSLEB128()
Definition: datastream.h:219
ReadStream(const uint8_t *buffer, intptr_t size)
Definition: datastream.h:53
C::only_if_unsigned< T, T > ReadLEB128()
Definition: datastream.h:173
intptr_t Position() const
Definition: datastream.h:127
intptr_t PendingBytes() const
Definition: datastream.h:147
const uint8_t * AddressOfCurrentPosition() const
Definition: datastream.h:140
void Advance(intptr_t value)
Definition: datastream.h:142
void SetPosition(intptr_t value)
Definition: datastream.h:128
void ReadBytes(void *addr, intptr_t len)
Definition: datastream.h:90
virtual void Realloc(intptr_t new_size)
Definition: datastream.cc:40
StreamingWriteStream(intptr_t initial_capacity, Dart_StreamingWriteCallback callback, void *callback_data)
Definition: datastream.h:671
virtual void SetPosition(intptr_t value)
Definition: datastream.h:690
virtual intptr_t Position() const
Definition: datastream.h:686
static constexpr T NBitMask(size_t n)
Definition: utils.h:548
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)
Definition: utils.h:120
static bool IsUint(intptr_t N, T value)
Definition: utils.h:328
ZoneWriteStream(Zone *zone, intptr_t initial_size)
Definition: datastream.h:653
virtual void Realloc(intptr_t new_size)
Definition: datastream.cc:28
void(* Dart_StreamingWriteCallback)(void *callback_data, const uint8_t *buffer, intptr_t size)
Definition: dart_api.h:3935
#define UNROLLED_BODY(bit_start)
Definition: datastream.h:258
#define UNROLLED_END(bit_start)
Definition: datastream.h:272
#define UNROLLED_INIT()
Definition: datastream.h:248
#define STAGE
#define ASSERT(E)
static bool b
struct MyStruct s
glong glong end
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
uint8_t value
GAsyncResult * result
uint32_t uint32_t * format
size_t length
SK_API bool Read(SkStreamSeekable *src, SkDocumentPage *dstArray, int dstArrayCount, const SkDeserialProcs *=nullptr)
Definition: dart_vm.cc:33
DART_FORCE_INLINE D bit_cast(const S &source)
Definition: globals.h:646
constexpr intptr_t kBitsPerWord
Definition: globals.h:514
constexpr intptr_t kBitsPerByte
Definition: globals.h:463
uintptr_t uword
Definition: globals.h:501
intptr_t word
Definition: globals.h:500
static constexpr int8_t kMaxUnsignedDataPerByte
Definition: datastream.h:20
static constexpr uint8_t kEndUnsignedByteMarker
Definition: datastream.h:25
static constexpr int8_t kByteMask
Definition: datastream.h:19
intx_t sign_extend(int32_t x)
constexpr intptr_t kBitsPerInt32
Definition: globals.h:466
static constexpr int8_t kMinDataPerByte
Definition: datastream.h:21
static constexpr int8_t kMaxDataPerByte
Definition: datastream.h:22
static constexpr int8_t kDataBitsPerByte
Definition: datastream.h:18
static constexpr uint8_t kEndByteMarker
Definition: datastream.h:24
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
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
Definition: globals.h:697
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition: globals.h:581
#define T
Definition: precompiler.cc:65
SeparatedVector2 offset
static constexpr uint8_t kSignMask
Definition: datastream.h:45
static constexpr uint8_t kDataBitsPerByte
Definition: datastream.h:40
static constexpr uint8_t kDataByteMask
Definition: datastream.h:41
typename std::enable_if< std::is_unsigned< T >::value, S >::type only_if_unsigned
Definition: datastream.h:37
static constexpr uint8_t kMoreDataMask
Definition: datastream.h:43
typename std::enable_if< std::is_signed< T >::value, S >::type only_if_signed
Definition: datastream.h:32