Flutter Engine
The Flutter Engine
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 5092 of file object.h.

Member Function Documentation

◆ AddClass()

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

Definition at line 13914 of file object.cc.

13914 {
13916 const String& class_name = String::Handle(cls.Name());
13917 AddObject(cls, class_name);
13918 // Link class to this library.
13919 cls.set_library(*this);
13920}
static bool IsBackgroundCompilation()
Definition: compiler.cc:298
void AddObject(const Object &obj, const String &name) const
Definition: object.cc:13815
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 14196 of file object.cc.

14196 {
14197 Array& exports = Array::Handle(this->exports());
14198 intptr_t num_exports = exports.Length();
14199 exports = Array::Grow(exports, num_exports + 1);
14200 untag()->set_exports(exports.ptr());
14201 exports.SetAt(num_exports, ns);
14202}
static ArrayPtr Grow(const Array &source, intptr_t new_length, Heap::Space space=Heap::kNew)
Definition: object.cc:24853
ArrayPtr exports() const
Definition: object.h:5217
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)
Definition: raw_object.cc:558

◆ AddImport()

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

Definition at line 14174 of file object.cc.

14174 {
14175 Array& imports = Array::Handle(this->imports());
14176 intptr_t capacity = imports.Length();
14177 if (num_imports() == capacity) {
14178 capacity = capacity + kImportsCapacityIncrement + (capacity >> 2);
14179 imports = Array::Grow(imports, capacity);
14180 untag()->set_imports(imports.ptr());
14181 }
14182 intptr_t index = num_imports();
14183 imports.SetAt(index, ns);
14184 set_num_imports(index + 1);
14185}
intptr_t num_imports() const
Definition: object.h:5219
intptr_t index() const
Definition: object.h:5270
ArrayPtr imports() const
Definition: object.h:5216

◆ AddMetadata()

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

Definition at line 13640 of file object.cc.

13641 {
13642#if defined(DART_PRECOMPILED_RUNTIME)
13643 UNREACHABLE();
13644#else
13645 Thread* thread = Thread::Current();
13646 ASSERT(thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
13647
13648 MetadataMap map(metadata());
13649 map.UpdateOrInsert(declaration, Smi::Handle(Smi::New(kernel_offset)));
13650 set_metadata(map.Release());
13651#endif // defined(DART_PRECOMPILED_RUNTIME)
13652}
#define UNREACHABLE()
Definition: assert.h:248
friend class Thread
Definition: object.h:1025
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static Thread * Current()
Definition: thread.h:362
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 13815 of file object.cc.

13815 {
13816 ASSERT(Thread::Current()->IsDartMutatorThread());
13817 ASSERT(obj.IsClass() || obj.IsFunction() || obj.IsField() ||
13818 obj.IsLibraryPrefix());
13819 ASSERT(name.Equals(String::Handle(obj.DictionaryName())));
13820 ASSERT(LookupLocalObject(name) == Object::null());
13821 const Array& dict = Array::Handle(dictionary());
13822 intptr_t dict_size = dict.Length() - 1;
13823 intptr_t index = name.Hash() % dict_size;
13824
13825 Object& entry = Object::Handle();
13826 entry = dict.At(index);
13827 // An empty spot will be found because we keep the hash set at most 75% full.
13828 while (!entry.IsNull()) {
13829 index = (index + 1) % dict_size;
13830 entry = dict.At(index);
13831 }
13832
13833 // Insert the object at the empty slot.
13834 dict.SetAt(index, obj);
13835 // One more element added.
13836 intptr_t used_elements = Smi::Value(Smi::RawCast(dict.At(dict_size))) + 1;
13837 const Smi& used = Smi::Handle(Smi::New(used_elements));
13838 dict.SetAt(dict_size, used); // Update used count.
13839
13840 // Rehash if symbol_table is 75% full.
13841 if (used_elements > ((dict_size / 4) * 3)) {
13842 // TODO(iposva): Avoid exponential growth.
13843 RehashDictionary(dict, 2 * dict_size);
13844 }
13845
13846 // Invalidate the cache of loaded scripts.
13847 if (loaded_scripts() != Array::null()) {
13848 untag()->set_loaded_scripts(Array::null());
13849 }
13850}
friend class Object
Definition: object.h:5440
StringPtr name() const
Definition: object.h:5094
static ObjectPtr null()
Definition: object.h:433
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
intptr_t Value() const
Definition: object.h:9990

◆ AsyncLibrary()

LibraryPtr dart::Library::AsyncLibrary ( )
static

Definition at line 14779 of file object.cc.

14779 {
14780 return IsolateGroup::Current()->object_store()->async_library();
14781}
ObjectStore * object_store() const
Definition: isolate.h:510
static IsolateGroup * Current()
Definition: isolate.h:539

◆ 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:5436

◆ CollectionLibrary()

LibraryPtr dart::Library::CollectionLibrary ( )
static

Definition at line 14791 of file object.cc.

14791 {
14792 return IsolateGroup::Current()->object_store()->collection_library();
14793}

◆ CompileAll()

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

Definition at line 15228 of file object.cc.

15228 {
15229 Thread* thread = Thread::Current();
15230 Zone* zone = thread->zone();
15231 Error& error = Error::Handle(zone);
15232 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
15233 IsolateGroup::Current()->object_store()->libraries());
15234 Library& lib = Library::Handle(zone);
15235 Class& cls = Class::Handle(zone);
15236 for (int i = 0; i < libs.Length(); i++) {
15237 lib ^= libs.At(i);
15238 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
15239 while (it.HasNext()) {
15240 cls = it.GetNextClass();
15241 error = cls.EnsureIsFinalized(thread);
15242 if (!error.IsNull()) {
15243 if (ignore_error) continue;
15244 return error.ptr();
15245 }
15247 if (!error.IsNull()) {
15248 if (ignore_error) continue;
15249 return error.ptr();
15250 }
15251 }
15252 }
15253
15254 Object& result = Object::Handle(zone);
15255 ClosureFunctionsCache::ForAllClosureFunctions([&](const Function& func) {
15256 if (!func.HasCode()) {
15257 result = Compiler::CompileFunction(thread, func);
15258 if (result.IsError()) {
15259 error = Error::Cast(result).ptr();
15260 return false; // Stop iteration.
15261 }
15262 }
15263 return true; // Continue iteration.
15264 });
15265 return error.ptr();
15266}
static void ForAllClosureFunctions(std::function< bool(const Function &)> callback)
static ErrorPtr CompileAllFunctions(const Class &cls)
Definition: compiler.cc:948
friend class Class
Definition: object.h:5434
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result

◆ ConvertLibrary()

LibraryPtr dart::Library::ConvertLibrary ( )
static

Definition at line 14783 of file object.cc.

14783 {
14784 return IsolateGroup::Current()->object_store()->convert_library();
14785}

◆ CopyPragmas()

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

Definition at line 13745 of file object.cc.

