4#if !defined(DART_PRECOMPILED_RUNTIME)
33#define IG (thread_->isolate_group())
34#define T (type_translator_)
35#define H (translation_helper_)
43 : translation_helper_(*translation_helper),
44 zone_(translation_helper_.
zone()),
45 simple_value_(nullptr),
46 helper_(reader_helper) {}
53 case kBigIntLiteral: {
55 const String& literal_str =
59 if (simple_value_->
IsNull()) {
60 H.ReportError(
"Integer literal %s is out of range",
64 *simple_value_ =
H.Canonicalize(*simple_value_);
69 simple_value_ = &
H.DartSymbolPlain(
72 case kSpecializedIntLiteral:
78 *simple_value_ =
H.Canonicalize(*simple_value_);
80 case kNegativeIntLiteral:
85 *simple_value_ =
H.Canonicalize(*simple_value_);
87 case kPositiveIntLiteral:
92 *simple_value_ =
H.Canonicalize(*simple_value_);
98 *simple_value_ =
H.Canonicalize(*simple_value_);
129ArrayPtr KernelLoader::MakeFieldsArray() {
130 const intptr_t len = fields_.length();
132 for (intptr_t i = 0; i < len; i++) {
133 res.
SetAt(i, *fields_[i]);
138ArrayPtr KernelLoader::MakeFunctionsArray() {
139 const intptr_t
len = functions_.length();
141 for (intptr_t i = 0; i <
len; i++) {
142 res.SetAt(i, *functions_[i]);
150 return loader_->LookupLibrary(library);
156 LibraryLookupHandleScope library_lookup_handle_scope(library_lookup_handle_);
158 library_lookup_handle_ = loader_->LookupLibraryFromClass(klass);
159 return loader_->LookupClass(library_lookup_handle_, klass);
163 : reader_(kernel_data) {
164 intptr_t data_size = reader_.
size();
167 procedure_index_offset_ = data_size - 4 - (procedure_count_ + 1) * 4;
169 class_count_ = reader_.
ReadUInt32At(procedure_index_offset_ - 4);
170 class_index_offset_ = procedure_index_offset_ - 4 - (class_count_ + 1) * 4;
172 source_references_offset_ = -1;
173 source_references_offset_ = reader_.
ReadUInt32At(class_index_offset_ - 4);
177 intptr_t class_offset,
179 : reader_(library_kernel_data) {
180 Init(class_offset, class_size);
183void ClassIndex::Init(intptr_t class_offset, intptr_t class_size) {
184 procedure_count_ = reader_.
ReadUInt32At(class_offset + class_size - 4);
185 procedure_index_offset_ =
186 class_offset + class_size - 4 - (procedure_count_ + 1) * 4;
194 thread_(
Thread::Current()),
195 zone_(thread_->zone()),
196 no_active_isolate_scope_(),
197 patch_classes_(
Array::Handle(zone_)),
199 library_kernel_offset_(-1),
200 correction_offset_(-1),
201 loading_native_wrappers_library_(
false),
204 translation_helper_(this, thread_,
Heap::
kOld),
206 &translation_helper_,
209 constant_reader_(&helper_, &active_class_),
210 type_translator_(&helper_,
214 inferred_type_metadata_helper_(&helper_, &constant_reader_),
215 static_field_value_(
Object::Handle(
Z)),
216 name_index_handle_(
Smi::Handle(
Z)),
217 expression_evaluation_library_(
Library::Handle(
Z)) {
218 if (!program->is_single_program()) {
220 "Trying to load a concatenated dill file at a time where that is "
223 InitializeFields(uri_to_source_table);
226void KernelLoader::ReadObfuscationProhibitions() {
231void KernelLoader::ReadLoadingUnits() {
236Object& KernelLoader::LoadEntireProgram(Program* program,
237 bool process_pending_classes) {
242 if (program->is_single_program()) {
250 index_programs(&reader, &subprogram_file_starts);
255 intptr_t subprogram_count = subprogram_file_starts.
length() - 1;
262 for (intptr_t i = subprogram_count - 1; i >= 0; --i) {
263 intptr_t subprogram_start = subprogram_file_starts.
At(i);
264 intptr_t subprogram_end = subprogram_file_starts.
At(i + 1);
266 program->binary().ViewFromTo(subprogram_start, subprogram_end));
270 for (intptr_t index = 0; index < source_table_size; ++index) {
272 wrapper.
uri = &uri_string;
275 if (line_starts.
Length() == 0)
continue;
277 wrapper.
uri = &uri_string;
279 if (pair !=
nullptr) {
283 const bool line_starts_differ =
285 if (src_differ || line_starts_differ) {
287 "Invalid kernel binary: Contains at least two source entries "
288 "that do not agree. URI '%s', difference: %s. Subprogram count: "
291 src_differ && line_starts_differ
292 ?
"src and line starts"
293 : (src_differ ?
"src" :
"line starts"),
298 tmp->
uri = &uri_string;
301 uri_to_source_table.
Insert(tmp);
307 for (intptr_t i = subprogram_count - 1; i >= 0; --i) {
308 intptr_t subprogram_start = subprogram_file_starts.
At(i);
309 intptr_t subprogram_end = subprogram_file_starts.
At(i + 1);
311 program->binary().ViewFromTo(subprogram_start, subprogram_end));
313 const char*
error =
nullptr;
314 std::unique_ptr<Program> subprogram = Program::ReadFrom(&reader, &
error);
315 if (subprogram ==
nullptr) {
316 FATAL(
"Failed to load kernel file: %s",
error);
318 ASSERT(subprogram->is_single_program());
319 KernelLoader loader(subprogram.get(), &uri_to_source_table);
321 if (load_result.IsError())
return load_result;
323 if (load_result.IsLibrary()) {
324 library ^= load_result.
ptr();
336void KernelLoader::index_programs(
343 subprogram_file_starts->
Add(reader->
size());
345 while (reader->
offset() > 0) {
349 FATAL(
"Invalid kernel binary: Indicated size is invalid.");
354 subprogram_file_starts->
Reverse();
357StringPtr KernelLoader::FindSourceForScript(
const uint8_t* kernel_buffer,
358 intptr_t kernel_buffer_length,
361 kExternalTypedDataUint8ArrayCid,
const_cast<uint8_t*
>(kernel_buffer),
369 for (intptr_t i = 0; i < source_table_size; ++i) {
379 const intptr_t source_table_size = helper_.SourceTableSize();
383 const auto& binary = program_->binary();
386 ASSERT(program_->string_table_offset() >= 0);
388 reader.set_offset(program_->string_table_offset());
389 intptr_t
count = reader.ReadUInt() + 1;
392 offsets.SetUint32(0, 0);
393 intptr_t end_offset = 0;
394 for (intptr_t i = 1; i <
count; ++i) {
395 end_offset = reader.ReadUInt();
396 offsets.SetUint32(i << 2, end_offset);
401 reader.ViewFromTo(reader.offset(), reader.offset() + end_offset));
405 program_->constant_table_offset(), program_->name_table_offset()));
409 reader.set_offset(program_->name_table_offset());
410 count = reader.ReadUInt() * 2;
413 for (intptr_t i = 0; i <
count; ++i) {
414 names.SetUint32(i << 2, reader.ReadUInt());
419 reader.ViewFromTo(program_->metadata_payloads_offset(),
420 program_->metadata_mappings_offset()));
426 program_->metadata_mappings_offset(), program_->string_table_offset()));
429 MetadataHelper::VerifyMetadataMappings(metadata_mappings);
432 const Array& libraries_cache =
436 const intptr_t kClassesPerLibraryGuess = 5;
439 kClassesPerLibraryGuess * program_->library_count(),
Heap::kOld));
441 kernel_program_info_ = KernelProgramInfo::New(
442 binary, string_data, metadata_payloads, metadata_mappings,
443 constants_table, offsets,
names,
scripts, libraries_cache, classes_cache);
445 H.InitFromKernelProgramInfo(kernel_program_info_);
448 for (intptr_t index = 0; index < source_table_size; ++index) {
449 script = LoadScriptAt(index, uri_to_source_table);
454KernelLoader::KernelLoader(
const KernelProgramInfo& kernel_program_info,
455 const TypedDataBase& kernel_data,
456 intptr_t data_program_offset)
458 thread_(Thread::Current()),
459 zone_(thread_->zone()),
460 no_active_isolate_scope_(),
461 patch_classes_(Array::Handle(zone_)),
462 library_kernel_offset_(data_program_offset),
463 correction_offset_(0),
464 loading_native_wrappers_library_(
false),
465 library_kernel_data_(TypedDataView::Handle(zone_)),
466 kernel_program_info_(
467 KernelProgramInfo::Handle(zone_, kernel_program_info.ptr())),
468 translation_helper_(this, thread_, Heap::
kOld),
469 helper_(zone_, &translation_helper_, kernel_data, 0),
470 constant_reader_(&helper_, &active_class_),
471 type_translator_(&helper_,
475 inferred_type_metadata_helper_(&helper_, &constant_reader_),
476 static_field_value_(Object::Handle(
Z)),
477 name_index_handle_(Smi::Handle(
Z)),
478 expression_evaluation_library_(Library::Handle(
Z)) {
479 ASSERT(
T.active_class_ == &active_class_);
481 H.InitFromKernelProgramInfo(kernel_program_info_);
484bool KernelLoader::IsClassName(NameIndex
name,
485 const String& library,
486 const String& klass) {
488 StringIndex class_name_index =
H.CanonicalNameString(
name);
490 if (!
H.StringEquals(class_name_index, klass.ToCString())) {
494 StringIndex library_name_index =
495 H.CanonicalNameString(
H.CanonicalNameParent(
name));
496 return H.StringEquals(library_name_index, library.ToCString());
503 if (!program_->is_single_program()) {
505 "Trying to load a concatenated dill file at a time where that is "
510 if (setjmp(*jump.
Set()) == 0) {
512 const intptr_t
length = program_->library_count();
513 for (intptr_t i = 0; i <
length; i++) {
518 if (process_pending_classes) {
521 return H.thread()->StealStickyError();
530 const intptr_t num_consts = constant_reader.
NumConstants();
532 for (intptr_t i = 0; i < num_consts; i++) {
533 array.
SetAt(i, Object::sentinel());
536 H.SetConstants(array);
541 return LookupLibrary(main_library);
559 const intptr_t num_libraries = program_->library_count();
560 for (intptr_t i = 0; i < num_libraries; ++i) {
561 const String& library_uri = LibraryUri(i);
562 if (library_uri.
Equals(uri)) {
570 const String& library_url,
582 const intptr_t num_cids =
IG->class_table()->NumCids();
583 const intptr_t num_libs =
588 ASSERT(
H.GetExpressionEvaluationClass().IsNull());
589 ASSERT(
H.GetExpressionEvaluationFunction().IsNull());
590 H.SetExpressionEvaluationRealClass(real_class);
600 ASSERT(
IG->class_table()->NumCids() == num_cids);
606 function.SetKernelLibraryAndEvalScript(
607 eval_script, kernel_program_info_,
631 bool* is_empty_program,
632 intptr_t* p_num_classes,
633 intptr_t* p_num_procedures) {
636 if (setjmp(*jump.
Set()) == 0) {
642 intptr_t num_libs = libs.Length();
644 for (intptr_t i = 0; i < num_libs; i++) {
653 if (p_num_classes !=
nullptr) {
656 if (p_num_procedures !=
nullptr) {
657 *p_num_procedures = 0;
662 *is_empty_program =
true;
663 if (program->is_single_program()) {
665 loader.walk_incremental_kernel(modified_libs, is_empty_program,
666 p_num_classes, p_num_procedures);
676 intptr_t subprogram_count = subprogram_file_starts.
length() - 1;
677 for (intptr_t i = 0; i < subprogram_count; ++i) {
678 intptr_t subprogram_start = subprogram_file_starts.
At(i);
679 intptr_t subprogram_end = subprogram_file_starts.
At(i + 1);
681 program->binary().ViewFromTo(subprogram_start, subprogram_end));
683 const char*
error =
nullptr;
684 std::unique_ptr<Program> subprogram = Program::ReadFrom(&reader, &
error);
685 if (subprogram ==
nullptr) {
686 FATAL(
"Failed to load kernel file: %s",
error);
688 ASSERT(subprogram->is_single_program());
690 loader.walk_incremental_kernel(modified_libs, is_empty_program,
691 p_num_classes, p_num_procedures);
696void KernelLoader::walk_incremental_kernel(
BitVector* modified_libs,
697 bool* is_empty_program,
698 intptr_t* p_num_classes,
699 intptr_t* p_num_procedures) {
700 intptr_t
length = program_->library_count();
701 *is_empty_program = *is_empty_program && (
length == 0);
702 bool collect_library_stats =
703 p_num_classes !=
nullptr || p_num_procedures !=
nullptr;
704 intptr_t num_classes = 0;
705 intptr_t num_procedures = 0;
707 for (intptr_t i = 0; i <
length; i++) {
708 intptr_t kernel_offset = library_offset(i);
712 lib = LookupLibraryOrNull(library_helper.canonical_name_);
717 if (collect_library_stats) {
718 intptr_t library_end = library_offset(i + 1);
719 library_kernel_data_ =
721 LibraryIndex library_index(library_kernel_data_);
722 num_classes += library_index.class_count();
723 num_procedures += library_index.procedure_count();
726 if (p_num_classes !=
nullptr) {
727 *p_num_classes += num_classes;
729 if (p_num_procedures !=
nullptr) {
730 *p_num_procedures += num_procedures;
734void KernelLoader::ReadInferredType(
const Field& field,
735 intptr_t kernel_offset) {
736 const InferredTypeMetadata
type =
739 if (
type.IsTrivial()) {
742 field.set_guarded_cid(
type.cid);
743 field.set_is_nullable(
type.IsNullable());
745 if (FLAG_precompiled_mode) {
746 field.set_is_unboxed(!field.is_late() && !field.is_static() &&
747 !field.is_nullable() &&
748 ((field.guarded_cid() == kDoubleCid &&
750 (field.guarded_cid() == kFloat32x4Cid &&
752 (field.guarded_cid() == kFloat64x2Cid &&
758void KernelLoader::CheckForInitializer(
const Field& field) {
759 if (helper_.
PeekTag() == kSomething) {
760 field.set_has_initializer(
true);
761 SimpleExpressionConverter
converter(&
H, &helper_);
762 const bool has_simple_initializer =
764 if (!has_simple_initializer ||
765 (!field.is_static() && !
converter.SimpleValue().IsNull())) {
766 field.set_has_nontrivial_initializer(
true);
770 field.set_has_initializer(
false);
771 field.set_has_nontrivial_initializer(
false);
775 if (!program_->is_single_program()) {
777 "Trying to load a concatenated dill file at a time where that is "
782 library_kernel_offset_ = library_offset(index);
783 correction_offset_ = library_kernel_offset_;
784 intptr_t library_end = library_offset(index + 1);
785 intptr_t library_size = library_end - library_kernel_offset_;
792 helper_.
SetOffset(library_kernel_offset_);
794 LibraryHelper library_helper(&helper_);
796 if (!FLAG_precompiled_mode && !
IG->should_load_vmservice()) {
797 StringIndex lib_name_index =
798 H.CanonicalNameString(library_helper.canonical_name_);
802 skip_vmservice_library_ = library_helper.canonical_name_;
803 ASSERT(
H.IsLibrary(skip_vmservice_library_));
811 if (library.Loaded())
return library.ptr();
813 if (!library_helper.IsNonNullableByDefault()) {
815 "Library '%s' was compiled without sound null safety (in weak mode) "
816 "and it cannot be used at runtime",
820 library_helper.GetNonNullableByDefaultCompiledMode();
823 "Library '%s' was compiled in an unsupported mixed mode between sound "
824 "null safety and not sound null safety.",
829 "Library '%s' was compiled without sound null safety (in weak mode) "
830 "and it cannot be used at runtime",
835 library_kernel_offset_, library_kernel_offset_ + library_size);
836 library.set_kernel_library_index(index);
837 library.set_kernel_program_info(kernel_program_info_);
839 const intptr_t start_offset =
841 const intptr_t end_offset =
844 LibraryIndex library_index(library_kernel_data_);
845 intptr_t class_count = library_index.class_count();
848 library.SetName(
H.DartSymbolObfuscate(library_helper.name_index_));
852 if (library.name() ==
854 ASSERT(library.LoadInProgress());
855 loading_native_wrappers_library_ =
true;
857 loading_native_wrappers_library_ =
false;
858 library.SetLoadInProgress();
861 if (library.url() == Symbols::vm_ffi_native_assets().ptr()) {
862 const auto& native_assets_library =
864 ASSERT(native_assets_library.IsNull());
865 IG->object_store()->set_native_assets_library(library);
873 intptr_t annotations_kernel_offset =
875 const intptr_t annotation_count =
877 for (intptr_t i = 0; i < annotation_count; ++i) {
887 const bool register_class =
888 library.ptr() != expression_evaluation_library_.
ptr();
890 Class& toplevel_class =
892 TokenPosition::kNoSource, register_class));
893 toplevel_class.set_is_abstract();
894 toplevel_class.set_is_declaration_loaded();
895 toplevel_class.set_is_type_finalized();
896 toplevel_class.set_num_type_arguments_unsafe(0);
897 library.set_toplevel_class(toplevel_class);
900 LoadLibraryImportsAndExports(&library, toplevel_class);
906 const GrowableObjectArray& classes =
910 intptr_t next_class_offset = library_index.ClassOffset(0);
912 for (intptr_t i = 0; i < class_count; ++i) {
914 next_class_offset = library_index.ClassOffset(i + 1);
915 LoadClass(library, toplevel_class, next_class_offset, &klass);
916 if (register_class) {
921 if (loading_native_wrappers_library_ || !register_class) {
922 FinishTopLevelClassLoading(toplevel_class, library, library_index);
927 if (annotation_count > 0) {
928 ASSERT(annotations_kernel_offset > 0);
929 library.AddMetadata(library, annotations_kernel_offset);
932 if (register_class) {
933 helper_.
SetOffset(library_index.SourceReferencesOffset());
935 const GrowableObjectArray& used_scripts =
938 for (intptr_t i = 0; i <
count; i++) {
939 intptr_t uri_index = helper_.
ReadUInt();
940 script = ScriptAt(uri_index);
941 used_scripts.Add(script);
944 if (!library.Loaded()) library.SetLoaded();
946 return library.ptr();
949void KernelLoader::FinishTopLevelClassLoading(
950 const Class& toplevel_class,
951 const Library& library,
952 const LibraryIndex& library_index) {
953 if (toplevel_class.is_loaded()) {
958 ActiveClassScope active_class_scope(&active_class_, &toplevel_class);
962 const intptr_t correction = correction_offset_ - library_kernel_offset_;
963 helper_.
SetOffset(library_index.ClassOffset(library_index.class_count()) +
967 for (intptr_t i = 0; i < extension_count; ++i) {
979 for (intptr_t j = 0; j < extension_member_count; ++j) {
988 const intptr_t extension_type_declaration_count = helper_.
ReadListLength();
989 for (intptr_t i = 0; i < extension_type_declaration_count; ++i) {
1003 const intptr_t extension_type_procedure_count =
1005 for (intptr_t i = 0; i < extension_type_procedure_count; ++i) {
1006 ProcedureHelper procedure_helper(&helper_);
1010 const intptr_t extension_type_member_count = helper_.
ReadListLength();
1011 for (intptr_t j = 0; j < extension_type_member_count; ++j) {
1025 for (intptr_t i = 0; i < field_count; ++i) {
1026 intptr_t field_offset = helper_.
ReaderOffset() - correction_offset_;
1027 ActiveMemberScope active_member_scope(&active_class_,
nullptr);
1028 FieldHelper field_helper(&helper_);
1036 uint32_t pragma_bits = 0;
1037 ReadVMAnnotations(annotation_count, &pragma_bits);
1041 const Object& script_class =
1042 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_);
1045 const bool is_final = field_helper.IsConst() || field_helper.IsFinal();
1047 ASSERT(!field_helper.IsCovariant() &&
1048 !field_helper.IsGenericCovariantImpl());
1049 const bool is_late = field_helper.IsLate();
1050 const bool is_extension_member = field_helper.IsExtensionMember();
1051 const bool is_extension_type_member = field_helper.IsExtensionTypeMember();
1054 script_class, field_helper.position_,
1055 field_helper.end_position_));
1056 field.set_kernel_offset(field_offset);
1058 field.set_is_extension_member(is_extension_member);
1059 field.set_is_extension_type_member(is_extension_type_member);
1060 const AbstractType&
type =
T.BuildType();
1061 field.SetFieldType(
type);
1062 ReadInferredType(field, field_offset + library_kernel_offset_);
1063 CheckForInitializer(field);
1065 if (field.has_initializer()) {
1066 field.set_is_late(
true);
1070 intptr_t field_initializer_offset = helper_.
ReaderOffset();
1074 AlternativeReadingScope alt(&helper_.
reader_, field_initializer_offset);
1075 static_field_value_ = ReadInitialFieldValue(field, &field_helper);
1077 GenerateFieldAccessors(toplevel_class, field, &field_helper);
1078 IG->RegisterStaticField(field, static_field_value_);
1081 annotation_count > 0) {
1082 library.AddMetadata(field, field_offset);
1084 fields_.Add(&field);
1087 ASSERT(!toplevel_class.is_loaded());
1090 intptr_t next_procedure_offset =
1091 library_index.ProcedureOffset(0) + correction;
1092 const intptr_t procedure_count = library_index.procedure_count();
1093 for (intptr_t i = 0; i < procedure_count; ++i) {
1094 helper_.
SetOffset(next_procedure_offset);
1095 next_procedure_offset = library_index.ProcedureOffset(i + 1) + correction;
1096 LoadProcedure(library, toplevel_class,
false, next_procedure_offset);
1102 if (toplevel_class.is_loaded()) {
1108 toplevel_class.SetFunctions(
Array::Handle(MakeFunctionsArray()));
1111 for (intptr_t i = 0, n = fields_.length(); i < n; ++i) {
1112 const Field* field = fields_.At(i);
1113 name = field->name();
1114 library.AddObject(*field,
name);
1116 for (intptr_t i = 0, n = functions_.length(); i < n; ++i) {
1117 const Function*
function = functions_.At(i);
1122 ASSERT(!toplevel_class.is_loaded());
1123 toplevel_class.set_is_loaded(
true);
1126void KernelLoader::LoadLibraryImportsAndExports(Library* library,
1127 const Class& toplevel_class) {
1137 for (intptr_t dep = 0; dep < deps_count; ++dep) {
1138 LibraryDependencyHelper dependency_helper(&helper_);
1141 intptr_t annotations_kernel_offset =
1148 if (dependency_helper.target_library_canonical_name_ < 0) {
1150 for (intptr_t c = 0; c < combinator_count; ++c) {
1160 for (intptr_t c = 0; c < combinator_count; ++c) {
1163 for (intptr_t n = 0; n < name_count; ++n) {
1164 String& show_hide_name =
1174 if (show_list.Length() > 0) {
1180 if (hide_list.Length() > 0) {
1187 Z, LookupLibrary(dependency_helper.target_library_canonical_name_));
1188 if (!FLAG_enable_mirrors &&
1189 target_library.url() == Symbols::DartMirrors().ptr()) {
1191 "import of dart:mirrors is not supported in the current Dart "
1195 target_library.url() == Symbols::DartFfi().ptr() &&
1196 library->url() != Symbols::DartCore().ptr() &&
1197 library->url() != Symbols::DartInternal().ptr() &&
1198 library->url() != Symbols::DartFfi().ptr()) {
1200 "import of dart:ffi is not supported in the current Dart runtime");
1202 String&
prefix =
H.DartSymbolPlain(dependency_helper.name_index_);
1203 ns = Namespace::New(target_library, show_names, hide_names, *library);
1205 library->AddExport(ns);
1208 library->AddImport(ns);
1210 library_prefix = library->LookupLocalLibraryPrefix(prefix);
1211 if (!library_prefix.IsNull()) {
1212 library_prefix.AddImport(ns);
1214 library_prefix = LibraryPrefix::New(
1219 library->AddObject(library_prefix, prefix);
1224 if (FLAG_enable_mirrors && dependency_helper.annotation_count_ > 0) {
1225 ASSERT(annotations_kernel_offset > 0);
1226 library->AddMetadata(ns, annotations_kernel_offset);
1230 deps.SetAt(dep, ns);
1232 deps.SetAt(dep, library_prefix);
1236 library->set_dependencies(deps);
1239void KernelLoader::LoadPreliminaryClass(ClassHelper* class_helper,
1240 intptr_t type_parameter_count) {
1241 const Class* klass = active_class_.
klass;
1252 T.LoadAndSetupTypeParameters(&active_class_, Object::null_function(), *klass,
1253 Object::null_function_type(),
1254 type_parameter_count);
1256 ActiveTypeParametersScope scope(&active_class_,
nullptr,
Z);
1258 T.LoadAndSetupBounds(&active_class_, Object::null_function(), *klass,
1259 Object::null_function_type(), type_parameter_count);
1263 if (type_tag == kSomething) {
1264 AbstractType& super_type =
1265 T.BuildTypeWithoutFinalization();
1266 klass->set_super_type(Type::Cast(super_type));
1274 if (interface_count == 0) {
1275 klass->set_interfaces(Object::empty_array());
1277 const Array& interfaces =
1279 for (intptr_t i = 0; i < interface_count; i++) {
1280 const AbstractType&
type =
1281 T.BuildTypeWithoutFinalization();
1282 interfaces.SetAt(i,
type);
1284 klass->set_interfaces(interfaces);
1288 if (class_helper->is_abstract()) {
1289 klass->set_is_abstract();
1291 if (class_helper->is_transformed_mixin_application()) {
1292 klass->set_is_transformed_mixin_application();
1294 if (class_helper->has_const_constructor()) {
1295 klass->set_is_const();
1297 if (class_helper->is_sealed()) {
1298 klass->set_is_sealed();
1300 if (class_helper->is_mixin_class()) {
1301 klass->set_is_mixin_class();
1303 if (class_helper->is_base()) {
1304 klass->set_is_base_class();
1306 if (class_helper->is_interface()) {
1307 klass->set_is_interface_class();
1309 if (class_helper->is_final()) {
1310 klass->set_is_final();
1314void KernelLoader::LoadClass(
const Library& library,
1315 const Class& toplevel_class,
1319 ClassIndex class_index(program_->binary(), class_offset,
1320 class_end - class_offset);
1322 ClassHelper class_helper(&helper_);
1324 *out_class = LookupClass(library, class_helper.canonical_name_);
1325 out_class->set_kernel_offset(class_offset - correction_offset_);
1334 out_class->set_script(script);
1336 if (out_class->token_pos() == TokenPosition::kNoSource) {
1338 out_class->set_token_pos(class_helper.start_position_);
1339 out_class->set_end_token_pos(class_helper.end_position_);
1343 if (class_helper.is_enum_class()) {
1344 out_class->set_is_enum_class();
1349 uint32_t pragma_bits = 0;
1350 ReadVMAnnotations(annotation_count, &pragma_bits);
1352 out_class->set_is_isolate_unsendable_due_to_pragma(
true);
1355 out_class->set_is_deeply_immutable(
true);
1362 out_class->set_has_pragma(
true);
1366 intptr_t type_parameter_counts =
1369 ActiveClassScope active_class_scope(&active_class_, out_class);
1370 if (!out_class->is_declaration_loaded()) {
1371 LoadPreliminaryClass(&class_helper, type_parameter_counts);
1373 ASSERT(type_parameter_counts == 0);
1378 annotation_count > 0) {
1379 library.AddMetadata(*out_class, class_offset - correction_offset_);
1385 const bool register_class =
1386 library.ptr() != expression_evaluation_library_.
ptr();
1387 if (!register_class) {
1388 H.SetExpressionEvaluationClass(*out_class);
1391 if (loading_native_wrappers_library_ || !register_class) {
1392 FinishClassLoading(*out_class, library, toplevel_class, class_offset,
1393 class_index, &class_helper);
1399void KernelLoader::FinishClassLoading(
const Class& klass,
1400 const Library& library,
1401 const Class& toplevel_class,
1402 intptr_t class_offset,
1403 const ClassIndex& class_index,
1404 ClassHelper* class_helper) {
1405 if (klass.is_loaded()) {
1411 ActiveClassScope active_class_scope(&active_class_, &klass);
1416 const bool discard_fields = klass.InjectCIDFields();
1420 if (!discard_fields) {
1423 for (intptr_t i = 0; i < field_count; ++i) {
1424 intptr_t field_offset = helper_.
ReaderOffset() - correction_offset_;
1425 ActiveMemberScope active_member(&active_class_,
nullptr);
1426 FieldHelper field_helper(&helper_);
1429 const Object& script_class =
1430 ClassForScriptAt(klass, field_helper.source_uri_index_);
1438 uint32_t pragma_bits = 0;
1439 ReadVMAnnotations(annotation_count, &pragma_bits);
1443 const AbstractType&
type =
1444 T.BuildTypeWithoutFinalization();
1447 const bool is_reflectable =
1448 field_helper.position_.IsReal() &&
1449 !(library.is_dart_scheme() && library.IsPrivate(
name));
1452 const bool is_final = field_helper.IsConst() || field_helper.IsFinal();
1453 const bool is_late = field_helper.IsLate();
1454 const bool is_extension_member = field_helper.IsExtensionMember();
1455 const bool is_extension_type_member =
1456 field_helper.IsExtensionTypeMember();
1458 Z, Field::New(
name, field_helper.IsStatic(), is_final,
1459 field_helper.IsConst(), is_reflectable, is_late,
1460 script_class,
type, field_helper.position_,
1461 field_helper.end_position_));
1462 field.set_kernel_offset(field_offset);
1464 field.set_is_covariant(field_helper.IsCovariant());
1465 field.set_is_generic_covariant_impl(
1466 field_helper.IsGenericCovariantImpl());
1467 field.set_is_extension_member(is_extension_member);
1468 field.set_is_extension_type_member(is_extension_type_member);
1469 ReadInferredType(field, field_offset + library_kernel_offset_);
1470 CheckForInitializer(field);
1472 if (field_helper.IsStatic() && field.has_initializer()) {
1473 field.set_is_late(
true);
1476 intptr_t field_initializer_offset = helper_.
ReaderOffset();
1480 AlternativeReadingScope alt(&helper_.
reader_, field_initializer_offset);
1481 static_field_value_ = ReadInitialFieldValue(field, &field_helper);
1483 GenerateFieldAccessors(klass, field, &field_helper);
1484 if (field.is_static()) {
1485 IG->RegisterStaticField(field, static_field_value_);
1488 annotation_count > 0) {
1489 library.AddMetadata(field, field_offset);
1491 fields_.Add(&field);
1495 if (klass.is_enum_class()) {
1499 deleted_enum_sentinel =
1500 Field::New(Symbols::_DeletedEnumSentinel(),
1505 false, klass, Object::dynamic_type(),
1506 TokenPosition::kNoSource, TokenPosition::kNoSource);
1508 fields_.Add(&deleted_enum_sentinel);
1518 if (klass.UserVisibleName() == Symbols::Compound().ptr() &&
1522 .StartsWith(Symbols::_typedDataBase()));
1524 fields_[0]->set_is_nullable(
true);
1534 if (!super_class.IsNull() &&
1535 super_class.UserVisibleName() == Symbols::AbiSpecificInteger().ptr() &&
1537 Symbols::DartFfi().
ptr()) {
1538 const char*
error =
nullptr;
1541 if (
error !=
nullptr) {
1542 H.ReportError(
"%s",
error);
1548 if (klass.is_loaded()) {
1557 for (intptr_t i = 0; i < constructor_count; ++i) {
1558 intptr_t constructor_offset = helper_.
ReaderOffset() - correction_offset_;
1559 ActiveMemberScope active_member_scope(&active_class_,
nullptr);
1560 ConstructorHelper constructor_helper(&helper_);
1563 uint32_t pragma_bits = 0;
1564 ReadVMAnnotations(annotation_count, &pragma_bits);
1568 const String&
name =
1569 H.DartConstructorName(constructor_helper.canonical_name_);
1574 const Object* owner = &klass;
1575 const intptr_t source_uri_index = constructor_helper.source_uri_index_;
1576 if (source_uri_index != 0) {
1577 owner = &ClassForScriptAt(klass, source_uri_index);
1584 constructor_helper.IsConst(),
1586 constructor_helper.IsExternal(),
1588 *owner, constructor_helper.start_position_));
1589 function.set_end_token_pos(constructor_helper.end_position_);
1590 function.set_kernel_offset(constructor_offset);
1591 signature.set_result_type(
T.ReceiverType(klass));
1595 FunctionNodeHelper function_node_helper(&helper_);
1596 function_node_helper.ReadUntilExcluding(
1598 T.SetupFunctionParameters(klass,
function,
1601 &function_node_helper);
1602 T.SetupUnboxingInfoMetadata(
function, library_kernel_offset_);
1604 if (library.is_dart_scheme() &&
1605 H.IsPrivate(constructor_helper.canonical_name_)) {
1606 function.set_is_reflectable(
false);
1609 if (constructor_helper.IsSynthetic()) {
1617 if (klass.is_finalized()) {
1628 annotation_count > 0) {
1629 library.AddMetadata(
function, constructor_offset);
1635 if (klass.is_loaded()) {
1642 intptr_t procedure_count = class_index.procedure_count();
1646 intptr_t correction = correction_offset_ - library_kernel_offset_;
1647 intptr_t next_procedure_offset = class_index.ProcedureOffset(0) + correction;
1648 for (intptr_t i = 0; i < procedure_count; ++i) {
1649 helper_.
SetOffset(next_procedure_offset);
1650 next_procedure_offset = class_index.ProcedureOffset(i + 1) + correction;
1651 LoadProcedure(library, klass,
true, next_procedure_offset);
1656 if (klass.is_loaded()) {
1663 ASSERT(!klass.is_loaded());
1664 klass.set_is_loaded(
true);
1673 const auto& library_kernel_data =
1675 ASSERT(!library_kernel_data.IsNull());
1677 const auto& kernel_info =
1679 const intptr_t library_kernel_offset =
1682 KernelLoader kernel_loader(kernel_info, library_kernel_data,
1683 library_kernel_offset);
1689 kernel_loader.FinishTopLevelClassLoading(klass, library, library_index);
1695 library_kernel_data, class_offset,
1702 kernel_loader.helper_.
SetOffset(class_offset);
1705 kernel_loader.FinishClassLoading(klass, library, toplevel_class, class_offset,
1706 class_index, &class_helper);
1718void KernelLoader::ReadVMAnnotations(intptr_t annotation_count,
1719 uint32_t* pragma_bits,
1722 if (annotation_count == 0) {
1726 for (intptr_t i = 0; i < annotation_count; ++i) {
1727 const intptr_t tag = helper_.
PeekTag();
1728 if (tag == kConstantExpression || tag == kFileUriConstantExpression) {
1731 if (tag == kFileUriConstantExpression) {
1735 const intptr_t index_in_constant_table = helper_.
ReadUInt();
1738 ConstantReader constant_reader(&helper_, &active_class_);
1740 intptr_t name_index = -1;
1741 intptr_t options_index = -1;
1742 if (constant_reader.IsPragmaInstanceConstant(
1743 index_in_constant_table, &name_index, &options_index)) {
1746 if (constant_reader.IsStringConstant(name_index,
"vm:invisible")) {
1749 if (constant_reader.IsStringConstant(name_index,
"vm:external-name")) {
1751 constant_reader.GetStringConstant(options_index, native_name);
1753 if (constant_reader.IsStringConstant(name_index,
1754 "vm:isolate-unsendable")) {
1757 if (constant_reader.IsStringConstant(name_index,
1758 "vm:deeply-immutable")) {
1761 if (constant_reader.IsStringConstant(name_index,
"vm:ffi:native")) {
1772void KernelLoader::LoadProcedure(
const Library& library,
1775 intptr_t procedure_end) {
1776 intptr_t procedure_offset = helper_.
ReaderOffset() - correction_offset_;
1777 ProcedureHelper procedure_helper(&helper_);
1788 if (!FLAG_precompiled_mode && procedure_helper.IsMemberSignature()) {
1792 const String&
name =
H.DartProcedureName(procedure_helper.canonical_name_);
1793 bool is_method = in_class && !procedure_helper.IsStatic();
1794 bool is_abstract = procedure_helper.IsAbstract();
1795 bool is_external = procedure_helper.IsExternal();
1796 bool is_extension_member = procedure_helper.IsExtensionMember();
1797 bool is_extension_type_member = procedure_helper.IsExtensionTypeMember();
1798 bool is_synthetic = procedure_helper.IsSynthetic();
1800 uint32_t pragma_bits = 0;
1802 ReadVMAnnotations(annotation_count, &pragma_bits, &native_name);
1803 is_external = is_external && native_name.IsNull();
1805 const Object& script_class =
1806 ClassForScriptAt(owner, procedure_helper.source_uri_index_);
1812 const bool register_function = !
name.Equals(Symbols::DebugProcedureName());
1820 is_abstract, is_external,
1821 !native_name.IsNull() || is_ffi_native,
1822 script_class, procedure_helper.start_position_));
1824 function.set_end_token_pos(procedure_helper.end_position_);
1825 function.set_is_synthetic(procedure_helper.IsNoSuchMethodForwarder() ||
1826 procedure_helper.IsMemberSignature() ||
1829 if (register_function) {
1832 H.SetExpressionEvaluationFunction(
function);
1834 function.set_kernel_offset(procedure_offset);
1835 function.set_is_extension_member(is_extension_member);
1836 function.set_is_extension_type_member(is_extension_type_member);
1837 if ((library.is_dart_scheme() &&
1838 H.IsPrivate(procedure_helper.canonical_name_)) ||
1840 function.set_is_reflectable(
false);
1842 if (procedure_helper.IsMemberSignature()) {
1843 function.set_is_reflectable(
false);
1846 ActiveMemberScope active_member(&active_class_, &
function);
1850 FunctionNodeHelper function_node_helper(&helper_);
1856 }
else if (function_node_helper.async_marker_ ==
1861 }
else if (function_node_helper.async_marker_ ==
1873 if (!native_name.IsNull()) {
1874 function.set_native_name(native_name);
1878 T.SetupFunctionParameters(owner,
function, is_method,
1880 &function_node_helper);
1881 T.SetupUnboxingInfoMetadata(
function, library_kernel_offset_);
1883 function_node_helper.ReadUntilExcluding(
1891 if (annotation_count > 0) {
1892 library.AddMetadata(
function, procedure_offset);
1896const Object& KernelLoader::ClassForScriptAt(
const Class& klass,
1897 intptr_t source_uri_index) {
1898 const Script& correct_script =
Script::Handle(
Z, ScriptAt(source_uri_index));
1899 if (klass.script() != correct_script.ptr()) {
1901 if (patch_classes_.
IsNull()) {
1909 patch_class ^= patch_classes_.
At(source_uri_index);
1910 if (patch_class.IsNull() || patch_class.wrapped_class() != klass.ptr()) {
1913 PatchClass::New(klass, kernel_program_info_, correct_script);
1915 patch_classes_.
SetAt(source_uri_index, patch_class);
1922ScriptPtr KernelLoader::LoadScriptAt(intptr_t index,
1932 if (uri_to_source_table !=
nullptr) {
1933 UriToSourceTableEntry wrapper;
1934 wrapper.uri = &uri_string;
1935 UriToSourceTableEntry* pair = uri_to_source_table->LookupValue(&wrapper);
1936 if (pair !=
nullptr) {
1937 sources = pair->sources->ptr();
1938 line_starts = pair->line_starts->ptr();
1942 if (
sources.IsNull() || line_starts.IsNull()) {
1943 const String& script_source = helper_.
GetSourceFor(index);
1947 line_starts.Length() == 0 && uri_string.Length() > 0) {
1952 const GrowableObjectArray&
libs =
1954 for (intptr_t i = 0; i <
libs.Length(); i++) {
1956 script = lib.LookupScript(uri_string,
true);
1959 line_starts =
script.line_starts();
1964 sources = script_source.ptr();
1970 script.InitializeFromKernel(kernel_program_info_, index, line_starts,
1975ObjectPtr KernelLoader::ReadInitialFieldValue(
const Field& field,
1976 FieldHelper* field_helper) {
1978 const bool has_initializer = (tag == kSomething);
1980 if (has_initializer) {
1981 SimpleExpressionConverter
converter(&
H, &helper_);
1982 const bool has_simple_initializer =
1984 if (has_simple_initializer) {
1985 if (field_helper->IsStatic()) {
1988 field.RecordStore(
converter.SimpleValue());
1993 if (field_helper->IsStatic()) {
1994 if (!has_initializer && !field_helper->IsLate()) {
2000 ASSERT(field.NeedsGetter());
2003 return field_helper->IsStatic() ? Object::sentinel().ptr() :
Object::null();
2006void KernelLoader::GenerateFieldAccessors(
const Class& klass,
2008 FieldHelper* field_helper) {
2009 const bool needs_getter = field.NeedsGetter();
2010 const bool needs_setter = field.NeedsSetter();
2012 if (!needs_getter && !needs_setter) {
2016 const Object& script_class =
2017 ClassForScriptAt(klass, field_helper->source_uri_index_);
2021 const String& getter_name =
2022 H.DartGetterName(field_helper->canonical_name_getter_);
2023 const FunctionType& signature =
2028 signature, getter_name,
2029 field_helper->IsStatic() ? UntaggedFunction::kImplicitStaticGetter
2030 : UntaggedFunction::kImplicitGetter,
2031 field_helper->IsStatic(),
2035 field_helper->IsStatic() ? field_helper->IsConst()
2036 : field_helper->IsFinal(),
2040 script_class, field_helper->position_));
2041 functions_.Add(&getter);
2042 getter.set_end_token_pos(field_helper->end_position_);
2043 getter.set_kernel_offset(field.kernel_offset());
2044 signature.set_result_type(field_type);
2045 getter.set_is_debuggable(
false);
2046 getter.set_accessor_field(field);
2047 getter.set_is_extension_member(field.is_extension_member());
2048 getter.set_is_extension_type_member(field.is_extension_type_member());
2049 H.SetupFieldAccessorFunction(klass, getter, field_type);
2050 T.SetupUnboxingInfoMetadataForFieldAccessors(getter,
2051 library_kernel_offset_);
2056 ASSERT(!field_helper->IsConst());
2057 const String& setter_name =
2058 H.DartSetterName(field_helper->canonical_name_setter_);
2059 const FunctionType& signature =
2063 Function::New(signature, setter_name, UntaggedFunction::kImplicitSetter,
2064 field_helper->IsStatic(),
2069 script_class, field_helper->position_));
2070 functions_.Add(&setter);
2071 setter.set_end_token_pos(field_helper->end_position_);
2072 setter.set_kernel_offset(field.kernel_offset());
2073 signature.set_result_type(Object::void_type());
2074 setter.set_is_debuggable(
false);
2075 setter.set_accessor_field(field);
2076 setter.set_is_extension_member(field.is_extension_member());
2077 setter.set_is_extension_type_member(field.is_extension_type_member());
2078 H.SetupFieldAccessorFunction(klass, setter, field_type);
2079 T.SetupUnboxingInfoMetadataForFieldAccessors(setter,
2080 library_kernel_offset_);
2084LibraryPtr KernelLoader::LookupLibraryOrNull(NameIndex library) {
2086 name_index_handle_ =
Smi::New(library);
2089 NoSafepointScope no_safepoint_scope(thread_);
2094 const String& url =
H.DartString(
H.CanonicalNameString(library));
2097 NoSafepointScope no_safepoint_scope(thread_);
2103 name_index_handle_ =
Smi::New(library);
2104 return kernel_program_info_.
InsertLibrary(thread_, name_index_handle_,
2108LibraryPtr KernelLoader::LookupLibrary(NameIndex library) {
2109 name_index_handle_ =
Smi::New(library);
2112 kernel_program_info_.
LookupLibrary(thread_, name_index_handle_);
2113 NoSafepointScope no_safepoint_scope(thread_);
2120 const String& url =
H.DartSymbolPlain(
H.CanonicalNameString(library));
2124 if (url.Equals(Symbols::EvalSourceUri())) {
2125 if (expression_evaluation_library_.
IsNull()) {
2126 handle = Library::New(url);
2127 expression_evaluation_library_ = handle.
ptr();
2129 return expression_evaluation_library_.
ptr();
2132 if (handle.IsNull()) {
2133 handle = Library::New(url);
2134 handle.Register(thread_);
2136 ASSERT(!handle.IsNull());
2137 name_index_handle_ =
Smi::New(library);
2138 return kernel_program_info_.
InsertLibrary(thread_, name_index_handle_,
2142LibraryPtr KernelLoader::LookupLibraryFromClass(NameIndex klass) {
2143 return LookupLibrary(
H.CanonicalNameParent(klass));
2146ClassPtr KernelLoader::LookupClass(
const Library& library, NameIndex klass) {
2147 name_index_handle_ =
Smi::New(klass);
2149 ClassPtr raw_class =
2150 kernel_program_info_.
LookupClass(thread_, name_index_handle_);
2151 NoSafepointScope no_safepoint_scope(thread_);
2157 ASSERT(!library.IsNull());
2158 const String&
name =
H.DartClassName(klass);
2160 bool register_class =
true;
2161 if (handle.IsNull()) {
2165 register_class = library.ptr() != expression_evaluation_library_.
ptr();
2168 TokenPosition::kNoSource, register_class);
2169 if (register_class) {
2170 library.AddClass(handle);
2173 ASSERT(!handle.IsNull());
2174 if (register_class) {
2175 name_index_handle_ =
Smi::New(klass);
2176 kernel_program_info_.
InsertClass(thread_, name_index_handle_, handle);
2178 return handle.ptr();
2183 intptr_t lookuptable[] = {
2184 UntaggedFunction::kRegularFunction,
2185 UntaggedFunction::kGetterFunction,
2186 UntaggedFunction::kSetterFunction,
2187 UntaggedFunction::kRegularFunction,
2188 UntaggedFunction::kConstructor,
2190 intptr_t kind =
static_cast<int>(procedure_kind);
2195FunctionPtr KernelLoader::LoadClosureFunction(
const Function& parent_function,
2196 const Object& closure_owner) {
2197 const intptr_t func_decl_offset = helper_.
ReaderOffset();
2199 ASSERT((tag == kFunctionExpression) || (tag == kFunctionDeclaration));
2204 uint32_t pragma_bits = 0;
2205 intptr_t annotation_count = 0;
2207 if (is_declaration) {
2209 VariableDeclarationHelper variable_helper(&helper_);
2213 ReadVMAnnotations(annotation_count, &pragma_bits);
2217 name = &
H.DartSymbolObfuscate(variable_helper.name_index_);
2219 name = &Symbols::AnonymousClosure();
2222 const intptr_t func_node_offset = helper_.
ReaderOffset();
2224 FunctionNodeHelper function_node_helper(&helper_);
2228 if (!closure_owner.IsNull()) {
2230 UntaggedFunction::kClosureFunction, *
name, parent_function,
2231 parent_function.is_static(), position, closure_owner);
2237 function.set_has_pragma(has_pragma);
2239 if ((FLAG_enable_mirrors && (annotation_count > 0)) || has_pragma) {
2242 lib.AddMetadata(
function, func_decl_offset);
2249 }
else if (function_node_helper.async_marker_ ==
2254 }
else if (function_node_helper.async_marker_ ==
2269 position.IsReal() ? function_node_helper.end_position_ : position);
2271 function.set_kernel_offset(func_node_offset);
2275 &function_node_helper);
2291 intptr_t func_decl_offset,
2294 const Object& closure_owner) {
2297 intptr_t func_node_offset = -1;
2299 const auto& kernel_info =
2301 const auto& library_kernel_data =
2303 ASSERT(!library_kernel_data.IsNull());
2306 KernelLoader kernel_loader(kernel_info, library_kernel_data,
2307 library_kernel_offset);
2311 kernel_loader.helper_.
SetOffset(func_decl_offset);
2313 func_node_offset = kernel_loader.helper_.
ReaderOffset();
2318 member_function, func_node_offset);
2327 member_function, func_node_offset);
2330 &kernel_loader.active_class_,
2335 &kernel_loader.active_class_, member_function,
2337 kernel_loader.helper_.
SetOffset(func_decl_offset);
2339 kernel_loader.LoadClosureFunction(parent_function, closure_owner);
2346 const Field& field) {
2360 const auto& kernel_program_info =
2363 zone, PatchClass::New(field_owner, kernel_program_info, script));
2371 Function::New(signature, init_name, UntaggedFunction::kFieldInitializer,
2377 initializer_owner, TokenPosition::kNoSource));
2388 initializer_fun.set_is_reflectable(
false);
2389 initializer_fun.set_is_inlinable(
false);
2395 initializer_fun.set_is_extension_type_member(
2402 return initializer_fun.
ptr();
#define ASSERT_EQUAL(expected, actual)
static bool IsFfiEnabled()
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
ObjectPtr At(intptr_t index) const
static ArrayPtr MakeFixedLength(const GrowableObjectArray &growable_array, bool unique=false)
void SetAt(intptr_t index, const Object &value) const
KeyValueTrait::Value LookupValue(typename KeyValueTrait::Key key) const
void Insert(typename KeyValueTrait::Pair kv)
const T & At(intptr_t index) const
static constexpr T decode(S value)
static constexpr S update(T value, S original)
static const Bool & Get(bool value)
static AbstractTypePtr FinalizeType(const AbstractType &type, FinalizationKind finalization=kCanonicalize)
static bool ProcessPendingClasses()
intptr_t kernel_offset() const
LibraryPtr library() const
void set_is_declaration_loaded() const
TypePtr DeclarationType() const
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
KernelProgramInfoPtr KernelProgramInfo() const
bool is_finalized() const
static void AddClosureFunctionLocked(const Function &function, bool allow_implicit_closure_functions=false)
static FunctionPtr LookupClosureFunctionLocked(const Function &member_function, intptr_t kernel_offset)
static DoublePtr New(double d, Heap::Space space=Heap::kNew)
static ExternalTypedDataPtr New(intptr_t class_id, uint8_t *data, intptr_t len, Heap::Space space=Heap::kNew, bool perform_eager_msan_initialization_check=true)
FunctionPtr InitializerFunction() const
void SetInitializerFunction(const Function &initializer) const
bool is_extension_member() const
static FieldPtr NewTopLevel(const String &name, bool is_final, bool is_const, bool is_late, const Object &owner, TokenPosition token_pos, TokenPosition end_token_pos)
AbstractTypePtr type() const
bool is_extension_type_member() const
TokenPosition end_token_pos() const
TokenPosition token_pos() const
KernelProgramInfoPtr KernelProgramInfo() const
static bool SupportsUnboxedDoubles()
static bool SupportsUnboxedSimd128()
void set_result_type(const AbstractType &value) const
void SetParameterTypeAt(intptr_t index, const AbstractType &value) const
void set_num_fixed_parameters(intptr_t value) const
void set_parameter_types(const Array &value) const
static FunctionTypePtr New(intptr_t num_parent_type_arguments=0, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
void set_accessor_field(const Field &value) const
void set_end_token_pos(TokenPosition value) const
void InheritKernelOffsetFrom(const Function &src) const
void CreateNameArray(Heap::Space space=Heap::kOld) const
static FunctionPtr New(const FunctionType &signature, const String &name, UntaggedFunction::Kind kind, bool is_static, bool is_const, bool is_abstract, bool is_external, bool is_native, const Object &owner, TokenPosition token_pos, Heap::Space space=Heap::kOld)
void set_token_pos(TokenPosition value) const
void SetParameterNameAt(intptr_t index, const String &value) const
intptr_t KernelLibraryOffset() const
static FunctionPtr NewClosureFunctionWithKind(UntaggedFunction::Kind kind, const String &name, const Function &parent, bool is_static, TokenPosition token_pos, const Object &owner)
static FunctionPtr NewClosureFunction(const String &name, const Function &parent, TokenPosition token_pos)
TypedDataViewPtr KernelLibrary() const
KernelProgramInfoPtr KernelProgramInfo() const
void SetSignature(const FunctionType &value) const
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
static Table::Storage::ArrayPtr New(intptr_t initial_capacity, Heap::Space space=Heap::kNew)
static IntegerPtr New(const String &str, Heap::Space space=Heap::kNew)
ObjectStore * object_store() const
SafepointRwLock * program_lock()
void set_constants(const Array &constants) const
intptr_t KernelLibraryStartOffset(intptr_t library_index) const
intptr_t KernelLibraryEndOffset(intptr_t library_index) const
LibraryPtr LookupLibrary(Thread *thread, const Smi &name_index) const
ClassPtr LookupClass(Thread *thread, const Smi &name_index) const
ArrayPtr constants() const
TypedDataViewPtr constants_table() const
LibraryPtr InsertLibrary(Thread *thread, const Smi &name_index, const Library &lib) const
ClassPtr InsertClass(Thread *thread, const Smi &name_index, const Class &klass) const
TypedDataViewPtr KernelLibrary() const
ClassPtr LookupClassAllowPrivate(const String &name) const
ClassPtr toplevel_class() const
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
bool is_dart_scheme() const
static LibraryPtr InternalLibrary()
intptr_t kernel_library_index() const
virtual const char * ToCString() const
static Object & ZoneHandle()
void set_kernel_library_index(intptr_t index) const
static ScriptPtr New(const String &url, const String &source)
static SmiPtr New(intptr_t value)
bool EndsWith(const String &other) const
bool Equals(const String &str) const
intptr_t CompareTo(const String &other) const
static const char * ToCString(Thread *thread, StringPtr ptr)
static const String & Symbol(intptr_t index)
static StringPtr FromConcat(Thread *thread, const String &str1, const String &str2)
static const String & This()
static const String & Empty()
static Thread * Current()
DART_WARN_UNUSED_RESULT ErrorPtr StealStickyError()
IsolateGroup * isolate_group() const
virtual bool CanonicalizeEquals(const Instance &other) const
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
static const NativeType * FromAbstractType(Zone *zone, const AbstractType &type, const char **error)
virtual ClassPtr LookupClassByKernelClass(NameIndex klass, bool required=true)
virtual LibraryPtr LookupLibraryByKernelLibrary(NameIndex library, bool required=true)
ClassIndex(const TypedDataBase &kernel_data, intptr_t class_offset, intptr_t class_size)
@ kRedirectingFactoryTarget
static void index_programs(kernel::Reader *reader, GrowableArray< intptr_t > *subprogram_file_starts)
ObjectPtr LoadExpressionEvaluationFunction(const String &library_url, const String &klass)
void LoadLibrary(const Library &library)
KernelLoader(Program *program, DirectChainedHashMap< UriToSourceTableTrait > *uri_to_source_table)
static void FinishLoading(const Class &klass)
static void FindModifiedLibraries(Program *program, IsolateGroup *isolate_group, BitVector *modified_libs, bool force_reload, bool *is_empty_program, intptr_t *p_num_classes, intptr_t *p_num_procedures)
ObjectPtr LoadProgram(bool process_pending_classes=true)
static FunctionPtr GetClosureFunction(Thread *thread, intptr_t func_decl_offset, const Function &member_function, const Function &parent_function, const Object &closure_owner)
const String & GetSourceFor(intptr_t index)
void SkipTypeParametersList()
void SetOffset(intptr_t offset)
String & SourceTableUriFor(intptr_t index)
void ReadUntilFunctionNode()
void SkipListOfDartTypes()
intptr_t SourceTableSize()
intptr_t ReadListLength()
void SkipLibraryCombinator()
TokenPosition ReadPosition()
Tag ReadTag(uint8_t *payload=nullptr)
void SkipListOfExpressions()
Tag PeekTag(uint8_t *payload=nullptr)
intptr_t ReaderOffset() const
const String & ReadNameAsFieldName()
void SkipCanonicalNameReference()
String & SourceTableImportUriFor(intptr_t index)
void SkipStringReference()
StringIndex ReadStringReference()
TypedDataViewPtr GetConstantCoverageFor(intptr_t index)
TypedDataPtr GetLineStartsFor(intptr_t index)
intptr_t SizeOfClassAtOffset(intptr_t class_offset) const
LibraryIndex(const TypedDataView &kernel_data)
void set_offset(intptr_t offset)
uint32_t ReadUInt32At(intptr_t offset) const
TypedDataViewPtr ViewFromTo(intptr_t start, intptr_t end)
const Instance & SimpleValue()
SimpleExpressionConverter(TranslationHelper *translation_helper, KernelReaderHelper *reader_helper)
bool IsSimple(intptr_t kernel_offset)
FlutterSemanticsFlag flags
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
DirectChainedHashMap< UriToSourceTableTrait > UriToSourceTable
static constexpr int SpecializedIntLiteralBias
FunctionPtr CreateFieldInitializerFunction(Thread *thread, Zone *zone, const Field &field)
static const char *const kVMServiceIOLibraryUri
static const char *const names[]
constexpr intptr_t kWordSize
bool IsDeeplyImmutableCid(intptr_t predefined_cid)
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 mode
const TypedData * line_starts
#define TIMELINE_DURATION(thread, stream, name)
#define NOT_IN_PRODUCT(code)