5#ifndef RUNTIME_VM_COMPILER_FRONTEND_KERNEL_TRANSLATION_HELPER_H_
6#define RUNTIME_VM_COMPILER_FRONTEND_KERNEL_TRANSLATION_HELPER_H_
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
22class KernelReaderHelper;
156 bool required =
true);
158 bool required =
true);
160 bool required =
true);
164 bool required =
true);
166 bool required =
true);
168 bool required =
true);
171 bool required =
true);
174 bool required =
true);
176 const String& method_name,
177 bool required =
true);
201 ASSERT(expression_evaluation_function_ ==
nullptr);
205 if (expression_evaluation_function_ ==
nullptr) {
206 return Function::null_function();
208 return *expression_evaluation_function_;
211 ASSERT(expression_evaluation_class_ ==
nullptr);
216 if (expression_evaluation_class_ ==
nullptr) {
217 return Class::null_class();
219 return *expression_evaluation_class_;
222 ASSERT(expression_evaluation_real_class_ ==
nullptr);
224 expression_evaluation_real_class_ = &
Class::Handle(zone_, real_class.
ptr());
227 if (expression_evaluation_real_class_ ==
nullptr) {
228 return Class::null_class();
230 return *expression_evaluation_real_class_;
240 bool symbolize =
true,
241 bool obfuscate =
true);
244 bool symbolize =
true,
245 bool obfuscate =
true);
260 Smi& name_index_handle_;
262 Function* expression_evaluation_function_ =
nullptr;
267 Class* expression_evaluation_class_ =
nullptr;
271 Class* expression_evaluation_real_class_ =
nullptr;
505 : helper_(helper), next_read_(
kStart) {}
605 : helper_(helper), next_read_(
kStart) {}
690 : helper_(helper), next_read_(
kStart) {}
766 : helper_(helper), next_read_(
kStart) {}
782 return (
flags_ & Flag::kIsEliminatedMixin) != 0;
786 return (
flags_ & Flag::kHasConstConstructor) != 0;
857 : helper_(helper), next_read_(
kFlags) {}
939 bool precompiler_only);
942 static void VerifyMetadataMappings(
const TypedDataView& metadata_mappings);
963 void SetMetadataMappings(intptr_t mappings_offset, intptr_t mappings_num);
964 void ScanMetadataMappings();
967 bool mappings_scanned_;
968 bool precompiler_only_;
969 intptr_t mappings_offset_;
970 intptr_t mappings_num_;
971 intptr_t last_node_offset_;
972 intptr_t last_mapping_index_;
993 static const char*
tag() {
return "vm.direct-call.metadata"; }
1003 bool ReadMetadata(intptr_t node_offset,
1005 bool* check_receiver_for_null,
1006 intptr_t* closure_id =
nullptr);
1025 const Object& constant_value_ = Object::null_object())
1048 bool can_be_sentinel =
false)
const {
1071 return "vm.inferred-type.metadata";
1073 return "vm.inferred-arg-type.metadata";
1084 bool read_constant =
true);
1109 static const char*
tag() {
return "vm.procedure-attributes.metadata"; }
1116 bool ReadMetadata(intptr_t node_offset,
1124 static const char*
tag() {
return "vm.obfuscation-prohibitions.metadata"; }
1131 void ReadMetadata(intptr_t node_offset);
1138 static const char*
tag() {
return "vm.loading-units.metadata"; }
1145 void ReadMetadata(intptr_t node_offset);
1157 static const char*
tag() {
return "vm.call-site-attributes.metadata"; }
1195 static const char*
tag() {
return "vm.table-selector.metadata"; }
1202 static constexpr uint8_t kCalledOnNullBit = 1 << 0;
1203 static constexpr uint8_t kTornOffBit = 1 << 1;
1252 static const char*
tag() {
return "vm.unboxing-info.metadata"; }
1269 intptr_t data_program_offset)
1395 const Script& interesting_script);
1414 return function_kind == UntaggedFunction::kRegularFunction ||
1415 function_kind == UntaggedFunction::kGetterFunction ||
1416 function_kind == UntaggedFunction::kSetterFunction ||
1417 function_kind == UntaggedFunction::kMethodExtractor ||
1418 function_kind == UntaggedFunction::kDynamicInvocationForwarder ||
1463 : active_class_(active_class), saved_(*active_class) {
1464 active_class_->
klass = klass;
1479 : active_class_(active_class), saved_(*active_class) {
1481 active_class_->
member = member;
1497 : active_class_(active_class), saved_(*active_class) {
1498 active_class_->
enclosing = enclosing_signature;
1544 bool finalize =
false,
1545 bool in_constant_context =
false);
1553 const Class& receiver_class,
1558 const Class& parameterized_class,
1560 intptr_t type_parameter_count);
1564 const Class& parameterized_class,
1566 intptr_t type_parameter_count);
1578 intptr_t library_kernel_offset);
1579 void SetupUnboxingInfoMetadataForFieldAccessors(
1581 intptr_t library_kernel_offset);
1583 void BuildTypeInternal();
1584 void BuildInterfaceType(
bool simple);
1585 void BuildFunctionType(
bool simple);
1586 void BuildRecordType();
1587 void BuildTypeParameterType();
1588 void BuildIntersectionType();
1589 void BuildExtensionType();
1590 void BuildFutureOrType();
1593 if (active_class_ !=
nullptr) {
1599 class TypeParameterScope {
1601 TypeParameterScope(
TypeTranslator* translator, intptr_t parameter_count)
1602 : parameter_count_(parameter_count),
1603 outer_(translator->type_parameter_scope_),
1604 translator_(translator) {
1605 outer_parameter_count_ = 0;
1606 if (outer_ !=
nullptr) {
1607 outer_parameter_count_ =
1608 outer_->outer_parameter_count_ + outer_->parameter_count_;
1610 translator_->type_parameter_scope_ =
this;
1612 ~TypeParameterScope() { translator_->type_parameter_scope_ = outer_; }
1614 TypeParameterScope* outer()
const {
return outer_; }
1615 intptr_t parameter_count()
const {
return parameter_count_; }
1616 intptr_t outer_parameter_count()
const {
return outer_parameter_count_; }
1619 intptr_t parameter_count_;
1620 intptr_t outer_parameter_count_;
1621 TypeParameterScope* outer_;
1629 TypeParameterScope* type_parameter_scope_;
1635 const bool in_constant_context_;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static bool skip(SkStream *stream, size_t amount)
intptr_t NumTypeArguments() const
static CompileType FromAbstractType(const AbstractType &type, bool can_be_null, bool can_be_sentinel)
UntaggedFunction::Kind kind() const
virtual const char * ToCString() const
static Object & ZoneHandle()
static RecordShape ForUnnamed(intptr_t num_fields)
static TypePtr NullableIntType()
ActiveClassScope(ActiveClass *active_class, const Class *klass)
const FunctionType * enclosing
const TypeArguments * local_type_parameters
intptr_t ClassNumTypeArguments()
bool MemberIsFactoryProcedure()
intptr_t MemberTypeParameterCount(Zone *zone)
ActiveEnclosingFunctionScope(ActiveClass *active_class, const FunctionType *enclosing_signature)
~ActiveEnclosingFunctionScope()
ActiveMemberScope(ActiveClass *active_class, const Function *member)
void SetJustRead(Field field)
bool is_enum_class() const
bool is_transformed_mixin_application() const
bool is_mixin_class() const
intptr_t source_uri_index_
bool is_interface() const
intptr_t procedure_count_
ClassHelper(KernelReaderHelper *helper)
NameIndex canonical_name_
void ReadUntilIncluding(Field field)
bool has_const_constructor() const
void SetNext(Field field)
TokenPosition end_position_
TokenPosition start_position_
void ReadUntilExcluding(Field field)
intptr_t annotation_count_
intptr_t annotation_count_
void SetJustRead(Field field)
TokenPosition end_position_
TokenPosition start_position_
NameIndex canonical_name_
intptr_t source_uri_index_
ConstructorHelper(KernelReaderHelper *helper)
void ReadUntilIncluding(Field field)
void ReadUntilExcluding(Field field)
void SetNext(Field field)
FieldHelper(KernelReaderHelper *helper)
NameIndex canonical_name_getter_
NameIndex canonical_name_field_
bool IsExtensionMember() const
void ReadUntilExcluding(Field field)
void SetNext(Field field)
intptr_t source_uri_index_
bool IsExtensionTypeMember() const
void SetJustRead(Field field)
void ReadUntilIncluding(Field field)
TokenPosition end_position_
bool IsGenericCovariantImpl()
@ kIsGenericCovariantImpl
@ kInternalImplementation
NameIndex canonical_name_setter_
intptr_t annotation_count_
intptr_t total_parameter_count_
FunctionNodeHelper(KernelReaderHelper *helper)
AsyncMarker async_marker_
void ReadUntilIncluding(Field field)
intptr_t required_parameter_count_
void ReadUntilExcluding(Field field)
void SetNext(Field field)
AsyncMarker dart_async_marker_
@ kRedirectingFactoryTarget
@ kRequiredParameterCount
void SetJustRead(Field field)
TokenPosition end_position_
void SkipFunctionType(bool simple)
const String & GetSourceFor(intptr_t index)
uint32_t PeekListLength()
friend ArrayPtr CollectConstConstructorCoverageFrom(const Script &interesting_script)
void SkipListOfCanonicalNameReferences()
void SkipListOfVariableDeclarations()
friend bool NeedsDynamicInvocationForwarder(const Function &function)
intptr_t ReaderSize() const
void SkipTypeParametersList()
void SetOffset(intptr_t offset)
String & SourceTableUriFor(intptr_t index)
const String & ReadNameAsGetterName()
const String & ReadNameAsMethodName()
void ReadUntilFunctionNode()
void SkipOptionalDartType()
void SkipListOfDartTypes()
KernelReaderHelper(Zone *zone, TranslationHelper *translation_helper, const TypedDataBase &data, intptr_t data_program_offset)
intptr_t data_program_offset_
virtual ~KernelReaderHelper()=default
void SkipConstantReference()
intptr_t SourceTableSize()
const String & ReadNameAsSetterName()
intptr_t ReadListLength()
TranslationHelper & translation_helper_
void SkipLibraryCombinator()
TokenPosition ReadPosition()
Tag ReadTag(uint8_t *payload=nullptr)
void SkipListOfExpressions()
virtual void set_current_script_id(intptr_t id)
virtual void ReportUnexpectedTag(const char *variant, Tag tag)
Tag PeekTag(uint8_t *payload=nullptr)
NameIndex ReadInterfaceMemberNameReference()
void SkipLibraryDependency()
void SkipListOfNamedExpressions()
intptr_t GetOffsetForSourceInfo(intptr_t index)
intptr_t ReaderOffset() const
virtual void RecordTokenPosition(TokenPosition position)
void SkipInterfaceMemberNameReference()
NameIndex ReadCanonicalNameReference()
const String & ReadNameAsFieldName()
friend class ConstantHelper
StringIndex ReadNameAsStringIndex()
void SkipCanonicalNameReference()
void SkipVariableDeclaration()
String & SourceTableImportUriFor(intptr_t index)
void SkipStringReference()
void SkipBytes(intptr_t skip)
StringIndex ReadStringReference()
void SkipInterfaceType(bool simple)
TypedDataViewPtr GetConstantCoverageFor(intptr_t index)
Nullability ReadNullability()
TypedDataPtr GetLineStartsFor(intptr_t index)
void ReadUntilExcluding(Field field)
NameIndex target_library_canonical_name_
intptr_t annotation_count_
void ReadUntilIncluding(Field field)
LibraryDependencyHelper(KernelReaderHelper *helper)
void SetJustRead(Field field)
@ kNonNullableByDefaultCompiledModeBit1
@ kNonNullableByDefaultCompiledModeBit2
void ReadUntilIncluding(Field field)
void ReadUntilExcluding(Field field)
NameIndex canonical_name_
LibraryHelper(KernelReaderHelper *helper)
void SetNext(Field field)
intptr_t source_uri_index_
NNBDCompiledMode GetNonNullableByDefaultCompiledMode() const
NameIndex canonical_name_
bool IsExtensionMember() const
bool IsMemberSignature() const
NameIndex concrete_forwarding_stub_target_
bool IsExtensionTypeMember() const
bool IsNoSuchMethodForwarder() const
@ kInternalImplementation
@ kHasWeakTearoffReferencePragma
@ kAbstractForwardingStubKind
@ kConcreteForwardingStubKind
@ kNoSuchMethodForwarderStubKind
@ kMemberSignatureStubKind
void SetNext(Field field)
void ReadUntilExcluding(Field field)
bool IsForwardingStub() const
void SetJustRead(Field field)
intptr_t source_uri_index_
ProcedureHelper(KernelReaderHelper *helper)
void ReadUntilIncluding(Field field)
TokenPosition end_position_
intptr_t annotation_count_
TokenPosition start_position_
bool IsInternalImplementation() const
const Class & GetExpressionEvaluationRealClass()
const String & DartProcedureName(NameIndex procedure)
bool IsGetter(NameIndex name)
IsolateGroup * isolate_group()
Type & GetDeclarationType(const Class &klass)
void SetConstantsTable(const TypedDataView &constants_table)
InstancePtr Canonicalize(const Instance &instance)
FunctionPtr LookupStaticMethodByKernelProcedure(NameIndex procedure, bool required=true)
const TypedDataView & string_data() const
FunctionPtr LookupDynamicFunction(const Class &klass, const String &name)
const TypedDataView & metadata_mappings() const
const String & DartSetterName(NameIndex setter)
FieldPtr LookupFieldByKernelGetterOrSetter(NameIndex field, bool required=true)
String & DartString(StringIndex index)
intptr_t StringSize(StringIndex index) const
void SetCanonicalNames(const TypedData &canonical_names)
const TypedDataView & constants_table() const
intptr_t StringOffset(StringIndex index) const
void ReportError(const char *format,...) PRINTF_ATTRIBUTE(2
const String & DartClassName(NameIndex kernel_class)
uint8_t * StringBuffer(StringIndex index) const
const String & DartString(const char *content)
bool IsField(NameIndex name)
FunctionPtr LookupMethodByMember(NameIndex target, const String &method_name, bool required=true)
bool IsFactory(NameIndex name)
bool IsMember(NameIndex name)
const Function & GetExpressionEvaluationFunction()
virtual ~TranslationHelper()
bool IsMethod(NameIndex name)
bool IsConstructor(NameIndex name)
const String & DartConstructorName(NameIndex constructor)
bool IsProcedure(NameIndex name)
NameIndex CanonicalNameParent(NameIndex name)
FieldPtr LookupFieldByKernelField(NameIndex field, bool required=true)
void SetMetadataMappings(const TypedDataView &metadata_mappings)
const KernelProgramInfo & GetKernelProgramInfo() const
void SetKernelProgramInfo(const KernelProgramInfo &info)
void InitFromKernelProgramInfo(const KernelProgramInfo &info)
ClassPtr LookupClassByKernelClassOrLibrary(NameIndex kernel_name, bool required=true)
bool IsPrivate(NameIndex name)
Heap::Space allocation_space()
bool IsAdministrative(NameIndex name)
bool IsLibrary(NameIndex name)
bool IsClass(NameIndex name)
uint8_t CharacterAt(StringIndex string_index, intptr_t index)
String & DartIdentifier(const Library &lib, StringIndex string_index)
const Class & GetExpressionEvaluationClass()
const TypedData & canonical_names() const
const String & DartFactoryName(NameIndex factory)
void SetExpressionEvaluationClass(const Class &cls)
const TypedData & string_offsets() const
const String & DartMethodName(NameIndex method)
const TypedDataView & metadata_payloads() const
const String & DartSymbolPlain(const char *content) const
DART_NORETURN void LookupFailed(NameIndex name)
bool IsRoot(NameIndex name)
virtual LibraryPtr LookupLibraryByKernelLibrary(NameIndex library, bool required=true)
FunctionPtr LookupConstructorByKernelConstructor(NameIndex constructor, bool required=true)
const String & DartGetterName(NameIndex getter)
void SetupFieldAccessorFunction(const Class &klass, const Function &function, const AbstractType &field_type)
bool IsSetter(NameIndex name)
NameIndex EnclosingName(NameIndex name)
const String & DartSymbolObfuscate(const char *content) const
TranslationHelper(Thread *thread)
bool StringEquals(StringIndex string_index, const char *other)
StringIndex CanonicalNameString(NameIndex name)
void SetExpressionEvaluationRealClass(const Class &real_class)
void SetStringOffsets(const TypedData &string_offsets)
const String & DartFieldName(NameIndex field)
void SetConstants(const Array &constants)
void SetStringData(const TypedDataView &string_data)
ObjectPtr LookupMemberByMember(NameIndex kernel_name, bool required=true)
void SetMetadataPayloads(const TypedDataView &metadata_payloads)
const Array & constants()
void void void void void SetExpressionEvaluationFunction(const Function &function)
virtual ClassPtr LookupClassByKernelClass(NameIndex klass, bool required=true)
void SetNext(Field field)
void ReadUntilIncluding(Field field)
TypeParameterHelper(KernelReaderHelper *helper)
void ReadUntilExcludingAndSetJustRead(Field field)
void ReadUntilExcluding(Field field)
void SetJustRead(Field field)
@ kIsGenericCovariantImpl
bool IsGenericCovariantImpl()
TypeTranslator(KernelReaderHelper *helper, ConstantReader *constant_reader, ActiveClass *active_class, bool finalize=false, bool in_constant_context=false)
AbstractType & BuildType()
const TypeArguments & BuildTypeArguments(intptr_t length)
void SetupFunctionParameters(const Class &klass, const Function &function, bool is_method, bool is_closure, FunctionNodeHelper *function_node_helper)
const Type & ReceiverType(const Class &klass)
AbstractType & BuildTypeWithoutFinalization()
void LoadAndSetupTypeParameters(ActiveClass *active_class, const Function &function, const Class ¶meterized_class, const FunctionType ¶meterized_signature, intptr_t type_parameter_count)
const TypeArguments & BuildInstantiatedTypeArguments(const Class &receiver_class, intptr_t length)
void LoadAndSetupBounds(ActiveClass *active_class, const Function &function, const Class ¶meterized_class, const FunctionType ¶meterized_signature, intptr_t type_parameter_count)
void ReadUntilIncluding(Field field)
bool IsGenericCovariantImpl() const
void SetNext(Field field)
TokenPosition equals_position_
intptr_t annotation_count_
VariableDeclarationHelper(KernelReaderHelper *helper)
bool HasDeclaredInitializer() const
void SetJustRead(Field field)
void ReadUntilExcluding(Field field)
bool IsSynthesized() const
@ kHasDeclaredInitializer
@ kIsGenericCovariantImpl
FlutterSemanticsFlag flags
uint32_t uint32_t * format
Dart_NativeFunction function
union flutter::testing::@2836::KeyboardChange::@76 content
static int8_t data[kExtLength]