13745 {
13746 auto thread = Thread::Current();
13747 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
13748 MetadataMap new_map(metadata());
13749 MetadataMap old_map(old_lib.metadata());
13750 Object& declaration = Object::Handle();
13752 MetadataMap::Iterator it(&old_map);
13753 while (it.MoveNext()) {
13754 const intptr_t entry = it.Current();
13755 ASSERT(entry != -1);
13756 declaration = old_map.GetKey(entry);
13757 if (HasPragma(declaration)) {
13758 value = old_map.GetPayload(entry, 0);
13759 ASSERT(!value.IsNull());
13760 // Pragmas should be evaluated during hot reload phase 1
13761 // (when checkpointing libraries).
13762 ASSERT(!value.IsSmi());
13763 new_map.UpdateOrInsert(declaration, value);
13764 }
13765 }
13766 old_lib.set_metadata(old_map.Release());
13767 set_metadata(new_map.Release());
13768}
uint8_t value
static bool HasPragma(const Object &declaration)
Definition: object.cc:13713

◆ CoreLibrary()

LibraryPtr dart::Library::CoreLibrary ( )
static

Definition at line 14787 of file object.cc.

14787 {
14788 return IsolateGroup::Current()->object_store()->core_library();
14789}

◆ dependencies()

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

Definition at line 5223 of file object.h.

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

◆ DeveloperLibrary()

LibraryPtr dart::Library::DeveloperLibrary ( )
static

Definition at line 14795 of file object.cc.

14795 {
14796 return IsolateGroup::Current()->object_store()->developer_library();
14797}

◆ DropDependenciesAndCaches()

void dart::Library::DropDependenciesAndCaches ( ) const

Definition at line 14162 of file object.cc.

14162 {
14163 untag()->set_imports(Object::empty_array().ptr());
14164 untag()->set_exports(Object::empty_array().ptr());
14165 StoreNonPointer(&untag()->num_imports_, 0);
14166 untag()->set_loaded_scripts(Array::null());
14167 untag()->set_dependencies(Array::null());
14168#if defined(PRODUCT)
14169 // used_scripts is only used by vm-service.
14170 untag()->set_used_scripts(GrowableObjectArray::null());
14171#endif
14172}
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 14044 of file object.cc.

14044 {
14045 if (toplevel_class() == Object::null()) {
14046 return;
14047 }
14048 Thread* thread = Thread::Current();
14049 const Class& cls = Class::Handle(thread->zone(), toplevel_class());
14050 if (cls.is_finalized()) {
14051 return;
14052 }
14053 const Error& error =
14054 Error::Handle(thread->zone(), cls.EnsureIsFinalized(thread));
14055 if (!error.IsNull()) {
14057 }
14058}
static DART_NORETURN void PropagateError(const Error &error)
Definition: exceptions.cc:1003
ClassPtr toplevel_class() const
Definition: object.h:5208

◆ 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 4811 of file object.cc.

4815 {
4816 const auto& klass = Class::Handle(toplevel_class());
4817 return klass.EvaluateCompiledExpression(kernel_buffer, type_definitions,
4818 arguments, type_arguments);
4819}

◆ EvaluatePragmas()

void dart::Library::EvaluatePragmas ( )

Definition at line 13720 of file object.cc.

13720 {
13721 Object& declaration = Object::Handle();
13722 const GrowableObjectArray& declarations =
13724 {
13725 auto thread = Thread::Current();
13726 SafepointReadRwLocker ml(thread, thread->isolate_group()->program_lock());
13727 MetadataMap map(metadata());
13728 MetadataMap::Iterator it(&map);
13729 while (it.MoveNext()) {
13730 const intptr_t entry = it.Current();
13731 ASSERT(entry != -1);
13732 declaration = map.GetKey(entry);
13733 if (HasPragma(declaration)) {
13734 declarations.Add(declaration);
13735 }
13736 }
13737 set_metadata(map.Release());
13738 }
13739 for (intptr_t i = 0; i < declarations.Length(); ++i) {
13740 declaration = declarations.At(i);
13741 GetMetadata(declaration);
13742 }
13743}
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition: object.h:11144
ObjectPtr GetMetadata(const Object &declaration) const
Definition: object.cc:13654

◆ exports()

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

Definition at line 5217 of file object.h.

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

◆ ffi_native_resolver()

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

Definition at line 5250 of file object.h.

5250 {
5251 return LoadNonPointer<Dart_FfiNativeResolver, std::memory_order_relaxed>(
5252 &untag()->ffi_native_resolver_);
5253 }

◆ FfiLibrary()

LibraryPtr dart::Library::FfiLibrary ( )
static

Definition at line 14799 of file object.cc.

14799 {
14800 return IsolateGroup::Current()->object_store()->ffi_library();
14801}

◆ FinalizeAllClasses()

ErrorPtr dart::Library::FinalizeAllClasses ( )
static

Definition at line 15270 of file object.cc.

