Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
dart::Library Class Reference

#include <object.h>

Inheritance diagram for dart::Library:
dart::Object

Public Member Functions

StringPtr name () const
 
void SetName (const String &name) const
 
StringPtr url () const
 
StringPtr private_key () const
 
bool LoadNotStarted () const
 
bool LoadRequested () const
 
bool LoadInProgress () const
 
void SetLoadRequested () const
 
void SetLoadInProgress () const
 
bool Loaded () const
 
void SetLoaded () const
 
LoadingUnitPtr loading_unit () const
 
void set_loading_unit (const LoadingUnit &value) const
 
ObjectPtr Invoke (const String &selector, const Array &arguments, const Array &argument_names, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeGetter (const String &selector, bool throw_nsm_if_absent, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeSetter (const String &selector, const Instance &argument, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr EvaluateCompiledExpression (const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &param_values, const TypeArguments &type_param_values) const
 
void AddClass (const Class &cls) const
 
void AddObject (const Object &obj, const String &name) const
 
ObjectPtr LookupReExport (const String &name, ZoneGrowableArray< intptr_t > *visited=nullptr) const
 
ObjectPtr LookupLocalOrReExportObject (const String &name) const
 
LibraryPrefixPtr LookupLocalLibraryPrefix (const String &name) const
 
ClassPtr LookupClass (const String &name) const
 
ClassPtr LookupClassAllowPrivate (const String &name) const
 
FieldPtr LookupFieldAllowPrivate (const String &name) const
 
FunctionPtr LookupFunctionAllowPrivate (const String &name) const
 
ScriptPtr LookupScript (const String &url, bool useResolvedUri=false) const
 
ArrayPtr LoadedScripts () const
 
void AddExport (const Namespace &ns) const
 
void AddMetadata (const Object &declaration, intptr_t kernel_offset) const
 
ObjectPtr GetMetadata (const Object &declaration) const
 
void EvaluatePragmas ()
 
void CopyPragmas (const Library &old_lib)
 
ClassPtr toplevel_class () const
 
void set_toplevel_class (const Class &value) const
 
GrowableObjectArrayPtr used_scripts () const
 
ArrayPtr imports () const
 
ArrayPtr exports () const
 
void AddImport (const Namespace &ns) const
 
intptr_t num_imports () const
 
NamespacePtr ImportAt (intptr_t index) const
 
LibraryPtr ImportLibraryAt (intptr_t index) const
 
ArrayPtr dependencies () const
 
void set_dependencies (const Array &deps) const
 
void DropDependenciesAndCaches () const
 
Dart_NativeEntryResolver native_entry_resolver () const
 
void set_native_entry_resolver (Dart_NativeEntryResolver value) const
 
Dart_NativeEntrySymbol native_entry_symbol_resolver () const
 
void set_native_entry_symbol_resolver (Dart_NativeEntrySymbol native_symbol_resolver) const
 
Dart_FfiNativeResolver ffi_native_resolver () const
 
void set_ffi_native_resolver (Dart_FfiNativeResolver value) const
 
bool is_in_fullsnapshot () const
 
void set_is_in_fullsnapshot (bool value) const
 
StringPtr PrivateName (const String &name) const
 
intptr_t index () const
 
void set_index (intptr_t value) const
 
void Register (Thread *thread) const
 
bool IsDebuggable () const
 
void set_debuggable (bool value) const
 
bool is_dart_scheme () const
 
void set_is_dart_scheme (bool value) const
 
bool IsAnyCoreLibrary () const
 
intptr_t UrlHash () const
 
KernelProgramInfoPtr kernel_program_info () const
 
void set_kernel_program_info (const KernelProgramInfo &info) const
 
TypedDataViewPtr KernelLibrary () const
 
intptr_t KernelLibraryOffset () const
 
intptr_t kernel_library_index () const
 
void set_kernel_library_index (intptr_t value) const
 
void CheckReload (const Library &replacement, ProgramReloadContext *context) const
 
ObjectPtr GetFunctionClosure (const String &name) const
 
void EnsureTopLevelClassIsFinalized () const
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static StringPtr UrlOf (LibraryPtr lib)
 
static intptr_t InstanceSize ()
 
static LibraryPtr New (const String &url)
 
static bool FindPragma (Thread *T, bool only_core, const Object &object, const String &pragma_name, bool multiple=false, Object *options=nullptr)
 
static void RegisterLibraries (Thread *thread, const GrowableObjectArray &libs)
 
static LibraryPtr LookupLibrary (Thread *thread, const String &url)
 
static LibraryPtr GetLibrary (intptr_t index)
 
static void InitCoreLibrary (IsolateGroup *isolate_group)
 
static void InitNativeWrappersLibrary (IsolateGroup *isolate_group, bool is_kernel_file)
 
static LibraryPtr AsyncLibrary ()
 
static LibraryPtr ConvertLibrary ()
 
static LibraryPtr CoreLibrary ()
 
static LibraryPtr CollectionLibrary ()
 
static LibraryPtr DeveloperLibrary ()
 
static LibraryPtr FfiLibrary ()
 
static LibraryPtr InternalLibrary ()
 
static LibraryPtr IsolateLibrary ()
 
static LibraryPtr MathLibrary ()
 
static LibraryPtr MirrorsLibrary ()
 
static LibraryPtr NativeWrappersLibrary ()
 
static LibraryPtr TypedDataLibrary ()
 
static LibraryPtr VMServiceLibrary ()
 
static ErrorPtr CompileAll (bool ignore_error=false)
 
static ErrorPtr FinalizeAllClasses ()
 
static bool IsPrivate (const String &name)
 
static const StringPrivateCoreLibName (const String &member)
 
static bool IsPrivateCoreLibName (const String &name, const String &member)
 
static ClassPtr LookupCoreClass (const String &class_name)
 
static FunctionPtr GetFunction (const GrowableArray< Library * > &libs, const char *class_name, const char *function_name)
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Static Public Attributes

static const char kPrivateIdentifierStart = '_'
 
static const char kPrivateKeySeparator = '@'
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Friends

class Bootstrap
 
class Class
 
class Debugger
 
class DictionaryIterator
 
class Isolate
 
class LibraryDeserializationCluster
 
class Namespace
 
class Object
 
class Precompiler
 

Additional Inherited Members

- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 
- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 5063 of file object.h.

Member Function Documentation

◆ AddClass()

void dart::Library::AddClass ( const Class cls) const

Definition at line 13961 of file object.cc.

13961 {
13963 const String& class_name = String::Handle(cls.Name());
13964 AddObject(cls, class_name);
13965 // Link class to this library.
13966 cls.set_library(*this);
13967}
static bool IsBackgroundCompilation()
Definition compiler.cc:299
void AddObject(const Object &obj, const String &name) const
Definition object.cc:13862
static Object & Handle()
Definition object.h:407
#define ASSERT(E)
const char *const class_name

◆ AddExport()

void dart::Library::AddExport ( const Namespace ns) const

Definition at line 14243 of file object.cc.

14243 {
14244 Array& exports = Array::Handle(this->exports());
14245 intptr_t num_exports = exports.Length();
14246 exports = Array::Grow(exports, num_exports + 1);
14247 untag()->set_exports(exports.ptr());
14248 exports.SetAt(num_exports, ns);
14249}
static ArrayPtr Grow(const Array &source, intptr_t new_length, Heap::Space space=Heap::kNew)
Definition object.cc:24932
ArrayPtr exports() const
Definition object.h:5188
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)

◆ AddImport()

void dart::Library::AddImport ( const Namespace ns) const

Definition at line 14221 of file object.cc.

14221 {
14222 Array& imports = Array::Handle(this->imports());
14223 intptr_t capacity = imports.Length();
14224 if (num_imports() == capacity) {
14225 capacity = capacity + kImportsCapacityIncrement + (capacity >> 2);
14226 imports = Array::Grow(imports, capacity);
14227 untag()->set_imports(imports.ptr());
14228 }
14229 intptr_t index = num_imports();
14230 imports.SetAt(index, ns);
14231 set_num_imports(index + 1);
14232}
intptr_t num_imports() const
Definition object.h:5190
intptr_t index() const
Definition object.h:5241
ArrayPtr imports() const
Definition object.h:5187

◆ AddMetadata()

void dart::Library::AddMetadata ( const Object declaration,
intptr_t  kernel_offset 
) const

Definition at line 13687 of file object.cc.

13688 {
13689#if defined(DART_PRECOMPILED_RUNTIME)
13690 UNREACHABLE();
13691#else
13692 Thread* thread = Thread::Current();
13693 ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
13694
13695 MetadataMap map(metadata());
13696 map.UpdateOrInsert(declaration, Smi::Handle(Smi::New(kernel_offset)));
13697 set_metadata(map.Release());
13698#endif // defined(DART_PRECOMPILED_RUNTIME)
13699}
#define UNREACHABLE()
Definition assert.h:248
friend class Thread
Definition object.h:1025
static SmiPtr New(intptr_t value)
Definition object.h:9985
static Thread * Current()
Definition thread.h:361
UnorderedHashMap< MetadataMapTraits > MetadataMap
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680

◆ AddObject()

void dart::Library::AddObject ( const Object obj,
const String name 
) const

Definition at line 13862 of file object.cc.

13862 {
13863 ASSERT(Thread::Current()->IsDartMutatorThread());
13864 ASSERT(obj.IsClass() || obj.IsFunction() || obj.IsField() ||
13865 obj.IsLibraryPrefix());
13866 ASSERT(name.Equals(String::Handle(obj.DictionaryName())));
13867 ASSERT(LookupLocalObject(name) == Object::null());
13868 const Array& dict = Array::Handle(dictionary());
13869 intptr_t dict_size = dict.Length() - 1;
13870 intptr_t index = name.Hash() % dict_size;
13871
13872 Object& entry = Object::Handle();
13873 entry = dict.At(index);
13874 // An empty spot will be found because we keep the hash set at most 75% full.
13875 while (!entry.IsNull()) {
13876 index = (index + 1) % dict_size;
13877 entry = dict.At(index);
13878 }
13879
13880 // Insert the object at the empty slot.
13881 dict.SetAt(index, obj);
13882 // One more element added.
13883 intptr_t used_elements = Smi::Value(Smi::RawCast(dict.At(dict_size))) + 1;
13884 const Smi& used = Smi::Handle(Smi::New(used_elements));
13885 dict.SetAt(dict_size, used); // Update used count.
13886
13887 // Rehash if symbol_table is 75% full.
13888 if (used_elements > ((dict_size / 4) * 3)) {
13889 // TODO(iposva): Avoid exponential growth.
13890 RehashDictionary(dict, 2 * dict_size);
13891 }
13892
13893 // Invalidate the cache of loaded scripts.
13894 if (loaded_scripts() != Array::null()) {
13895 untag()->set_loaded_scripts(Array::null());
13896 }
13897}
friend class Object
Definition object.h:5411
StringPtr name() const
Definition object.h:5065
static ObjectPtr null()
Definition object.h:433
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969

◆ AsyncLibrary()

LibraryPtr dart::Library::AsyncLibrary ( )
static

Definition at line 14826 of file object.cc.

14826 {
14827 return IsolateGroup::Current()->object_store()->async_library();
14828}
ObjectStore * object_store() const
Definition isolate.h:505
static IsolateGroup * Current()
Definition isolate.h:534

◆ CheckReload()

void dart::Library::CheckReload ( const Library replacement,
ProgramReloadContext context 
) const

Definition at line 733 of file object_reload.cc.

734 {
735 // Carry over the loaded bit of any deferred prefixes.
736 Object& object = Object::Handle();
737 LibraryPrefix& prefix = LibraryPrefix::Handle();
738 LibraryPrefix& original_prefix = LibraryPrefix::Handle();
739 String& name = String::Handle();
740 String& original_name = String::Handle();
741 DictionaryIterator it(replacement);
742 while (it.HasNext()) {
743 object = it.GetNext();
744 if (!object.IsLibraryPrefix()) continue;
745 prefix ^= object.ptr();
746 if (!prefix.is_deferred_load()) continue;
747
748 name = prefix.name();
749 DictionaryIterator original_it(*this);
750 while (original_it.HasNext()) {
751 object = original_it.GetNext();
752 if (!object.IsLibraryPrefix()) continue;
753 original_prefix ^= object.ptr();
754 if (!original_prefix.is_deferred_load()) continue;
755 original_name = original_prefix.name();
756 if (!name.Equals(original_name)) continue;
757
758 // The replacement of the old prefix with the new prefix
759 // in Isolate::loaded_prefixes_set_ implicitly carried
760 // the loaded state over to the new prefix.
761 context->AddBecomeMapping(original_prefix, prefix);
762 }
763 }
764}
friend class DictionaryIterator
Definition object.h:5407

◆ CollectionLibrary()

LibraryPtr dart::Library::CollectionLibrary ( )
static

Definition at line 14838 of file object.cc.

14838 {
14839 return IsolateGroup::Current()->object_store()->collection_library();
14840}

◆ CompileAll()

ErrorPtr dart::Library::CompileAll ( bool  ignore_error = false)
static

Definition at line 15275 of file object.cc.

15275 {
15276 Thread* thread = Thread::Current();
15277 Zone* zone = thread->zone();
15278 Error& error = Error::Handle(zone);
15279 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
15280 IsolateGroup::Current()->object_store()->libraries());
15281 Library& lib = Library::Handle(zone);
15282 Class& cls = Class::Handle(zone);
15283 for (int i = 0; i < libs.Length(); i++) {
15284 lib ^= libs.At(i);
15285 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
15286 while (it.HasNext()) {
15287 cls = it.GetNextClass();
15288 error = cls.EnsureIsFinalized(thread);
15289 if (!error.IsNull()) {
15290 if (ignore_error) continue;
15291 return error.ptr();
15292 }
15294 if (!error.IsNull()) {
15295 if (ignore_error) continue;
15296 return error.ptr();
15297 }
15298 }
15299 }
15300
15301 Object& result = Object::Handle(zone);
15302 ClosureFunctionsCache::ForAllClosureFunctions([&](const Function& func) {
15303 if (!func.HasCode()) {
15304 result = Compiler::CompileFunction(thread, func);
15305 if (result.IsError()) {
15306 error = Error::Cast(result).ptr();
15307 return false; // Stop iteration.
15308 }
15309 }
15310 return true; // Continue iteration.
15311 });
15312 return error.ptr();
15313}
static void ForAllClosureFunctions(std::function< bool(const Function &)> callback)
static ErrorPtr CompileAllFunctions(const Class &cls)
Definition compiler.cc:949
friend class Class
Definition object.h:5405
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result

◆ ConvertLibrary()

LibraryPtr dart::Library::ConvertLibrary ( )
static

Definition at line 14830 of file object.cc.

14830 {
14831 return IsolateGroup::Current()->object_store()->convert_library();
14832}

◆ CopyPragmas()

void dart::Library::CopyPragmas ( const Library old_lib)

Definition at line 13792 of file object.cc.

13792 {
13793 auto thread = Thread::Current();
13794 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
13795 MetadataMap new_map(metadata());
13796 MetadataMap old_map(old_lib.metadata());
13797 Object& declaration = Object::Handle();
13799 MetadataMap::Iterator it(&old_map);
13800 while (it.MoveNext()) {
13801 const intptr_t entry = it.Current();
13802 ASSERT(entry != -1);
13803 declaration = old_map.GetKey(entry);
13804 if (HasPragma(declaration)) {
13805 value = old_map.GetPayload(entry, 0);
13806 ASSERT(!value.IsNull());
13807 // Pragmas should be evaluated during hot reload phase 1
13808 // (when checkpointing libraries).
13809 ASSERT(!value.IsSmi());
13810 new_map.UpdateOrInsert(declaration, value);
13811 }
13812 }
13813 old_lib.set_metadata(old_map.Release());
13814 set_metadata(new_map.Release());
13815}
uint8_t value
static bool HasPragma(const Object &declaration)
Definition object.cc:13760

◆ CoreLibrary()

LibraryPtr dart::Library::CoreLibrary ( )
static

Definition at line 14834 of file object.cc.

14834 {
14835 return IsolateGroup::Current()->object_store()->core_library();
14836}

◆ dependencies()

ArrayPtr dart::Library::dependencies ( ) const
inline

Definition at line 5194 of file object.h.

5194{ return untag()->dependencies(); }

◆ DeveloperLibrary()

LibraryPtr dart::Library::DeveloperLibrary ( )
static

Definition at line 14842 of file object.cc.

14842 {
14843 return IsolateGroup::Current()->object_store()->developer_library();
14844}

◆ DropDependenciesAndCaches()

void dart::Library::DropDependenciesAndCaches ( ) const

Definition at line 14209 of file object.cc.

14209 {
14210 untag()->set_imports(Object::empty_array().ptr());
14211 untag()->set_exports(Object::empty_array().ptr());
14212 StoreNonPointer(&untag()->num_imports_, 0);
14213 untag()->set_loaded_scripts(Array::null());
14214 untag()->set_dependencies(Array::null());
14215#if defined(PRODUCT)
14216 // used_scripts is only used by vm-service.
14217 untag()->set_used_scripts(GrowableObjectArray::null());
14218#endif
14219}
void StoreNonPointer(const FieldType *addr, ValueType value) const
Definition object.h:819
ObjectPtr ptr() const
Definition object.h:332

◆ EnsureTopLevelClassIsFinalized()

void dart::Library::EnsureTopLevelClassIsFinalized ( ) const

Definition at line 14091 of file object.cc.

14091 {
14092 if (toplevel_class() == Object::null()) {
14093 return;
14094 }
14095 Thread* thread = Thread::Current();
14096 const Class& cls = Class::Handle(thread->zone(), toplevel_class());
14097 if (cls.is_finalized()) {
14098 return;
14099 }
14100 const Error& error =
14101 Error::Handle(thread->zone(), cls.EnsureIsFinalized(thread));
14102 if (!error.IsNull()) {
14104 }
14105}
static DART_NORETURN void PropagateError(const Error &error)
ClassPtr toplevel_class() const
Definition object.h:5179

◆ EvaluateCompiledExpression()

ObjectPtr dart::Library::EvaluateCompiledExpression ( const ExternalTypedData kernel_buffer,
const Array type_definitions,
const Array param_values,
const TypeArguments type_param_values 
) const

Definition at line 4866 of file object.cc.

4870 {
4871 const auto& klass = Class::Handle(toplevel_class());
4872 return klass.EvaluateCompiledExpression(kernel_buffer, type_definitions,
4873 arguments, type_arguments);
4874}

◆ EvaluatePragmas()

void dart::Library::EvaluatePragmas ( )

Definition at line 13767 of file object.cc.

13767 {
13768 Object& declaration = Object::Handle();
13769 const GrowableObjectArray& declarations =
13771 {
13772 auto thread = Thread::Current();
13773 SafepointReadRwLocker ml(thread, thread->isolate_group()->program_lock());
13774 MetadataMap map(metadata());
13775 MetadataMap::Iterator it(&map);
13776 while (it.MoveNext()) {
13777 const intptr_t entry = it.Current();
13778 ASSERT(entry != -1);
13779 declaration = map.GetKey(entry);
13780 if (HasPragma(declaration)) {
13781 declarations.Add(declaration);
13782 }
13783 }
13784 set_metadata(map.Release());
13785 }
13786 for (intptr_t i = 0; i < declarations.Length(); ++i) {
13787 declaration = declarations.At(i);
13788 GetMetadata(declaration);
13789 }
13790}
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition object.h:11118
ObjectPtr GetMetadata(const Object &declaration) const
Definition object.cc:13701

◆ exports()

ArrayPtr dart::Library::exports ( ) const
inline

Definition at line 5188 of file object.h.

5188{ return untag()->exports(); }

◆ ffi_native_resolver()

Dart_FfiNativeResolver dart::Library::ffi_native_resolver ( ) const
inline

Definition at line 5221 of file object.h.

5221 {
5222 return LoadNonPointer<Dart_FfiNativeResolver, std::memory_order_relaxed>(
5223 &untag()->ffi_native_resolver_);
5224 }

◆ FfiLibrary()

LibraryPtr dart::Library::FfiLibrary ( )
static

Definition at line 14846 of file object.cc.

14846 {
14847 return IsolateGroup::Current()->object_store()->ffi_library();
14848}

◆ FinalizeAllClasses()

ErrorPtr dart::Library::FinalizeAllClasses ( )
static

Definition at line 15317 of file object.cc.

15317 {
15318 Thread* thread = Thread::Current();
15319 ASSERT(thread->IsDartMutatorThread());
15320 Zone* zone = thread->zone();
15321 Error& error = Error::Handle(zone);
15322 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
15323 IsolateGroup::Current()->object_store()->libraries());
15324 Library& lib = Library::Handle(zone);
15325 Class& cls = Class::Handle(zone);
15326 for (int i = 0; i < libs.Length(); i++) {
15327 lib ^= libs.At(i);
15328 if (!lib.Loaded()) {
15329 String& uri = String::Handle(zone, lib.url());
15330 String& msg = String::Handle(
15331 zone,
15332 String::NewFormatted("Library '%s' is not loaded. "
15333 "Did you forget to call Dart_FinalizeLoading?",
15334 uri.ToCString()));
15335 return ApiError::New(msg);
15336 }
15337 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
15338 while (it.HasNext()) {
15339 cls = it.GetNextClass();
15340 error = cls.EnsureIsFinalized(thread);
15341 if (!error.IsNull()) {
15342 return error.ptr();
15343 }
15344 }
15345 }
15346 return Error::null();
15347}
static StringPtr NewFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition object.cc:24083

