5#ifndef RUNTIME_VM_KERNEL_LOADER_H_
6#define RUNTIME_VM_KERNEL_LOADER_H_
8#if !defined(DART_PRECOMPILED_RUNTIME)
34 bool required =
true);
36 bool required =
true);
42 class LibraryLookupHandleScope {
44 explicit LibraryLookupHandleScope(
Library& lib) : lib_(lib) {
58 Library& library_lookup_handle_;
63template <
typename VmType>
66 bool Lookup(intptr_t canonical_name, VmType** handle) {
68 if (pair !=
nullptr) {
69 *handle = pair->
value;
75 void Insert(intptr_t canonical_name, VmType*
object) {
76 map_.
Insert(canonical_name,
object);
92 return reader_.
ReadUInt32At(class_index_offset_ + index * 4);
96 return reader_.
ReadUInt32At(procedure_index_offset_ + index * 4);
100 for (intptr_t
i = 0,
offset = class_index_offset_;
i < class_count_;
114 intptr_t source_references_offset_;
115 intptr_t class_index_offset_;
116 intptr_t class_count_;
117 intptr_t procedure_index_offset_;
118 intptr_t procedure_count_;
128 intptr_t class_offset,
129 intptr_t class_size);
134 return reader_.
ReadUInt32At(procedure_index_offset_ + index * 4);
138 void Init(intptr_t class_offset, intptr_t class_size);
141 intptr_t procedure_count_;
142 intptr_t procedure_index_offset_;
178 bool process_pending_classes =
true);
202 bool* is_empty_program,
203 intptr_t* p_num_classes,
204 intptr_t* p_num_procedures);
207 intptr_t kernel_buffer_length,
218 intptr_t func_decl_offset,
221 const Object& closure_owner);
244 void FinishTopLevelClassLoading(
const Class& toplevel_class,
250 void ReadVMAnnotations(intptr_t annotation_count,
251 uint32_t* pragma_bits,
252 String* native_name =
nullptr);
256 intptr_t data_program_offset);
258 void InitializeFields(
263 const String& LibraryUri(intptr_t library_index) {
266 library_canonical_name(library_index)));
269 intptr_t library_offset(intptr_t index) {
271 return reader.ReadFromIndexNoReset(reader.size(),
276 NameIndex library_canonical_name(intptr_t index) {
278 reader.set_offset(library_offset(index));
285 return reader.ReadCanonicalNameReference();
288 uint8_t CharacterAt(StringIndex string_index, intptr_t index);
290 void walk_incremental_kernel(BitVector* modified_libs,
291 bool* is_empty_program,
292 intptr_t* p_num_classes,
293 intptr_t* p_num_procedures);
295 void LoadPreliminaryClass(ClassHelper* class_helper,
296 intptr_t type_parameter_count);
298 void ReadInferredType(
const Field& field, intptr_t kernel_offset);
299 void CheckForInitializer(
const Field& field);
301 void LoadClass(
const Library& library,
302 const Class& toplevel_class,
306 void FinishClassLoading(
const Class& klass,
307 const Library& library,
308 const Class& toplevel_class,
309 intptr_t class_offset,
310 const ClassIndex& class_index,
311 ClassHelper* class_helper);
313 void LoadProcedure(
const Library& library,
316 intptr_t procedure_end);
318 ArrayPtr MakeFieldsArray();
319 ArrayPtr MakeFunctionsArray();
321 ScriptPtr LoadScriptAt(
323 DirectChainedHashMap<UriToSourceTableTrait>* uri_to_source_table);
328 const Object& ClassForScriptAt(
const Class& klass, intptr_t source_uri_index);
329 ScriptPtr ScriptAt(intptr_t source_uri_index) {
330 return kernel_program_info_.
ScriptAt(source_uri_index);
334 ObjectPtr ReadInitialFieldValue(
const Field& field,
335 FieldHelper* field_helper);
338 void GenerateFieldAccessors(
const Class& klass,
340 FieldHelper* field_helper);
342 void LoadLibraryImportsAndExports(Library* library,
343 const Class& toplevel_class);
345 LibraryPtr LookupLibraryOrNull(NameIndex library);
346 LibraryPtr LookupLibrary(NameIndex library);
347 LibraryPtr LookupLibraryFromClass(NameIndex klass);
348 ClassPtr LookupClass(
const Library& library, NameIndex klass);
355 FunctionPtr LoadClosureFunction(
const Function& parent_function,
356 const Object& closure_owner);
362 NoActiveIsolateScope no_active_isolate_scope_;
363 Array& patch_classes_;
364 ActiveClass active_class_;
367 intptr_t library_kernel_offset_;
370 intptr_t correction_offset_;
371 bool loading_native_wrappers_library_;
373 NameIndex skip_vmservice_library_;
375 TypedDataView& library_kernel_data_;
376 KernelProgramInfo& kernel_program_info_;
378 KernelReaderHelper helper_;
379 ConstantReader constant_reader_;
380 TypeTranslator type_translator_;
381 InferredTypeMetadataHelper inferred_type_metadata_helper_;
383 Object& static_field_value_;
385 Smi& name_index_handle_;
413 Library& expression_evaluation_library_;
415 GrowableArray<const Function*> functions_;
416 GrowableArray<const Field*> fields_;
Pair * LookupPair(const Key &key) const
void Insert(const Key &key, const Value &value)
ScriptPtr ScriptAt(intptr_t index) const
intptr_t CompareTo(const String &other) const
virtual ClassPtr LookupClassByKernelClass(NameIndex klass, bool required=true)
BuildingTranslationHelper(KernelLoader *loader, Thread *thread, Heap::Space space)
virtual ~BuildingTranslationHelper()
virtual LibraryPtr LookupLibraryByKernelLibrary(NameIndex library, bool required=true)
intptr_t procedure_count() const
ClassIndex(const TypedDataBase &kernel_data, intptr_t class_offset, intptr_t class_size)
intptr_t ProcedureOffset(intptr_t index) const
static Object & LoadEntireProgram(Program *program, bool process_pending_classes=true)
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)
friend class BuildingTranslationHelper
KernelLoader(Program *program, DirectChainedHashMap< UriToSourceTableTrait > *uri_to_source_table)
static StringPtr FindSourceForScript(const uint8_t *kernel_buffer, intptr_t kernel_buffer_length, const String &url)
void ReadObfuscationProhibitions()
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)
intptr_t SizeOfClassAtOffset(intptr_t class_offset) const
intptr_t class_count() const
intptr_t procedure_count() const
intptr_t SourceReferencesOffset()
intptr_t ProcedureOffset(intptr_t index) const
LibraryIndex(const TypedDataView &kernel_data)
intptr_t ClassOffset(intptr_t index) const
bool Lookup(intptr_t canonical_name, VmType **handle)
void Insert(intptr_t canonical_name, VmType *object)
const TypedDataBase & binary()
uint32_t ReadUInt32At(intptr_t offset) const
const String & DartSymbolPlain(const char *content) const
StringIndex CanonicalNameString(NameIndex name)
FunctionPtr CreateFieldInitializerFunction(Thread *thread, Zone *zone, const Field &field)
static constexpr int LibraryCountFieldCountFromEnd
const TypedData * line_starts
static Value ValueOf(Pair kv)
UriToSourceTableEntry * Pair
static bool IsKeyEqual(Pair kv, Key key)
static uword Hash(Key key)
static Key KeyOf(Pair kv)
const UriToSourceTableEntry * Key
UriToSourceTableEntry * Value