15270 {
15271 Thread* thread = Thread::Current();
15272 ASSERT(thread->IsDartMutatorThread());
15273 Zone* zone = thread->zone();
15274 Error& error = Error::Handle(zone);
15275 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
15276 IsolateGroup::Current()->object_store()->libraries());
15277 Library& lib = Library::Handle(zone);
15278 Class& cls = Class::Handle(zone);
15279 for (int i = 0; i < libs.Length(); i++) {
15280 lib ^= libs.At(i);
15281 if (!lib.Loaded()) {
15282 String& uri = String::Handle(zone, lib.url());
15283 String& msg = String::Handle(
15284 zone,
15285 String::NewFormatted("Library '%s' is not loaded. "
15286 "Did you forget to call Dart_FinalizeLoading?",
15287 uri.ToCString()));
15288 return ApiError::New(msg);
15289 }
15290 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
15291 while (it.HasNext()) {
15292 cls = it.GetNextClass();
15293 error = cls.EnsureIsFinalized(thread);
15294 if (!error.IsNull()) {
15295 return error.ptr();
15296 }
15297 }
15298 }
15299 return Error::null();
15300}
static StringPtr NewFormatted(const char *format,...) PRINTF_ATTRIBUTE(1
Definition: object.cc:24004

◆ 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 4151 of file object.cc.

4156 {
4157 auto Z = T->zone();
4158 auto& lib = Library::Handle(Z);
4159
4160 if (obj.IsLibrary()) {
4161 lib = Library::Cast(obj).ptr();
4162 } else if (obj.IsClass()) {
4163 auto& klass = Class::Cast(obj);
4164 if (!klass.has_pragma()) return false;
4165 lib = klass.library();
4166 } else if (obj.IsFunction()) {
4167 auto& function = Function::Cast(obj);
4168 if (!function.has_pragma()) return false;
4169 lib = Class::Handle(Z, function.Owner()).library();
4170 } else if (obj.IsField()) {
4171 auto& field = Field::Cast(obj);
4172 if (!field.has_pragma()) return false;
4173 lib = Class::Handle(Z, field.Owner()).library();
4174 } else {
4175 UNREACHABLE();
4176 }
4177
4178 if (only_core && !lib.IsAnyCoreLibrary()) {
4179 return false;
4180 }
4181
4182 Object& metadata_obj = Object::Handle(Z, lib.GetMetadata(obj));
4183 if (metadata_obj.IsUnwindError()) {
4184 Report::LongJump(UnwindError::Cast(metadata_obj));
4185 }
4186
4187 return FindPragmaInMetadata(T, metadata_obj, pragma_name, multiple, options);
4188}
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:4092
#define T
Definition: precompiler.cc:65

◆ GetFunction()

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

Definition at line 15305 of file object.cc.

15307 {
15308 Thread* thread = Thread::Current();
15309 Zone* zone = thread->zone();
15310 Function& func = Function::Handle(zone);
15311 String& class_str = String::Handle(zone);
15312 String& func_str = String::Handle(zone);
15313 Class& cls = Class::Handle(zone);
15314 for (intptr_t l = 0; l < libs.length(); l++) {
15315 const Library& lib = *libs[l];
15316 if (strcmp(class_name, "::") == 0) {
15317 cls = lib.toplevel_class();
15318 } else {
15319 class_str = String::New(class_name);
15320 cls = lib.LookupClassAllowPrivate(class_str);
15321 }
15322 if (!cls.IsNull()) {
15323 if (cls.EnsureIsFinalized(thread) == Error::null()) {
15324 func_str = String::New(function_name);
15325 if (function_name[0] == '.') {
15326 func_str = String::Concat(class_str, func_str);
15327 }
15328 func = cls.LookupFunctionAllowPrivate(func_str);
15329 }
15330 }
15331 if (!func.IsNull()) {
15332 return func.ptr();
15333 }
15334 }
15335 return Function::null();
15336}
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static StringPtr Concat(const String &str1, const String &str2, Heap::Space space=Heap::kNew)
Definition: object.cc:24037
const char *const function_name

◆ GetFunctionClosure()

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

Definition at line 15338 of file object.cc.

15338 {
15339 Thread* thread = Thread::Current();
15340 Zone* zone = thread->zone();
15341 Function& func = Function::Handle(zone, LookupFunctionAllowPrivate(name));
15342 if (func.IsNull()) {
15343 // Check whether the function is reexported into the library.
15344 const Object& obj = Object::Handle(zone, LookupReExport(name));
15345 if (obj.IsFunction()) {
15346 func ^= obj.ptr();
15347 } else {
15348 // Check if there is a getter of 'name', in which case invoke it
15349 // and return the result.
15350 const String& getter_name = String::Handle(zone, Field::GetterName(name));
15351 func = LookupFunctionAllowPrivate(getter_name);
15352 if (func.IsNull()) {
15353 return Closure::null();
15354 }
15355 // Invoke the getter and return the result.
15356 return DartEntry::InvokeFunction(func, Object::empty_array());
15357 }
15358 }
15359 func = func.ImplicitClosureFunction();
15360 return func.ImplicitStaticClosure();
15361}
static ObjectPtr InvokeFunction(const Function &function, const Array &arguments)
Definition: dart_entry.cc:31
static StringPtr GetterName(const String &field_name)
Definition: object.cc:11792
ObjectPtr LookupReExport(const String &name, ZoneGrowableArray< intptr_t > *visited=nullptr) const
Definition: object.cc:13855
FunctionPtr LookupFunctionAllowPrivate(const String &name) const
Definition: object.cc:14084

◆ GetLibrary()

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

Definition at line 14716 of file object.cc.

14716 {
14717 Thread* thread = Thread::Current();
14718 Zone* zone = thread->zone();
14719 auto isolate_group = thread->isolate_group();
14720 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
14721 zone, isolate_group->object_store()->libraries());
14722 ASSERT(!libs.IsNull());
14723 if ((0 <= index) && (index < libs.Length())) {
14724 Library& lib = Library::Handle(zone);
14725 lib ^= libs.At(index);
14726 return lib.ptr();
14727 }
14728 return Library::null();
14729}

◆ GetMetadata()

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

Definition at line 13654 of file object.cc.

13654 {
13655#if defined(DART_PRECOMPILED_RUNTIME)
13656 return Object::empty_array().ptr();
13657#else
13658 RELEASE_ASSERT(declaration.IsClass() || declaration.IsField() ||
13659 declaration.IsFunction() || declaration.IsLibrary() ||
13660 declaration.IsTypeParameter() || declaration.IsNamespace());
13661
13662 auto thread = Thread::Current();
13663 auto zone = thread->zone();
13664
13665 if (declaration.IsLibrary()) {
13666 // Ensure top-level class is loaded as it may contain annotations of
13667 // a library.
13668 const auto& cls = Class::Handle(zone, toplevel_class());
13669 if (!cls.IsNull()) {
13670 cls.EnsureDeclarationLoaded();
13671 }
13672 }
13673 Object& value = Object::Handle(zone);
13674 {
13675 SafepointReadRwLocker ml(thread, thread->isolate_group()->program_lock());
13676 MetadataMap map(metadata());
13677 value = map.GetOrNull(declaration);
13678 set_metadata(map.Release());
13679 }
13680 if (value.IsNull()) {
13681 // There is no metadata for this object.
13682 return Object::empty_array().ptr();
13683 }
13684 if (!value.IsSmi()) {
13685 // Metadata is already evaluated.
13686 ASSERT(value.IsArray());
13687 return value.ptr();
13688 }
13689 const auto& smi_value = Smi::Cast(value);
13690 intptr_t kernel_offset = smi_value.Value();
13691 ASSERT(kernel_offset > 0);
13692 const auto& evaluated_value = Object::Handle(
13694 *this, kernel_offset,
13695 /* is_annotations_offset = */ declaration.IsLibrary() ||
13696 declaration.IsNamespace()));
13697 if (evaluated_value.IsArray() || evaluated_value.IsNull()) {
13698 ASSERT(evaluated_value.ptr() != Object::empty_array().ptr());
13699 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
13700 MetadataMap map(metadata());
13701 if (map.GetOrNull(declaration) == smi_value.ptr()) {
13702 map.UpdateOrInsert(declaration, evaluated_value);
13703 } else {
13704 ASSERT(map.GetOrNull(declaration) == evaluated_value.ptr());
13705 }
13706 set_metadata(map.Release());
13707 }
13708 return evaluated_value.ptr();
13709#endif // defined(DART_PRECOMPILED_RUNTIME)
13710}
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
ObjectPtr EvaluateMetadata(const Library &library, intptr_t kernel_offset, bool is_annotations_offset)
Definition: kernel.cc:467

◆ ImportAt()

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

Definition at line 14154 of file object.cc.

14154 {
14155 if ((index < 0) || index >= num_imports()) {
14156 return Namespace::null();
14157 }
14158 const Array& import_list = Array::Handle(imports());
14159 return Namespace::RawCast(import_list.At(index));
14160}

◆ ImportLibraryAt()

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

Definition at line 14146 of file object.cc.

14146 {
14148 if (import.IsNull()) {
14149 return Library::null();
14150 }
14151 return import.target();
14152}
NamespacePtr ImportAt(intptr_t index) const
Definition: object.cc:14154
friend class Namespace
Definition: object.h:5439
bool IsNull() const
Definition: object.h:363

◆ imports()

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

Definition at line 5216 of file object.h.

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

◆ index()

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

Definition at line 5270 of file object.h.

5270{ return untag()->index_; }

◆ InitCoreLibrary()

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

Definition at line 14302 of file object.cc.