◆ FindPragma()

bool dart::Library::FindPragma ( Thread T,
bool  only_core,
const Object object,
const String pragma_name,
bool  multiple = false,
Object options = nullptr 
)
static

Definition at line 4201 of file object.cc.

4206 {
4207 auto Z = T->zone();
4208 auto& lib = Library::Handle(Z);
4209
4210 if (obj.IsLibrary()) {
4211 lib = Library::Cast(obj).ptr();
4212 } else if (obj.IsClass()) {
4213 auto& klass = Class::Cast(obj);
4214 if (!klass.has_pragma()) return false;
4215 lib = klass.library();
4216 } else if (obj.IsFunction()) {
4217 auto& function = Function::Cast(obj);
4218 if (!function.has_pragma()) return false;
4219 lib = Class::Handle(Z, function.Owner()).library();
4220 } else if (obj.IsField()) {
4221 auto& field = Field::Cast(obj);
4222 if (!field.has_pragma()) return false;
4223 lib = Class::Handle(Z, field.Owner()).library();
4224 } else {
4225 UNREACHABLE();
4226 }
4227
4228 if (only_core && !lib.IsAnyCoreLibrary()) {
4229 return false;
4230 }
4231
4232 Object& metadata_obj = Object::Handle(Z, lib.GetMetadata(obj));
4233 if (metadata_obj.IsUnwindError()) {
4234 Report::LongJump(UnwindError::Cast(metadata_obj));
4235 }
4236
4237 return FindPragmaInMetadata(T, metadata_obj, pragma_name, multiple, options);
4238}
const char * options
#define Z
static DART_NORETURN void LongJump(const Error &error)
Definition report.cc:86
Dart_NativeFunction function
Definition fuchsia.cc:51
bool FindPragmaInMetadata(Thread *T, const Object &metadata_obj, const String &pragma_name, bool multiple, Object *options)
Definition object.cc:4142
#define T

