4#if !defined(DART_PRECOMPILED_RUNTIME)
34#define IG (thread_->isolate_group())
35#define T (type_translator_)
36#define H (translation_helper_)
48 "Shared memory multithreading in only available for "
49 "experimentation in dev or main");
55 experimental_shared_data,
56 "Enable experiment to share data between isolates.");
62 : translation_helper_(*translation_helper),
63 zone_(translation_helper_.
zone()),
64 simple_value_(nullptr),
65 helper_(reader_helper) {}
72 case kBigIntLiteral: {
74 const String& literal_str =
78 if (simple_value_->
IsNull()) {
79 H.ReportError(
"Integer literal %s is out of range",
83 *simple_value_ =
H.Canonicalize(*simple_value_);
88 simple_value_ = &
H.DartSymbolPlain(
91 case kSpecializedIntLiteral:
97 *simple_value_ =
H.Canonicalize(*simple_value_);
99 case kNegativeIntLiteral:
104 *simple_value_ =
H.Canonicalize(*simple_value_);
106 case kPositiveIntLiteral:
111 *simple_value_ =
H.Canonicalize(*simple_value_);
117 *simple_value_ =
H.Canonicalize(*simple_value_);
148ArrayPtr KernelLoader::MakeFieldsArray() {
149 const intptr_t
len = fields_.length();
151 for (intptr_t
i = 0;
i <
len;
i++) {
157ArrayPtr KernelLoader::MakeFunctionsArray() {
158 const intptr_t
len = functions_.length();
160 for (intptr_t
i = 0;
i <
len;
i++) {
161 res.SetAt(
i, *functions_[
i]);
169 return loader_->LookupLibrary(library);
175 LibraryLookupHandleScope library_lookup_handle_scope(library_lookup_handle_);
177 library_lookup_handle_ = loader_->LookupLibraryFromClass(klass);
178 return loader_->LookupClass(library_lookup_handle_, klass);
182 : reader_(kernel_data) {
183 intptr_t data_size = reader_.
size();
186 procedure_index_offset_ = data_size - 4 - (procedure_count_ + 1) * 4;
188 class_count_ = reader_.
ReadUInt32At(procedure_index_offset_ - 4);
189 class_index_offset_ = procedure_index_offset_ - 4 - (class_count_ + 1) * 4;
191 source_references_offset_ = -1;
192 source_references_offset_ = reader_.
ReadUInt32At(class_index_offset_ - 4);
196 intptr_t class_offset,
198 : reader_(library_kernel_data) {
199 Init(class_offset, class_size);
202void ClassIndex::Init(intptr_t class_offset, intptr_t class_size) {
203 procedure_count_ = reader_.
ReadUInt32At(class_offset + class_size - 4);
204 procedure_index_offset_ =
205 class_offset + class_size - 4 - (procedure_count_ + 1) * 4;
213 thread_(
Thread::Current()),
214 zone_(thread_->zone()),
215 no_active_isolate_scope_(),
216 patch_classes_(
Array::Handle(zone_)),
218 library_kernel_offset_(-1),
219 correction_offset_(-1),
220 loading_native_wrappers_library_(
false),
223 translation_helper_(this, thread_,
Heap::
kOld),
225 &translation_helper_,
228 constant_reader_(&helper_, &active_class_),
229 type_translator_(&helper_,
233 inferred_type_metadata_helper_(&helper_, &constant_reader_),
234 static_field_value_(
Object::Handle(
Z)),
235 name_index_handle_(
Smi::Handle(
Z)),
236 expression_evaluation_library_(
Library::Handle(
Z)) {
239 "Trying to load a concatenated dill file at a time where that is "
242 InitializeFields(uri_to_source_table);
245void KernelLoader::ReadObfuscationProhibitions() {
250void KernelLoader::ReadLoadingUnits() {
256 bool process_pending_classes) {
269 index_programs(&reader, &subprogram_file_starts);
274 intptr_t subprogram_count = subprogram_file_starts.
length() - 1;
281 for (intptr_t
i = subprogram_count - 1;
i >= 0; --
i) {
282 intptr_t subprogram_start = subprogram_file_starts.
At(
i);
283 intptr_t subprogram_end = subprogram_file_starts.
At(
i + 1);
289 for (intptr_t index = 0; index < source_table_size; ++index) {
291 wrapper.
uri = &uri_string;
294 if (line_starts.
Length() == 0)
continue;
296 wrapper.
uri = &uri_string;
298 if (pair !=
nullptr) {
302 const bool line_starts_differ =
304 if (src_differ || line_starts_differ) {
306 "Invalid kernel binary: Contains at least two source entries "
307 "that do not agree. URI '%s', difference: %s. Subprogram count: "
310 src_differ && line_starts_differ
311 ?
"src and line starts"
312 : (src_differ ?
"src" :
"line starts"),
317 tmp->
uri = &uri_string;
320 uri_to_source_table.
Insert(tmp);
326 for (intptr_t
i = subprogram_count - 1;
i >= 0; --
i) {
327 intptr_t subprogram_start = subprogram_file_starts.
At(
i);
328 intptr_t subprogram_end = subprogram_file_starts.
At(
i + 1);
332 const char*
error =
nullptr;
333 std::unique_ptr<Program> subprogram = Program::ReadFrom(&reader, &
error);
334 if (subprogram ==
nullptr) {
335 FATAL(
"Failed to load kernel file: %s",
error);
337 ASSERT(subprogram->is_single_program());
338 KernelLoader loader(subprogram.get(), &uri_to_source_table);
340 if (load_result.IsError())
return load_result;
342 if (load_result.IsLibrary()) {
343 library ^= load_result.
ptr();
355void KernelLoader::index_programs(
362 subprogram_file_starts->
Add(reader->
size());
364 while (reader->
offset() > 0) {
368 FATAL(
"Invalid kernel binary: Indicated size is invalid.");
373 subprogram_file_starts->
Reverse();
376StringPtr KernelLoader::FindSourceForScript(
const uint8_t* kernel_buffer,
377 intptr_t kernel_buffer_length,
380 kExternalTypedDataUint8ArrayCid,
const_cast<uint8_t*
>(kernel_buffer),
388 for (intptr_t
i = 0;
i < source_table_size; ++
i) {
398 const intptr_t source_table_size = helper_.SourceTableSize();
402 const auto&
binary = program_->binary();
405 ASSERT(program_->string_table_offset() >= 0);
407 reader.set_offset(program_->string_table_offset());
408 intptr_t
count = reader.ReadUInt() + 1;
412 intptr_t end_offset = 0;
413 for (intptr_t
i = 1;
i <
count; ++
i) {
414 end_offset = reader.ReadUInt();
415 offsets.SetUint32(
i << 2, end_offset);
420 reader.ViewFromTo(reader.offset(), reader.offset() + end_offset));
424 program_->constant_table_offset(), program_->name_table_offset()));
428 reader.set_offset(program_->name_table_offset());
429 count = reader.ReadUInt() * 2;
432 for (intptr_t
i = 0;
i <
count; ++
i) {
433 names.SetUint32(
i << 2, reader.ReadUInt());
438 reader.ViewFromTo(program_->metadata_payloads_offset(),
439 program_->metadata_mappings_offset()));
445 program_->metadata_mappings_offset(), program_->string_table_offset()));
448 MetadataHelper::VerifyMetadataMappings(metadata_mappings);
451 const Array& libraries_cache =
455 const intptr_t kClassesPerLibraryGuess = 5;
458 kClassesPerLibraryGuess * program_->library_count(),
Heap::kOld));
460 kernel_program_info_ = KernelProgramInfo::New(
461 binary, string_data, metadata_payloads, metadata_mappings,
464 H.InitFromKernelProgramInfo(kernel_program_info_);
467 for (intptr_t index = 0; index < source_table_size; ++index) {
468 script = LoadScriptAt(index, uri_to_source_table);
473KernelLoader::KernelLoader(
const KernelProgramInfo& kernel_program_info,
474 const TypedDataBase& kernel_data,
475 intptr_t data_program_offset)
477 thread_(Thread::Current()),
478 zone_(thread_->zone()),
479 no_active_isolate_scope_(),
480 patch_classes_(Array::Handle(zone_)),
481 library_kernel_offset_(data_program_offset),
482 correction_offset_(0),
483 loading_native_wrappers_library_(
false),
484 library_kernel_data_(TypedDataView::Handle(zone_)),
485 kernel_program_info_(
486 KernelProgramInfo::Handle(zone_, kernel_program_info.ptr())),
487 translation_helper_(this, thread_, Heap::
kOld),
488 helper_(zone_, &translation_helper_, kernel_data, 0),
489 constant_reader_(&helper_, &active_class_),
490 type_translator_(&helper_,
494 inferred_type_metadata_helper_(&helper_, &constant_reader_),
495 static_field_value_(Object::Handle(
Z)),
496 name_index_handle_(Smi::Handle(
Z)),
497 expression_evaluation_library_(Library::Handle(
Z)) {
498 ASSERT(
T.active_class_ == &active_class_);
500 H.InitFromKernelProgramInfo(kernel_program_info_);
503bool KernelLoader::IsClassName(NameIndex
name,
504 const String& library,
505 const String& klass) {
507 StringIndex class_name_index =
H.CanonicalNameString(
name);
509 if (!
H.StringEquals(class_name_index, klass.ToCString())) {
513 StringIndex library_name_index =
514 H.CanonicalNameString(
H.CanonicalNameParent(
name));
515 return H.StringEquals(library_name_index, library.ToCString());
524 "Trying to load a concatenated dill file at a time where that is "
529 if (setjmp(*jump.
Set()) == 0) {
537 if (process_pending_classes) {
540 return H.thread()->StealStickyError();
549 const intptr_t num_consts = constant_reader.
NumConstants();
551 for (intptr_t
i = 0;
i < num_consts;
i++) {
552 array.
SetAt(
i, Object::sentinel());
555 H.SetConstants(array);
560 return LookupLibrary(main_library);
579 for (intptr_t
i = 0;
i < num_libraries; ++
i) {
580 const String& library_uri = LibraryUri(
i);
581 if (library_uri.
Equals(uri)) {
589 const String& library_url,
601 const intptr_t num_cids =
IG->class_table()->NumCids();
602 const intptr_t num_libs =
607 ASSERT(
H.GetExpressionEvaluationClass().IsNull());
608 ASSERT(
H.GetExpressionEvaluationFunction().IsNull());
609 H.SetExpressionEvaluationRealClass(real_class);
619 ASSERT(
IG->class_table()->NumCids() == num_cids);
625 function.SetKernelLibraryAndEvalScript(
626 eval_script, kernel_program_info_,
650 bool* is_empty_program,
651 intptr_t* p_num_classes,
652 intptr_t* p_num_procedures) {
655 if (setjmp(*jump.
Set()) == 0) {
661 intptr_t num_libs =
libs.Length();
663 for (intptr_t
i = 0;
i < num_libs;
i++) {
672 if (p_num_classes !=
nullptr) {
675 if (p_num_procedures !=
nullptr) {
676 *p_num_procedures = 0;
681 *is_empty_program =
true;
684 loader.walk_incremental_kernel(modified_libs, is_empty_program,
685 p_num_classes, p_num_procedures);
695 intptr_t subprogram_count = subprogram_file_starts.
length() - 1;
696 for (intptr_t
i = 0;
i < subprogram_count; ++
i) {
697 intptr_t subprogram_start = subprogram_file_starts.
At(
i);
698 intptr_t subprogram_end = subprogram_file_starts.
At(
i + 1);
702 const char*
error =
nullptr;
704 if (subprogram ==
nullptr) {
705 FATAL(
"Failed to load kernel file: %s",
error);
707 ASSERT(subprogram->is_single_program());
709 loader.walk_incremental_kernel(modified_libs, is_empty_program,
710 p_num_classes, p_num_procedures);
715void KernelLoader::walk_incremental_kernel(
BitVector* modified_libs,
716 bool* is_empty_program,
717 intptr_t* p_num_classes,
718 intptr_t* p_num_procedures) {
720 *is_empty_program = *is_empty_program && (
length == 0);
721 bool collect_library_stats =
722 p_num_classes !=
nullptr || p_num_procedures !=
nullptr;
723 intptr_t num_classes = 0;
724 intptr_t num_procedures = 0;
727 intptr_t kernel_offset = library_offset(
i);
731 lib = LookupLibraryOrNull(library_helper.canonical_name_);
736 if (collect_library_stats) {
737 intptr_t library_end = library_offset(
i + 1);
738 library_kernel_data_ =
740 LibraryIndex library_index(library_kernel_data_);
741 num_classes += library_index.class_count();
742 num_procedures += library_index.procedure_count();
745 if (p_num_classes !=
nullptr) {
746 *p_num_classes += num_classes;
748 if (p_num_procedures !=
nullptr) {
749 *p_num_procedures += num_procedures;
753void KernelLoader::ReadInferredType(
const Field& field,
754 intptr_t kernel_offset) {
755 const InferredTypeMetadata
type =
758 if (
type.IsTrivial()) {
761 field.set_guarded_cid(
type.cid);
762 field.set_is_nullable(
type.IsNullable());
764 if (FLAG_precompiled_mode) {
765 field.set_is_unboxed(!field.is_late() && !field.is_static() &&
766 !field.is_nullable() &&
767 ((field.guarded_cid() == kDoubleCid) ||
768 (field.guarded_cid() == kFloat32x4Cid &&
770 (field.guarded_cid() == kFloat64x2Cid &&
776void KernelLoader::CheckForInitializer(
const Field& field) {
777 if (helper_.
PeekTag() == kSomething) {
778 field.set_has_initializer(
true);
779 SimpleExpressionConverter
converter(&
H, &helper_);
780 const bool has_simple_initializer =
782 if (!has_simple_initializer ||
783 (!field.is_static() && !
converter.SimpleValue().IsNull())) {
784 field.set_has_nontrivial_initializer(
true);
788 field.set_has_initializer(
false);
789 field.set_has_nontrivial_initializer(
false);
795 "Trying to load a concatenated dill file at a time where that is "
800 library_kernel_offset_ = library_offset(index);
801 correction_offset_ = library_kernel_offset_;
802 intptr_t library_end = library_offset(index + 1);
803 intptr_t library_size = library_end - library_kernel_offset_;
810 helper_.
SetOffset(library_kernel_offset_);
812 LibraryHelper library_helper(&helper_);
814 if (!FLAG_precompiled_mode && !
IG->should_load_vmservice()) {
815 StringIndex lib_name_index =
816 H.CanonicalNameString(library_helper.canonical_name_);
820 skip_vmservice_library_ = library_helper.canonical_name_;
821 ASSERT(
H.IsLibrary(skip_vmservice_library_));
829 if (library.Loaded())
return library.ptr();
832 library_helper.GetNonNullableByDefaultCompiledMode();
835 "Library '%s' was compiled in an unsupported mixed mode between sound "
836 "null safety and not sound null safety.",
841 "Library '%s' was compiled without sound null safety (in weak mode) "
842 "and it cannot be used at runtime",
847 library_kernel_offset_, library_kernel_offset_ + library_size);
848 library.set_kernel_library_index(index);
849 library.set_kernel_program_info(kernel_program_info_);
851 const intptr_t start_offset =
853 const intptr_t end_offset =
856 LibraryIndex library_index(library_kernel_data_);
857 intptr_t class_count = library_index.class_count();
860 library.SetName(
H.DartSymbolObfuscate(library_helper.name_index_));
864 if (library.name() ==
866 ASSERT(library.LoadInProgress());
867 loading_native_wrappers_library_ =
true;
869 loading_native_wrappers_library_ =
false;
870 library.SetLoadInProgress();
873 if (library.url() == Symbols::vm_ffi_native_assets().ptr()) {
874 const auto& native_assets_library =
876 ASSERT(native_assets_library.IsNull());
877 IG->object_store()->set_native_assets_library(library);
885 intptr_t annotations_kernel_offset =
887 const intptr_t annotation_count =
889 for (intptr_t
i = 0;
i < annotation_count; ++
i) {
899 const bool register_class =
900 library.ptr() != expression_evaluation_library_.
ptr();
902 Class& toplevel_class =
904 TokenPosition::kNoSource, register_class));
905 toplevel_class.set_is_abstract();
906 toplevel_class.set_is_declaration_loaded();
907 toplevel_class.set_is_type_finalized();
908 toplevel_class.set_num_type_arguments_unsafe(0);
909 library.set_toplevel_class(toplevel_class);
912 LoadLibraryImportsAndExports(&library, toplevel_class);
918 const GrowableObjectArray& classes =
922 intptr_t next_class_offset = library_index.ClassOffset(0);
924 for (intptr_t
i = 0;
i < class_count; ++
i) {
926 next_class_offset = library_index.ClassOffset(
i + 1);
927 LoadClass(library, toplevel_class, next_class_offset, &klass);
928 if (register_class) {
933 if (loading_native_wrappers_library_ || !register_class) {
934 FinishTopLevelClassLoading(toplevel_class, library, library_index);
939 if (annotation_count > 0) {
940 ASSERT(annotations_kernel_offset > 0);
941 library.AddMetadata(library, annotations_kernel_offset);
944 if (register_class) {
945 helper_.
SetOffset(library_index.SourceReferencesOffset());
947 const GrowableObjectArray& used_scripts =
950 for (intptr_t
i = 0;
i <
count;
i++) {
951 intptr_t uri_index = helper_.
ReadUInt();
952 script = ScriptAt(uri_index);
956 if (!library.Loaded()) library.SetLoaded();
958 return library.ptr();
961void KernelLoader::FinishTopLevelClassLoading(
962 const Class& toplevel_class,
963 const Library& library,
964 const LibraryIndex& library_index) {
965 if (toplevel_class.is_loaded()) {
970 ActiveClassScope active_class_scope(&active_class_, &toplevel_class);
974 const intptr_t correction = correction_offset_ - library_kernel_offset_;
975 helper_.
SetOffset(library_index.ClassOffset(library_index.class_count()) +
979 for (intptr_t
i = 0;
i < extension_count; ++
i) {
991 for (intptr_t j = 0; j < extension_member_count; ++j) {
1000 const intptr_t extension_type_declaration_count = helper_.
ReadListLength();
1001 for (intptr_t
i = 0;
i < extension_type_declaration_count; ++
i) {
1015 const intptr_t extension_type_procedure_count =
1017 for (intptr_t
i = 0;
i < extension_type_procedure_count; ++
i) {
1018 ProcedureHelper procedure_helper(&helper_);
1022 const intptr_t extension_type_member_count = helper_.
ReadListLength();
1023 for (intptr_t j = 0; j < extension_type_member_count; ++j) {
1037 for (intptr_t
i = 0;
i < field_count; ++
i) {
1038 intptr_t field_offset = helper_.
ReaderOffset() - correction_offset_;
1039 ActiveMemberScope active_member_scope(&active_class_,
nullptr);
1040 FieldHelper field_helper(&helper_);
1048 uint32_t pragma_bits = 0;
1049 ReadVMAnnotations(annotation_count, &pragma_bits);
1053 const Object& script_class =
1054 ClassForScriptAt(toplevel_class, field_helper.source_uri_index_);
1057 const bool is_final = field_helper.IsConst() || field_helper.IsFinal();
1059 ASSERT(!field_helper.IsCovariant() &&
1060 !field_helper.IsGenericCovariantImpl());
1061 const bool is_late = field_helper.IsLate();
1062 const bool is_extension_member = field_helper.IsExtensionMember();
1063 const bool is_extension_type_member = field_helper.IsExtensionTypeMember();
1066 script_class, field_helper.position_,
1067 field_helper.end_position_));
1068 field.set_kernel_offset(field_offset);
1070 field.set_is_extension_member(is_extension_member);
1071 field.set_is_extension_type_member(is_extension_type_member);
1073 const AbstractType&
type =
T.BuildType();
1074 field.SetFieldType(
type);
1075 ReadInferredType(field, field_offset + library_kernel_offset_);
1076 CheckForInitializer(field);
1078 if (field.has_initializer()) {
1079 field.set_is_late(
true);
1083 intptr_t field_initializer_offset = helper_.
ReaderOffset();
1087 AlternativeReadingScope alt(&helper_.
reader_, field_initializer_offset);
1088 static_field_value_ = ReadInitialFieldValue(field, &field_helper);
1090 GenerateFieldAccessors(toplevel_class, field, &field_helper);
1091 IG->RegisterStaticField(field, static_field_value_);
1094 annotation_count > 0) {
1095 library.AddMetadata(field, field_offset);
1097 fields_.Add(&field);
1100 ASSERT(!toplevel_class.is_loaded());
1103 intptr_t next_procedure_offset =
1104 library_index.ProcedureOffset(0) + correction;
1105 const intptr_t procedure_count = library_index.procedure_count();
1106 for (intptr_t
i = 0;
i < procedure_count; ++
i) {
1107 helper_.
SetOffset(next_procedure_offset);
1108 next_procedure_offset = library_index.ProcedureOffset(
i + 1) + correction;
1109 LoadProcedure(library, toplevel_class,
false, next_procedure_offset);
1115 if (toplevel_class.is_loaded()) {
1121 toplevel_class.SetFunctions(
Array::Handle(MakeFunctionsArray()));
1124 for (intptr_t
i = 0, n = fields_.length();
i < n; ++
i) {
1125 const Field* field = fields_.At(
i);
1126 name = field->name();
1127 library.AddObject(*field,
name);
1129 for (intptr_t
i = 0, n = functions_.length();
i < n; ++
i) {
1130 const Function*
function = functions_.At(
i);
1135 ASSERT(!toplevel_class.is_loaded());
1136 toplevel_class.set_is_loaded(
true);
1139void KernelLoader::LoadLibraryImportsAndExports(Library* library,
1140 const Class& toplevel_class) {
1150 for (intptr_t dep = 0; dep < deps_count; ++dep) {
1151 LibraryDependencyHelper dependency_helper(&helper_);
1154 intptr_t annotations_kernel_offset =
1161 if (dependency_helper.target_library_canonical_name_ < 0) {
1163 for (intptr_t c = 0; c < combinator_count; ++c) {
1173 for (intptr_t c = 0; c < combinator_count; ++c) {
1176 for (intptr_t n = 0; n < name_count; ++n) {
1177 String& show_hide_name =
1187 if (show_list.Length() > 0) {
1193 if (hide_list.Length() > 0) {
1200 Z, LookupLibrary(dependency_helper.target_library_canonical_name_));
1201 if (!FLAG_enable_mirrors &&
1202 target_library.url() == Symbols::DartMirrors().ptr()) {
1204 "import of dart:mirrors is not supported in the current Dart "
1208 target_library.url() == Symbols::DartFfi().ptr() &&
1209 library->url() != Symbols::DartCore().ptr() &&
1210 library->url() != Symbols::DartInternal().ptr() &&
1211 library->url() != Symbols::DartFfi().ptr()) {
1213 "import of dart:ffi is not supported in the current Dart runtime");
1215 String&
prefix =
H.DartSymbolPlain(dependency_helper.name_index_);
1216 ns = Namespace::New(target_library, show_names, hide_names, *library);
1218 library->AddExport(ns);
1221 library->AddImport(ns);
1223 library_prefix = library->LookupLocalLibraryPrefix(
prefix);
1224 if (!library_prefix.IsNull()) {
1225 library_prefix.AddImport(ns);
1227 library_prefix = LibraryPrefix::New(
1232 library->AddObject(library_prefix,
prefix);
1237 if (FLAG_enable_mirrors && dependency_helper.annotation_count_ > 0) {
1238 ASSERT(annotations_kernel_offset > 0);
1239 library->AddMetadata(ns, annotations_kernel_offset);
1243 deps.SetAt(dep, ns);
1245 deps.SetAt(dep, library_prefix);
1249 library->set_dependencies(deps);
1252void KernelLoader::LoadPreliminaryClass(ClassHelper* class_helper,
1253 intptr_t type_parameter_count) {
1254 const Class* klass = active_class_.
klass;
1265 T.LoadAndSetupTypeParameters(&active_class_, Object::null_function(), *klass,
1266 Object::null_function_type(),
1267 type_parameter_count);
1269 ActiveTypeParametersScope scope(&active_class_,
nullptr,
Z);
1271 T.LoadAndSetupBounds(&active_class_, Object::null_function(), *klass,
1272 Object::null_function_type(), type_parameter_count);
1276 if (type_tag == kSomething) {
1277 AbstractType& super_type =
1278 T.BuildTypeWithoutFinalization();
1279 klass->set_super_type(Type::Cast(super_type));
1287 if (interface_count == 0) {
1288 klass->set_interfaces(Object::empty_array());
1290 const Array& interfaces =
1292 for (intptr_t
i = 0;
i < interface_count;
i++) {
1293 const AbstractType&
type =
1294 T.BuildTypeWithoutFinalization();
1295 interfaces.SetAt(
i,
type);
1297 klass->set_interfaces(interfaces);
1301 if (class_helper->is_abstract()) {
1302 klass->set_is_abstract();
1304 if (class_helper->is_transformed_mixin_application()) {
1305 klass->set_is_transformed_mixin_application();
1307 if (class_helper->has_const_constructor()) {
1308 klass->set_is_const();
1310 if (class_helper->is_sealed()) {
1311 klass->set_is_sealed();
1313 if (class_helper->is_mixin_class()) {
1314 klass->set_is_mixin_class();
1316 if (class_helper->is_base()) {
1317 klass->set_is_base_class();
1319 if (class_helper->is_interface()) {
1320 klass->set_is_interface_class();
1322 if (class_helper->is_final()) {
1323 klass->set_is_final();
1327void KernelLoader::LoadClass(
const Library& library,
1328 const Class& toplevel_class,
1332 ClassIndex class_index(program_->
binary(), class_offset,
1333 class_end - class_offset);
1335 ClassHelper class_helper(&helper_);
1337 *out_class = LookupClass(library, class_helper.canonical_name_);
1338 out_class->set_kernel_offset(class_offset - correction_offset_);
1347 out_class->set_script(
script);
1349 if (out_class->token_pos() == TokenPosition::kNoSource) {
1351 out_class->set_token_pos(class_helper.start_position_);
1352 out_class->set_end_token_pos(class_helper.end_position_);
1356 if (class_helper.is_enum_class()) {
1357 out_class->set_is_enum_class();
1362 uint32_t pragma_bits = 0;
1363 ReadVMAnnotations(annotation_count, &pragma_bits);
1365 out_class->set_is_isolate_unsendable_due_to_pragma(
true);
1368 out_class->set_is_deeply_immutable(
true);
1375 out_class->set_has_pragma(
true);
1378 out_class->set_is_dynamically_extendable(
true);
1379 IG->set_has_dynamically_extendable_classes(
true);
1383 intptr_t type_parameter_counts =
1386 ActiveClassScope active_class_scope(&active_class_, out_class);
1387 if (!out_class->is_declaration_loaded()) {
1388 LoadPreliminaryClass(&class_helper, type_parameter_counts);
1390 ASSERT(type_parameter_counts == 0);
1395 annotation_count > 0) {
1396 library.AddMetadata(*out_class, class_offset - correction_offset_);
1402 const bool register_class =
1403 library.ptr() != expression_evaluation_library_.
ptr();
1404 if (!register_class) {
1405 H.SetExpressionEvaluationClass(*out_class);
1408 if (loading_native_wrappers_library_ || !register_class) {
1409 FinishClassLoading(*out_class, library, toplevel_class, class_offset,
1410 class_index, &class_helper);
1416void KernelLoader::FinishClassLoading(
const Class& klass,
1417 const Library& library,
1418 const Class& toplevel_class,
1419 intptr_t class_offset,
1420 const ClassIndex& class_index,
1421 ClassHelper* class_helper) {
1422 if (klass.is_loaded()) {
1428 ActiveClassScope active_class_scope(&active_class_, &klass);
1433 const bool discard_fields = klass.InjectCIDFields();
1437 if (!discard_fields) {
1440 for (intptr_t
i = 0;
i < field_count; ++
i) {
1441 intptr_t field_offset = helper_.
ReaderOffset() - correction_offset_;
1442 ActiveMemberScope active_member(&active_class_,
nullptr);
1443 FieldHelper field_helper(&helper_);
1446 const Object& script_class =
1447 ClassForScriptAt(klass, field_helper.source_uri_index_);
1455 uint32_t pragma_bits = 0;
1456 ReadVMAnnotations(annotation_count, &pragma_bits);
1460 const AbstractType&
type =
1461 T.BuildTypeWithoutFinalization();
1464 const bool is_reflectable =
1465 field_helper.position_.IsReal() &&
1466 !(library.is_dart_scheme() && library.IsPrivate(
name));
1469 const bool is_final = field_helper.IsConst() || field_helper.IsFinal();
1470 const bool is_late = field_helper.IsLate();
1471 const bool is_extension_member = field_helper.IsExtensionMember();
1472 const bool is_extension_type_member =
1473 field_helper.IsExtensionTypeMember();
1475 Z, Field::New(
name, field_helper.IsStatic(), is_final,
1476 field_helper.IsConst(), is_reflectable, is_late,
1477 script_class,
type, field_helper.position_,
1478 field_helper.end_position_));
1479 field.set_kernel_offset(field_offset);
1481 field.set_is_covariant(field_helper.IsCovariant());
1482 field.set_is_generic_covariant_impl(
1483 field_helper.IsGenericCovariantImpl());
1484 field.set_is_extension_member(is_extension_member);
1485 field.set_is_extension_type_member(is_extension_type_member);
1487 ReadInferredType(field, field_offset + library_kernel_offset_);
1488 CheckForInitializer(field);
1490 if (field_helper.IsStatic() && field.has_initializer()) {
1491 field.set_is_late(
true);
1494 intptr_t field_initializer_offset = helper_.
ReaderOffset();
1498 AlternativeReadingScope alt(&helper_.
reader_, field_initializer_offset);
1499 static_field_value_ = ReadInitialFieldValue(field, &field_helper);
1501 GenerateFieldAccessors(klass, field, &field_helper);
1502 if (field.is_static()) {
1503 IG->RegisterStaticField(field, static_field_value_);
1506 annotation_count > 0) {
1507 library.AddMetadata(field, field_offset);
1509 fields_.Add(&field);
1513 if (klass.is_enum_class()) {
1517 deleted_enum_sentinel =
1518 Field::New(Symbols::_DeletedEnumSentinel(),
1523 false, klass, Object::dynamic_type(),
1524 TokenPosition::kNoSource, TokenPosition::kNoSource);
1526 fields_.Add(&deleted_enum_sentinel);
1536 if (klass.UserVisibleName() == Symbols::Compound().ptr() &&
1540 .StartsWith(Symbols::_typedDataBase()));
1542 fields_[0]->set_is_nullable(
true);
1552 if (!super_class.IsNull() &&
1553 super_class.UserVisibleName() == Symbols::AbiSpecificInteger().ptr() &&
1555 Symbols::DartFfi().
ptr()) {
1556 const char*
error =
nullptr;
1559 if (
error !=
nullptr) {
1560 H.ReportError(
"%s",
error);
1566 if (klass.is_loaded()) {
1575 for (intptr_t
i = 0;
i < constructor_count; ++
i) {
1576 intptr_t constructor_offset = helper_.
ReaderOffset() - correction_offset_;
1577 ActiveMemberScope active_member_scope(&active_class_,
nullptr);
1578 ConstructorHelper constructor_helper(&helper_);
1581 uint32_t pragma_bits = 0;
1582 ReadVMAnnotations(annotation_count, &pragma_bits);
1586 const String&
name =
1587 H.DartConstructorName(constructor_helper.canonical_name_);
1592 const Object* owner = &klass;
1593 const intptr_t source_uri_index = constructor_helper.source_uri_index_;
1594 if (source_uri_index != 0) {
1595 owner = &ClassForScriptAt(klass, source_uri_index);
1602 constructor_helper.IsConst(),
1604 constructor_helper.IsExternal(),
1606 *owner, constructor_helper.start_position_));
1607 function.set_end_token_pos(constructor_helper.end_position_);
1608 function.set_kernel_offset(constructor_offset);
1609 signature.set_result_type(
T.ReceiverType(klass));
1612 function.SetIsDynamicallyOverridden(
1615 FunctionNodeHelper function_node_helper(&helper_);
1616 function_node_helper.ReadUntilExcluding(
1618 T.SetupFunctionParameters(klass,
function,
1621 &function_node_helper);
1622 T.SetupUnboxingInfoMetadata(
function, library_kernel_offset_);
1624 if (library.is_dart_scheme() &&
1625 H.IsPrivate(constructor_helper.canonical_name_)) {
1626 function.set_is_reflectable(
false);
1629 if (constructor_helper.IsSynthetic()) {
1637 if (klass.is_finalized()) {
1648 annotation_count > 0) {
1649 library.AddMetadata(
function, constructor_offset);
1655 if (klass.is_loaded()) {
1662 intptr_t procedure_count = class_index.procedure_count();
1666 intptr_t correction = correction_offset_ - library_kernel_offset_;
1667 intptr_t next_procedure_offset = class_index.ProcedureOffset(0) + correction;
1668 for (intptr_t
i = 0;
i < procedure_count; ++
i) {
1669 helper_.
SetOffset(next_procedure_offset);
1670 next_procedure_offset = class_index.ProcedureOffset(
i + 1) + correction;
1671 LoadProcedure(library, klass,
true, next_procedure_offset);
1676 if (klass.is_loaded()) {
1683 ASSERT(!klass.is_loaded());
1684 klass.set_is_loaded(
true);
1693 const auto& library_kernel_data =
1695 ASSERT(!library_kernel_data.IsNull());
1697 const auto& kernel_info =
1699 const intptr_t library_kernel_offset =
1702 KernelLoader kernel_loader(kernel_info, library_kernel_data,
1703 library_kernel_offset);
1709 kernel_loader.FinishTopLevelClassLoading(klass, library, library_index);
1715 library_kernel_data, class_offset,
1722 kernel_loader.helper_.
SetOffset(class_offset);
1725 kernel_loader.FinishClassLoading(klass, library, toplevel_class, class_offset,
1726 class_index, &class_helper);
1738void KernelLoader::ReadVMAnnotations(intptr_t annotation_count,
1739 uint32_t* pragma_bits,
1742 if (annotation_count == 0) {
1746 for (intptr_t
i = 0;
i < annotation_count; ++
i) {
1747 const intptr_t tag = helper_.
PeekTag();
1748 if (tag == kConstantExpression || tag == kFileUriConstantExpression) {
1751 if (tag == kFileUriConstantExpression) {
1755 const intptr_t index_in_constant_table = helper_.
ReadUInt();
1758 ConstantReader constant_reader(&helper_, &active_class_);
1760 intptr_t name_index = -1;
1761 intptr_t options_index = -1;
1762 if (constant_reader.IsPragmaInstanceConstant(
1763 index_in_constant_table, &name_index, &options_index)) {
1766 if (constant_reader.IsStringConstant(name_index,
"vm:invisible")) {
1769 if (constant_reader.IsStringConstant(name_index,
"vm:external-name")) {
1771 constant_reader.GetStringConstant(options_index, native_name);
1773 if (constant_reader.IsStringConstant(name_index,
1774 "vm:isolate-unsendable")) {
1777 if (constant_reader.IsStringConstant(name_index,
1778 "vm:deeply-immutable")) {
1781 if (constant_reader.IsStringConstant(name_index,
"vm:ffi:native")) {
1784 if (constant_reader.IsStringConstant(name_index,
"vm:shared")) {
1787 "Encountered vm:shared when functionality is disabled. "
1788 "Pass --experimental-shared-data");
1792 if (constant_reader.IsStringConstant(name_index,
1793 "dyn-module:extendable")) {
1796 if (constant_reader.IsStringConstant(name_index,
1797 "dyn-module:can-be-overridden")) {
1809void KernelLoader::LoadProcedure(
const Library& library,
1812 intptr_t procedure_end) {
1813 intptr_t procedure_offset = helper_.
ReaderOffset() - correction_offset_;
1814 ProcedureHelper procedure_helper(&helper_);
1825 if (!FLAG_precompiled_mode && procedure_helper.IsMemberSignature()) {
1829 const String&
name =
H.DartProcedureName(procedure_helper.canonical_name_);
1830 bool is_method = in_class && !procedure_helper.IsStatic();
1831 bool is_abstract = procedure_helper.IsAbstract();
1832 bool is_external = procedure_helper.IsExternal();
1833 bool is_extension_member = procedure_helper.IsExtensionMember();
1834 bool is_extension_type_member = procedure_helper.IsExtensionTypeMember();
1835 bool is_synthetic = procedure_helper.IsSynthetic();
1837 uint32_t pragma_bits = 0;
1839 ReadVMAnnotations(annotation_count, &pragma_bits, &native_name);
1840 is_external = is_external && native_name.IsNull();
1842 const Object& script_class =
1843 ClassForScriptAt(owner, procedure_helper.source_uri_index_);
1849 const bool register_function = !
name.Equals(Symbols::DebugProcedureName());
1857 is_abstract, is_external,
1858 !native_name.IsNull() || is_ffi_native,
1859 script_class, procedure_helper.start_position_));
1861 function.set_end_token_pos(procedure_helper.end_position_);
1862 function.set_is_synthetic(procedure_helper.IsNoSuchMethodForwarder() ||
1863 procedure_helper.IsMemberSignature() ||
1866 function.SetIsDynamicallyOverridden(
1868 if (register_function) {
1871 H.SetExpressionEvaluationFunction(
function);
1873 function.set_kernel_offset(procedure_offset);
1874 function.set_is_extension_member(is_extension_member);
1875 function.set_is_extension_type_member(is_extension_type_member);
1876 if ((library.is_dart_scheme() &&
1877 H.IsPrivate(procedure_helper.canonical_name_)) ||
1879 function.set_is_reflectable(
false);
1881 if (procedure_helper.IsMemberSignature()) {
1882 function.set_is_reflectable(
false);
1885 ActiveMemberScope active_member(&active_class_, &
function);
1889 FunctionNodeHelper function_node_helper(&helper_);
1895 }
else if (function_node_helper.async_marker_ ==
1900 }
else if (function_node_helper.async_marker_ ==
1912 if (!native_name.IsNull()) {
1913 function.set_native_name(native_name);
1917 T.SetupFunctionParameters(owner,
function, is_method,
1919 &function_node_helper);
1920 T.SetupUnboxingInfoMetadata(
function, library_kernel_offset_);
1922 function_node_helper.ReadUntilExcluding(
1930 if (annotation_count > 0) {
1931 library.AddMetadata(
function, procedure_offset);
1935const Object& KernelLoader::ClassForScriptAt(
const Class& klass,
1936 intptr_t source_uri_index) {
1937 const Script& correct_script =
Script::Handle(
Z, ScriptAt(source_uri_index));
1938 if (klass.script() != correct_script.ptr()) {
1940 if (patch_classes_.
IsNull()) {
1948 patch_class ^= patch_classes_.
At(source_uri_index);
1949 if (patch_class.IsNull() || patch_class.wrapped_class() != klass.ptr()) {
1952 PatchClass::New(klass, kernel_program_info_, correct_script);
1954 patch_classes_.
SetAt(source_uri_index, patch_class);
1961ScriptPtr KernelLoader::LoadScriptAt(intptr_t index,
1971 if (uri_to_source_table !=
nullptr) {
1972 UriToSourceTableEntry wrapper;
1973 wrapper.uri = &uri_string;
1974 UriToSourceTableEntry* pair = uri_to_source_table->LookupValue(&wrapper);
1975 if (pair !=
nullptr) {
1976 sources = pair->sources->ptr();
1977 line_starts = pair->line_starts->ptr();
1981 if (
sources.IsNull() || line_starts.IsNull()) {
1982 const String& script_source = helper_.
GetSourceFor(index);
1986 line_starts.Length() == 0 && uri_string.Length() > 0) {
1991 const GrowableObjectArray&
libs =
1993 for (intptr_t
i = 0;
i <
libs.Length();
i++) {
1995 script = lib.LookupScript(uri_string,
true);
1998 line_starts =
script.line_starts();
2003 sources = script_source.ptr();
2009 script.InitializeFromKernel(kernel_program_info_, index, line_starts,
2014ObjectPtr KernelLoader::ReadInitialFieldValue(
const Field& field,
2015 FieldHelper* field_helper) {
2017 const bool has_initializer = (tag == kSomething);
2019 if (has_initializer) {
2020 SimpleExpressionConverter
converter(&
H, &helper_);
2021 const bool has_simple_initializer =
2023 if (has_simple_initializer) {
2024 if (field_helper->IsStatic()) {
2027 field.RecordStore(
converter.SimpleValue());
2032 if (field_helper->IsStatic()) {
2033 if (!has_initializer && !field_helper->IsLate()) {
2039 ASSERT(field.NeedsGetter());
2042 return field_helper->IsStatic() ? Object::sentinel().ptr() :
Object::null();
2045void KernelLoader::GenerateFieldAccessors(
const Class& klass,
2047 FieldHelper* field_helper) {
2048 const bool needs_getter = field.NeedsGetter();
2049 const bool needs_setter = field.NeedsSetter();
2051 if (!needs_getter && !needs_setter) {
2055 const Object& script_class =
2056 ClassForScriptAt(klass, field_helper->source_uri_index_);
2060 const String& getter_name =
2061 H.DartGetterName(field_helper->canonical_name_getter_);
2062 const FunctionType& signature =
2067 signature, getter_name,
2068 field_helper->IsStatic() ? UntaggedFunction::kImplicitStaticGetter
2069 : UntaggedFunction::kImplicitGetter,
2070 field_helper->IsStatic(),
2074 field_helper->IsStatic() ? field_helper->IsConst()
2075 : field_helper->IsFinal(),
2079 script_class, field_helper->position_));
2080 functions_.Add(&getter);
2081 getter.set_end_token_pos(field_helper->end_position_);
2082 getter.set_kernel_offset(field.kernel_offset());
2083 signature.set_result_type(field_type);
2084 getter.set_is_debuggable(
false);
2085 getter.set_accessor_field(field);
2086 getter.set_is_extension_member(field.is_extension_member());
2087 getter.set_is_extension_type_member(field.is_extension_type_member());
2088 H.SetupFieldAccessorFunction(klass, getter, field_type);
2089 T.SetupUnboxingInfoMetadataForFieldAccessors(getter,
2090 library_kernel_offset_);
2095 ASSERT(!field_helper->IsConst());
2096 const String& setter_name =
2097 H.DartSetterName(field_helper->canonical_name_setter_);
2098 const FunctionType& signature =
2102 Function::New(signature, setter_name, UntaggedFunction::kImplicitSetter,
2103 field_helper->IsStatic(),
2108 script_class, field_helper->position_));
2109 functions_.Add(&setter);
2110 setter.set_end_token_pos(field_helper->end_position_);
2111 setter.set_kernel_offset(field.kernel_offset());
2112 signature.set_result_type(Object::void_type());
2113 setter.set_is_debuggable(
false);
2114 setter.set_accessor_field(field);
2115 setter.set_is_extension_member(field.is_extension_member());
2116 setter.set_is_extension_type_member(field.is_extension_type_member());
2117 H.SetupFieldAccessorFunction(klass, setter, field_type);
2118 T.SetupUnboxingInfoMetadataForFieldAccessors(setter,
2119 library_kernel_offset_);
2123LibraryPtr KernelLoader::LookupLibraryOrNull(NameIndex library) {
2125 name_index_handle_ =
Smi::New(library);
2128 NoSafepointScope no_safepoint_scope(thread_);
2133 const String& url =
H.DartString(
H.CanonicalNameString(library));
2136 NoSafepointScope no_safepoint_scope(thread_);
2142 name_index_handle_ =
Smi::New(library);
2143 return kernel_program_info_.
InsertLibrary(thread_, name_index_handle_,
2147LibraryPtr KernelLoader::LookupLibrary(NameIndex library) {
2148 name_index_handle_ =
Smi::New(library);
2151 kernel_program_info_.
LookupLibrary(thread_, name_index_handle_);
2152 NoSafepointScope no_safepoint_scope(thread_);
2159 const String& url =
H.DartSymbolPlain(
H.CanonicalNameString(library));
2163 if (url.Equals(Symbols::EvalSourceUri())) {
2164 if (expression_evaluation_library_.
IsNull()) {
2165 handle = Library::New(url);
2166 expression_evaluation_library_ = handle.
ptr();
2168 return expression_evaluation_library_.
ptr();
2171 if (handle.IsNull()) {
2172 handle = Library::New(url);
2173 handle.Register(thread_);
2175 ASSERT(!handle.IsNull());
2176 name_index_handle_ =
Smi::New(library);
2177 return kernel_program_info_.
InsertLibrary(thread_, name_index_handle_,
2181LibraryPtr KernelLoader::LookupLibraryFromClass(NameIndex klass) {
2182 return LookupLibrary(
H.CanonicalNameParent(klass));
2185ClassPtr KernelLoader::LookupClass(
const Library& library, NameIndex klass) {
2186 name_index_handle_ =
Smi::New(klass);
2188 ClassPtr raw_class =
2189 kernel_program_info_.
LookupClass(thread_, name_index_handle_);
2190 NoSafepointScope no_safepoint_scope(thread_);
2196 ASSERT(!library.IsNull());
2197 const String&
name =
H.DartClassName(klass);
2199 bool register_class =
true;
2200 if (handle.IsNull()) {
2204 register_class = library.ptr() != expression_evaluation_library_.
ptr();
2207 TokenPosition::kNoSource, register_class);
2208 if (register_class) {
2209 library.AddClass(handle);
2212 ASSERT(!handle.IsNull());
2213 if (register_class) {
2214 name_index_handle_ =
Smi::New(klass);
2215 kernel_program_info_.
InsertClass(thread_, name_index_handle_, handle);
2217 return handle.ptr();
2222 intptr_t lookuptable[] = {
2223 UntaggedFunction::kRegularFunction,
2224 UntaggedFunction::kGetterFunction,
2225 UntaggedFunction::kSetterFunction,
2226 UntaggedFunction::kRegularFunction,
2227 UntaggedFunction::kConstructor,
2229 intptr_t kind =
static_cast<int>(procedure_kind);
2234FunctionPtr KernelLoader::LoadClosureFunction(
const Function& parent_function,
2235 const Object& closure_owner) {
2236 const intptr_t func_decl_offset = helper_.
ReaderOffset();
2238 ASSERT((tag == kFunctionExpression) || (tag == kFunctionDeclaration));
2243 uint32_t pragma_bits = 0;
2244 intptr_t annotation_count = 0;
2246 if (is_declaration) {
2248 VariableDeclarationHelper variable_helper(&helper_);
2252 ReadVMAnnotations(annotation_count, &pragma_bits);
2256 name = &
H.DartSymbolObfuscate(variable_helper.name_index_);
2258 name = &Symbols::AnonymousClosure();
2261 const intptr_t func_node_offset = helper_.
ReaderOffset();
2263 FunctionNodeHelper function_node_helper(&helper_);
2267 if (!closure_owner.IsNull()) {
2269 UntaggedFunction::kClosureFunction, *
name, parent_function,
2270 parent_function.is_static(), position, closure_owner);
2276 function.set_has_pragma(has_pragma);
2278 if ((FLAG_enable_mirrors && (annotation_count > 0)) || has_pragma) {
2281 lib.AddMetadata(
function, func_decl_offset);
2288 }
else if (function_node_helper.async_marker_ ==
2293 }
else if (function_node_helper.async_marker_ ==
2308 position.IsReal() ? function_node_helper.end_position_ : position);
2310 function.set_kernel_offset(func_node_offset);
2314 &function_node_helper);
2330 intptr_t func_decl_offset,
2333 const Object& closure_owner) {
2336 intptr_t func_node_offset = -1;
2338 const auto& kernel_info =
2340 const auto& library_kernel_data =
2342 ASSERT(!library_kernel_data.IsNull());
2345 KernelLoader kernel_loader(kernel_info, library_kernel_data,
2346 library_kernel_offset);
2350 kernel_loader.helper_.
SetOffset(func_decl_offset);
2352 func_node_offset = kernel_loader.helper_.
ReaderOffset();
2357 member_function, func_node_offset);
2366 member_function, func_node_offset);
2369 &kernel_loader.active_class_,
2374 &kernel_loader.active_class_, member_function,
2376 kernel_loader.helper_.
SetOffset(func_decl_offset);
2378 kernel_loader.LoadClosureFunction(parent_function, closure_owner);
2385 const Field& field) {
2399 const auto& kernel_program_info =
2402 zone, PatchClass::New(field_owner, kernel_program_info,
script));
2410 Function::New(signature, init_name, UntaggedFunction::kFieldInitializer,
2416 initializer_owner, TokenPosition::kNoSource));
2427 initializer_fun.set_is_reflectable(
false);
2428 initializer_fun.set_is_inlinable(
false);
2434 initializer_fun.set_is_extension_type_member(
2441 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 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::kNonNullable, 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
TypedDataViewPtr ViewFromTo(intptr_t start, intptr_t end, Heap::Space space=Heap::kNew) 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 char * Channel()
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)
const TypedDataBase & binary()
static std::unique_ptr< Program > ReadFrom(Reader *reader, const char **error=nullptr)
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
DEFINE_FLAG_HANDLER(EnableExperimentSharedData, experimental_shared_data, "Enable experiment to share data between isolates.")
DirectChainedHashMap< UriToSourceTableTrait > UriToSourceTable
static bool IsMainOrDevChannel()
static void EnableExperimentSharedData(bool value)
static constexpr int SpecializedIntLiteralBias
static bool is_experimental_shared_data_enabled
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)
NOT_IN_PRODUCT(LibraryPtr ReloadTestScript(const char *script))
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
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
const TypedData * line_starts
#define TIMELINE_DURATION(thread, stream, name)