14302 {
14303 Thread* thread = Thread::Current();
14304 Zone* zone = thread->zone();
14305 const String& core_lib_url = Symbols::DartCore();
14306 const Library& core_lib =
14307 Library::Handle(zone, Library::NewLibraryHelper(core_lib_url, false));
14308 core_lib.SetLoadRequested();
14309 core_lib.Register(thread);
14310 isolate_group->object_store()->set_bootstrap_library(ObjectStore::kCore,
14311 core_lib);
14312 isolate_group->object_store()->set_root_library(Library::Handle());
14313}

◆ InitNativeWrappersLibrary()

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

Definition at line 14543 of file object.cc.

14544 {
14545 const int kNumNativeWrappersClasses = 4;
14546 COMPILE_ASSERT((kNumNativeWrappersClasses > 0) &&
14547 (kNumNativeWrappersClasses < 10));
14548 Thread* thread = Thread::Current();
14549 Zone* zone = thread->zone();
14550 const String& native_flds_lib_url = Symbols::DartNativeWrappers();
14551 const Library& native_flds_lib = Library::Handle(
14552 zone, Library::NewLibraryHelper(native_flds_lib_url, false));
14553 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName();
14554 native_flds_lib.SetName(native_flds_lib_name);
14555 native_flds_lib.SetLoadRequested();
14556 native_flds_lib.Register(thread);
14557 native_flds_lib.SetLoadInProgress();
14558 isolate_group->object_store()->set_native_wrappers_library(native_flds_lib);
14559 const char* const kNativeWrappersClass = "NativeFieldWrapperClass";
14560 const int kNameLength = 25;
14561 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1));
14562 char name_buffer[kNameLength];
14563 String& cls_name = String::Handle(zone);
14564 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) {
14565 Utils::SNPrint(name_buffer, kNameLength, "%s%d", kNativeWrappersClass,
14566 fld_cnt);
14567 cls_name = Symbols::New(thread, name_buffer);
14568 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt);
14569 }
14570 // NOTE: If we bootstrap from a Kernel IR file we want to generate the
14571 // synthetic constructors for the native wrapper classes. We leave this up to
14572 // the [KernelLoader] who will take care of it later.
14573 if (!is_kernel) {
14574 native_flds_lib.SetLoaded();
14575 }
14576}
static ClassPtr NewNativeWrapper(const Library &library, const String &name, int num_fields)
Definition: object.cc:5189
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
COMPILE_ASSERT(kUnreachableReference==WeakTable::kNoValue)

◆ InstanceSize()

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

Definition at line 5119 of file object.h.