◆ GetFunction()

FunctionPtr dart::Library::GetFunction ( const GrowableArray< Library * > &  libs,
const char *  class_name,
const char *  function_name 
)
static

Definition at line 15352 of file object.cc.

15354 {
15355 Thread* thread = Thread::Current();
15356 Zone* zone = thread->zone();
15357 Function& func = Function::Handle(zone);
15358 String& class_str = String::Handle(zone);
15359 String& func_str = String::Handle(zone);
15360 Class& cls = Class::Handle(zone);
15361 for (intptr_t l = 0; l < libs.length(); l++) {
15362 const Library& lib = *libs[l];
15363 if (strcmp(class_name, "::") == 0) {
15364 cls = lib.toplevel_class();
15365 } else {
15366 class_str = String::New(class_name);
15367 cls = lib.LookupClassAllowPrivate(class_str);
15368 }
15369 if (!cls.IsNull()) {
15370 if (cls.EnsureIsFinalized(thread) == Error::null()) {
15371 func_str = String::New(function_name);
15372 if (function_name[0] == '.') {
15373 func_str = String::Concat(class_str, func_str);
15374 }
15375 func = cls.LookupFunctionAllowPrivate(func_str);
15376 }
15377 }
15378 if (!func.IsNull()) {
15379 return func.ptr();
15380 }
15381 }
15382 return Function::null();
15383}
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition object.cc:23777
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition object.cc:24116
const char *const function_name

◆ GetFunctionClosure()

ObjectPtr dart::Library::GetFunctionClosure ( const String name) const

Definition at line 15385 of file object.cc.

15385 {
15386 Thread* thread = Thread::Current();
15387 Zone* zone = thread->zone();
15388 Function& func = Function::Handle(zone, LookupFunctionAllowPrivate(name));
15389 if (func.IsNull()) {
15390 // Check whether the function is reexported into the library.
15391 const Object& obj = Object::Handle(zone, LookupReExport(name));
15392 if (obj.IsFunction()) {
15393 func ^= obj.ptr();
15394 } else {
15395 // Check if there is a getter of 'name', in which case invoke it
15396 // and return the result.
15397 const String& getter_name = String::Handle(zone, Field::GetterName(name));
15398 func = LookupFunctionAllowPrivate(getter_name);
15399 if (func.IsNull()) {
15400 return Closure::null();
15401 }
15402 // Invoke the getter and return the result.
15403 return DartEntry::InvokeFunction(func, Object::empty_array());
15404 }
15405 }
15406 func = func.ImplicitClosureFunction();
15407 return func.ImplicitStaticClosure();
15408}
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
Definition dart_entry.cc:31
static StringPtr GetterName(const String &field_name)
Definition object.cc:11843
ObjectPtr LookupReExport(const String &name, ZoneGrowableArray< intptr_t > *visited=nullptr) const
Definition object.cc:13902
FunctionPtr LookupFunctionAllowPrivate(const String &name) const
Definition object.cc:14131

◆ GetLibrary()

LibraryPtr dart::Library::GetLibrary ( intptr_t  index)
static

Definition at line 14763 of file object.cc.

14763 {
14764 Thread* thread = Thread::Current();
14765 Zone* zone = thread->zone();
14766 auto isolate_group = thread->isolate_group();
14767 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
14768 zone, isolate_group->object_store()->libraries());
14769 ASSERT(!libs.IsNull());
14770 if ((0 <= index) && (index < libs.Length())) {
14771 Library& lib = Library::Handle(zone);
14772 lib ^= libs.At(index);
14773 return lib.ptr();
14774 }
14775 return Library::null();
14776}

