5#ifndef RUNTIME_VM_KERNEL_BINARY_H_
6#define RUNTIME_VM_KERNEL_BINARY_H_
8#if !defined(DART_PRECOMPILED_RUNTIME)
24#define KERNEL_TAG_LIST(V) \
29 V(ExtensionTypeDeclaration, 85) \
34 V(InvalidInitializer, 7) \
35 V(FieldInitializer, 8) \
36 V(SuperInitializer, 9) \
37 V(RedirectingInitializer, 10) \
38 V(LocalInitializer, 11) \
39 V(AssertInitializer, 12) \
40 V(CheckLibraryIsLoaded, 13) \
44 V(StaticTearOff, 17) \
45 V(ConstStaticInvocation, 18) \
46 V(InvalidExpression, 19) \
49 V(AbstractSuperPropertyGet, 22) \
50 V(AbstractSuperPropertySet, 23) \
51 V(SuperPropertyGet, 24) \
52 V(SuperPropertySet, 25) \
55 V(AbstractSuperMethodInvocation, 28) \
56 V(SuperMethodInvocation, 29) \
57 V(StaticInvocation, 30) \
58 V(ConstructorInvocation, 31) \
59 V(ConstConstructorInvocation, 32) \
62 V(LogicalExpression, 34) \
63 V(ConditionalExpression, 35) \
64 V(StringConcatenation, 36) \
65 V(ListConcatenation, 111) \
66 V(SetConcatenation, 112) \
67 V(MapConcatenation, 113) \
68 V(InstanceCreation, 114) \
69 V(FileUriExpression, 116) \
72 V(StringLiteral, 39) \
73 V(DoubleLiteral, 40) \
77 V(SymbolLiteral, 44) \
79 V(ThisExpression, 46) \
85 V(AwaitExpression, 51) \
86 V(FunctionExpression, 52) \
88 V(BlockExpression, 82) \
89 V(Instantiation, 54) \
90 V(PositiveIntLiteral, 55) \
91 V(NegativeIntLiteral, 56) \
92 V(BigIntLiteral, 57) \
93 V(ConstListLiteral, 58) \
94 V(ConstSetLiteral, 110) \
95 V(ConstMapLiteral, 59) \
96 V(ConstructorTearOff, 60) \
97 V(TypedefTearOff, 83) \
98 V(RedirectingFactoryTearOff, 84) \
99 V(RecordIndexGet, 101) \
100 V(RecordNameGet, 102) \
101 V(RecordLiteral, 104) \
102 V(ConstRecordLiteral, 105) \
103 V(ExpressionStatement, 61) \
105 V(EmptyStatement, 63) \
106 V(AssertStatement, 64) \
107 V(LabeledStatement, 65) \
108 V(BreakStatement, 66) \
109 V(WhileStatement, 67) \
111 V(ForStatement, 69) \
112 V(ForInStatement, 70) \
113 V(SwitchStatement, 71) \
114 V(ContinueSwitchStatement, 72) \
116 V(ReturnStatement, 74) \
119 V(YieldStatement, 77) \
120 V(VariableDeclaration, 78) \
121 V(FunctionDeclaration, 79) \
122 V(AsyncForInStatement, 80) \
128 V(InterfaceType, 93) \
129 V(FunctionType, 94) \
130 V(TypeParameterType, 95) \
131 V(SimpleInterfaceType, 96) \
132 V(SimpleFunctionType, 97) \
134 V(IntersectionType, 99) \
136 V(ExtensionType, 103) \
137 V(ConstantExpression, 106) \
138 V(FutureOrType, 107) \
139 V(FileUriConstantExpression, 108) \
140 V(InstanceGet, 118) \
141 V(InstanceSet, 119) \
142 V(InstanceInvocation, 120) \
143 V(InstanceGetterInvocation, 89) \
144 V(InstanceTearOff, 121) \
147 V(DynamicInvocation, 124) \
148 V(FunctionInvocation, 125) \
149 V(FunctionTearOff, 126) \
150 V(LocalFunctionInvocation, 127) \
152 V(AssignedVariablePattern, 129) \
153 V(CastPattern, 130) \
154 V(ConstantPattern, 131) \
155 V(InvalidPattern, 132) \
156 V(ListPattern, 133) \
158 V(NamedPattern, 135) \
159 V(NullAssertPattern, 136) \
160 V(NullCheckPattern, 137) \
161 V(ObjectPattern, 138) \
163 V(RecordPattern, 140) \
164 V(RelationalPattern, 141) \
165 V(RestPattern, 142) \
166 V(VariablePattern, 143) \
167 V(WildcardPattern, 144) \
168 V(MapPatternEntry, 145) \
169 V(MapPatternRestEntry, 146) \
170 V(PatternSwitchStatement, 147) \
171 V(SwitchExpression, 148) \
172 V(IfCaseStatement, 149) \
173 V(PatternAssignment, 150) \
174 V(PatternVariableDeclaration, 151) \
176 V(SpecializedVariableGet, 224) \
177 V(SpecializedVariableSet, 232) \
178 V(SpecializedIntLiteral, 240)
185#define DECLARE(Name, value) k##Name = value,
288 intptr_t fields_before,
290 intptr_t list_index) {
291 intptr_t org_offset =
offset();
294 offset_ = org_offset;
306 intptr_t fields_before,
308 intptr_t list_index) {
309 offset_ = end_offset - (fields_before + list_size - list_index) * 4;
320 ASSERT((size_ >= 8) && (offset_ >= 0) && (offset_ <= size_ - 8));
322 LoadUnaligned(
reinterpret_cast<const double*
>(&raw_buffer_[offset_]));
328 ASSERT((size_ >= 1) && (offset_ >= 0) && (offset_ <= size_ - 1));
330 const uint8_t*
buffer = raw_buffer_;
332 if ((byte0 & 0x80) == 0) {
336 }
else if ((byte0 & 0xc0) == 0x80) {
338 ASSERT((size_ >= 2) && (offset_ >= 0) && (offset_ <= size_ - 2));
340 ((byte0 & ~static_cast<uword>(0x80)) << 8) | (
buffer[offset_ + 1]);
345 ASSERT((size_ >= 4) && (offset_ >= 0) && (offset_ <= size_ - 4));
346 uint32_t
value = ((byte0 & ~static_cast<uword>(0xc0)) << 24) |
347 (
buffer[offset_ + 1] << 16) |
348 (
buffer[offset_ + 2] << 8) | (
buffer[offset_ + 3] << 0);
357 offset_ =
stream.Position();
364 offset_ =
stream.Position();
383 uint8_t
ReadByte() {
return raw_buffer_[offset_++]; }
385 uint8_t
PeekByte() {
return raw_buffer_[offset_]; }
388 for (
int i = 0;
i <
size;
i++) {
404 if (payload !=
nullptr) {
409 return static_cast<Tag>(byte);
418 if (payload !=
nullptr) {
423 return static_cast<Tag>(byte);
428 switch (kernel_nullability) {
435 FATAL(
"Legacy nullability is not supported.");
451 if (offset_ != size_) {
453 "Reading Kernel file: Expected to be at EOF "
454 "(offset: %" Pd ", size: %" Pd ")",
474 intptr_t
offset()
const {
return offset_; }
479 intptr_t
size()
const {
return size_; }
487 return &raw_buffer_[
offset];
498 : thread_(nullptr), raw_buffer_(
buffer), size_(
size) {}
502 raw_buffer_ =
reinterpret_cast<uint8_t*
>(typed_data_->
DataAddr(0));
507 Thread* thread_ =
nullptr;
513 const uint8_t* raw_buffer_ =
nullptr;
516 intptr_t offset_ = 0;
519 intptr_t current_script_id_ = -1;
530 : reader_(reader), saved_offset_(reader_->offset_) {
531 reader_->offset_ = new_position;
535 : reader_(reader), saved_offset_(reader_->offset_) {}
543 const intptr_t saved_offset_;
554 intptr_t new_position)
556 saved_size_(reader_->size_),
557 saved_raw_buffer_(reader_->raw_buffer_),
558 saved_typed_data_(reader_->typed_data_),
559 saved_offset_(reader_->offset_) {
560 reader_->typed_data_ = new_typed_data;
562 reader_->offset_ = new_position;
566 reader_->raw_buffer_ = saved_raw_buffer_;
567 reader_->typed_data_ = saved_typed_data_;
568 reader_->size_ = saved_size_;
569 reader_->offset_ = saved_offset_;
576 intptr_t saved_size_;
577 const uint8_t* saved_raw_buffer_;
579 intptr_t saved_offset_;
593 min_(reader->min_position_),
594 max_(reader->max_position_) {
595 reader->min_position_ = reader->max_position_ = TokenPosition::kNoSource;
static const TokenPosition & Min(const TokenPosition &a, const TokenPosition &b)
static TokenPosition Deserialize(int32_t value)
static const TokenPosition & Max(const TokenPosition &a, const TokenPosition &b)
TypedDataViewPtr ViewFromTo(intptr_t start, intptr_t end, Heap::Space space=Heap::kNew) const
intptr_t LengthInBytes() const
bool IsExternalOrExternalView() const
void * DataAddr(intptr_t byte_offset) const
static uint32_t BigEndianToHost32(uint32_t be_value)
AlternativeReadingScopeWithNewData(Reader *reader, const TypedDataBase *new_typed_data, intptr_t new_position)
~AlternativeReadingScopeWithNewData()
AlternativeReadingScope(Reader *reader, intptr_t new_position)
AlternativeReadingScope(Reader *reader)
~AlternativeReadingScope()
PositionScope(Reader *reader)
const TypedDataBase * typed_data()
static Nullability ConvertNullability(KernelNullability kernel_nullability)
TokenPosition ReadPosition()
uint32_t ReadFromIndexNoReset(intptr_t end_offset, intptr_t fields_before, intptr_t list_size, intptr_t list_index)
void set_offset(intptr_t offset)
TokenPosition min_position()
TokenPosition max_position()
uint32_t ReadUInt32At(intptr_t offset) const
Reader(const TypedDataBase &typed_data)
TypedDataViewPtr ViewFromTo(intptr_t start, intptr_t end)
uint32_t ReadFromIndex(intptr_t end_offset, intptr_t fields_before, intptr_t list_size, intptr_t list_index)
void ReadBytes(uint8_t *buffer, uint8_t size)
TypedDataPtr ReadLineStartsData(intptr_t line_start_count)
Nullability ReadNullability()
Tag ReadTag(uint8_t *payload=nullptr)
int64_t ReadSLEB128AsInt64()
static const char * TagName(Tag tag)
Tag PeekTag(uint8_t *payload=nullptr)
NameIndex ReadCanonicalNameReference()
const uint8_t * BufferAt(intptr_t offset)
intptr_t ReadListLength()
#define DECLARE(Name, value)
#define KERNEL_TAG_LIST(V)
@ kTypedefTearOffConstant
@ kConstructorTearOffConstant
@ kRedirectingFactoryTearOffConstant
static constexpr int SpecializedIntLiteralBias
@ kYieldStatementFlagYieldStar
static const uint32_t kMagicProgramFile
static constexpr int SourceTableFieldCountFromFirstLibraryOffset
static constexpr int LibraryCountFieldCountFromEnd
static constexpr intptr_t kSpecializedPayloadMask
static constexpr intptr_t kSpecializedTagHighBits
static const uint32_t kSupportedKernelFormatVersion
@ kDynamicInvocationFlagImplicitCall
static constexpr intptr_t kSpecializedTagMask
@ kInstanceInvocationFlagBoundsSafe
@ kInstanceInvocationFlagInvariant
static constexpr int HeaderSize
@ kAsExpressionFlagUnchecked
@ kAsExpressionFlagCovarianceCheck
@ kAsExpressionFlagForDynamic
@ kAsExpressionFlagTypeError
static constexpr int KernelFormatVersionOffset
static T LoadUnaligned(const T *ptr)
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