5119 {
5120 return RoundedAllocationSize(sizeof(UntaggedLibrary));
5121 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758

◆ InternalLibrary()

LibraryPtr dart::Library::InternalLibrary ( )
static

Definition at line 14803 of file object.cc.

14803 {
14804 return IsolateGroup::Current()->object_store()->_internal_library();
14805}

◆ 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 14473 of file object.cc.

14477 {
14478 Thread* thread = Thread::Current();
14479 Zone* zone = thread->zone();
14480
14481 // We don't pass any explicit type arguments, which will be understood as
14482 // using dynamic for any function type arguments by lower layers.
14483 const int kTypeArgsLen = 0;
14484 const Array& args_descriptor_array = Array::Handle(
14485 zone, ArgumentsDescriptor::NewBoxed(kTypeArgsLen, args.Length(),
14486 arg_names, Heap::kNew));
14487 ArgumentsDescriptor args_descriptor(args_descriptor_array);
14488
14489 auto& function = Function::Handle(zone);
14490 auto& result =
14492 if (result.IsFunction()) {
14493 function ^= result.ptr();
14494 }
14495
14496 if (!function.IsNull() && check_is_entrypoint) {
14497 CHECK_ERROR(function.VerifyCallEntryPoint());
14498 }
14499
14500 if (function.IsNull()) {
14501 // Didn't find a method: try to find a getter and invoke call on its result.
14502 const Object& getter_result = Object::Handle(
14503 zone, InvokeGetter(function_name, false, respect_reflectable,
14504 check_is_entrypoint));
14505 if (getter_result.ptr() != Object::sentinel().ptr()) {
14506 if (check_is_entrypoint) {
14508 }
14509 const auto& call_args_descriptor_array = Array::Handle(
14510 zone, ArgumentsDescriptor::NewBoxed(args_descriptor.TypeArgsLen(),
14511 args_descriptor.Count() + 1,
14512 arg_names, Heap::kNew));
14513 const auto& call_args = Array::Handle(
14514 zone,
14515 CreateCallableArgumentsFromStatic(zone, Instance::Cast(getter_result),
14516 args, arg_names, args_descriptor));
14517 return DartEntry::InvokeClosure(thread, call_args,
14518 call_args_descriptor_array);
14519 }
14520 }
14521
14522 if (function.IsNull() ||
14523 (respect_reflectable && !function.is_reflectable())) {
14524 return ThrowNoSuchMethod(Object::null_string(), function_name, args,
14525 arg_names, InvocationMirror::kTopLevel,
14527 }
14528 if (!function.AreValidArguments(args_descriptor, nullptr)) {
14529 return ThrowNoSuchMethod(
14530 String::Handle(function.UserVisibleSignature()), function_name, args,
14532 }
14533 // This is a static function, so we pass an empty instantiator tav.
14534 ASSERT(function.is_static());
14535 ObjectPtr type_error = function.DoArgumentTypesMatch(
14536 args, args_descriptor, Object::empty_type_arguments());
14537 if (type_error != Error::null()) {
14538 return type_error;
14539 }
14540 return DartEntry::InvokeFunction(function, args, args_descriptor_array);
14541}
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)
Definition: dart_entry.cc:282
@ 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:14342
ObjectPtr LookupLocalOrReExportObject(const String &name) const
Definition: object.cc:14065
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:4652
DART_WARN_UNUSED_RESULT ErrorPtr EntryPointFieldInvocationError(const String &getter_name)
Definition: object.cc:27196
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(error)
Definition: object.cc:134

◆ 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 14342 of file object.cc.

14345 {
14347 Function& getter = Function::Handle();
14348 if (obj.IsField()) {
14349 const Field& field = Field::Cast(obj);
14350 if (check_is_entrypoint) {
14351 CHECK_ERROR(field.VerifyEntryPoint(EntryPointPragma::kGetterOnly));
14352 }
14353 if (!field.IsUninitialized()) {
14354 return field.StaticValue();
14355 }
14356 // An uninitialized field was found. Check for a getter in the field's
14357 // owner class.
14358 const Class& klass = Class::Handle(field.Owner());
14359 const String& internal_getter_name =
14360 String::Handle(Field::GetterName(getter_name));
14361 getter = klass.LookupStaticFunction(internal_getter_name);
14362 } else {
14363 // No field found. Check for a getter in the lib.
14364 const String& internal_getter_name =
14365 String::Handle(Field::GetterName(getter_name));
14366 obj = LookupLocalOrReExportObject(internal_getter_name);
14367 if (obj.IsFunction()) {
14368 getter = Function::Cast(obj).ptr();
14369 if (check_is_entrypoint) {
14370 CHECK_ERROR(getter.VerifyCallEntryPoint());
14371 }
14372 } else {
14373 obj = LookupLocalOrReExportObject(getter_name);
14374 // Normally static top-level methods cannot be closurized through the
14375 // native API even if they are marked as entry-points, with the one
14376 // exception of "main".
14377 if (obj.IsFunction() && check_is_entrypoint) {
14378 if (!getter_name.Equals(String::Handle(String::New("main"))) ||
14379 ptr() != IsolateGroup::Current()->object_store()->root_library()) {
14380 CHECK_ERROR(Function::Cast(obj).VerifyClosurizedEntryPoint());
14381 }
14382 }
14383 if (obj.IsFunction() && Function::Cast(obj).SafeToClosurize()) {
14384 // Looking for a getter but found a regular method: closurize it.
14385 const Function& closure_function =
14386 Function::Handle(Function::Cast(obj).ImplicitClosureFunction());
14387 return closure_function.ImplicitStaticClosure();
14388 }
14389 }
14390 }
14391
14392 if (getter.IsNull() || (respect_reflectable && !getter.is_reflectable())) {
14393 if (throw_nsm_if_absent) {
14394 return ThrowNoSuchMethod(Object::null_string(), getter_name,
14395 Object::null_array(), Object::null_array(),
14398 }
14399
14400 // Fall through case: Indicate that we didn't find any function or field
14401 // using a special null instance. This is different from a field being null.
14402 // Callers make sure that this null does not leak into Dartland.
14403 return Object::sentinel().ptr();
14404 }
14405
14406 // Invoke the getter and return the result.
14407 return DartEntry::InvokeFunction(getter, Object::empty_array());
14408}

◆ InvokeSetter()

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

Definition at line 14410 of file object.cc.

14413 {
14415 const String& internal_setter_name =
14416 String::Handle(Field::SetterName(setter_name));
14417 AbstractType& setter_type = AbstractType::Handle();
14418 AbstractType& argument_type = AbstractType::Handle(value.GetType(Heap::kOld));
14419 if (obj.IsField()) {
14420 const Field& field = Field::Cast(obj);
14421 if (check_is_entrypoint) {
14422 CHECK_ERROR(field.VerifyEntryPoint(EntryPointPragma::kSetterOnly));
14423 }
14424 setter_type = field.type();
14425 if (!argument_type.IsNullType() && !setter_type.IsDynamicType() &&
14426 !value.IsInstanceOf(setter_type, Object::null_type_arguments(),
14427 Object::null_type_arguments())) {
14428 return ThrowTypeError(field.token_pos(), value, setter_type, setter_name);
14429 }
14430 if (field.is_final() || (respect_reflectable && !field.is_reflectable())) {
14431 const int kNumArgs = 1;
14432 const Array& args = Array::Handle(Array::New(kNumArgs));
14433 args.SetAt(0, value);
14434
14435 return ThrowNoSuchMethod(Object::null_string(), internal_setter_name,
14436 args, Object::null_array(),
14439 }
14440 field.SetStaticValue(value);
14441 return value.ptr();
14442 }
14443
14444 Function& setter = Function::Handle();
14445 obj = LookupLocalOrReExportObject(internal_setter_name);
14446 if (obj.IsFunction()) {
14447 setter ^= obj.ptr();
14448 }
14449
14450 if (!setter.IsNull() && check_is_entrypoint) {
14451 CHECK_ERROR(setter.VerifyCallEntryPoint());
14452 }
14453
14454 const int kNumArgs = 1;
14455 const Array& args = Array::Handle(Array::New(kNumArgs));
14456 args.SetAt(0, value);
14457 if (setter.IsNull() || (respect_reflectable && !setter.is_reflectable())) {
14458 return ThrowNoSuchMethod(Object::null_string(), internal_setter_name, args,
14459 Object::null_array(), InvocationMirror::kTopLevel,
14461 }
14462
14463 setter_type = setter.ParameterTypeAt(0);
14464 if (!argument_type.IsNullType() && !setter_type.IsDynamicType() &&
14465 !value.IsInstanceOf(setter_type, Object::null_type_arguments(),
14466 Object::null_type_arguments())) {
14467 return ThrowTypeError(setter.token_pos(), value, setter_type, setter_name);
14468 }
14469
14470 return DartEntry::InvokeFunction(setter, args);
14471}
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
static StringPtr SetterName(const String &field_name)
Definition: object.cc:11804
@ 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:4496

◆ is_dart_scheme()

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

Definition at line 5288 of file object.h.

5288 {
5290 }
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124

◆ is_in_fullsnapshot()

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

Definition at line 5260 of file object.h.

5260 {
5262 }

◆ IsAnyCoreLibrary()

bool dart::Library::IsAnyCoreLibrary ( ) const

Definition at line 13569 of file object.cc.

13569 {
13570 String& url_str = Thread::Current()->StringHandle();
13571 url_str = url();
13572 return url_str.StartsWith(Symbols::DartScheme()) ||
13573 url_str.StartsWith(Symbols::DartSchemePrivate());
13574}
StringPtr url() const
Definition: object.h:5097

◆ IsDebuggable()

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

Definition at line 5281 of file object.h.

5281 {
5283 }

◆ IsolateLibrary()

LibraryPtr dart::Library::IsolateLibrary ( )
static

Definition at line 14807 of file object.cc.

14807 {
14808 return IsolateGroup::Current()->object_store()->isolate_library();
14809}

◆ IsPrivate()

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

Definition at line 14619 of file object.cc.

14619 {
14620 if (ShouldBePrivate(name)) return true;
14621 // Factory names: List._fromLiteral.
14622 for (intptr_t i = 1; i < name.Length() - 1; i++) {
14623 if (name.CharAt(i) == '.') {
14624 if (name.CharAt(i + 1) == '_') {
14625 return true;
14626 }
14627 }
14628 }
14629 return false;
14630}
static bool ShouldBePrivate(const String &name)
Definition: object.cc:13771

◆ IsPrivateCoreLibName()

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

Definition at line 14680 of file object.cc.

14680 {
14681 Zone* zone = Thread::Current()->zone();
14682 const auto& core_lib = Library::Handle(zone, Library::CoreLibrary());
14683 const auto& private_key = String::Handle(zone, core_lib.private_key());
14684
14685 ASSERT(core_lib.IsPrivate(member));
14686 return name.EqualsConcat(member, private_key);
14687}
static LibraryPtr CoreLibrary()
Definition: object.cc:14787
StringPtr private_key() const
Definition: object.h:5099
Zone * zone() const
Definition: thread_state.h:37

◆ kernel_library_index()

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

Definition at line 5309 of file object.h.

5309 {
5310#if defined(DART_PRECOMPILED_RUNTIME)
5311 return 0;
5312#else
5313 return untag()->kernel_library_index_;
5314#endif
5315 }

◆ kernel_program_info()

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

Definition at line 5301 of file object.h.

5301 {
5302 return untag()->kernel_program_info();
5303 }

◆ KernelLibrary()

TypedDataViewPtr dart::Library::KernelLibrary ( ) const

Definition at line 13601 of file object.cc.

13601 {
13603 return info.KernelLibrary(kernel_library_index());
13604}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
intptr_t kernel_library_index() const
Definition: object.h:5309
KernelProgramInfoPtr kernel_program_info() const
Definition: object.h:5301

◆ KernelLibraryOffset()

intptr_t dart::Library::KernelLibraryOffset ( ) const

Definition at line 13606 of file object.cc.

13606 {
13608 return info.KernelLibraryStartOffset(kernel_library_index());
13609}

◆ Loaded()

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

Definition at line 5111 of file object.h.

5111 {
5112 return untag()->load_state_ == UntaggedLibrary::kLoaded;
5113 }

◆ LoadedScripts()

ArrayPtr dart::Library::LoadedScripts ( ) const

Definition at line 13940 of file object.cc.

13940 {
13941 // We compute the list of loaded scripts lazily. The result is
13942 // cached in loaded_scripts_.
13943 if (loaded_scripts() == Array::null()) {
13944 // TODO(jensj): This can be cleaned up.
13945 // It really should just return the content of `used_scripts`, and there
13946 // should be no need to do the O(n) call to `AddScriptIfUnique` per script.
13947
13948 // Iterate over the library dictionary and collect all scripts.
13949 const GrowableObjectArray& scripts =
13951 Object& entry = Object::Handle();
13952 Class& cls = Class::Handle();
13953 Script& owner_script = Script::Handle();
13954 DictionaryIterator it(*this);
13955 while (it.HasNext()) {
13956 entry = it.GetNext();
13957 if (entry.IsClass()) {
13958 owner_script = Class::Cast(entry).script();
13959 } else if (entry.IsFunction()) {
13960 owner_script = Function::Cast(entry).script();
13961 } else if (entry.IsField()) {
13962 owner_script = Field::Cast(entry).Script();
13963 } else {
13964 continue;
13965 }
13966 AddScriptIfUnique(scripts, owner_script);
13967 }
13968
13969 // Add all scripts from patch classes.
13970 GrowableObjectArray& patches = GrowableObjectArray::Handle(used_scripts());
13971 for (intptr_t i = 0; i < patches.Length(); i++) {
13972 entry = patches.At(i);
13973 if (entry.IsClass()) {
13974 owner_script = Class::Cast(entry).script();
13975 } else {
13976 ASSERT(entry.IsScript());
13977 owner_script = Script::Cast(entry).ptr();
13978 }
13979 AddScriptIfUnique(scripts, owner_script);
13980 }
13981
13982 cls = toplevel_class();
13983 if (!cls.IsNull()) {
13984 owner_script = cls.script();
13985 AddScriptIfUnique(scripts, owner_script);
13986 // Special case: Scripts that only contain external top-level functions
13987 // are not included above, but can be referenced through a library's
13988 // anonymous classes. Example: dart-core:identical.dart.
13989 Function& func = Function::Handle();
13990 Array& functions = Array::Handle(cls.current_functions());
13991 for (intptr_t j = 0; j < functions.Length(); j++) {
13992 func ^= functions.At(j);
13993 if (func.is_external()) {
13994 owner_script = func.script();
13995 AddScriptIfUnique(scripts, owner_script);
13996 }
13997 }
13998 }
13999
14000 // Create the array of scripts and cache it in loaded_scripts_.
14001 const Array& scripts_array = Array::Handle(Array::MakeFixedLength(scripts));
14002 untag()->set_loaded_scripts(scripts_array.ptr());
14003 }
14004 return loaded_scripts();
14005}
static ArrayPtr MakeFixedLength(const GrowableObjectArray &growable_array, bool unique=false)
Definition: object.cc:24935
GrowableObjectArrayPtr used_scripts() const
Definition: object.h:5211
static void AddScriptIfUnique(const GrowableObjectArray &scripts, const Script &candidate)
Definition: object.cc:13922

◆ loading_unit()

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

Definition at line 5116 of file object.h.

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

◆ LoadInProgress()

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

Definition at line 5106 of file object.h.

5106 {
5107 return untag()->load_state_ == UntaggedLibrary::kLoadInProgress;
5108 }

◆ LoadNotStarted()

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

Definition at line 5100 of file object.h.

5100 {
5101 return untag()->load_state_ == UntaggedLibrary::kAllocated;
5102 }

◆ LoadRequested()

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

Definition at line 5103 of file object.h.

5103 {
5104 return untag()->load_state_ == UntaggedLibrary::kLoadRequested;
5105 }

◆ LookupClass()

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

Definition at line 14105 of file object.cc.

14105 {
14106 Object& obj = Object::Handle(LookupLocalObject(name));
14107 if (obj.IsClass()) {
14108 return Class::Cast(obj).ptr();
14109 }
14110 return Class::null();
14111}

◆ LookupClassAllowPrivate()

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

Definition at line 14113 of file object.cc.

14113 {
14114 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14115 if (obj.IsClass()) {
14116 return Class::Cast(obj).ptr();
14117 }
14118 return Class::null();
14119}

◆ LookupCoreClass()

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

Definition at line 14689 of file object.cc.

14689 {
14690 Thread* thread = Thread::Current();
14691 Zone* zone = thread->zone();
14692 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
14693 String& name = String::Handle(zone, class_name.ptr());
14694 if (class_name.CharAt(0) == kPrivateIdentifierStart) {
14695 // Private identifiers are mangled on a per library basis.
14696 name = Symbols::FromConcat(thread, name,
14697 String::Handle(zone, core_lib.private_key()));
14698 }
14699 return core_lib.LookupClass(name);
14700}
static const char kPrivateIdentifierStart
Definition: object.h:5380
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 14075 of file object.cc.

14075 {
14077 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14078 if (obj.IsField()) {
14079 return Field::Cast(obj).ptr();
14080 }
14081 return Field::null();
14082}
void EnsureTopLevelClassIsFinalized() const
Definition: object.cc:14044

◆ LookupFunctionAllowPrivate()

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

Definition at line 14084 of file object.cc.

14084 {
14086 Object& obj = Object::Handle(LookupLocalObjectAllowPrivate(name));
14087 if (obj.IsFunction()) {
14088 return Function::Cast(obj).ptr();
14089 }
14090 return Function::null();
14091}

◆ LookupLibrary()

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

Definition at line 14599 of file object.cc.

14599 {
14600 Zone* zone = thread->zone();
14601 ObjectStore* object_store = thread->isolate_group()->object_store();
14602
14603 // Make sure the URL string has an associated hash code
14604 // to speed up the repeated equality checks.
14605 url.Hash();
14606
14607 // Use the libraries map to lookup the library by URL.
14608 Library& lib = Library::Handle(zone);
14609 if (object_store->libraries_map() == Array::null()) {
14610 return Library::null();
14611 } else {
14612 LibraryLookupMap map(object_store->libraries_map());
14613 lib ^= map.GetOrNull(url);
14614 ASSERT(map.Release().ptr() == object_store->libraries_map());
14615 }
14616 return lib.ptr();
14617}
UnorderedHashMap< LibraryLookupTraits > LibraryLookupMap
Definition: object.cc:14596

◆ LookupLocalLibraryPrefix()

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

Definition at line 14121 of file object.cc.

14121 {
14122 const Object& obj = Object::Handle(LookupLocalObject(name));
14123 if (obj.IsLibraryPrefix()) {
14124 return LibraryPrefix::Cast(obj).ptr();
14125 }
14126 return LibraryPrefix::null();
14127}

◆ LookupLocalOrReExportObject()

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

Definition at line 14065 of file object.cc.

14065 {
14066 intptr_t index;
14068 const Object& result = Object::Handle(LookupEntry(name, &index));
14069 if (!result.IsNull() && !result.IsLibraryPrefix()) {
14070 return result.ptr();
14071 }
14072 return LookupReExport(name);
14073}

◆ LookupReExport()

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

Definition at line 13855 of file object.cc.

13856 {
13857 if (!HasExports()) {
13858 return Object::null();
13859 }
13860
13861 if (trail == nullptr) {
13862 trail = new ZoneGrowableArray<intptr_t>();
13863 }
13864 Object& obj = Object::Handle();
13865
13866 const intptr_t lib_id = this->index();
13867 ASSERT(lib_id >= 0); // We use -1 to indicate that a cycle was found.
13868 trail->Add(lib_id);
13869 const Array& exports = Array::Handle(this->exports());
13871 for (int i = 0; i < exports.Length(); i++) {
13872 ns ^= exports.At(i);
13873 obj = ns.Lookup(name, trail);
13874 if (!obj.IsNull()) {
13875 // The Lookup call above may return a setter x= when we are looking
13876 // for the name x. Make sure we only return when a matching name
13877 // is found.
13878 String& obj_name = String::Handle(obj.DictionaryName());
13879 if (Field::IsSetterName(obj_name) == Field::IsSetterName(name)) {
13880 break;
13881 }
13882 }
13883 }
13884 trail->RemoveLast();
13885 return obj.ptr();
13886}
static bool IsSetterName(const String &function_name)
Definition: object.cc:11835

◆ LookupScript()

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

Definition at line 14009 of file object.cc.

14010 {
14011 const intptr_t url_length = url.Length();
14012 if (url_length == 0) {
14013 return Script::null();
14014 }
14015 const Array& scripts = Array::Handle(LoadedScripts());
14016 Script& script = Script::Handle();
14017 String& script_url = String::Handle();
14018 const intptr_t num_scripts = scripts.Length();
14019 for (int i = 0; i < num_scripts; i++) {
14020 script ^= scripts.At(i);
14021 if (useResolvedUri) {
14022 // Use for urls with 'org-dartlang-sdk:' or 'file:' schemes
14023 script_url = script.resolved_url();
14024 } else {
14025 // Use for urls with 'dart:', 'package:', or 'file:' schemes
14026 script_url = script.url();
14027 }
14028 const intptr_t start_idx = script_url.Length() - url_length;
14029 if ((start_idx == 0) && url.Equals(script_url)) {
14030 return script.ptr();
14031 } else if (start_idx > 0) {
14032 // If we do a suffix match, only match if the partial path
14033 // starts at or immediately after the path separator.
14034 if (((url.CharAt(0) == '/') ||
14035 (script_url.CharAt(start_idx - 1) == '/')) &&
14036 url.Equals(script_url, start_idx, url_length)) {
14037 return script.ptr();
14038 }
14039 }
14040 }
14041 return Script::null();
14042}
ArrayPtr LoadedScripts() const
Definition: object.cc:13940

◆ MathLibrary()

LibraryPtr dart::Library::MathLibrary ( )
static

Definition at line 14811 of file object.cc.

14811 {
14812 return IsolateGroup::Current()->object_store()->math_library();
14813}

◆ MirrorsLibrary()

LibraryPtr dart::Library::MirrorsLibrary ( )
static

Definition at line 14816 of file object.cc.

14816 {
14817 return IsolateGroup::Current()->object_store()->mirrors_library();
14818}

◆ name()

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

Definition at line 5094 of file object.h.

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

◆ native_entry_resolver()

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

Definition at line 5229 of file object.h.

5229 {
5230 return LoadNonPointer<Dart_NativeEntryResolver, std::memory_order_relaxed>(
5231 &untag()->native_entry_resolver_);
5232 }

◆ native_entry_symbol_resolver()

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

Definition at line 5238 of file object.h.

5238 {
5239 return LoadNonPointer<Dart_NativeEntrySymbol, std::memory_order_relaxed>(
5240 &untag()->native_entry_symbol_resolver_);
5241 }

◆ NativeWrappersLibrary()

LibraryPtr dart::Library::NativeWrappersLibrary ( )
static

Definition at line 14821 of file object.cc.

14821 {
14822 return IsolateGroup::Current()->object_store()->native_wrappers_library();
14823}

◆ New()

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

Definition at line 14294 of file object.cc.

14294 {
14295 return NewLibraryHelper(url, false);
14296}

◆ num_imports()

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

Definition at line 5219 of file object.h.

5219{ return untag()->num_imports_; }

◆ private_key()

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

Definition at line 5099 of file object.h.

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

◆ PrivateCoreLibName()

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

Definition at line 14674 of file object.cc.

14674 {
14675 const Library& core_lib = Library::Handle(Library::CoreLibrary());
14676 const String& private_name = String::ZoneHandle(core_lib.PrivateName(member));
14677 return private_name;
14678}
static Object & ZoneHandle()
Definition: object.h:419

◆ PrivateName()

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

Definition at line 14704 of file object.cc.

14704 {
14705 Thread* thread = Thread::Current();
14706 Zone* zone = thread->zone();
14708 // ASSERT(strchr(name, '@') == nullptr);
14709 String& str = String::Handle(zone);
14710 str = name.ptr();
14711 str = Symbols::FromConcat(thread, str,
14712 String::Handle(zone, this->private_key()));
14713 return str.ptr();
14714}
static bool IsPrivate(const String &name)
Definition: object.cc:14619

◆ Register()

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

Definition at line 14731 of file object.cc.

14731 {
14732 Zone* zone = thread->zone();
14733 auto isolate_group = thread->isolate_group();
14734 ObjectStore* object_store = isolate_group->object_store();
14735
14736 // A library is "registered" in two places:
14737 // - A growable array mapping from index to library.
14738 const String& lib_url = String::Handle(zone, url());
14739 ASSERT(Library::LookupLibrary(thread, lib_url) == Library::null());
14740 ASSERT(lib_url.HasHash());
14741 GrowableObjectArray& libs =
14742 GrowableObjectArray::Handle(zone, object_store->libraries());
14743 ASSERT(!libs.IsNull());
14744 set_index(libs.Length());
14745 libs.Add(*this);
14746
14747 // - A map from URL string to library.
14748 if (object_store->libraries_map() == Array::null()) {
14749 LibraryLookupMap map(HashTables::New<LibraryLookupMap>(16, Heap::kOld));
14750 object_store->set_libraries_map(map.Release());
14751 }
14752
14753 LibraryLookupMap map(object_store->libraries_map());
14754 bool present = map.UpdateOrInsert(lib_url, *this);
14755 ASSERT(!present);
14756 object_store->set_libraries_map(map.Release());
14757}
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
Definition: object.cc:14599
void set_index(intptr_t value) const
Definition: object.h:5271

◆ RegisterLibraries()

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

Definition at line 14759 of file object.cc.

14760 {
14761 Zone* zone = thread->zone();
14762 auto isolate_group = thread->isolate_group();
14763 Library& lib = Library::Handle(zone);
14764 String& lib_url = String::Handle(zone);
14765
14766 LibraryLookupMap map(HashTables::New<LibraryLookupMap>(16, Heap::kOld));
14767
14768 intptr_t len = libs.Length();
14769 for (intptr_t i = 0; i < len; i++) {
14770 lib ^= libs.At(i);
14771 lib_url = lib.url();
14772 map.InsertNewOrGetValue(lib_url, lib);
14773 }
14774 // Now remember these in the isolate's object store.
14775 isolate_group->object_store()->set_libraries(libs);
14776 isolate_group->object_store()->set_libraries_map(map.Release());
14777}

◆ set_debuggable()

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

Definition at line 5284 of file object.h.

5284 {
5285 set_flags(UntaggedLibrary::DebuggableBit::update(value, untag()->flags_));
5286 }

◆ set_dependencies()

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

Definition at line 14134 of file object.cc.

14134 {
14135 untag()->set_dependencies(deps.ptr());
14136}

◆ set_ffi_native_resolver()

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

Definition at line 5254 of file object.h.

5254 {
5256 std::memory_order_relaxed>(&untag()->ffi_native_resolver_,
5257 value);
5258 }
void *(* Dart_FfiNativeResolver)(const char *name, uintptr_t args_n)
Definition: dart_api.h:3262

◆ set_index()

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

Definition at line 5271 of file object.h.

5271 {
5272 ASSERT((value == -1) ||
5274 StoreNonPointer(&untag()->index_, value);
5275 }
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ set_is_dart_scheme()

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

Definition at line 5291 of file object.h.

5291 {
5292 set_flags(UntaggedLibrary::DartSchemeBit::update(value, untag()->flags_));
5293 }

◆ set_is_in_fullsnapshot()

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

Definition at line 5263 of file object.h.

5263 {
5264 set_flags(
5265 UntaggedLibrary::InFullSnapshotBit::update(value, untag()->flags_));
5266 }

◆ set_kernel_library_index()

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

Definition at line 5317 of file object.h.

5317 {
5318#if defined(DART_PRECOMPILED_RUNTIME)
5319 UNREACHABLE();
5320#else
5321 ASSERT(value >= 0);
5322 StoreNonPointer(&untag()->kernel_library_index_, value);
5323#endif
5324 }

◆ set_kernel_program_info()

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

Definition at line 13597 of file object.cc.

13597 {
13598 untag()->set_kernel_program_info(info.ptr());
13599}

◆ set_loading_unit()

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

Definition at line 13612 of file object.cc.

13612 {
13613 untag()->set_loading_unit(value.ptr());
13614}

◆ set_native_entry_resolver()

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

Definition at line 5233 of file object.h.

5233 {
5235 std::memory_order_relaxed>(&untag()->native_entry_resolver_,
5236 value);
5237 }
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
Definition: dart_api.h:3234

◆ set_native_entry_symbol_resolver()

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

Definition at line 5242 of file object.h.

5243 {
5245 std::memory_order_relaxed>(
5246 &untag()->native_entry_symbol_resolver_, native_symbol_resolver);
5247 }
const uint8_t *(* Dart_NativeEntrySymbol)(Dart_NativeFunction nf)
Definition: dart_api.h:3255

◆ set_toplevel_class()

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

Definition at line 14129 of file object.cc.

14129 {
14131 untag()->set_toplevel_class(value.ptr());
14132}

◆ SetLoaded()

void dart::Library::SetLoaded ( ) const

Definition at line 13634 of file object.cc.

13634 {
13635 // Should not be already loaded or just allocated.
13637 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoaded);
13638}
bool LoadRequested() const
Definition: object.h:5103
bool LoadInProgress() const
Definition: object.h:5106

◆ SetLoadInProgress()

void dart::Library::SetLoadInProgress ( ) const

Definition at line 13622 of file object.cc.

13622 {
13623 // Must not already be in the process of being loaded.
13624 ASSERT(untag()->load_state_ <= UntaggedLibrary::kLoadRequested);
13625 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoadInProgress);
13626}

◆ SetLoadRequested()

void dart::Library::SetLoadRequested ( ) const

Definition at line 13628 of file object.cc.

13628 {
13629 // Must not be already loaded.
13630 ASSERT(untag()->load_state_ == UntaggedLibrary::kAllocated);
13631 StoreNonPointer(&untag()->load_state_, UntaggedLibrary::kLoadRequested);
13632}

◆ SetName()

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

Definition at line 13616 of file object.cc.

13616 {
13617 // Only set name once.
13618 ASSERT(!Loaded());
13619 set_name(name);
13620}
bool Loaded() const
Definition: object.h:5111

◆ toplevel_class()

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

Definition at line 5208 of file object.h.

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

◆ TypedDataLibrary()

LibraryPtr dart::Library::TypedDataLibrary ( )
static

Definition at line 14825 of file object.cc.

14825 {
14826 return IsolateGroup::Current()->object_store()->typed_data_library();
14827}

◆ url()

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

Definition at line 5097 of file object.h.

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

◆ UrlHash()

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

Definition at line 13353 of file object.h.

13353 {
13354 intptr_t result = String::GetCachedHash(url());
13355 ASSERT(result != 0);
13356 return result;
13357}
static uint32_t GetCachedHash(const StringPtr obj)
Definition: object.h:10445

◆ UrlOf()

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

Definition at line 5098 of file object.h.

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

◆ used_scripts()

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

Definition at line 5211 of file object.h.

5211 {
5212 return untag()->used_scripts();
5213 }

◆ VMServiceLibrary()

LibraryPtr dart::Library::VMServiceLibrary ( )
static

Definition at line 14829 of file object.cc.

14829 {
14830 return IsolateGroup::Current()->object_store()->_vmservice_library();
14831}

Friends And Related Function Documentation

◆ Bootstrap

friend class Bootstrap
friend

Definition at line 5433 of file object.h.

◆ Class

friend class Class
friend

Definition at line 5434 of file object.h.

◆ Debugger

friend class Debugger
friend

Definition at line 5435 of file object.h.

◆ DictionaryIterator

friend class DictionaryIterator
friend

Definition at line 5436 of file object.h.

◆ Isolate

friend class Isolate
friend

Definition at line 5437 of file object.h.

◆ LibraryDeserializationCluster

friend class LibraryDeserializationCluster
friend

Definition at line 5438 of file object.h.

◆ Namespace

friend class Namespace
friend

Definition at line 5439 of file object.h.

◆ Object

friend class Object
friend

Definition at line 5440 of file object.h.

◆ Precompiler

friend class Precompiler
friend

Definition at line 5441 of file object.h.

Member Data Documentation

◆ kPrivateIdentifierStart

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

Definition at line 5380 of file object.h.

◆ kPrivateKeySeparator

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

Definition at line 5384 of file object.h.


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