◆ GetMetadata()

ObjectPtr dart::Library::GetMetadata ( const Object declaration) const

Definition at line 13701 of file object.cc.

13701 {
13702#if defined(DART_PRECOMPILED_RUNTIME)
13703 return Object::empty_array().ptr();
13704#else
13705 RELEASE_ASSERT(declaration.IsClass() || declaration.IsField() ||
13706 declaration.IsFunction() || declaration.IsLibrary() ||
13707 declaration.IsTypeParameter() || declaration.IsNamespace());
13708
13709 auto thread = Thread::Current();
13710 auto zone = thread->zone();
13711
13712 if (declaration.IsLibrary()) {
13713 // Ensure top-level class is loaded as it may contain annotations of
13714 // a library.
13715 const auto& cls = Class::Handle(zone, toplevel_class());
13716 if (!cls.IsNull()) {
13717 cls.EnsureDeclarationLoaded();
13718 }
13719 }
13720 Object& value = Object::Handle(zone);
13721 {
13722 SafepointReadRwLocker ml(thread, thread->isolate_group()->program_lock());
13723 MetadataMap map(metadata());
13724 value = map.GetOrNull(declaration);
13725 set_metadata(map.Release());
13726 }
13727 if (value.IsNull()) {
13728 // There is no metadata for this object.
13729 return Object::empty_array().ptr();
13730 }
13731 if (!value.IsSmi()) {
13732 // Metadata is already evaluated.
13733 ASSERT(value.IsArray());
13734 return value.ptr();
13735 }
13736 const auto& smi_value = Smi::Cast(value);
13737 intptr_t kernel_offset = smi_value.Value();
13738 ASSERT(kernel_offset > 0);
13739 const auto& evaluated_value = Object::Handle(
13740 zone, kernel::EvaluateMetadata(
13741 *this, kernel_offset,
13742 /* is_annotations_offset = */ declaration.IsLibrary() ||
13743 declaration.IsNamespace()));
13744 if (evaluated_value.IsArray() || evaluated_value.IsNull()) {
13745 ASSERT(evaluated_value.ptr() != Object::empty_array().ptr());
13746 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
13747 MetadataMap map(metadata());
13748 if (map.GetOrNull(declaration) == smi_value.ptr()) {
13749 map.UpdateOrInsert(declaration, evaluated_value);
13750 } else {
13751 ASSERT(map.GetOrNull(declaration) == evaluated_value.ptr());
13752 }
13753 set_metadata(map.Release());
13754 }
13755 return evaluated_value.ptr();
13756#endif // defined(DART_PRECOMPILED_RUNTIME)
13757}
#define RELEASE_ASSERT(cond)
Definition assert.h:327

◆ ImportAt()

NamespacePtr dart::Library::ImportAt ( intptr_t  index) const

Definition at line 14201 of file object.cc.

14201 {
14202 if ((index < 0) || index >= num_imports()) {
14203 return Namespace::null();
14204 }
14205 const Array& import_list = Array::Handle(imports());
14206 return Namespace::RawCast(import_list.At(index));
14207}

◆ ImportLibraryAt()

LibraryPtr dart::Library::ImportLibraryAt ( intptr_t  index) const

Definition at line 14193 of file object.cc.

14193 {
14194 Namespace& import = Namespace::Handle(ImportAt(index));
14195 if (import.IsNull()) {
14196 return Library::null();
14197 }
14198 return import.target();
14199}
friend class Namespace
Definition object.h:5410
bool IsNull() const
Definition object.h:363

◆ imports()

ArrayPtr dart::Library::imports ( ) const
inline

Definition at line 5187 of file object.h.

5187{ return untag()->imports(); }

◆ index()

intptr_t dart::Library::index ( ) const
inline

Definition at line 5241 of file object.h.

5241{ return untag()->index_; }

◆ InitCoreLibrary()

void dart::Library::InitCoreLibrary ( IsolateGroup isolate_group)
static

Definition at line 14349 of file object.cc.

14349 {
14350 Thread* thread = Thread::Current();
14351 Zone* zone = thread->zone();
14352 const String& core_lib_url = Symbols::DartCore();
14353 const Library& core_lib =
14354 Library::Handle(zone, Library::NewLibraryHelper(core_lib_url, false));
14355 core_lib.SetLoadRequested();
14356 core_lib.Register(thread);
14357 isolate_group->object_store()->set_bootstrap_library(ObjectStore::kCore,
14358 core_lib);
14359 isolate_group->object_store()->set_root_library(Library::Handle());
14360}

◆ InitNativeWrappersLibrary()

void dart::Library::InitNativeWrappersLibrary ( IsolateGroup isolate_group,
bool  is_kernel_file 
)
static

Definition at line 14590 of file object.cc.

14591 {
14592 const int kNumNativeWrappersClasses = 4;
14593 COMPILE_ASSERT((kNumNativeWrappersClasses > 0) &&
14594 (kNumNativeWrappersClasses < 10));
14595 Thread* thread = Thread::Current();
14596 Zone* zone = thread->zone();
14597 const String& native_flds_lib_url = Symbols::DartNativeWrappers();
14598 const Library& native_flds_lib = Library::Handle(
14599 zone, Library::NewLibraryHelper(native_flds_lib_url, false));
14600 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName();
14601 native_flds_lib.SetName(native_flds_lib_name);
14602 native_flds_lib.SetLoadRequested();
14603 native_flds_lib.Register(thread);
14604 native_flds_lib.SetLoadInProgress();
14605 isolate_group->object_store()->set_native_wrappers_library(native_flds_lib);
14606 const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
14607 const int kNameLength = 25;
14608 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1));
14609 char name_buffer[kNameLength];
14610 String& cls_name = String::Handle(zone);
14611 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) {
14612 Utils::SNPrint(name_buffer, kNameLength, "%s%d", kNativeWrappersClass,
14613 fld_cnt);
14614 cls_name = Symbols::New(thread, name_buffer);
14615 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt);
14616 }
14617 // NOTE: If we bootstrap from a Kernel IR file we want to generate the
14618 // synthetic constructors for the native wrapper classes. We leave this up to
14619 // the [KernelLoader] who will take care of it later.
14620 if (!is_kernel) {
14621 native_flds_lib.SetLoaded();
14622 }
14623}
#define COMPILE_ASSERT(expr)
Definition assert.h:339
static ClassPtr NewNativeWrapper(const Library &library, const String &name, int num_fields)
Definition object.cc:5244
static StringPtr New(Thread *thread, const char *cstr)
Definition symbols.h:722
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3

◆ InstanceSize()

static intptr_t dart::Library::InstanceSize ( )
inlinestatic

Definition at line 5090 of file object.h.

5090 {
5091 return RoundedAllocationSize(sizeof(UntaggedLibrary));
5092 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ InternalLibrary()

LibraryPtr dart::Library::InternalLibrary ( )
static

Definition at line 14850 of file object.cc.

14850 {
14851 return IsolateGroup::Current()->object_store()->_internal_library();
14852}

◆ Invoke()

ObjectPtr dart::Library::Invoke ( const String selector,
const Array arguments,
const Array argument_names,
bool  respect_reflectable = true,
bool  check_is_entrypoint = false 
) const

Definition at line 14520 of file object.cc.

14524 {
14525 Thread* thread = Thread::Current();
14526 Zone* zone = thread->zone();
14527
14528 // We don't pass any explicit type arguments, which will be understood as
14529 // using dynamic for any function type arguments by lower layers.
14530 const int kTypeArgsLen = 0;
14531 const Array& args_descriptor_array = Array::Handle(
14532 zone, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, args.Length(),
14533 arg_names, Heap::kNew));
14534 ArgumentsDescriptor args_descriptor(args_descriptor_array);
14535
14536 auto& function = Function::Handle(zone);
14537 auto& result =
14539 if (result.IsFunction()) {
14540 function ^= result.ptr();
14541 }
14542
14543 if (!function.IsNull() && check_is_entrypoint) {
14544 CHECK_ERROR(function.VerifyCallEntryPoint());
14545 }
14546
14547 if (function.IsNull()) {
14548 // Didn't find a method: try to find a getter and invoke call on its result.
14549 const Object& getter_result = Object::Handle(
14550 zone, InvokeGetter(function_name, false, respect_reflectable,
14551 check_is_entrypoint));
14552 if (getter_result.ptr() != Object::sentinel().ptr()) {
14553 if (check_is_entrypoint) {
14555 }
14556 const auto& call_args_descriptor_array = Array::Handle(
14557 zone, ArgumentsDescriptor::NewBoxed(args_descriptor.TypeArgsLen(),
14558 args_descriptor.Count() + 1,
14559 arg_names, Heap::kNew));
14560 const auto& call_args = Array::Handle(
14561 zone,
14562 CreateCallableArgumentsFromStatic(zone, Instance::Cast(getter_result),
14563 args, arg_names, args_descriptor));
14564 return DartEntry::InvokeClosure(thread, call_args,
14565 call_args_descriptor_array);
14566 }
14567 }
14568
14569 if (function.IsNull() ||
14570 (respect_reflectable && !function.is_reflectable())) {
14571 return ThrowNoSuchMethod(Object::null_string(), function_name, args,
14572 arg_names, InvocationMirror::kTopLevel,
14574 }
14575 if (!function.AreValidArguments(args_descriptor, nullptr)) {
14576 return ThrowNoSuchMethod(
14577 String::Handle(function.UserVisibleSignature()), function_name, args,
14579 }
14580 // This is a static function, so we pass an empty instantiator tav.
14581 ASSERT(function.is_static());
14582 ObjectPtr type_error = function.DoArgumentTypesMatch(
14583 args, args_descriptor, Object::empty_type_arguments());
14584 if (type_error != Error::null()) {
14585 return type_error;
14586 }
14587 return DartEntry::InvokeFunction(function, args, args_descriptor_array);
14588}
static ArrayPtr NewBoxed(intptr_t type_args_len, intptr_t num_arguments, const Array &optional_arguments_names, Heap::Space space=Heap::kOld)
Definition dart_entry.h:83
static ObjectPtr InvokeClosure(Thread *thread, const Array &arguments)
@ kNew
Definition heap.h:38
ObjectPtr InvokeGetter(const String &selector, bool throw_nsm_if_absent, bool respect_reflectable=true, bool check_is_entrypoint=false) const
Definition object.cc:14389
ObjectPtr LookupLocalOrReExportObject(const String &name) const
Definition object.cc:14112
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static ArrayPtr CreateCallableArgumentsFromStatic(Zone *zone, const Instance &receiver, const Array &static_args, const Array &arg_names, const ArgumentsDescriptor &static_args_descriptor)
Definition object.cc:4707
DART_WARN_UNUSED_RESULT ErrorPtr EntryPointFieldInvocationError(const String &getter_name)
Definition object.cc:27272
static void ThrowNoSuchMethod(const Instance &receiver, const String &function_name, const Array &arguments, const Array &argument_names, const InvocationMirror::Level level, const InvocationMirror::Kind kind)
Definition mirrors.cc:49
#define CHECK_ERROR(value, message)

◆ InvokeGetter()

ObjectPtr dart::Library::InvokeGetter ( const String selector,
bool  throw_nsm_if_absent,
bool  respect_reflectable = true,
bool  check_is_entrypoint = false 
) const

Definition at line 14389 of file object.cc.

14392 {
14394 Function& getter = Function::Handle();
14395 if (obj.IsField()) {
14396 const Field& field = Field::Cast(obj);
14397 if (check_is_entrypoint) {
14398 CHECK_ERROR(field.VerifyEntryPoint(EntryPointPragma::kGetterOnly));
14399 }
14400 if (!field.IsUninitialized()) {
14401 return field.StaticValue();
14402 }
14403 // An uninitialized field was found. Check for a getter in the field's
14404 // owner class.
14405 const Class& klass = Class::Handle(field.Owner());
14406 const String& internal_getter_name =
14407 String::Handle(Field::GetterName(getter_name));
14408 getter = klass.LookupStaticFunction(internal_getter_name);
14409 } else {
14410 // No field found. Check for a getter in the lib.
14411 const String& internal_getter_name =
14412 String::Handle(Field::GetterName(getter_name));
14413 obj = LookupLocalOrReExportObject(internal_getter_name);
14414 if (obj.IsFunction()) {
14415 getter = Function::Cast(obj).ptr();
14416 if (check_is_entrypoint) {
14417 CHECK_ERROR(getter.VerifyCallEntryPoint());
14418 }
14419 } else {
14420 obj = LookupLocalOrReExportObject(getter_name);
14421 // Normally static top-level methods cannot be closurized through the
14422 // native API even if they are marked as entry-points, with the one
14423 // exception of "main".
14424 if (obj.IsFunction() && check_is_entrypoint) {
14425 if (!getter_name.Equals(String::Handle(String::New("main"))) ||
14426 ptr() != IsolateGroup::Current()->object_store()->root_library()) {
14427 CHECK_ERROR(Function::Cast(obj).VerifyClosurizedEntryPoint());
14428 }
14429 }
14430 if (obj.IsFunction() && Function::Cast(obj).SafeToClosurize()) {
14431 // Looking for a getter but found a regular method: closurize it.
14432 const Function& closure_function =
14433 Function::Handle(Function::Cast(obj).ImplicitClosureFunction());
14434 return closure_function.ImplicitStaticClosure();
14435 }
14436 }
14437 }
14438
14439 if (getter.IsNull() || (respect_reflectable && !getter.is_reflectable())) {
14440 if (throw_nsm_if_absent) {
14441 return ThrowNoSuchMethod(Object::null_string(), getter_name,
14442 Object::null_array(), Object::null_array(),
14445 }
14446
14447 // Fall through case: Indicate that we didn't find any function or field
14448 // using a special null instance. This is different from a field being null.
14449 // Callers make sure that this null does not leak into Dartland.
14450 return Object::sentinel().ptr();
14451 }
14452
14453 // Invoke the getter and return the result.
14454 return DartEntry::InvokeFunction(getter, Object::empty_array());
14455}

◆ InvokeSetter()

ObjectPtr dart::Library::InvokeSetter ( const String selector,
const Instance argument,
bool  respect_reflectable = true,
bool  check_is_entrypoint = false 
) const

Definition at line 14457 of file object.cc.

14460 {
14462 const String& internal_setter_name =
14463 String::Handle(Field::SetterName(setter_name));
14464 AbstractType& setter_type = AbstractType::Handle();
14465 AbstractType& argument_type = AbstractType::Handle(value.GetType(Heap::kOld));
14466 if (obj.IsField()) {
14467 const Field& field = Field::Cast(obj);
14468 if (check_is_entrypoint) {
14469 CHECK_ERROR(field.VerifyEntryPoint(EntryPointPragma::kSetterOnly));
14470 }
14471 setter_type = field.type();
14472 if (!argument_type.IsNullType() && !setter_type.IsDynamicType() &&
14473 !value.IsInstanceOf(setter_type, Object::null_type_arguments(),
14474 Object::null_type_arguments())) {
14475 return ThrowTypeError(field.token_pos(), value, setter_type, setter_name);
14476 }
14477 if (field.is_final() || (respect_reflectable && !field.is_reflectable())) {
14478 const int kNumArgs = 1;
14479 const Array& args = Array::Handle(Array::New(kNumArgs));
14480 args.SetAt(0, value);
14481
14482 return ThrowNoSuchMethod(Object::null_string(), internal_setter_name,
14483 args, Object::null_array(),
14486 }
14487 field.SetStaticValue(value);
14488 return value.ptr();
14489 }
14490
14491 Function& setter = Function::Handle();
14492 obj = LookupLocalOrReExportObject(internal_setter_name);
14493 if (obj.IsFunction()) {
14494 setter ^= obj.ptr();
14495 }
14496
14497 if (!setter.IsNull() && check_is_entrypoint) {
14498 CHECK_ERROR(setter.VerifyCallEntryPoint());
14499 }
14500
14501 const int kNumArgs = 1;
14502 const Array& args = Array::Handle(Array::New(kNumArgs));
14503 args.SetAt(0, value);
14504 if (setter.IsNull() || (respect_reflectable && !setter.is_reflectable())) {
14505 return ThrowNoSuchMethod(Object::null_string(), internal_setter_name, args,
14506 Object::null_array(), InvocationMirror::kTopLevel,
14508 }
14509
14510 setter_type = setter.ParameterTypeAt(0);
14511 if (!argument_type.IsNullType() && !setter_type.IsDynamicType() &&
14512 !value.IsInstanceOf(setter_type, Object::null_type_arguments(),
14513 Object::null_type_arguments())) {
14514 return ThrowTypeError(setter.token_pos(), value, setter_type, setter_name);
14515 }
14516
14517 return DartEntry::InvokeFunction(setter, args);
14518}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
static StringPtr SetterName(const String &field_name)
Definition object.cc:11855
@ kOld
Definition heap.h:39
static ObjectPtr ThrowTypeError(const TokenPosition token_pos, const Instance &src_value, const AbstractType &dst_type, const String &dst_name)
Definition object.cc:4551

◆ is_dart_scheme()

bool dart::Library::is_dart_scheme ( ) const
inline

Definition at line 5259 of file object.h.

5259 {
5261 }
static constexpr bool decode(uint8_t value)
Definition bitfield.h:173

◆ is_in_fullsnapshot()

bool dart::Library::is_in_fullsnapshot ( ) const
inline

Definition at line 5231 of file object.h.

5231 {
5233 }

◆ IsAnyCoreLibrary()

bool dart::Library::IsAnyCoreLibrary ( ) const

Definition at line 13616 of file object.cc.

13616 {
13617 String& url_str = Thread::Current()->StringHandle();
13618 url_str = url();
13619 return url_str.StartsWith(Symbols::DartScheme()) ||
13620 url_str.StartsWith(Symbols::DartSchemePrivate());
13621}
StringPtr url() const
Definition object.h:5068

◆ IsDebuggable()

bool dart::Library::IsDebuggable ( ) const
inline

Definition at line 5252 of file object.h.

5252 {
5254 }

◆ IsolateLibrary()

LibraryPtr dart::Library::IsolateLibrary ( )
static

Definition at line 14854 of file object.cc.

14854 {
14855 return IsolateGroup::Current()->object_store()->isolate_library();
14856}

◆ IsPrivate()

bool dart::Library::IsPrivate ( const String name)
static

Definition at line 14666 of file object.cc.

14666 {
14667 if (ShouldBePrivate(name)) return true;
14668 // Factory names: List._fromLiteral.
14669 for (intptr_t i = 1; i < name.Length() - 1; i++) {
14670 if (name.CharAt(i) == '.') {
14671 if (name.CharAt(i + 1) == '_') {
14672 return true;
14673 }
14674 }
14675 }
14676 return false;
14677}
static bool ShouldBePrivate(const String &name)
Definition object.cc:13818

◆ IsPrivateCoreLibName()

bool dart::Library::IsPrivateCoreLibName ( const String name,
const String member 
)
static

Definition at line 14727 of file object.cc.

14727 {
14728 Zone* zone = Thread::Current()->zone();
14729 const auto& core_lib = Library::Handle(zone, Library::CoreLibrary());
14730 const auto& private_key = String::Handle(zone, core_lib.private_key());
14731
14732 ASSERT(core_lib.IsPrivate(member));
14733 return name.EqualsConcat(member, private_key);
14734}
static LibraryPtr CoreLibrary()
Definition object.cc:14834
StringPtr private_key() const
Definition object.h:5070
Zone * zone() const

◆ kernel_library_index()

intptr_t dart::Library::kernel_library_index ( ) const
inline

Definition at line 5280 of file object.h.

5280 {
5281#if defined(DART_PRECOMPILED_RUNTIME)
5282 return 0;
5283#else
5284 return untag()->kernel_library_index_;
5285#endif
5286 }

◆ kernel_program_info()

KernelProgramInfoPtr dart::Library::kernel_program_info ( ) const
inline

Definition at line 5272 of file object.h.

5272 {
5273 return untag()->kernel_program_info();
5274 }

◆ KernelLibrary()

TypedDataViewPtr dart::Library::KernelLibrary ( ) const

Definition at line 13648 of file object.cc.

13648 {
13650 return info.KernelLibrary(kernel_library_index());
13651}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
intptr_t kernel_library_index() const
Definition object.h:5280
KernelProgramInfoPtr kernel_program_info() const
Definition object.h:5272

◆ KernelLibraryOffset()

intptr_t dart::Library::KernelLibraryOffset ( ) const

Definition at line 13653 of file object.cc.

13653 {
13655 return info.KernelLibraryStartOffset(kernel_library_index());
13656}

◆ Loaded()

bool dart::Library::Loaded ( ) const
inline

Definition at line 5082 of file object.h.

5082 {
5083 return untag()->load_state_ == UntaggedLibrary::kLoaded;
5084 }

◆ LoadedScripts()

ArrayPtr dart::Library::LoadedScripts ( ) const

Definition at line 13987 of file object.cc.

13987 {
13988 // We compute the list of loaded scripts lazily. The result is
13989 // cached in loaded_scripts_.
13990 if (loaded_scripts() == Array::null()) {
13991 // TODO(jensj): This can be cleaned up.
13992 // It really should just return the content of `used_scripts`, and there
13993 // should be no need to do the O(n) call to `AddScriptIfUnique` per script.
13994
13995 // Iterate over the library dictionary and collect all scripts.
13996 const GrowableObjectArray& scripts =
13998 Object& entry = Object::Handle();
13999 Class& cls = Class::Handle();
14000 Script& owner_script = Script::Handle();
14001 DictionaryIterator it(*this);
14002 while (it.HasNext()) {
14003 entry = it.GetNext();
14004 if (entry.IsClass()) {
14005 owner_script = Class::Cast(entry).script();
14006 } else if (entry.IsFunction()) {
14007 owner_script = Function::Cast(entry).script();
14008 } else if (entry.IsField()) {
14009 owner_script = Field::Cast(entry).Script();
14010 } else {
14011 continue;
14012 }
14013 AddScriptIfUnique(scripts, owner_script);
14014 }
14015
14016 // Add all scripts from patch classes.
14017 GrowableObjectArray& patches = GrowableObjectArray::Handle(used_scripts());
14018 for (intptr_t i = 0; i < patches.Length(); i++) {
14019 entry = patches.At(i);
14020 if (entry.IsClass()) {
14021 owner_script = Class::Cast(entry).script();
14022 } else {
14023 ASSERT(entry.IsScript());
14024 owner_script = Script::Cast(entry).ptr();
14025 }
14026 AddScriptIfUnique(scripts, owner_script);
14027 }
14028
14029 cls = toplevel_class();
14030 if (!cls.IsNull()) {
14031 owner_script = cls.script();
14032 AddScriptIfUnique(scripts, owner_script);
14033 // Special case: Scripts that only contain external top-level functions
14034 // are not included above, but can be referenced through a library's
14035 // anonymous classes. Example: dart-core:identical.dart.
14036 Function& func = Function::Handle();
14037 Array& functions = Array::Handle(cls.current_functions());
14038 for (intptr_t j = 0; j < functions.Length(); j++) {
14039 func ^= functions.At(j);
14040 if (func.is_external()) {
14041 owner_script = func.script();
14042 AddScriptIfUnique(scripts, owner_script);
14043 }
14044 }
14045 }
14046
14047 // Create the array of scripts and cache it in loaded_scripts_.
14048 const Array& scripts_array = Array::Handle(Array::MakeFixedLength(scripts));
14049 untag()->set_loaded_scripts(scripts_array.ptr());
14050 }
14051 return loaded_scripts();
14052}
static ArrayPtr MakeFixedLength(const GrowableObjectArray &growable_array, bool unique=false)
Definition object.cc:25014
GrowableObjectArrayPtr used_scripts() const
Definition object.h:5182
static void AddScriptIfUnique(const GrowableObjectArray &scripts, const Script &candidate)
Definition object.cc:13969

◆ loading_unit()

LoadingUnitPtr dart::Library::loading_unit ( ) const
inline

Definition at line 5087 of file object.h.

5087{ return untag()->loading_unit(); }

◆ LoadInProgress()

bool dart::Library::LoadInProgress ( ) const
inline

Definition at line 5077 of file object.h.

5077 {
5078 return untag()->load_state_ == UntaggedLibrary::kLoadInProgress;
5079 }

◆ LoadNotStarted()

bool dart::Library::LoadNotStarted ( ) const
inline

Definition at line 5071 of file object.h.

5071 {
5072 return untag()->load_state_ == UntaggedLibrary::kAllocated;
5073 }

◆ LoadRequested()

bool dart::Library::LoadRequested ( ) const
inline

Definition at line 5074 of file object.h.

5074 {
5075 return untag()->load_state_ == UntaggedLibrary::kLoadRequested;
5076 }

◆ LookupClass()

ClassPtr dart::Library::LookupClass ( const String name) const

Definition at line 14152 of file object.cc.

14152 {
14153 Object& obj = Object::Handle(LookupLocalObject(name));
14154 if (obj.IsClass()) {
14155 return Class::Cast(obj).ptr();
14156 }
14157 return Class::null();
14158}

◆ LookupClassAllowPrivate()

ClassPtr dart::Library::LookupClassAllowPrivate ( const String name) const

Definition at line 14160 of file object.cc.

14160 {
14161 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14162 if (obj.IsClass()) {
14163 return Class::Cast(obj).ptr();
14164 }
14165 return Class::null();
14166}

◆ LookupCoreClass()

ClassPtr dart::Library::LookupCoreClass ( const String class_name)
static

Definition at line 14736 of file object.cc.

14736 {
14737 Thread* thread = Thread::Current();
14738 Zone* zone = thread->zone();
14739 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
14740 String& name = String::Handle(zone, class_name.ptr());
14741 if (class_name.CharAt(0) == kPrivateIdentifierStart) {
14742 // Private identifiers are mangled on a per library basis.
14743 name = Symbols::FromConcat(thread, name,
14744 String::Handle(zone, core_lib.private_key()));
14745 }
14746 return core_lib.LookupClass(name);
14747}
static const char kPrivateIdentifierStart
Definition object.h:5351
static StringPtr FromConcat(Thread *thread, const String &str1, const String &str2)
Definition symbols.cc:235

◆ LookupFieldAllowPrivate()

FieldPtr dart::Library::LookupFieldAllowPrivate ( const String name) const

Definition at line 14122 of file object.cc.

14122 {
14124 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14125 if (obj.IsField()) {
14126 return Field::Cast(obj).ptr();
14127 }
14128 return Field::null();
14129}
void EnsureTopLevelClassIsFinalized() const
Definition object.cc:14091

◆ LookupFunctionAllowPrivate()

FunctionPtr dart::Library::LookupFunctionAllowPrivate ( const String name) const

Definition at line 14131 of file object.cc.

14131 {
14133 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14134 if (obj.IsFunction()) {
14135 return Function::Cast(obj).ptr();
14136 }
14137 return Function::null();
14138}

◆ LookupLibrary()

LibraryPtr dart::Library::LookupLibrary ( Thread thread,
const String url 
)
static

Definition at line 14646 of file object.cc.

14646 {
14647 Zone* zone = thread->zone();
14648 ObjectStore* object_store = thread->isolate_group()->object_store();
14649
14650 // Make sure the URL string has an associated hash code
14651 // to speed up the repeated equality checks.
14652 url.Hash();
14653
14654 // Use the libraries map to lookup the library by URL.
14655 Library& lib = Library::Handle(zone);
14656 if (object_store->libraries_map() == Array::null()) {
14657 return Library::null();
14658 } else {
14659 LibraryLookupMap map(object_store->libraries_map());
14660 lib ^= map.GetOrNull(url);
14661 ASSERT(map.Release().ptr() == object_store->libraries_map());
14662 }
14663 return lib.ptr();
14664}
UnorderedHashMap< LibraryLookupTraits > LibraryLookupMap
Definition object.cc:14643

◆ LookupLocalLibraryPrefix()

LibraryPrefixPtr dart::Library::LookupLocalLibraryPrefix ( const String name) const

Definition at line 14168 of file object.cc.

14168 {
14169 const Object& obj = Object::Handle(LookupLocalObject(name));
14170 if (obj.IsLibraryPrefix()) {
14171 return LibraryPrefix::Cast(obj).ptr();
14172 }
14173 return LibraryPrefix::null();
14174}

◆ LookupLocalOrReExportObject()

ObjectPtr dart::Library::LookupLocalOrReExportObject ( const String name) const

Definition at line 14112 of file object.cc.

14112 {
14113 intptr_t index;
14115 const Object& result = Object::Handle(LookupEntry(name, &index));
14116 if (!result.IsNull() && !result.IsLibraryPrefix()) {
14117 return result.ptr();
14118 }
14119 return LookupReExport(name);
14120}

◆ LookupReExport()

ObjectPtr dart::Library::LookupReExport ( const String name,
ZoneGrowableArray< intptr_t > *  visited = nullptr 
) const

Definition at line 13902 of file object.cc.

13903 {
13904 if (!HasExports()) {
13905 return Object::null();
13906 }
13907
13908 if (trail == nullptr) {
13909 trail = new ZoneGrowableArray<intptr_t>();
13910 }
13911 Object& obj = Object::Handle();
13912
13913 const intptr_t lib_id = this->index();
13914 ASSERT(lib_id >= 0); // We use -1 to indicate that a cycle was found.
13915 trail->Add(lib_id);
13916 const Array& exports = Array::Handle(this->exports());
13918 for (int i = 0; i < exports.Length(); i++) {
13919 ns ^= exports.At(i);
13920 obj = ns.Lookup(name, trail);
13921 if (!obj.IsNull()) {
13922 // The Lookup call above may return a setter x= when we are looking
13923 // for the name x. Make sure we only return when a matching name
13924 // is found.
13925 String& obj_name = String::Handle(obj.DictionaryName());
13926 if (Field::IsSetterName(obj_name) == Field::IsSetterName(name)) {
13927 break;
13928 }
13929 }
13930 }
13931 trail->RemoveLast();
13932 return obj.ptr();
13933}
static bool IsSetterName(const String &function_name)
Definition object.cc:11886

◆ LookupScript()

ScriptPtr dart::Library::LookupScript ( const String url,
bool  useResolvedUri = false 
) const

Definition at line 14056 of file object.cc.

14057 {
14058 const intptr_t url_length = url.Length();
14059 if (url_length == 0) {
14060 return Script::null();
14061 }
14062 const Array& scripts = Array::Handle(LoadedScripts());
14063 Script& script = Script::Handle();
14064 String& script_url = String::Handle();
14065 const intptr_t num_scripts = scripts.Length();
14066 for (int i = 0; i < num_scripts; i++) {
14067 script ^= scripts.At(i);
14068 if (useResolvedUri) {
14069 // Use for urls with 'org-dartlang-sdk:' or 'file:' schemes
14070 script_url = script.resolved_url();
14071 } else {
14072 // Use for urls with 'dart:', 'package:', or 'file:' schemes
14073 script_url = script.url();
14074 }
14075 const intptr_t start_idx = script_url.Length() - url_length;
14076 if ((start_idx == 0) && url.Equals(script_url)) {
14077 return script.ptr();
14078 } else if (start_idx > 0) {
14079 // If we do a suffix match, only match if the partial path
14080 // starts at or immediately after the path separator.
14081 if (((url.CharAt(0) == '/') ||
14082 (script_url.CharAt(start_idx - 1) == '/')) &&
14083 url.Equals(script_url, start_idx, url_length)) {
14084 return script.ptr();
14085 }
14086 }
14087 }
14088 return Script::null();
14089}
ArrayPtr LoadedScripts() const
Definition object.cc:13987

◆ MathLibrary()

LibraryPtr dart::Library::MathLibrary ( )
static

Definition at line 14858 of file object.cc.

14858 {
14859 return IsolateGroup::Current()->object_store()->math_library();
14860}

◆ MirrorsLibrary()

LibraryPtr dart::Library::MirrorsLibrary ( )
static

Definition at line 14863 of file object.cc.

14863 {
14864 return IsolateGroup::Current()->object_store()->mirrors_library();
14865}

◆ name()

StringPtr dart::Library::name ( ) const
inline

Definition at line 5065 of file object.h.

5065{ return untag()->name(); }

◆ native_entry_resolver()

Dart_NativeEntryResolver dart::Library::native_entry_resolver ( ) const
inline

Definition at line 5200 of file object.h.

5200 {
5201 return LoadNonPointer<Dart_NativeEntryResolver, std::memory_order_relaxed>(
5202 &untag()->native_entry_resolver_);
5203 }

◆ native_entry_symbol_resolver()

Dart_NativeEntrySymbol dart::Library::native_entry_symbol_resolver ( ) const
inline

Definition at line 5209 of file object.h.

5209 {
5210 return LoadNonPointer<Dart_NativeEntrySymbol, std::memory_order_relaxed>(
5211 &untag()->native_entry_symbol_resolver_);
5212 }

◆ NativeWrappersLibrary()

LibraryPtr dart::Library::NativeWrappersLibrary ( )
static

Definition at line 14868 of file object.cc.

14868 {
14869 return IsolateGroup::Current()->object_store()->native_wrappers_library();
14870}

◆ New()

LibraryPtr dart::Library::New ( const String url)
static

Definition at line 14341 of file object.cc.

14341 {
14342 return NewLibraryHelper(url, false);
14343}

◆ num_imports()

intptr_t dart::Library::num_imports ( ) const
inline

Definition at line 5190 of file object.h.

5190{ return untag()->num_imports_; }

◆ private_key()

StringPtr dart::Library::private_key ( ) const
inline

Definition at line 5070 of file object.h.

5070{ return untag()->private_key(); }

◆ PrivateCoreLibName()

const String & dart::Library::PrivateCoreLibName ( const String member)
static

Definition at line 14721 of file object.cc.

14721 {
14722 const Library& core_lib = Library::Handle(Library::CoreLibrary());
14723 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member));
14724 return private_name;
14725}
static Object & ZoneHandle()
Definition object.h:419

◆ PrivateName()

StringPtr dart::Library::PrivateName ( const String name) const

Definition at line 14751 of file object.cc.

14751 {
14752 Thread* thread = Thread::Current();
14753 Zone* zone = thread->zone();
14755 // ASSERT(strchr(name, '@') == nullptr);
14756 String& str = String::Handle(zone);
14757 str = name.ptr();
14758 str = Symbols::FromConcat(thread, str,
14759 String::Handle(zone, this->private_key()));
14760 return str.ptr();
14761}
static bool IsPrivate(const String &name)
Definition object.cc:14666

◆ Register()

void dart::Library::Register ( Thread thread) const

Definition at line 14778 of file object.cc.

14778 {
14779 Zone* zone = thread->zone();
14780 auto isolate_group = thread->isolate_group();
14781 ObjectStore* object_store = isolate_group->object_store();
14782
14783 // A library is "registered" in two places:
14784 // - A growable array mapping from index to library.
14785 const String& lib_url = String::Handle(zone, url());
14786 ASSERT(Library::LookupLibrary(thread, lib_url) == Library::null());
14787 ASSERT(lib_url.HasHash());
14788 GrowableObjectArray& libs =
14789 GrowableObjectArray::Handle(zone, object_store->libraries());
14790 ASSERT(!libs.IsNull());
14791 set_index(libs.Length());
14792 libs.Add(*this);
14793
14794 // - A map from URL string to library.
14795 if (object_store->libraries_map() == Array::null()) {
14796 LibraryLookupMap map(HashTables::New<LibraryLookupMap>(16, Heap::kOld));
14797 object_store->set_libraries_map(map.Release());
14798 }
14799
14800 LibraryLookupMap map(object_store->libraries_map());
14801 bool present = map.UpdateOrInsert(lib_url, *this);
14802 ASSERT(!present);
14803 object_store->set_libraries_map(map.Release());
14804}
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
Definition object.cc:14646
void set_index(intptr_t value) const
Definition object.h:5242

◆ RegisterLibraries()

void dart::Library::RegisterLibraries ( Thread thread,
const GrowableObjectArray libs 
)
static

Definition at line 14806 of file object.cc.

14807 {
14808 Zone* zone = thread->zone();
14809 auto isolate_group = thread->isolate_group();
14810 Library& lib = Library::Handle(zone);
14811 String& lib_url = String::Handle(zone);
14812
14813 LibraryLookupMap map(HashTables::New<LibraryLookupMap>(16, Heap::kOld));
14814
14815 intptr_t len = libs.Length();
14816 for (intptr_t i = 0; i < len; i++) {
14817 lib ^= libs.At(i);
14818 lib_url = lib.url();
14819 map.InsertNewOrGetValue(lib_url, lib);
14820 }
14821 // Now remember these in the isolate's object store.
14822 isolate_group->object_store()->set_libraries(libs);
14823 isolate_group->object_store()->set_libraries_map(map.Release());
14824}

◆ set_debuggable()

void dart::Library::set_debuggable ( bool  value) const
inline

Definition at line 5255 of file object.h.

5255 {
5256 set_flags(UntaggedLibrary::DebuggableBit::update(value, untag()->flags_));
5257 }
static constexpr uint8_t update(bool value, uint8_t original)
Definition bitfield.h:190

◆ set_dependencies()

void dart::Library::set_dependencies ( const Array deps) const

Definition at line 14181 of file object.cc.

14181 {
14182 untag()->set_dependencies(deps.ptr());
14183}

◆ set_ffi_native_resolver()

void dart::Library::set_ffi_native_resolver ( Dart_FfiNativeResolver  value) const
inline

Definition at line 5225 of file object.h.

5225 {
5227 std::memory_order_relaxed>(&untag()->ffi_native_resolver_,
5228 value);
5229 }
void *(* Dart_FfiNativeResolver)(const char *name, uintptr_t args_n)
Definition dart_api.h:3253

◆ set_index()

void dart::Library::set_index ( intptr_t  value) const
inline

Definition at line 5242 of file object.h.

5242 {
5243 ASSERT((value == -1) ||
5244 ((value >= 0) && (value < std::numeric_limits<classid_t>::max())));
5245 StoreNonPointer(&untag()->index_, value);
5246 }

◆ set_is_dart_scheme()

void dart::Library::set_is_dart_scheme ( bool  value) const
inline

Definition at line 5262 of file object.h.

5262 {
5263 set_flags(UntaggedLibrary::DartSchemeBit::update(value, untag()->flags_));
5264 }

◆ set_is_in_fullsnapshot()

void dart::Library::set_is_in_fullsnapshot ( bool  value) const
inline

Definition at line 5234 of file object.h.

5234 {
5235 set_flags(
5237 }

◆ set_kernel_library_index()

void dart::Library::set_kernel_library_index ( intptr_t  value) const
inline

Definition at line 5288 of file object.h.

5288 {
5289#if defined(DART_PRECOMPILED_RUNTIME)
5290 UNREACHABLE();
5291#else
5292 ASSERT(value >= 0);
5293 StoreNonPointer(&untag()->kernel_library_index_, value);
5294#endif
5295 }

◆ set_kernel_program_info()

void dart::Library::set_kernel_program_info ( const KernelProgramInfo info) const

Definition at line 13644 of file object.cc.

13644 {
13645 untag()->set_kernel_program_info(info.ptr());
13646}

◆ set_loading_unit()

void dart::Library::set_loading_unit ( const LoadingUnit value) const

Definition at line 13659 of file object.cc.

13659 {
13660 untag()->set_loading_unit(value.ptr());
13661}

◆ set_native_entry_resolver()

void dart::Library::set_native_entry_resolver ( Dart_NativeEntryResolver  value) const
inline

Definition at line 5204 of file object.h.

5204 {
5206 std::memory_order_relaxed>(&untag()->native_entry_resolver_,
5207 value);
5208 }
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
Definition dart_api.h:3225

◆ set_native_entry_symbol_resolver()

void dart::Library::set_native_entry_symbol_resolver ( Dart_NativeEntrySymbol  native_symbol_resolver) const
inline

Definition at line 5213 of file object.h.

5214 {
5216 std::memory_order_relaxed>(
5217 &untag()->native_entry_symbol_resolver_, native_symbol_resolver);
5218 }
const uint8_t *(* Dart_NativeEntrySymbol)(Dart_NativeFunction nf)
Definition dart_api.h:3246

◆ set_toplevel_class()

void dart::Library::set_toplevel_class ( const Class value) const

Definition at line 14176 of file object.cc.

14176 {
14178 untag()->set_toplevel_class(value.ptr());
14179}

◆ SetLoaded()

void dart::Library::SetLoaded ( ) const

Definition at line 13681 of file object.cc.

13681 {
13682 // Should not be already loaded or just allocated.
13684 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoaded);
13685}
bool LoadRequested() const
Definition object.h:5074
bool LoadInProgress() const
Definition object.h:5077

◆ SetLoadInProgress()

void dart::Library::SetLoadInProgress ( ) const

Definition at line 13669 of file object.cc.

13669 {
13670 // Must not already be in the process of being loaded.
13671 ASSERT(untag()->load_state_ <= UntaggedLibrary::kLoadRequested);
13672 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoadInProgress);
13673}

◆ SetLoadRequested()

void dart::Library::SetLoadRequested ( ) const

Definition at line 13675 of file object.cc.

13675 {
13676 // Must not be already loaded.
13677 ASSERT(untag()->load_state_ == UntaggedLibrary::kAllocated);
13678 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoadRequested);
13679}

◆ SetName()

void dart::Library::SetName ( const String name) const

Definition at line 13663 of file object.cc.

13663 {
13664 // Only set name once.
13665 ASSERT(!Loaded());
13666 set_name(name);
13667}
bool Loaded() const
Definition object.h:5082

◆ toplevel_class()

ClassPtr dart::Library::toplevel_class ( ) const
inline

Definition at line 5179 of file object.h.

5179{ return untag()->toplevel_class(); }

◆ TypedDataLibrary()

LibraryPtr dart::Library::TypedDataLibrary ( )
static

Definition at line 14872 of file object.cc.

14872 {
14873 return IsolateGroup::Current()->object_store()->typed_data_library();
14874}

◆ url()

StringPtr dart::Library::url ( ) const
inline

Definition at line 5068 of file object.h.

5068{ return untag()->url(); }

◆ UrlHash()

intptr_t dart::Library::UrlHash ( ) const
inline

Definition at line 13327 of file object.h.

13327 {
13328 intptr_t result = String::GetCachedHash(url());
13329 ASSERT(result != 0);
13330 return result;
13331}
static uint32_t GetCachedHash(const StringPtr obj)
Definition object.h:10424

◆ UrlOf()

static StringPtr dart::Library::UrlOf ( LibraryPtr  lib)
inlinestatic

Definition at line 5069 of file object.h.

5069{ return lib->untag()->url(); }

◆ used_scripts()

GrowableObjectArrayPtr dart::Library::used_scripts ( ) const
inline

Definition at line 5182 of file object.h.

5182 {
5183 return untag()->used_scripts();
5184 }

◆ VMServiceLibrary()

LibraryPtr dart::Library::VMServiceLibrary ( )
static

Definition at line 14876 of file object.cc.

14876 {
14877 return IsolateGroup::Current()->object_store()->_vmservice_library();
14878}

Friends And Related Symbol Documentation

◆ Bootstrap

friend class Bootstrap
friend

Definition at line 5404 of file object.h.

◆ Class

friend class Class
friend

Definition at line 5405 of file object.h.

◆ Debugger

friend class Debugger
friend

Definition at line 5406 of file object.h.

◆ DictionaryIterator

friend class DictionaryIterator
friend

Definition at line 5407 of file object.h.

◆ Isolate

friend class Isolate
friend

Definition at line 5408 of file object.h.

◆ LibraryDeserializationCluster

friend class LibraryDeserializationCluster
friend

Definition at line 5409 of file object.h.

◆ Namespace

friend class Namespace
friend

Definition at line 5410 of file object.h.

◆ Object

friend class Object
friend

Definition at line 5411 of file object.h.

◆ Precompiler

friend class Precompiler
friend

Definition at line 5412 of file object.h.

Member Data Documentation

◆ kPrivateIdentifierStart

const char dart::Library::kPrivateIdentifierStart = '_'
static

Definition at line 5351 of file object.h.

◆ kPrivateKeySeparator

const char dart::Library::kPrivateKeySeparator = '@'
static

Definition at line 5355 of file object.h.


The documentation for this class was generated from the following files: