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

#include <object.h>

Inheritance diagram for dart::Object:
dart::CallSiteData dart::Class dart::ClosureData dart::Code dart::CodeSourceMap dart::CompressedStackMaps dart::Context dart::ContextScope dart::Error dart::ExceptionHandlers dart::FfiTrampolineData dart::Field dart::Function dart::Instance dart::Instructions dart::InstructionsSection dart::InstructionsTable dart::KernelProgramInfo dart::Library dart::LoadingUnit dart::LocalVarDescriptors dart::MonomorphicSmiableCall dart::Namespace dart::ObjectPool dart::PassiveObject dart::PatchClass dart::PcDescriptors dart::Script dart::Sentinel dart::SingleTargetCache dart::SubtypeTestCache dart::TypeParameters dart::WeakArray dart::WeakSerializationReference

Public Types

enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 

Public Member Functions

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 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 constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Protected Member Functions

 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

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

ObjectPtr ptr_
 

Friends

class Closure
 
class InstanceDeserializationCluster
 
class ObjectGraphCopier
 
class Simd128MessageDeserializationCluster
 
class OneByteString
 
class TwoByteString
 
class Thread
 
ObjectPtr AllocateObject (intptr_t, intptr_t, intptr_t)
 
void ClassTable::Register (const Class &cls)
 
void UntaggedObject::Validate (IsolateGroup *isolate_group) const
 

Detailed Description

Definition at line 315 of file object.h.

Member Typedef Documentation

◆ ObjectPtrType

Definition at line 318 of file object.h.

◆ UntaggedObjectType

Definition at line 317 of file object.h.

Member Enumeration Documentation

◆ NameDisambiguation

Enumerator
kYes 
kNo 

Definition at line 657 of file object.h.

◆ NameVisibility

Enumerator
kInternalName 
kScrubbedName 
kUserVisibleName 

Definition at line 609 of file object.h.

609 {
610 // Internal names are the true names of classes, fields,
611 // etc. inside the vm. These names include privacy suffixes,
612 // getter prefixes, and trailing dots on unnamed constructors.
613 //
614 // The names of core implementation classes (like _OneByteString)
615 // are preserved as well.
616 //
617 // e.g.
618 // private getter -> get:foo@6be832b
619 // private constructor -> _MyClass@6b3832b.
620 // private named constructor -> _MyClass@6b3832b.named
621 // core impl class name shown -> _OneByteString
622 kInternalName = 0,
623
624 // Scrubbed names drop privacy suffixes, getter prefixes, and
625 // trailing dots on unnamed constructors. These names are used in
626 // the vm service.
627 //
628 // e.g.
629 // get:foo@6be832b -> foo
630 // _MyClass@6b3832b. -> _MyClass
631 // _MyClass@6b3832b.named -> _MyClass.named
632 // _OneByteString -> _OneByteString (not remapped)
634
635 // User visible names are appropriate for reporting type errors
636 // directly to programmers. The names have been scrubbed and
637 // the names of core implementation classes are remapped to their
638 // public interface names.
639 //
640 // e.g.
641 // get:foo@6be832b -> foo
642 // _MyClass@6b3832b. -> _MyClass
643 // _MyClass@6b3832b.named -> _MyClass.named
644 // _OneByteString -> String (remapped)
646 };
@ kUserVisibleName
Definition object.h:645
@ kInternalName
Definition object.h:622
@ kScrubbedName
Definition object.h:633

Constructor & Destructor Documentation

◆ ~Object()

virtual dart::Object::~Object ( )
inlinevirtual

Definition at line 327 of file object.h.

327{}

◆ Object()

dart::Object::Object ( )
inlineprotected

Definition at line 668 of file object.h.

668: ptr_(null_) {}
ObjectPtr ptr_
Definition object.h:870

Member Function Documentation

◆ AddCommonObjectProperties()

void dart::Object::AddCommonObjectProperties ( JSONObject jsobj,
const char *  protocol_type,
bool  ref 
) const
protected

Definition at line 29 of file object_service.cc.

31 {
32 const char* vm_type = JSONType();
33 bool same_type = (strcmp(protocol_type, vm_type) == 0);
34 if (ref) {
35 jsobj->AddPropertyF("type", "@%s", protocol_type);
36 } else {
37 jsobj->AddProperty("type", protocol_type);
38 }
39 if (!same_type) {
40 jsobj->AddProperty("_vmType", vm_type);
41 }
42 if (!ref || IsInstance() || IsNull()) {
43 // TODO(turnidge): Provide the type arguments here too?
44 const Class& cls = Class::Handle(this->clazz());
45 jsobj->AddProperty("class", cls);
46 }
47 if (!ref) {
48 if (ptr()->IsHeapObject()) {
49 jsobj->AddProperty("size", ptr()->untag()->HeapSize());
50 } else {
51 jsobj->AddProperty("size", (intptr_t)0);
52 }
53 }
54}
ObjectPtr ptr() const
Definition object.h:332
virtual const char * JSONType() const
Definition object.h:380
bool IsNull() const
Definition object.h:363
static Object & Handle()
Definition object.h:407
ClassPtr clazz() const
Definition object.h:13192
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)

◆ Allocate() [1/3]

template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType dart::Object::Allocate ( Heap::Space  space)
inlinestaticprotected

Definition at line 722 of file object.h.

723 {
724 return static_cast<typename T::ObjectPtrType>(Allocate(
725 T::kClassId, T::InstanceSize(), space, T::ContainsCompressedPointers(),
726 Object::from_offset<T>(), Object::to_offset<T>()));
727 }
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)
Definition object.cc:2820

◆ Allocate() [2/3]

template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType dart::Object::Allocate ( Heap::Space  space,
intptr_t  elements 
)
inlinestaticprotected

Definition at line 729 of file object.h.

731 {
732 return static_cast<typename T::ObjectPtrType>(
733 Allocate(T::kClassId, T::InstanceSize(elements), space,
734 T::ContainsCompressedPointers(), Object::from_offset<T>(),
735 Object::to_offset<T>(elements)));
736 }

◆ Allocate() [3/3]

ObjectPtr dart::Object::Allocate ( intptr_t  cls_id,
intptr_t  size,
Heap::Space  space,
bool  compressed,
uword  ptr_field_start_offset,
uword  ptr_field_end_offset 
)
staticprotected

Definition at line 2820 of file object.cc.

2825 {
2827 Thread* thread = Thread::Current();
2828 ASSERT(thread->execution_state() == Thread::kThreadInVM);
2829 ASSERT(thread->no_safepoint_scope_depth() == 0);
2830 ASSERT(thread->no_callback_scope_depth() == 0);
2831 Heap* heap = thread->heap();
2832
2833 uword address = heap->Allocate(thread, size, space);
2834 if (UNLIKELY(address == 0)) {
2835 // SuspendLongJumpScope during Dart entry ensures that if a longjmp base is
2836 // available, it is the innermost error handler, so check for a longjmp base
2837 // before checking for an exit frame.
2838 if (thread->long_jump_base() != nullptr) {
2839 Report::LongJump(Object::out_of_memory_error());
2840 UNREACHABLE();
2841 } else if (thread->top_exit_frame_info() != 0) {
2842 // Use the preallocated out of memory exception to avoid calling
2843 // into dart code or allocating any code.
2845 UNREACHABLE();
2846 } else {
2847 // Nowhere to propagate an exception to.
2848 OUT_OF_MEMORY();
2849 }
2850 }
2851
2852 ObjectPtr raw_obj;
2853 NoSafepointScope no_safepoint(thread);
2854 InitializeObject(address, cls_id, size, compressed, ptr_field_start_offset,
2855 ptr_field_end_offset);
2856 raw_obj = static_cast<ObjectPtr>(address + kHeapObjectTag);
2857 ASSERT(cls_id == UntaggedObject::ClassIdTag::decode(raw_obj->untag()->tags_));
2858 if (raw_obj->IsOldObject() && UNLIKELY(thread->is_marking())) {
2859 // Black allocation. Prevents a data race between the mutator and
2860 // concurrent marker on ARM and ARM64 (the marker may observe a
2861 // publishing store of this object before the stores that initialize its
2862 // slots), and helps the collection to finish sooner.
2863 // release: Setting the mark bit must not be ordered after a publishing
2864 // store of this object. Compare Scavenger::ScavengePointer.
2865 raw_obj->untag()->SetMarkBitRelease();
2866 heap->old_space()->AllocateBlack(size);
2867 }
2868
2869#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
2870 HeapProfileSampler& heap_sampler = thread->heap_sampler();
2871 if (heap_sampler.HasOutstandingSample()) {
2872 thread->IncrementNoCallbackScopeDepth();
2873 void* data = heap_sampler.InvokeCallbackForLastSample(cls_id);
2874 heap->SetHeapSamplingData(raw_obj, data);
2875 thread->DecrementNoCallbackScopeDepth();
2876 }
2877#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
2878
2879#if !defined(PRODUCT)
2880 auto class_table = thread->isolate_group()->class_table();
2881 if (class_table->ShouldTraceAllocationFor(cls_id)) {
2882 uint32_t hash =
2883 HeapSnapshotWriter::GetHeapSnapshotIdentityHash(thread, raw_obj);
2884 Profiler::SampleAllocation(thread, cls_id, hash);
2885 }
2886#endif // !defined(PRODUCT)
2887 return raw_obj;
2888}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
#define UNREACHABLE()
Definition assert.h:248
#define OUT_OF_MEMORY()
Definition assert.h:250
static DART_NORETURN void ThrowOOM()
friend class Thread
Definition object.h:1025
static void SampleAllocation(Thread *thread, intptr_t cid, uint32_t identity_hash)
Definition profiler.cc:1265
static DART_NORETURN void LongJump(const Error &error)
Definition report.cc:86
static Thread * Current()
Definition thread.h:361
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:77
#define ASSERT(E)
@ kHeapObjectTag
uintptr_t uword
Definition globals.h:501
static constexpr intptr_t kObjectAlignment
static int8_t data[kExtLength]
#define UNLIKELY(cond)
Definition globals.h:261

◆ AllocateVariant() [1/2]

template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType dart::Object::AllocateVariant ( intptr_t  class_id,
Heap::Space  space 
)
inlinestaticprotected

Definition at line 742 of file object.h.

744 {
745 return static_cast<typename T::ObjectPtrType>(Allocate(
746 class_id, T::InstanceSize(), space, T::ContainsCompressedPointers(),
747 Object::from_offset<T>(), Object::to_offset<T>()));
748 }

◆ AllocateVariant() [2/2]

template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType dart::Object::AllocateVariant ( intptr_t  class_id,
Heap::Space  space,
intptr_t  elements 
)
inlinestaticprotected

Definition at line 751 of file object.h.

751 {
752 return static_cast<typename T::ObjectPtrType>(
753 Allocate(class_id, T::InstanceSize(elements), space,
754 T::ContainsCompressedPointers(), Object::from_offset<T>(),
755 Object::to_offset<T>(elements)));
756 }

◆ api_error_class()

static ClassPtr dart::Object::api_error_class ( )
inlinestatic

Definition at line 552 of file object.h.

552{ return api_error_class_; }

◆ CheckHandle()

void dart::Object::CheckHandle ( ) const
protected

Definition at line 2808 of file object.cc.

2808 {
2809#if defined(DEBUG)
2810 if (ptr_ != Object::null()) {
2811 intptr_t cid = ptr_->GetClassIdMayBeSmi();
2812 if (cid >= kNumPredefinedCids) {
2813 cid = kInstanceCid;
2814 }
2815 ASSERT(vtable() == builtin_vtables_[cid]);
2816 }
2817#endif
2818}
intptr_t GetClassIdMayBeSmi() const
static ObjectPtr null()
Definition object.h:433
cpp_vtable vtable() const
Definition object.h:700
@ kNumPredefinedCids
Definition class_id.h:257
const intptr_t cid

◆ class_class()

static ClassPtr dart::Object::class_class ( )
inlinestatic

Definition at line 513 of file object.h.

513{ return class_class_; }

◆ CLASS_LIST()

dart::Object::CLASS_LIST ( STORE_NON_POINTER_ILLEGAL_TYPE  )
protected

◆ CLASS_LIST_FOR_HANDLES()

dart::Object::CLASS_LIST_FOR_HANDLES ( DEFINE_CLASS_TESTER  )

◆ clazz()

ClassPtr dart::Object::clazz ( ) const
inline

Definition at line 13192 of file object.h.

13192 {
13193 uword raw_value = static_cast<uword>(ptr_);
13194 if ((raw_value & kSmiTagMask) == kSmiTag) {
13195 return Smi::Class();
13196 }
13198}
ClassPtr At(intptr_t cid) const
static IsolateGroup * Current()
Definition isolate.h:534
ClassTable * class_table() const
Definition isolate.h:491
intptr_t GetClassId() const
Definition object.h:341
uword raw_value() const
Definition object.h:670
friend class Class
Definition object.h:10026

◆ Cleanup()

void dart::Object::Cleanup ( )
static

Definition at line 1364 of file object.cc.

1364 {
1365 null_ = static_cast<ObjectPtr>(RAW_NULL);
1366 true_ = static_cast<BoolPtr>(RAW_NULL);
1367 false_ = static_cast<BoolPtr>(RAW_NULL);
1368 class_class_ = static_cast<ClassPtr>(RAW_NULL);
1369 dynamic_class_ = static_cast<ClassPtr>(RAW_NULL);
1370 void_class_ = static_cast<ClassPtr>(RAW_NULL);
1371 type_parameters_class_ = static_cast<ClassPtr>(RAW_NULL);
1372 type_arguments_class_ = static_cast<ClassPtr>(RAW_NULL);
1373 patch_class_class_ = static_cast<ClassPtr>(RAW_NULL);
1374 function_class_ = static_cast<ClassPtr>(RAW_NULL);
1375 closure_data_class_ = static_cast<ClassPtr>(RAW_NULL);
1376 ffi_trampoline_data_class_ = static_cast<ClassPtr>(RAW_NULL);
1377 field_class_ = static_cast<ClassPtr>(RAW_NULL);
1378 script_class_ = static_cast<ClassPtr>(RAW_NULL);
1379 library_class_ = static_cast<ClassPtr>(RAW_NULL);
1380 namespace_class_ = static_cast<ClassPtr>(RAW_NULL);
1381 kernel_program_info_class_ = static_cast<ClassPtr>(RAW_NULL);
1382 code_class_ = static_cast<ClassPtr>(RAW_NULL);
1383 instructions_class_ = static_cast<ClassPtr>(RAW_NULL);
1384 instructions_section_class_ = static_cast<ClassPtr>(RAW_NULL);
1385 instructions_table_class_ = static_cast<ClassPtr>(RAW_NULL);
1386 object_pool_class_ = static_cast<ClassPtr>(RAW_NULL);
1387 pc_descriptors_class_ = static_cast<ClassPtr>(RAW_NULL);
1388 code_source_map_class_ = static_cast<ClassPtr>(RAW_NULL);
1389 compressed_stackmaps_class_ = static_cast<ClassPtr>(RAW_NULL);
1390 var_descriptors_class_ = static_cast<ClassPtr>(RAW_NULL);
1391 exception_handlers_class_ = static_cast<ClassPtr>(RAW_NULL);
1392 context_class_ = static_cast<ClassPtr>(RAW_NULL);
1393 context_scope_class_ = static_cast<ClassPtr>(RAW_NULL);
1394 singletargetcache_class_ = static_cast<ClassPtr>(RAW_NULL);
1395 unlinkedcall_class_ = static_cast<ClassPtr>(RAW_NULL);
1396 monomorphicsmiablecall_class_ = static_cast<ClassPtr>(RAW_NULL);
1397 icdata_class_ = static_cast<ClassPtr>(RAW_NULL);
1398 megamorphic_cache_class_ = static_cast<ClassPtr>(RAW_NULL);
1399 subtypetestcache_class_ = static_cast<ClassPtr>(RAW_NULL);
1400 loadingunit_class_ = static_cast<ClassPtr>(RAW_NULL);
1401 api_error_class_ = static_cast<ClassPtr>(RAW_NULL);
1402 language_error_class_ = static_cast<ClassPtr>(RAW_NULL);
1403 unhandled_exception_class_ = static_cast<ClassPtr>(RAW_NULL);
1404 unwind_error_class_ = static_cast<ClassPtr>(RAW_NULL);
1405}
#define RAW_NULL
Definition object.cc:132

◆ ClearCanonical()

void dart::Object::ClearCanonical ( ) const
inline

Definition at line 337 of file object.h.

337{ ptr()->untag()->ClearCanonical(); }
UntaggedObject * untag() const

◆ ClearImmutable()

void dart::Object::ClearImmutable ( ) const
inline

Definition at line 340 of file object.h.

340{ ptr()->untag()->ClearImmutable(); }

◆ Clone()

ObjectPtr dart::Object::Clone ( const Object orig,
Heap::Space  space,
bool  load_with_relaxed_atomics = false 
)
staticprotected

Definition at line 2960 of file object.cc.

2962 {
2963 // Generic function types should be cloned with FunctionType::Clone.
2964 ASSERT(!orig.IsFunctionType() || !FunctionType::Cast(orig).IsGeneric());
2965 const Class& cls = Class::Handle(orig.clazz());
2966 intptr_t size = orig.ptr()->untag()->HeapSize();
2967 // All fields (including non-SmiPtr fields) will be initialized with Smi 0,
2968 // but the contents of the original object are copied over before the thread
2969 // is allowed to reach a safepoint.
2970 ObjectPtr raw_clone =
2971 Object::Allocate(cls.id(), size, space, cls.HasCompressedPointers(),
2972 from_offset<Object>(), to_offset<Object>());
2973 NoSafepointScope no_safepoint;
2974 // Copy the body of the original into the clone.
2975 uword orig_addr = UntaggedObject::ToAddr(orig.ptr());
2976 uword clone_addr = UntaggedObject::ToAddr(raw_clone);
2977 const intptr_t kHeaderSizeInBytes = sizeof(UntaggedObject);
2978 if (load_with_relaxed_atomics) {
2979 auto orig_atomics_ptr = reinterpret_cast<std::atomic<uword>*>(orig_addr);
2980 auto clone_ptr = reinterpret_cast<uword*>(clone_addr);
2981 for (intptr_t i = kHeaderSizeInBytes / kWordSize; i < size / kWordSize;
2982 i++) {
2983 *(clone_ptr + i) =
2984 (orig_atomics_ptr + i)->load(std::memory_order_relaxed);
2985 }
2986 } else {
2987 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes),
2988 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes),
2989 size - kHeaderSizeInBytes);
2990 }
2991
2992 if (IsTypedDataClassId(raw_clone->GetClassId())) {
2993 auto raw_typed_data = TypedData::RawCast(raw_clone);
2994 raw_typed_data.untag()->RecomputeDataField();
2995 }
2996
2997 // Add clone to store buffer, if needed.
2998 if (!raw_clone->IsOldObject()) {
2999 // No need to remember an object in new space.
3000 return raw_clone;
3001 }
3002 WriteBarrierUpdateVisitor visitor(Thread::Current(), raw_clone);
3003 raw_clone->untag()->VisitPointers(&visitor);
3004 return raw_clone;
3005}
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
static uword ToAddr(const UntaggedObject *raw_obj)
Definition raw_object.h:501
bool IsTypedDataClassId(intptr_t index)
Definition class_id.h:433
constexpr intptr_t kWordSize
Definition globals.h:509
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ closure_data_class()

static ClassPtr dart::Object::closure_data_class ( )
inlinestatic

Definition at line 520 of file object.h.

520{ return closure_data_class_; }

◆ code_class()

static ClassPtr dart::Object::code_class ( )
inlinestatic

Definition at line 531 of file object.h.

531{ return code_class_; }

◆ code_source_map_class()

static ClassPtr dart::Object::code_source_map_class ( )
inlinestatic

Definition at line 541 of file object.h.

541{ return code_source_map_class_; }

◆ compressed_stackmaps_class()

static ClassPtr dart::Object::compressed_stackmaps_class ( )
inlinestatic

Definition at line 542 of file object.h.

542 {
543 return compressed_stackmaps_class_;
544 }

◆ Contains()

bool dart::Object::Contains ( uword  addr) const
inlineprotected

Definition at line 762 of file object.h.

762{ return ptr()->untag()->Contains(addr); }
bool Contains(uword addr) const
Definition raw_object.h:415

◆ ContainsCompressedPointers()

static constexpr bool dart::Object::ContainsCompressedPointers ( )
inlinestaticconstexpr

Definition at line 329 of file object.h.

329 {
331 }
static constexpr bool kContainsCompressedPointers
Definition raw_object.h:527

◆ context_class()

static ClassPtr dart::Object::context_class ( )
inlinestatic

Definition at line 549 of file object.h.

549{ return context_class_; }

◆ context_scope_class()

static ClassPtr dart::Object::context_scope_class ( )
inlinestatic

Definition at line 550 of file object.h.

550{ return context_scope_class_; }

◆ DictionaryName()

StringPtr dart::Object::DictionaryName ( ) const
virtual

Reimplemented in dart::Class, dart::Function, dart::Field, and dart::LibraryPrefix.

Definition at line 2685 of file object.cc.

2685 {
2686 return String::null();
2687}

◆ dynamic_class()

static ClassPtr dart::Object::dynamic_class ( )
inlinestatic

Definition at line 514 of file object.h.

514{ return dynamic_class_; }

◆ exception_handlers_class()

static ClassPtr dart::Object::exception_handlers_class ( )
inlinestatic

Definition at line 546 of file object.h.

546 {
547 return exception_handlers_class_;
548 }

◆ ffi_trampoline_data_class()

static ClassPtr dart::Object::ffi_trampoline_data_class ( )
inlinestatic

Definition at line 521 of file object.h.

521 {
522 return ffi_trampoline_data_class_;
523 }

◆ field_class()

static ClassPtr dart::Object::field_class ( )
inlinestatic

Definition at line 524 of file object.h.

524{ return field_class_; }

◆ FinalizeReadOnlyObject()

void dart::Object::FinalizeReadOnlyObject ( ObjectPtr  object)
static

Definition at line 1556 of file object.cc.

1556 {
1557 NoSafepointScope no_safepoint;
1558 intptr_t cid = object->GetClassId();
1559 if (cid == kOneByteStringCid) {
1560 OneByteStringPtr str = static_cast<OneByteStringPtr>(object);
1561 if (String::GetCachedHash(str) == 0) {
1562 intptr_t hash = String::Hash(str);
1564 }
1565 intptr_t size = OneByteString::UnroundedSize(str);
1566 ASSERT(size <= str->untag()->HeapSize());
1567 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(str) + size), 0,
1568 str->untag()->HeapSize() - size);
1569 } else if (cid == kTwoByteStringCid) {
1570 TwoByteStringPtr str = static_cast<TwoByteStringPtr>(object);
1571 if (String::GetCachedHash(str) == 0) {
1572 intptr_t hash = String::Hash(str);
1574 }
1575 ASSERT(String::GetCachedHash(str) != 0);
1576 intptr_t size = TwoByteString::UnroundedSize(str);
1577 ASSERT(size <= str->untag()->HeapSize());
1578 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(str) + size), 0,
1579 str->untag()->HeapSize() - size);
1580 } else if (cid == kCodeSourceMapCid) {
1581 CodeSourceMapPtr map = CodeSourceMap::RawCast(object);
1582 intptr_t size = CodeSourceMap::UnroundedSize(map);
1583 ASSERT(size <= map->untag()->HeapSize());
1584 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(map) + size), 0,
1585 map->untag()->HeapSize() - size);
1586 } else if (cid == kCompressedStackMapsCid) {
1587 CompressedStackMapsPtr maps = CompressedStackMaps::RawCast(object);
1589 ASSERT(size <= maps->untag()->HeapSize());
1590 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(maps) + size), 0,
1591 maps->untag()->HeapSize() - size);
1592 } else if (cid == kPcDescriptorsCid) {
1593 PcDescriptorsPtr desc = PcDescriptors::RawCast(object);
1594 intptr_t size = PcDescriptors::UnroundedSize(desc);
1595 ASSERT(size <= desc->untag()->HeapSize());
1596 memset(reinterpret_cast<void*>(UntaggedObject::ToAddr(desc) + size), 0,
1597 desc->untag()->HeapSize() - size);
1598 }
1599}
static intptr_t UnroundedSize(CodeSourceMapPtr map)
Definition object.h:6198
static intptr_t UnroundedSize(CompressedStackMapsPtr maps)
Definition object.h:6266
static intptr_t UnroundedSize(OneByteStringPtr str)
Definition object.h:10537
static intptr_t UnroundedSize(PcDescriptorsPtr desc)
Definition object.h:6056
static uint32_t SetCachedHashIfNotSet(StringPtr obj, uint32_t hash)
Definition object.h:10428
uword Hash() const
Definition object.h:10195
static uint32_t GetCachedHash(const StringPtr obj)
Definition object.h:10424
static intptr_t UnroundedSize(TwoByteStringPtr str)
Definition object.h:10677
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition SkVx.h:680

◆ FinalizeVMIsolate()

void dart::Object::FinalizeVMIsolate ( IsolateGroup isolate_group)
static

Definition at line 1470 of file object.cc.

1470 {
1471 // Should only be run by the vm isolate.
1472 ASSERT(isolate_group == Dart::vm_isolate_group());
1473
1474 // Finish initialization of synthetic_getter_parameter_names_ which was
1475 // Started in Object::InitOnce()
1476 synthetic_getter_parameter_names_->SetAt(0, Symbols::This());
1477
1478 // Set up names for all VM singleton classes.
1479 Class& cls = Class::Handle();
1480
1481 SET_CLASS_NAME(class, Class);
1482 SET_CLASS_NAME(dynamic, Dynamic);
1483 SET_CLASS_NAME(void, Void);
1484 SET_CLASS_NAME(type_parameters, TypeParameters);
1485 SET_CLASS_NAME(type_arguments, TypeArguments);
1486 SET_CLASS_NAME(patch_class, PatchClass);
1487 SET_CLASS_NAME(function, Function);
1488 SET_CLASS_NAME(closure_data, ClosureData);
1489 SET_CLASS_NAME(ffi_trampoline_data, FfiTrampolineData);
1490 SET_CLASS_NAME(field, Field);
1491 SET_CLASS_NAME(script, Script);
1492 SET_CLASS_NAME(library, LibraryClass);
1493 SET_CLASS_NAME(namespace, Namespace);
1494 SET_CLASS_NAME(kernel_program_info, KernelProgramInfo);
1495 SET_CLASS_NAME(weak_serialization_reference, WeakSerializationReference);
1496 SET_CLASS_NAME(weak_array, WeakArray);
1497 SET_CLASS_NAME(code, Code);
1498 SET_CLASS_NAME(instructions, Instructions);
1499 SET_CLASS_NAME(instructions_section, InstructionsSection);
1500 SET_CLASS_NAME(instructions_table, InstructionsTable);
1501 SET_CLASS_NAME(object_pool, ObjectPool);
1502 SET_CLASS_NAME(code_source_map, CodeSourceMap);
1503 SET_CLASS_NAME(pc_descriptors, PcDescriptors);
1504 SET_CLASS_NAME(compressed_stackmaps, CompressedStackMaps);
1505 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors);
1506 SET_CLASS_NAME(exception_handlers, ExceptionHandlers);
1507 SET_CLASS_NAME(context, Context);
1508 SET_CLASS_NAME(context_scope, ContextScope);
1509 SET_CLASS_NAME(sentinel, Sentinel);
1510 SET_CLASS_NAME(singletargetcache, SingleTargetCache);
1511 SET_CLASS_NAME(unlinkedcall, UnlinkedCall);
1512 SET_CLASS_NAME(monomorphicsmiablecall, MonomorphicSmiableCall);
1513 SET_CLASS_NAME(icdata, ICData);
1514 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache);
1515 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache);
1516 SET_CLASS_NAME(loadingunit, LoadingUnit);
1517 SET_CLASS_NAME(api_error, ApiError);
1518 SET_CLASS_NAME(language_error, LanguageError);
1519 SET_CLASS_NAME(unhandled_exception, UnhandledException);
1520 SET_CLASS_NAME(unwind_error, UnwindError);
1521
1522 // Set up names for classes which are also pre-allocated in the vm isolate.
1523 cls = isolate_group->object_store()->array_class();
1524 cls.set_name(Symbols::_List());
1525 cls = isolate_group->object_store()->one_byte_string_class();
1526 cls.set_name(Symbols::OneByteString());
1527 cls = isolate_group->object_store()->never_class();
1528 cls.set_name(Symbols::Never());
1529
1530 // Set up names for the pseudo-classes for free list elements and forwarding
1531 // corpses. Mainly this makes VM debugging easier.
1532 cls = isolate_group->class_table()->At(kFreeListElement);
1533 cls.set_name(Symbols::FreeListElement());
1534 cls = isolate_group->class_table()->At(kForwardingCorpse);
1535 cls.set_name(Symbols::ForwardingCorpse());
1536
1537#if defined(DART_PRECOMPILER)
1538 const auto& function =
1539 Function::Handle(StubCode::UnknownDartCode().function());
1540 function.set_name(Symbols::OptimizedOut());
1541#endif // defined(DART_PRECOMPILER)
1542
1543 {
1544 ASSERT(isolate_group == Dart::vm_isolate_group());
1545 Thread* thread = Thread::Current();
1546 WritableVMIsolateScope scope(thread);
1547 HeapIterationScope iteration(thread);
1548 FinalizeVMIsolateVisitor premarker;
1549 ASSERT(isolate_group->heap()->UsedInWords(Heap::kNew) == 0);
1550 iteration.IterateOldObjectsNoImagePages(&premarker);
1551 // Make the VM isolate read-only again after setting all objects as marked.
1552 // Note objects in image pages are already pre-marked.
1553 }
1554}
static IsolateGroup * vm_isolate_group()
Definition dart.h:69
@ kNew
Definition heap.h:38
static const String & This()
Definition symbols.h:691
Dart_NativeFunction function
Definition fuchsia.cc:51
@ kForwardingCorpse
Definition class_id.h:225
@ kFreeListElement
Definition class_id.h:224
#define SET_CLASS_NAME(class_name, name)
Definition object.cc:1466

◆ FinishInit()

void dart::Object::FinishInit ( IsolateGroup isolate_group)
static

Definition at line 1351 of file object.cc.

1351 {
1352 // The type testing stubs we initialize in AbstractType objects for the
1353 // canonical type of kDynamicCid/kVoidCid need to be set in this
1354 // method, which is called after StubCode::InitOnce().
1355 Code& code = Code::Handle();
1356
1358 dynamic_type_->InitializeTypeTestingStubNonAtomic(code);
1359
1361 void_type_->InitializeTypeTestingStubNonAtomic(code);
1362}
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)

◆ from_offset()

template<typename T >
static DART_FORCE_INLINE uword dart::Object::from_offset ( )
inlinestaticprotected

Definition at line 879 of file object.h.

879 {
880 return UntaggedObject::from_offset<typename T::UntaggedObjectType>();
881 }

◆ function_class()

static ClassPtr dart::Object::function_class ( )
inlinestatic

Definition at line 519 of file object.h.

519{ return function_class_; }

◆ GetClassId()

intptr_t dart::Object::GetClassId ( ) const
inline

Definition at line 341 of file object.h.

341 {
342 return !ptr()->IsHeapObject() ? static_cast<intptr_t>(kSmiCid)
343 : ptr()->untag()->GetClassId();
344 }

◆ Handle() [1/4]

static Object & dart::Object::Handle ( )
inlinestatic

Definition at line 407 of file object.h.

407 {
408 return HandleImpl(Thread::Current()->zone(), null_, kObjectCid);
409 }
static DART_NOINLINE Object & HandleImpl(Zone *zone, ObjectPtr ptr, intptr_t default_cid)
Definition object.h:674

◆ Handle() [2/4]

static Object & dart::Object::Handle ( ObjectPtr  ptr)
inlinestatic

Definition at line 413 of file object.h.

413 {
414 return HandleImpl(Thread::Current()->zone(), ptr, kObjectCid);
415 }

◆ Handle() [3/4]

static Object & dart::Object::Handle ( Zone zone)
inlinestatic

Definition at line 410 of file object.h.

410 {
411 return HandleImpl(zone, null_, kObjectCid);
412 }

◆ Handle() [4/4]

static Object & dart::Object::Handle ( Zone zone,
ObjectPtr  ptr 
)
inlinestatic

Definition at line 416 of file object.h.

416 {
417 return HandleImpl(zone, ptr, kObjectCid);
418 }

◆ HandleImpl()

static DART_NOINLINE Object & dart::Object::HandleImpl ( Zone zone,
ObjectPtr  ptr,
intptr_t  default_cid 
)
inlinestaticprotected

Definition at line 674 of file object.h.

676 {
677 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(zone));
678 obj->setPtr(ptr, default_cid);
679 return *obj;
680 }
static uword AllocateHandle(Zone *zone)
Definition handles.cc:32

◆ icdata_class()

static ClassPtr dart::Object::icdata_class ( )
inlinestatic

Definition at line 563 of file object.h.

563{ return icdata_class_; }

◆ Init() [1/2]

void dart::Object::Init ( IsolateGroup isolate_group)
static

Definition at line 721 of file object.cc.

721 {
722 // Should only be run by the vm isolate.
723 ASSERT(isolate_group == Dart::vm_isolate_group());
724 Heap* heap = isolate_group->heap();
725 Thread* thread = Thread::Current();
726 ASSERT(thread != nullptr);
727 // Ensure lock checks in setters are happy.
728 SafepointWriteRwLocker ml(thread, isolate_group->program_lock());
729
730 InitVtables();
731
732// Allocate the read only object handles here.
733#define INITIALIZE_SHARED_READONLY_HANDLE(Type, name) \
734 name##_ = Type::ReadOnlyHandle();
736#undef INITIALIZE_SHARED_READONLY_HANDLE
737
738 *null_object_ = Object::null();
739 *null_class_ = Class::null();
740 *null_array_ = Array::null();
741 *null_string_ = String::null();
742 *null_instance_ = Instance::null();
743 *null_function_ = Function::null();
744 *null_function_type_ = FunctionType::null();
745 *null_record_type_ = RecordType::null();
746 *null_type_arguments_ = TypeArguments::null();
747 *null_closure_ = Closure::null();
748 *empty_type_arguments_ = TypeArguments::null();
749 *null_abstract_type_ = AbstractType::null();
750 *null_compressed_stackmaps_ = CompressedStackMaps::null();
751 *bool_true_ = true_;
752 *bool_false_ = false_;
753
754 // Initialize the empty array and empty instantiations cache array handles to
755 // null_ in order to be able to check if the empty and zero arrays were
756 // allocated (RAW_NULL is not available).
757 *empty_array_ = Array::null();
758 *empty_instantiations_cache_array_ = Array::null();
759 *empty_subtype_test_cache_array_ = Array::null();
760
761 Class& cls = Class::Handle();
762
763 // Allocate and initialize the class class.
764 {
765 intptr_t size = Class::InstanceSize();
766 uword address = heap->Allocate(thread, size, Heap::kOld);
767 class_class_ = static_cast<ClassPtr>(address + kHeapObjectTag);
768 InitializeObject<Class>(address);
769
770 Class fake;
771 // Initialization from Class::New<Class>.
772 // Directly set ptr_ to break a circular dependency: SetRaw will attempt
773 // to lookup class class in the class table where it is not registered yet.
774 cls.ptr_ = class_class_;
775 ASSERT(builtin_vtables_[kClassCid] == fake.vtable());
776 cls.set_instance_size(
778 compiler::target::RoundedAllocationSize(RTN::Class::InstanceSize()));
779 const intptr_t host_next_field_offset = Class::NextFieldOffset();
780 const intptr_t target_next_field_offset = RTN::Class::NextFieldOffset();
781 cls.set_next_field_offset(host_next_field_offset, target_next_field_offset);
782 cls.set_id(Class::kClassId);
783 cls.set_state_bits(0);
784 cls.set_is_allocate_finalized();
785 cls.set_is_declaration_loaded();
786 cls.set_is_type_finalized();
787 cls.set_type_arguments_field_offset_in_words(Class::kNoTypeArguments,
788 RTN::Class::kNoTypeArguments);
789 cls.set_num_type_arguments_unsafe(0);
790 cls.set_num_native_fields(0);
791 cls.InitEmptyFields();
792 isolate_group->class_table()->Register(cls);
793 }
794
795 // Allocate and initialize the null class.
796 cls = Class::New<Instance, RTN::Instance>(kNullCid, isolate_group);
797 cls.set_num_type_arguments_unsafe(0);
798 isolate_group->object_store()->set_null_class(cls);
799
800 // Allocate and initialize Never class.
801 cls = Class::New<Instance, RTN::Instance>(kNeverCid, isolate_group);
802 cls.set_num_type_arguments_unsafe(0);
803 cls.set_is_allocate_finalized();
804 cls.set_is_declaration_loaded();
805 cls.set_is_type_finalized();
806 isolate_group->object_store()->set_never_class(cls);
807
808 // Allocate and initialize the free list element class.
809 cls = Class::New<FreeListElement::FakeInstance,
810 RTN::FreeListElement::FakeInstance>(kFreeListElement,
811 isolate_group);
812 cls.set_num_type_arguments_unsafe(0);
813 cls.set_is_allocate_finalized();
814 cls.set_is_declaration_loaded();
815 cls.set_is_type_finalized();
816
817 // Allocate and initialize the forwarding corpse class.
818 cls = Class::New<ForwardingCorpse::FakeInstance,
819 RTN::ForwardingCorpse::FakeInstance>(kForwardingCorpse,
820 isolate_group);
821 cls.set_num_type_arguments_unsafe(0);
822 cls.set_is_allocate_finalized();
823 cls.set_is_declaration_loaded();
824 cls.set_is_type_finalized();
825
826 // Allocate and initialize Sentinel class.
827 cls = Class::New<Sentinel, RTN::Sentinel>(isolate_group);
828 sentinel_class_ = cls.ptr();
829
830 // Allocate and initialize the sentinel values.
831 {
832 *sentinel_ ^= Sentinel::New();
833 *transition_sentinel_ ^= Sentinel::New();
834 }
835
836 // Allocate and initialize optimizing compiler constants.
837 {
838 *unknown_constant_ ^= Sentinel::New();
839 *non_constant_ ^= Sentinel::New();
840 *optimized_out_ ^= Sentinel::New();
841 }
842
843 // Allocate the remaining VM internal classes.
844 cls = Class::New<TypeParameters, RTN::TypeParameters>(isolate_group);
845 type_parameters_class_ = cls.ptr();
846
847 cls = Class::New<TypeArguments, RTN::TypeArguments>(isolate_group);
848 type_arguments_class_ = cls.ptr();
849
850 cls = Class::New<PatchClass, RTN::PatchClass>(isolate_group);
851 patch_class_class_ = cls.ptr();
852
853 cls = Class::New<Function, RTN::Function>(isolate_group);
854 function_class_ = cls.ptr();
855
856 cls = Class::New<ClosureData, RTN::ClosureData>(isolate_group);
857 closure_data_class_ = cls.ptr();
858
859 cls = Class::New<FfiTrampolineData, RTN::FfiTrampolineData>(isolate_group);
860 ffi_trampoline_data_class_ = cls.ptr();
861
862 cls = Class::New<Field, RTN::Field>(isolate_group);
863 field_class_ = cls.ptr();
864
865 cls = Class::New<Script, RTN::Script>(isolate_group);
866 script_class_ = cls.ptr();
867
868 cls = Class::New<Library, RTN::Library>(isolate_group);
869 library_class_ = cls.ptr();
870
871 cls = Class::New<Namespace, RTN::Namespace>(isolate_group);
872 namespace_class_ = cls.ptr();
873
874 cls = Class::New<KernelProgramInfo, RTN::KernelProgramInfo>(isolate_group);
875 kernel_program_info_class_ = cls.ptr();
876
877 cls = Class::New<Code, RTN::Code>(isolate_group);
878 code_class_ = cls.ptr();
879
880 cls = Class::New<Instructions, RTN::Instructions>(isolate_group);
881 instructions_class_ = cls.ptr();
882
883 cls =
884 Class::New<InstructionsSection, RTN::InstructionsSection>(isolate_group);
885 instructions_section_class_ = cls.ptr();
886
887 cls = Class::New<InstructionsTable, RTN::InstructionsTable>(isolate_group);
888 instructions_table_class_ = cls.ptr();
889
890 cls = Class::New<ObjectPool, RTN::ObjectPool>(isolate_group);
891 object_pool_class_ = cls.ptr();
892
893 cls = Class::New<PcDescriptors, RTN::PcDescriptors>(isolate_group);
894 pc_descriptors_class_ = cls.ptr();
895
896 cls = Class::New<CodeSourceMap, RTN::CodeSourceMap>(isolate_group);
897 code_source_map_class_ = cls.ptr();
898
899 cls =
900 Class::New<CompressedStackMaps, RTN::CompressedStackMaps>(isolate_group);
901 compressed_stackmaps_class_ = cls.ptr();
902
903 cls =
904 Class::New<LocalVarDescriptors, RTN::LocalVarDescriptors>(isolate_group);
905 var_descriptors_class_ = cls.ptr();
906
907 cls = Class::New<ExceptionHandlers, RTN::ExceptionHandlers>(isolate_group);
908 exception_handlers_class_ = cls.ptr();
909
910 cls = Class::New<Context, RTN::Context>(isolate_group);
911 context_class_ = cls.ptr();
912
913 cls = Class::New<ContextScope, RTN::ContextScope>(isolate_group);
914 context_scope_class_ = cls.ptr();
915
916 cls = Class::New<SingleTargetCache, RTN::SingleTargetCache>(isolate_group);
917 singletargetcache_class_ = cls.ptr();
918
919 cls = Class::New<UnlinkedCall, RTN::UnlinkedCall>(isolate_group);
920 unlinkedcall_class_ = cls.ptr();
921
922 cls = Class::New<MonomorphicSmiableCall, RTN::MonomorphicSmiableCall>(
923 isolate_group);
924 monomorphicsmiablecall_class_ = cls.ptr();
925
926 cls = Class::New<ICData, RTN::ICData>(isolate_group);
927 icdata_class_ = cls.ptr();
928
929 cls = Class::New<MegamorphicCache, RTN::MegamorphicCache>(isolate_group);
930 megamorphic_cache_class_ = cls.ptr();
931
932 cls = Class::New<SubtypeTestCache, RTN::SubtypeTestCache>(isolate_group);
933 subtypetestcache_class_ = cls.ptr();
934
935 cls = Class::New<LoadingUnit, RTN::LoadingUnit>(isolate_group);
936 loadingunit_class_ = cls.ptr();
937
938 cls = Class::New<ApiError, RTN::ApiError>(isolate_group);
939 api_error_class_ = cls.ptr();
940
941 cls = Class::New<LanguageError, RTN::LanguageError>(isolate_group);
942 language_error_class_ = cls.ptr();
943
944 cls = Class::New<UnhandledException, RTN::UnhandledException>(isolate_group);
945 unhandled_exception_class_ = cls.ptr();
946
947 cls = Class::New<UnwindError, RTN::UnwindError>(isolate_group);
948 unwind_error_class_ = cls.ptr();
949
950 cls = Class::New<WeakSerializationReference, RTN::WeakSerializationReference>(
951 isolate_group);
952 weak_serialization_reference_class_ = cls.ptr();
953
954 cls = Class::New<WeakArray, RTN::WeakArray>(isolate_group);
955 weak_array_class_ = cls.ptr();
956
957 ASSERT(class_class() != null_);
958
959 // Pre-allocate classes in the vm isolate so that we can for example create a
960 // symbol table and populate it with some frequently used strings as symbols.
961 cls = Class::New<Array, RTN::Array>(isolate_group);
962 isolate_group->object_store()->set_array_class(cls);
963 cls.set_type_arguments_field_offset(Array::type_arguments_offset(),
964 RTN::Array::type_arguments_offset());
965 cls.set_num_type_arguments_unsafe(1);
966 cls = Class::New<Array, RTN::Array>(kImmutableArrayCid, isolate_group);
967 isolate_group->object_store()->set_immutable_array_class(cls);
968 cls.set_type_arguments_field_offset(Array::type_arguments_offset(),
969 RTN::Array::type_arguments_offset());
970 cls.set_num_type_arguments_unsafe(1);
971 // In order to be able to canonicalize arguments descriptors early.
972 cls.set_is_prefinalized();
973 cls =
974 Class::New<GrowableObjectArray, RTN::GrowableObjectArray>(isolate_group);
975 isolate_group->object_store()->set_growable_object_array_class(cls);
976 cls.set_type_arguments_field_offset(
978 RTN::GrowableObjectArray::type_arguments_offset());
979 cls.set_num_type_arguments_unsafe(1);
980 cls = Class::NewStringClass(kOneByteStringCid, isolate_group);
981 isolate_group->object_store()->set_one_byte_string_class(cls);
982 cls = Class::NewStringClass(kTwoByteStringCid, isolate_group);
983 isolate_group->object_store()->set_two_byte_string_class(cls);
984 cls = Class::New<Mint, RTN::Mint>(isolate_group);
985 isolate_group->object_store()->set_mint_class(cls);
986 cls = Class::New<Double, RTN::Double>(isolate_group);
987 isolate_group->object_store()->set_double_class(cls);
988 cls = Class::New<Float32x4, RTN::Float32x4>(isolate_group);
989 isolate_group->object_store()->set_float32x4_class(cls);
990 cls = Class::New<Float64x2, RTN::Float64x2>(isolate_group);
991 isolate_group->object_store()->set_float64x2_class(cls);
992 cls = Class::New<Int32x4, RTN::Int32x4>(isolate_group);
993 isolate_group->object_store()->set_int32x4_class(cls);
994
995 // Ensure that class kExternalTypedDataUint8ArrayCid is registered as we
996 // need it when reading in the token stream of bootstrap classes in the VM
997 // isolate.
998 Class::NewExternalTypedDataClass(kExternalTypedDataUint8ArrayCid,
999 isolate_group);
1000
1001 // Needed for object pools of VM isolate stubs.
1002 Class::NewTypedDataClass(kTypedDataInt8ArrayCid, isolate_group);
1003
1004 // Allocate and initialize the empty_array instance.
1005 {
1006 uword address = heap->Allocate(thread, Array::InstanceSize(0), Heap::kOld);
1007 InitializeObjectVariant<Array>(address, kImmutableArrayCid, 0);
1008 Array::initializeHandle(empty_array_,
1009 static_cast<ArrayPtr>(address + kHeapObjectTag));
1010 empty_array_->untag()->set_length(Smi::New(0));
1011 empty_array_->SetCanonical();
1012 }
1013
1014 Smi& smi = Smi::Handle();
1015 // Allocate and initialize the empty instantiations cache array instance,
1016 // which contains metadata as the first element and a sentinel value
1017 // at the start of the first entry.
1018 {
1019 const intptr_t array_size =
1021 uword address =
1022 heap->Allocate(thread, Array::InstanceSize(array_size), Heap::kOld);
1023 InitializeObjectVariant<Array>(address, kImmutableArrayCid, array_size);
1024 Array::initializeHandle(empty_instantiations_cache_array_,
1025 static_cast<ArrayPtr>(address + kHeapObjectTag));
1026 empty_instantiations_cache_array_->untag()->set_length(
1027 Smi::New(array_size));
1028 // The empty cache has no occupied entries and is not a hash-based cache.
1029 smi = Smi::New(0);
1030 empty_instantiations_cache_array_->SetAt(
1032 // Make the first (and only) entry unoccupied by setting its first element
1033 // to the sentinel value.
1035 InstantiationsCacheTable table(*empty_instantiations_cache_array_);
1037 // The other contents of the array are immaterial.
1038 empty_instantiations_cache_array_->SetCanonical();
1039 }
1040
1041 // Allocate and initialize the empty subtype test cache array instance,
1042 // which contains a single unoccupied entry.
1043 {
1044 const intptr_t array_size = SubtypeTestCache::kTestEntryLength;
1045 uword address =
1046 heap->Allocate(thread, Array::InstanceSize(array_size), Heap::kOld);
1047 InitializeObjectVariant<Array>(address, kImmutableArrayCid, array_size);
1048 Array::initializeHandle(empty_subtype_test_cache_array_,
1049 static_cast<ArrayPtr>(address + kHeapObjectTag));
1050 empty_subtype_test_cache_array_->untag()->set_length(Smi::New(array_size));
1051 // Make the first (and only) entry unoccupied by setting its first element
1052 // to the null value.
1053 empty_subtype_test_cache_array_->SetAt(
1054 SubtypeTestCache::kInstanceCidOrSignature, Object::null_object());
1056 SubtypeTestCacheTable table(*empty_subtype_test_cache_array_);
1058 Object::null_object());
1059 // The other contents of the array are immaterial.
1060 empty_subtype_test_cache_array_->SetCanonical();
1061 }
1062
1063 // Allocate and initialize the canonical empty context scope object.
1064 {
1065 uword address =
1066 heap->Allocate(thread, ContextScope::InstanceSize(0), Heap::kOld);
1067 InitializeObject<ContextScope>(address, 0);
1068 ContextScope::initializeHandle(
1069 empty_context_scope_,
1070 static_cast<ContextScopePtr>(address + kHeapObjectTag));
1071 empty_context_scope_->StoreNonPointer(
1072 &empty_context_scope_->untag()->num_variables_, 0);
1073 empty_context_scope_->StoreNonPointer(
1074 &empty_context_scope_->untag()->is_implicit_, true);
1075 empty_context_scope_->SetCanonical();
1076 }
1077
1078 // Allocate and initialize the canonical empty object pool object.
1079 {
1080 uword address =
1081 heap->Allocate(thread, ObjectPool::InstanceSize(0), Heap::kOld);
1082 InitializeObject<ObjectPool>(address, 0);
1083 ObjectPool::initializeHandle(
1084 empty_object_pool_,
1085 static_cast<ObjectPoolPtr>(address + kHeapObjectTag));
1086 empty_object_pool_->StoreNonPointer(&empty_object_pool_->untag()->length_,
1087 0);
1088 empty_object_pool_->SetCanonical();
1089 }
1090
1091 // Allocate and initialize the empty_compressed_stackmaps instance.
1092 {
1093 const intptr_t instance_size = CompressedStackMaps::InstanceSize(0);
1094 uword address = heap->Allocate(thread, instance_size, Heap::kOld);
1095 InitializeObject<CompressedStackMaps>(address, 0);
1096 CompressedStackMaps::initializeHandle(
1097 empty_compressed_stackmaps_,
1098 static_cast<CompressedStackMapsPtr>(address + kHeapObjectTag));
1099 empty_compressed_stackmaps_->untag()->payload()->set_flags_and_size(0);
1100 empty_compressed_stackmaps_->SetCanonical();
1101 }
1102
1103 // Allocate and initialize the empty_descriptors instance.
1104 {
1105 uword address =
1106 heap->Allocate(thread, PcDescriptors::InstanceSize(0), Heap::kOld);
1107 InitializeObject<PcDescriptors>(address, 0);
1108 PcDescriptors::initializeHandle(
1109 empty_descriptors_,
1110 static_cast<PcDescriptorsPtr>(address + kHeapObjectTag));
1111 empty_descriptors_->StoreNonPointer(&empty_descriptors_->untag()->length_,
1112 0);
1113 empty_descriptors_->SetCanonical();
1114 }
1115
1116 // Allocate and initialize the canonical empty variable descriptor object.
1117 {
1118 uword address = heap->Allocate(thread, LocalVarDescriptors::InstanceSize(0),
1119 Heap::kOld);
1120 InitializeObject<LocalVarDescriptors>(address, 0);
1121 LocalVarDescriptors::initializeHandle(
1122 empty_var_descriptors_,
1123 static_cast<LocalVarDescriptorsPtr>(address + kHeapObjectTag));
1124 empty_var_descriptors_->StoreNonPointer(
1125 &empty_var_descriptors_->untag()->num_entries_, 0);
1126 empty_var_descriptors_->SetCanonical();
1127 }
1128
1129 // Allocate and initialize the canonical empty exception handler info object.
1130 // The vast majority of all functions do not contain an exception handler
1131 // and can share this canonical descriptor.
1132 {
1133 uword address =
1134 heap->Allocate(thread, ExceptionHandlers::InstanceSize(0), Heap::kOld);
1135 InitializeObject<ExceptionHandlers>(address, 0);
1136 ExceptionHandlers::initializeHandle(
1137 empty_exception_handlers_,
1138 static_cast<ExceptionHandlersPtr>(address + kHeapObjectTag));
1139 empty_exception_handlers_->StoreNonPointer(
1140 &empty_exception_handlers_->untag()->packed_fields_, 0);
1141 empty_exception_handlers_->SetCanonical();
1142 }
1143
1144 // Empty exception handlers for async/async* functions.
1145 {
1146 uword address =
1147 heap->Allocate(thread, ExceptionHandlers::InstanceSize(0), Heap::kOld);
1148 InitializeObject<ExceptionHandlers>(address, 0);
1149 ExceptionHandlers::initializeHandle(
1150 empty_async_exception_handlers_,
1151 static_cast<ExceptionHandlersPtr>(address + kHeapObjectTag));
1152 empty_async_exception_handlers_->StoreNonPointer(
1153 &empty_async_exception_handlers_->untag()->packed_fields_,
1155 empty_async_exception_handlers_->SetCanonical();
1156 }
1157
1158 // Allocate and initialize the canonical empty type arguments object.
1159 {
1160 uword address =
1161 heap->Allocate(thread, TypeArguments::InstanceSize(0), Heap::kOld);
1162 InitializeObject<TypeArguments>(address, 0);
1163 TypeArguments::initializeHandle(
1164 empty_type_arguments_,
1165 static_cast<TypeArgumentsPtr>(address + kHeapObjectTag));
1166 empty_type_arguments_->untag()->set_length(Smi::New(0));
1167 empty_type_arguments_->untag()->set_hash(Smi::New(0));
1168 empty_type_arguments_->ComputeHash();
1169 empty_type_arguments_->SetCanonical();
1170 }
1171
1172 // The VM isolate snapshot object table is initialized to an empty array
1173 // as we do not have any VM isolate snapshot at this time.
1174 *vm_isolate_snapshot_object_table_ = Object::empty_array().ptr();
1175
1176 cls = Class::New<Instance, RTN::Instance>(kDynamicCid, isolate_group);
1177 cls.set_is_abstract();
1178 cls.set_num_type_arguments_unsafe(0);
1179 cls.set_is_allocate_finalized();
1180 cls.set_is_declaration_loaded();
1181 cls.set_is_type_finalized();
1182 dynamic_class_ = cls.ptr();
1183
1184 cls = Class::New<Instance, RTN::Instance>(kVoidCid, isolate_group);
1185 cls.set_num_type_arguments_unsafe(0);
1186 cls.set_is_allocate_finalized();
1187 cls.set_is_declaration_loaded();
1188 cls.set_is_type_finalized();
1189 void_class_ = cls.ptr();
1190
1191 cls = Class::New<Type, RTN::Type>(isolate_group);
1192 cls.set_is_allocate_finalized();
1193 cls.set_is_declaration_loaded();
1194 cls.set_is_type_finalized();
1195
1196 cls = Class::New<FunctionType, RTN::FunctionType>(isolate_group);
1197 cls.set_is_allocate_finalized();
1198 cls.set_is_declaration_loaded();
1199 cls.set_is_type_finalized();
1200
1201 cls = Class::New<RecordType, RTN::RecordType>(isolate_group);
1202 cls.set_is_allocate_finalized();
1203 cls.set_is_declaration_loaded();
1204 cls.set_is_type_finalized();
1205
1206 cls = dynamic_class_;
1207 *dynamic_type_ =
1208 Type::New(cls, Object::null_type_arguments(), Nullability::kNullable);
1209 dynamic_type_->SetIsFinalized();
1210 dynamic_type_->ComputeHash();
1211 dynamic_type_->SetCanonical();
1212
1213 cls = void_class_;
1214 *void_type_ =
1215 Type::New(cls, Object::null_type_arguments(), Nullability::kNullable);
1216 void_type_->SetIsFinalized();
1217 void_type_->ComputeHash();
1218 void_type_->SetCanonical();
1219
1220 // Since TypeArguments objects are passed as function arguments, make them
1221 // behave as Dart instances, although they are just VM objects.
1222 // Note that we cannot set the super type to ObjectType, which does not live
1223 // in the vm isolate. See special handling in Class::SuperClass().
1224 cls = type_arguments_class_;
1225 cls.set_interfaces(Object::empty_array());
1226 cls.SetFields(Object::empty_array());
1227 cls.SetFunctions(Object::empty_array());
1228
1229 cls = Class::New<Bool, RTN::Bool>(isolate_group);
1230 isolate_group->object_store()->set_bool_class(cls);
1231
1232 *smi_illegal_cid_ = Smi::New(kIllegalCid);
1233 *smi_zero_ = Smi::New(0);
1234
1235 String& error_str = String::Handle();
1236 error_str = String::New(
1237 "Callbacks into the Dart VM are currently prohibited. Either there are "
1238 "outstanding pointers from Dart_TypedDataAcquireData that have not been "
1239 "released with Dart_TypedDataReleaseData, or a finalizer is running.",
1240 Heap::kOld);
1241 *no_callbacks_error_ = ApiError::New(error_str, Heap::kOld);
1242 error_str = String::New(
1243 "No api calls are allowed while unwind is in progress", Heap::kOld);
1244 *unwind_in_progress_error_ = UnwindError::New(error_str, Heap::kOld);
1245 error_str = String::New("SnapshotWriter Error", Heap::kOld);
1246 *snapshot_writer_error_ =
1247 LanguageError::New(error_str, Report::kError, Heap::kOld);
1248 error_str = String::New("Branch offset overflow", Heap::kOld);
1249 *branch_offset_error_ =
1250 LanguageError::New(error_str, Report::kBailout, Heap::kOld);
1251 error_str = String::New("Speculative inlining failed", Heap::kOld);
1252 *speculative_inlining_error_ =
1253 LanguageError::New(error_str, Report::kBailout, Heap::kOld);
1254 error_str = String::New("Background Compilation Failed", Heap::kOld);
1255 *background_compilation_error_ =
1256 LanguageError::New(error_str, Report::kBailout, Heap::kOld);
1257 error_str = String::New("Out of memory", Heap::kOld);
1258 *out_of_memory_error_ =
1259 LanguageError::New(error_str, Report::kError, Heap::kOld);
1260
1261 // Allocate the parameter types and names for synthetic getters.
1262 *synthetic_getter_parameter_types_ = Array::New(1, Heap::kOld);
1263 synthetic_getter_parameter_types_->SetAt(0, Object::dynamic_type());
1264 *synthetic_getter_parameter_names_ = Array::New(1, Heap::kOld);
1265 // Fill in synthetic_getter_parameter_names_ later, after symbols are
1266 // initialized (in Object::FinalizeVMIsolate).
1267 // synthetic_getter_parameter_names_ object needs to be created earlier as
1268 // VM isolate snapshot reader references it before Object::FinalizeVMIsolate.
1269
1270 // Some thread fields need to be reinitialized as null constants have not been
1271 // initialized until now.
1272 thread->ClearStickyError();
1273
1274 ASSERT(!null_object_->IsSmi());
1275 ASSERT(!null_class_->IsSmi());
1276 ASSERT(null_class_->IsClass());
1277 ASSERT(!null_array_->IsSmi());
1278 ASSERT(null_array_->IsArray());
1279 ASSERT(!null_string_->IsSmi());
1280 ASSERT(null_string_->IsString());
1281 ASSERT(!null_instance_->IsSmi());
1282 ASSERT(null_instance_->IsInstance());
1283 ASSERT(!null_function_->IsSmi());
1284 ASSERT(null_function_->IsFunction());
1285 ASSERT(!null_function_type_->IsSmi());
1286 ASSERT(null_function_type_->IsFunctionType());
1287 ASSERT(!null_record_type_->IsSmi());
1288 ASSERT(null_record_type_->IsRecordType());
1289 ASSERT(!null_type_arguments_->IsSmi());
1290 ASSERT(null_type_arguments_->IsTypeArguments());
1291 ASSERT(!null_compressed_stackmaps_->IsSmi());
1292 ASSERT(null_compressed_stackmaps_->IsCompressedStackMaps());
1293 ASSERT(!empty_array_->IsSmi());
1294 ASSERT(empty_array_->IsArray());
1295 ASSERT(!empty_instantiations_cache_array_->IsSmi());
1296 ASSERT(empty_instantiations_cache_array_->IsArray());
1297 ASSERT(!empty_subtype_test_cache_array_->IsSmi());
1298 ASSERT(empty_subtype_test_cache_array_->IsArray());
1299 ASSERT(!empty_type_arguments_->IsSmi());
1300 ASSERT(empty_type_arguments_->IsTypeArguments());
1301 ASSERT(!empty_context_scope_->IsSmi());
1302 ASSERT(empty_context_scope_->IsContextScope());
1303 ASSERT(!empty_compressed_stackmaps_->IsSmi());
1304 ASSERT(empty_compressed_stackmaps_->IsCompressedStackMaps());
1305 ASSERT(!empty_descriptors_->IsSmi());
1306 ASSERT(empty_descriptors_->IsPcDescriptors());
1307 ASSERT(!empty_var_descriptors_->IsSmi());
1308 ASSERT(empty_var_descriptors_->IsLocalVarDescriptors());
1309 ASSERT(!empty_exception_handlers_->IsSmi());
1310 ASSERT(empty_exception_handlers_->IsExceptionHandlers());
1311 ASSERT(!empty_async_exception_handlers_->IsSmi());
1312 ASSERT(empty_async_exception_handlers_->IsExceptionHandlers());
1313 ASSERT(!sentinel_->IsSmi());
1314 ASSERT(sentinel_->IsSentinel());
1315 ASSERT(!transition_sentinel_->IsSmi());
1316 ASSERT(transition_sentinel_->IsSentinel());
1317 ASSERT(!unknown_constant_->IsSmi());
1318 ASSERT(unknown_constant_->IsSentinel());
1319 ASSERT(!non_constant_->IsSmi());
1320 ASSERT(non_constant_->IsSentinel());
1321 ASSERT(!optimized_out_->IsSmi());
1322 ASSERT(optimized_out_->IsSentinel());
1323 ASSERT(!bool_true_->IsSmi());
1324 ASSERT(bool_true_->IsBool());
1325 ASSERT(!bool_false_->IsSmi());
1326 ASSERT(bool_false_->IsBool());
1327 ASSERT(smi_illegal_cid_->IsSmi());
1328 ASSERT(smi_zero_->IsSmi());
1329 ASSERT(!no_callbacks_error_->IsSmi());
1330 ASSERT(no_callbacks_error_->IsApiError());
1331 ASSERT(!unwind_in_progress_error_->IsSmi());
1332 ASSERT(unwind_in_progress_error_->IsUnwindError());
1333 ASSERT(!snapshot_writer_error_->IsSmi());
1334 ASSERT(snapshot_writer_error_->IsLanguageError());
1335 ASSERT(!branch_offset_error_->IsSmi());
1336 ASSERT(branch_offset_error_->IsLanguageError());
1337 ASSERT(!speculative_inlining_error_->IsSmi());
1338 ASSERT(speculative_inlining_error_->IsLanguageError());
1339 ASSERT(!background_compilation_error_->IsSmi());
1340 ASSERT(background_compilation_error_->IsLanguageError());
1341 ASSERT(!out_of_memory_error_->IsSmi());
1342 ASSERT(out_of_memory_error_->IsLanguageError());
1343 ASSERT(!vm_isolate_snapshot_object_table_->IsSmi());
1344 ASSERT(vm_isolate_snapshot_object_table_->IsArray());
1345 ASSERT(!synthetic_getter_parameter_types_->IsSmi());
1346 ASSERT(synthetic_getter_parameter_types_->IsArray());
1347 ASSERT(!synthetic_getter_parameter_names_->IsSmi());
1348 ASSERT(synthetic_getter_parameter_names_->IsArray());
1349}
SI F table(const skcms_Curve *curve, F v)
static intptr_t type_arguments_offset()
Definition object.h:10902
static intptr_t InstanceSize()
Definition object.h:10910
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
static constexpr S update(T value, S original)
Definition bitfield.h:190
static intptr_t InstanceSize()
Definition object.h:1687
static ClassPtr NewExternalTypedDataClass(intptr_t class_id, IsolateGroup *isolate)
Definition object.cc:5373
static ClassPtr NewTypedDataClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition object.cc:5314
static constexpr intptr_t kNoTypeArguments
Definition object.h:1376
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
Definition object.cc:3114
static ClassPtr NewStringClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition object.cc:5287
static intptr_t InstanceSize()
Definition object.h:6272
static intptr_t InstanceSize()
Definition object.h:7506
static intptr_t InstanceSize()
Definition object.h:6579
static intptr_t type_arguments_offset()
Definition object.h:11103
@ kOld
Definition heap.h:39
static intptr_t InstanceSize()
Definition object.h:6026
static intptr_t InstanceSize()
Definition object.h:5620
static ClassPtr class_class()
Definition object.h:513
static const ClassId kClassId
Definition object.h:606
static void InitVtables()
Definition object.cc:615
static intptr_t InstanceSize()
Definition object.h:6060
static SentinelPtr New()
Definition object.cc:18779
static SmiPtr New(intptr_t value)
Definition object.h:9985
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition object.cc:23777
static SmiPtr Sentinel()
Definition object.cc:7231
static intptr_t InstanceSize()
Definition object.h:8962
static TypePtr New(const Class &clazz, const TypeArguments &arguments, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
Definition object.cc:22492
static UnwindErrorPtr New(const String &message, Heap::Space space=Heap::kNew)
Definition object.cc:20055
ArrayOfTuplesView< TypeArguments::Cache::Entry, std::tuple< Object, TypeArguments, TypeArguments >, TypeArguments::Cache::kHeaderSize > InstantiationsCacheTable
Definition object.h:13540
@ kIllegalCid
Definition class_id.h:214
@ kNullCid
Definition class_id.h:252
@ kVoidCid
Definition class_id.h:254
@ kDynamicCid
Definition class_id.h:253
@ kNeverCid
Definition class_id.h:255
ArrayOfTuplesView< SubtypeTestCache::Entries, std::tuple< Object, TypeArguments, TypeArguments, TypeArguments, TypeArguments, TypeArguments, AbstractType, Bool > > SubtypeTestCacheTable
Definition object.h:13532
#define SHARED_READONLY_HANDLES_LIST(V)
Definition object.h:457
#define INITIALIZE_SHARED_READONLY_HANDLE(Type, name)

◆ Init() [2/2]

ErrorPtr dart::Object::Init ( IsolateGroup isolate_group,
const uint8_t *  kernel_buffer,
intptr_t  kernel_buffer_size 
)
static

Definition at line 1721 of file object.cc.

1723 {
1724 Thread* thread = Thread::Current();
1725 Zone* zone = thread->zone();
1726 ASSERT(isolate_group == thread->isolate_group());
1727 TIMELINE_DURATION(thread, Isolate, "Object::Init");
1728
1729#if defined(DART_PRECOMPILED_RUNTIME)
1730 const bool bootstrapping = false;
1731#else
1732 const bool is_kernel = (kernel_buffer != nullptr);
1733 const bool bootstrapping =
1734 (Dart::vm_snapshot_kind() == Snapshot::kNone) || is_kernel;
1735#endif // defined(DART_PRECOMPILED_RUNTIME).
1736
1737 if (bootstrapping) {
1738#if !defined(DART_PRECOMPILED_RUNTIME)
1739 // Object::Init version when we are bootstrapping from source or from a
1740 // Kernel binary.
1741 // This will initialize isolate group object_store, shared by all isolates
1742 // running in the isolate group.
1743 ObjectStore* object_store = isolate_group->object_store();
1744 SafepointWriteRwLocker ml(thread, isolate_group->program_lock());
1745
1746 Class& cls = Class::Handle(zone);
1747 Type& type = Type::Handle(zone);
1748 Array& array = Array::Handle(zone);
1749 WeakArray& weak_array = WeakArray::Handle(zone);
1750 Library& lib = Library::Handle(zone);
1751 TypeArguments& type_args = TypeArguments::Handle(zone);
1752
1753 // All RawArray fields will be initialized to an empty array, therefore
1754 // initialize array class first.
1755 cls = Class::New<Array, RTN::Array>(isolate_group);
1756 ASSERT(object_store->array_class() == Class::null());
1757 object_store->set_array_class(cls);
1758
1759 // VM classes that are parameterized (Array, ImmutableArray,
1760 // GrowableObjectArray, Map, ConstMap,
1761 // Set, ConstSet) are also pre-finalized, so
1762 // CalculateFieldOffsets() is not called, so we need to set the offset
1763 // of their type_arguments_ field, which is explicitly
1764 // declared in their respective Raw* classes.
1765 cls.set_type_arguments_field_offset(Array::type_arguments_offset(),
1766 RTN::Array::type_arguments_offset());
1767 cls.set_num_type_arguments_unsafe(1);
1768
1769 // Set up the growable object array class (Has to be done after the array
1770 // class is setup as one of its field is an array object).
1771 cls = Class::New<GrowableObjectArray, RTN::GrowableObjectArray>(
1772 isolate_group);
1773 object_store->set_growable_object_array_class(cls);
1774 cls.set_type_arguments_field_offset(
1776 RTN::GrowableObjectArray::type_arguments_offset());
1777 cls.set_num_type_arguments_unsafe(1);
1778
1779 // Initialize hash set for regexp_table_.
1780 const intptr_t kInitialCanonicalRegExpSize = 4;
1781 weak_array = HashTables::New<CanonicalRegExpSet>(
1782 kInitialCanonicalRegExpSize, Heap::kOld);
1783 object_store->set_regexp_table(weak_array);
1784
1785 // Initialize hash set for canonical types.
1786 const intptr_t kInitialCanonicalTypeSize = 16;
1787 array = HashTables::New<CanonicalTypeSet>(kInitialCanonicalTypeSize,
1788 Heap::kOld);
1789 object_store->set_canonical_types(array);
1790
1791 // Initialize hash set for canonical function types.
1792 const intptr_t kInitialCanonicalFunctionTypeSize = 16;
1793 array = HashTables::New<CanonicalFunctionTypeSet>(
1794 kInitialCanonicalFunctionTypeSize, Heap::kOld);
1795 object_store->set_canonical_function_types(array);
1796
1797 // Initialize hash set for canonical record types.
1798 const intptr_t kInitialCanonicalRecordTypeSize = 16;
1799 array = HashTables::New<CanonicalRecordTypeSet>(
1800 kInitialCanonicalRecordTypeSize, Heap::kOld);
1801 object_store->set_canonical_record_types(array);
1802
1803 // Initialize hash set for canonical type parameters.
1804 const intptr_t kInitialCanonicalTypeParameterSize = 4;
1805 array = HashTables::New<CanonicalTypeParameterSet>(
1806 kInitialCanonicalTypeParameterSize, Heap::kOld);
1807 object_store->set_canonical_type_parameters(array);
1808
1809 // Initialize hash set for canonical_type_arguments_.
1810 const intptr_t kInitialCanonicalTypeArgumentsSize = 4;
1811 array = HashTables::New<CanonicalTypeArgumentsSet>(
1812 kInitialCanonicalTypeArgumentsSize, Heap::kOld);
1813 object_store->set_canonical_type_arguments(array);
1814
1815 // Setup type class early in the process.
1816 const Class& type_cls =
1817 Class::Handle(zone, Class::New<Type, RTN::Type>(isolate_group));
1818 const Class& function_type_cls = Class::Handle(
1819 zone, Class::New<FunctionType, RTN::FunctionType>(isolate_group));
1820 const Class& record_type_cls = Class::Handle(
1821 zone, Class::New<RecordType, RTN::RecordType>(isolate_group));
1822 const Class& type_parameter_cls = Class::Handle(
1823 zone, Class::New<TypeParameter, RTN::TypeParameter>(isolate_group));
1824 const Class& library_prefix_cls = Class::Handle(
1825 zone, Class::New<LibraryPrefix, RTN::LibraryPrefix>(isolate_group));
1826
1827 // Pre-allocate the OneByteString class needed by the symbol table.
1828 cls = Class::NewStringClass(kOneByteStringCid, isolate_group);
1829 object_store->set_one_byte_string_class(cls);
1830
1831 // Pre-allocate the TwoByteString class needed by the symbol table.
1832 cls = Class::NewStringClass(kTwoByteStringCid, isolate_group);
1833 object_store->set_two_byte_string_class(cls);
1834
1835 // Setup the symbol table for the symbols created in the isolate.
1836 Symbols::SetupSymbolTable(isolate_group);
1837
1838 // Set up the libraries array before initializing the core library.
1839 const GrowableObjectArray& libraries =
1841 object_store->set_libraries(libraries);
1842
1843 // Pre-register the core library.
1844 Library::InitCoreLibrary(isolate_group);
1845
1846 // Basic infrastructure has been setup, initialize the class dictionary.
1847 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
1848 ASSERT(!core_lib.IsNull());
1849
1850 const GrowableObjectArray& pending_classes =
1852 object_store->set_pending_classes(pending_classes);
1853
1854 // Now that the symbol table is initialized and that the core dictionary as
1855 // well as the core implementation dictionary have been setup, preallocate
1856 // remaining classes and register them by name in the dictionaries.
1857 String& name = String::Handle(zone);
1858 cls = object_store->array_class(); // Was allocated above.
1859 RegisterPrivateClass(cls, Symbols::_List(), core_lib);
1860 pending_classes.Add(cls);
1861 // We cannot use NewNonParameterizedType(), because Array is
1862 // parameterized. Warning: class _List has not been patched yet. Its
1863 // declared number of type parameters is still 0. It will become 1 after
1864 // patching. The array type allocated below represents the raw type _List
1865 // and not _List<E> as we could expect. Use with caution.
1866 type = Type::New(Class::Handle(zone, cls.ptr()),
1867 Object::null_type_arguments(), Nullability::kNonNullable);
1868 type.SetIsFinalized();
1869 type ^= type.Canonicalize(thread);
1870 object_store->set_array_type(type);
1871
1872 cls = object_store->growable_object_array_class(); // Was allocated above.
1873 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib);
1874 pending_classes.Add(cls);
1875
1876 cls = Class::New<Array, RTN::Array>(kImmutableArrayCid, isolate_group);
1877 object_store->set_immutable_array_class(cls);
1878 cls.set_type_arguments_field_offset(Array::type_arguments_offset(),
1879 RTN::Array::type_arguments_offset());
1880 cls.set_num_type_arguments_unsafe(1);
1881 ASSERT(object_store->immutable_array_class() !=
1882 object_store->array_class());
1883 cls.set_is_prefinalized();
1884 RegisterPrivateClass(cls, Symbols::_ImmutableList(), core_lib);
1885 pending_classes.Add(cls);
1886
1887 cls = object_store->one_byte_string_class(); // Was allocated above.
1888 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib);
1889 pending_classes.Add(cls);
1890
1891 cls = object_store->two_byte_string_class(); // Was allocated above.
1892 RegisterPrivateClass(cls, Symbols::TwoByteString(), core_lib);
1893 pending_classes.Add(cls);
1894
1895 // Pre-register the isolate library so the native class implementations can
1896 // be hooked up before compiling it.
1897 Library& isolate_lib = Library::Handle(
1898 zone, Library::LookupLibrary(thread, Symbols::DartIsolate()));
1899 if (isolate_lib.IsNull()) {
1900 isolate_lib = Library::NewLibraryHelper(Symbols::DartIsolate(), true);
1901 isolate_lib.SetLoadRequested();
1902 isolate_lib.Register(thread);
1903 }
1904 object_store->set_bootstrap_library(ObjectStore::kIsolate, isolate_lib);
1905 ASSERT(!isolate_lib.IsNull());
1906 ASSERT(isolate_lib.ptr() == Library::IsolateLibrary());
1907
1908 cls = Class::New<Capability, RTN::Capability>(isolate_group);
1909 RegisterPrivateClass(cls, Symbols::_Capability(), isolate_lib);
1910 pending_classes.Add(cls);
1911
1912 cls = Class::New<ReceivePort, RTN::ReceivePort>(isolate_group);
1913 RegisterPrivateClass(cls, Symbols::_RawReceivePort(), isolate_lib);
1914 pending_classes.Add(cls);
1915
1916 cls = Class::New<SendPort, RTN::SendPort>(isolate_group);
1917 RegisterPrivateClass(cls, Symbols::_SendPort(), isolate_lib);
1918 pending_classes.Add(cls);
1919
1920 cls = Class::New<TransferableTypedData, RTN::TransferableTypedData>(
1921 isolate_group);
1922 RegisterPrivateClass(cls, Symbols::_TransferableTypedDataImpl(),
1923 isolate_lib);
1924 pending_classes.Add(cls);
1925
1926 const Class& stacktrace_cls = Class::Handle(
1927 zone, Class::New<StackTrace, RTN::StackTrace>(isolate_group));
1928 RegisterPrivateClass(stacktrace_cls, Symbols::_StackTrace(), core_lib);
1929 pending_classes.Add(stacktrace_cls);
1930 // Super type set below, after Object is allocated.
1931
1932 cls = Class::New<RegExp, RTN::RegExp>(isolate_group);
1933 RegisterPrivateClass(cls, Symbols::_RegExp(), core_lib);
1934 pending_classes.Add(cls);
1935
1936 // Initialize the base interfaces used by the core VM classes.
1937
1938 // Allocate and initialize the pre-allocated classes in the core library.
1939 // The script and token index of these pre-allocated classes is set up when
1940 // the corelib script is compiled.
1941 cls = Class::New<Instance, RTN::Instance>(kInstanceCid, isolate_group);
1942 object_store->set_object_class(cls);
1943 cls.set_name(Symbols::Object());
1944 cls.set_num_type_arguments_unsafe(0);
1945 cls.set_is_prefinalized();
1946 cls.set_is_const();
1947 core_lib.AddClass(cls);
1948 pending_classes.Add(cls);
1950 ASSERT(type.IsCanonical());
1951 object_store->set_object_type(type);
1952 type = type.ToNullability(Nullability::kLegacy, Heap::kOld);
1953 ASSERT(type.IsCanonical());
1954 object_store->set_legacy_object_type(type);
1956 ASSERT(type.IsCanonical());
1957 object_store->set_non_nullable_object_type(type);
1958 type = type.ToNullability(Nullability::kNullable, Heap::kOld);
1959 ASSERT(type.IsCanonical());
1960 object_store->set_nullable_object_type(type);
1961
1962 cls = Class::New<Bool, RTN::Bool>(isolate_group);
1963 object_store->set_bool_class(cls);
1964 RegisterClass(cls, Symbols::Bool(), core_lib);
1965 pending_classes.Add(cls);
1966
1967 cls = Class::New<Instance, RTN::Instance>(kNullCid, isolate_group);
1968 object_store->set_null_class(cls);
1969 cls.set_num_type_arguments_unsafe(0);
1970 cls.set_is_prefinalized();
1971 RegisterClass(cls, Symbols::Null(), core_lib);
1972 pending_classes.Add(cls);
1973
1974 cls = Class::New<Instance, RTN::Instance>(kNeverCid, isolate_group);
1975 cls.set_num_type_arguments_unsafe(0);
1976 cls.set_is_allocate_finalized();
1977 cls.set_is_declaration_loaded();
1978 cls.set_is_type_finalized();
1979 cls.set_name(Symbols::Never());
1980 object_store->set_never_class(cls);
1981
1982 ASSERT(!library_prefix_cls.IsNull());
1983 RegisterPrivateClass(library_prefix_cls, Symbols::_LibraryPrefix(),
1984 core_lib);
1985 pending_classes.Add(library_prefix_cls);
1986
1987 RegisterPrivateClass(type_cls, Symbols::_Type(), core_lib);
1988 pending_classes.Add(type_cls);
1989
1990 RegisterPrivateClass(function_type_cls, Symbols::_FunctionType(), core_lib);
1991 pending_classes.Add(function_type_cls);
1992
1993 RegisterPrivateClass(record_type_cls, Symbols::_RecordType(), core_lib);
1994 pending_classes.Add(record_type_cls);
1995
1996 RegisterPrivateClass(type_parameter_cls, Symbols::_TypeParameter(),
1997 core_lib);
1998 pending_classes.Add(type_parameter_cls);
1999
2000 cls = Class::New<Integer, RTN::Integer>(isolate_group);
2001 object_store->set_integer_implementation_class(cls);
2002 RegisterPrivateClass(cls, Symbols::_IntegerImplementation(), core_lib);
2003 pending_classes.Add(cls);
2004
2005 cls = Class::New<Smi, RTN::Smi>(isolate_group);
2006 object_store->set_smi_class(cls);
2007 RegisterPrivateClass(cls, Symbols::_Smi(), core_lib);
2008 pending_classes.Add(cls);
2009
2010 cls = Class::New<Mint, RTN::Mint>(isolate_group);
2011 object_store->set_mint_class(cls);
2012 RegisterPrivateClass(cls, Symbols::_Mint(), core_lib);
2013 pending_classes.Add(cls);
2014
2015 cls = Class::New<Double, RTN::Double>(isolate_group);
2016 object_store->set_double_class(cls);
2017 RegisterPrivateClass(cls, Symbols::_Double(), core_lib);
2018 pending_classes.Add(cls);
2019
2020 // Class that represents the Dart class _Closure and C++ class Closure.
2021 cls = Class::New<Closure, RTN::Closure>(isolate_group);
2022 object_store->set_closure_class(cls);
2023 RegisterPrivateClass(cls, Symbols::_Closure(), core_lib);
2024 pending_classes.Add(cls);
2025
2026 cls = Class::New<Record, RTN::Record>(isolate_group);
2027 RegisterPrivateClass(cls, Symbols::_Record(), core_lib);
2028 pending_classes.Add(cls);
2029
2030 cls = Class::New<WeakProperty, RTN::WeakProperty>(isolate_group);
2031 object_store->set_weak_property_class(cls);
2032 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib);
2033
2034 cls = Class::New<WeakReference, RTN::WeakReference>(isolate_group);
2035 cls.set_type_arguments_field_offset(
2037 RTN::WeakReference::type_arguments_offset());
2038 cls.set_num_type_arguments_unsafe(1);
2039 object_store->set_weak_reference_class(cls);
2040 RegisterPrivateClass(cls, Symbols::_WeakReference(), core_lib);
2041
2042 // Pre-register the mirrors library so we can place the vm class
2043 // MirrorReference there rather than the core library.
2044 lib = Library::LookupLibrary(thread, Symbols::DartMirrors());
2045 if (lib.IsNull()) {
2046 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true);
2047 lib.SetLoadRequested();
2048 lib.Register(thread);
2049 }
2050 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib);
2051 ASSERT(!lib.IsNull());
2052 ASSERT(lib.ptr() == Library::MirrorsLibrary());
2053
2054 cls = Class::New<MirrorReference, RTN::MirrorReference>(isolate_group);
2055 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib);
2056
2057 // Pre-register the collection library so we can place the vm class
2058 // Map there rather than the core library.
2059 lib = Library::LookupLibrary(thread, Symbols::DartCollection());
2060 if (lib.IsNull()) {
2061 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true);
2062 lib.SetLoadRequested();
2063 lib.Register(thread);
2064 }
2065
2066 object_store->set_bootstrap_library(ObjectStore::kCollection, lib);
2067 ASSERT(!lib.IsNull());
2068 ASSERT(lib.ptr() == Library::CollectionLibrary());
2069 cls = Class::New<Map, RTN::Map>(isolate_group);
2070 object_store->set_map_impl_class(cls);
2071 cls.set_type_arguments_field_offset(Map::type_arguments_offset(),
2072 RTN::Map::type_arguments_offset());
2073 cls.set_num_type_arguments_unsafe(2);
2074 RegisterPrivateClass(cls, Symbols::_Map(), lib);
2075 pending_classes.Add(cls);
2076
2077 cls = Class::New<Map, RTN::Map>(kConstMapCid, isolate_group);
2078 object_store->set_const_map_impl_class(cls);
2079 cls.set_type_arguments_field_offset(Map::type_arguments_offset(),
2080 RTN::Map::type_arguments_offset());
2081 cls.set_num_type_arguments_unsafe(2);
2082 cls.set_is_prefinalized();
2083 RegisterPrivateClass(cls, Symbols::_ConstMap(), lib);
2084 pending_classes.Add(cls);
2085
2086 cls = Class::New<Set, RTN::Set>(isolate_group);
2087 object_store->set_set_impl_class(cls);
2088 cls.set_type_arguments_field_offset(Set::type_arguments_offset(),
2089 RTN::Set::type_arguments_offset());
2090 cls.set_num_type_arguments_unsafe(1);
2091 RegisterPrivateClass(cls, Symbols::_Set(), lib);
2092 pending_classes.Add(cls);
2093
2094 cls = Class::New<Set, RTN::Set>(kConstSetCid, isolate_group);
2095 object_store->set_const_set_impl_class(cls);
2096 cls.set_type_arguments_field_offset(Set::type_arguments_offset(),
2097 RTN::Set::type_arguments_offset());
2098 cls.set_num_type_arguments_unsafe(1);
2099 cls.set_is_prefinalized();
2100 RegisterPrivateClass(cls, Symbols::_ConstSet(), lib);
2101 pending_classes.Add(cls);
2102
2103 // Pre-register the async library so we can place the vm class
2104 // FutureOr there rather than the core library.
2105 lib = Library::LookupLibrary(thread, Symbols::DartAsync());
2106 if (lib.IsNull()) {
2107 lib = Library::NewLibraryHelper(Symbols::DartAsync(), true);
2108 lib.SetLoadRequested();
2109 lib.Register(thread);
2110 }
2111 object_store->set_bootstrap_library(ObjectStore::kAsync, lib);
2112 ASSERT(!lib.IsNull());
2113 ASSERT(lib.ptr() == Library::AsyncLibrary());
2114 cls = Class::New<FutureOr, RTN::FutureOr>(isolate_group);
2115 cls.set_type_arguments_field_offset(FutureOr::type_arguments_offset(),
2116 RTN::FutureOr::type_arguments_offset());
2117 cls.set_num_type_arguments_unsafe(1);
2118 RegisterClass(cls, Symbols::FutureOr(), lib);
2119 pending_classes.Add(cls);
2120 object_store->set_future_or_class(cls);
2121
2122 cls = Class::New<SuspendState, RTN::SuspendState>(isolate_group);
2123 RegisterPrivateClass(cls, Symbols::_SuspendState(), lib);
2124 pending_classes.Add(cls);
2125
2126 // Pre-register the developer library so we can place the vm class
2127 // UserTag there rather than the core library.
2128 lib = Library::LookupLibrary(thread, Symbols::DartDeveloper());
2129 if (lib.IsNull()) {
2130 lib = Library::NewLibraryHelper(Symbols::DartDeveloper(), true);
2131 lib.SetLoadRequested();
2132 lib.Register(thread);
2133 }
2134 object_store->set_bootstrap_library(ObjectStore::kDeveloper, lib);
2135 ASSERT(!lib.IsNull());
2136 ASSERT(lib.ptr() == Library::DeveloperLibrary());
2137 cls = Class::New<UserTag, RTN::UserTag>(isolate_group);
2138 RegisterPrivateClass(cls, Symbols::_UserTag(), lib);
2139 pending_classes.Add(cls);
2140
2141 // Setup some default native field classes which can be extended for
2142 // specifying native fields in dart classes.
2143 Library::InitNativeWrappersLibrary(isolate_group, is_kernel);
2144 ASSERT(object_store->native_wrappers_library() != Library::null());
2145
2146 // Pre-register the typed_data library so the native class implementations
2147 // can be hooked up before compiling it.
2148 lib = Library::LookupLibrary(thread, Symbols::DartTypedData());
2149 if (lib.IsNull()) {
2150 lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true);
2151 lib.SetLoadRequested();
2152 lib.Register(thread);
2153 }
2154 object_store->set_bootstrap_library(ObjectStore::kTypedData, lib);
2155 ASSERT(!lib.IsNull());
2156 ASSERT(lib.ptr() == Library::TypedDataLibrary());
2157#define REGISTER_TYPED_DATA_CLASS(clazz) \
2158 cls = Class::NewTypedDataClass(kTypedData##clazz##ArrayCid, isolate_group); \
2159 RegisterPrivateClass(cls, Symbols::_##clazz##List(), lib);
2160
2162#undef REGISTER_TYPED_DATA_CLASS
2163#define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \
2164 cls = \
2165 Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid, isolate_group); \
2166 RegisterPrivateClass(cls, Symbols::_##clazz##View(), lib); \
2167 pending_classes.Add(cls); \
2168 cls = Class::NewUnmodifiableTypedDataViewClass( \
2169 kUnmodifiableTypedData##clazz##ViewCid, isolate_group); \
2170 RegisterPrivateClass(cls, Symbols::_Unmodifiable##clazz##View(), lib); \
2171 pending_classes.Add(cls);
2172
2174
2175 cls = Class::NewTypedDataViewClass(kByteDataViewCid, isolate_group);
2176 RegisterPrivateClass(cls, Symbols::_ByteDataView(), lib);
2177 pending_classes.Add(cls);
2179 isolate_group);
2180 RegisterPrivateClass(cls, Symbols::_UnmodifiableByteDataView(), lib);
2181 pending_classes.Add(cls);
2182
2183#undef REGISTER_TYPED_DATA_VIEW_CLASS
2184#define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \
2185 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid, \
2186 isolate_group); \
2187 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib);
2188
2189 cls = Class::New<Instance, RTN::Instance>(kByteBufferCid, isolate_group,
2190 /*register_class=*/false);
2191 cls.set_instance_size(0, 0);
2192 cls.set_next_field_offset(-kWordSize, -compiler::target::kWordSize);
2193 isolate_group->class_table()->Register(cls);
2194 RegisterPrivateClass(cls, Symbols::_ByteBuffer(), lib);
2195 pending_classes.Add(cls);
2196
2198#undef REGISTER_EXT_TYPED_DATA_CLASS
2199 // Register Float32x4, Int32x4, and Float64x2 in the object store.
2200 cls = Class::New<Float32x4, RTN::Float32x4>(isolate_group);
2201 RegisterPrivateClass(cls, Symbols::_Float32x4(), lib);
2202 pending_classes.Add(cls);
2203 object_store->set_float32x4_class(cls);
2204
2205 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2206 /*register_class=*/true,
2207 /*is_abstract=*/true);
2208 RegisterClass(cls, Symbols::Float32x4(), lib);
2209 cls.set_num_type_arguments_unsafe(0);
2210 cls.set_is_prefinalized();
2212 object_store->set_float32x4_type(type);
2213
2214 cls = Class::New<Int32x4, RTN::Int32x4>(isolate_group);
2215 RegisterPrivateClass(cls, Symbols::_Int32x4(), lib);
2216 pending_classes.Add(cls);
2217 object_store->set_int32x4_class(cls);
2218
2219 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2220 /*register_class=*/true,
2221 /*is_abstract=*/true);
2222 RegisterClass(cls, Symbols::Int32x4(), lib);
2223 cls.set_num_type_arguments_unsafe(0);
2224 cls.set_is_prefinalized();
2226 object_store->set_int32x4_type(type);
2227
2228 cls = Class::New<Float64x2, RTN::Float64x2>(isolate_group);
2229 RegisterPrivateClass(cls, Symbols::_Float64x2(), lib);
2230 pending_classes.Add(cls);
2231 object_store->set_float64x2_class(cls);
2232
2233 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2234 /*register_class=*/true,
2235 /*is_abstract=*/true);
2236 RegisterClass(cls, Symbols::Float64x2(), lib);
2237 cls.set_num_type_arguments_unsafe(0);
2238 cls.set_is_prefinalized();
2240 object_store->set_float64x2_type(type);
2241
2242 // Set the super type of class StackTrace to Object type so that the
2243 // 'toString' method is implemented.
2244 type = object_store->object_type();
2245 stacktrace_cls.set_super_type(type);
2246
2247 // Abstract class that represents the Dart class Type.
2248 // Note that this class is implemented by Dart class _AbstractType.
2249 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2250 /*register_class=*/true,
2251 /*is_abstract=*/true);
2252 cls.set_num_type_arguments_unsafe(0);
2253 cls.set_is_prefinalized();
2254 RegisterClass(cls, Symbols::Type(), core_lib);
2255 pending_classes.Add(cls);
2257 object_store->set_type_type(type);
2258
2259 // Abstract class that represents the Dart class Function.
2260 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2261 /*register_class=*/true,
2262 /*is_abstract=*/true);
2263 cls.set_num_type_arguments_unsafe(0);
2264 cls.set_is_prefinalized();
2265 RegisterClass(cls, Symbols::Function(), core_lib);
2266 pending_classes.Add(cls);
2268 object_store->set_function_type(type);
2269
2270 // Abstract class that represents the Dart class Record.
2271 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2272 /*register_class=*/true,
2273 /*is_abstract=*/true);
2274 RegisterClass(cls, Symbols::Record(), core_lib);
2275 pending_classes.Add(cls);
2276 object_store->set_record_class(cls);
2277
2278 cls = Class::New<Number, RTN::Number>(isolate_group);
2279 RegisterClass(cls, Symbols::Number(), core_lib);
2280 pending_classes.Add(cls);
2282 object_store->set_number_type(type);
2283 type = type.ToNullability(Nullability::kNullable, Heap::kOld);
2284 object_store->set_nullable_number_type(type);
2285
2286 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2287 /*register_class=*/true,
2288 /*is_abstract=*/true);
2289 RegisterClass(cls, Symbols::Int(), core_lib);
2290 cls.set_num_type_arguments_unsafe(0);
2291 cls.set_is_prefinalized();
2292 pending_classes.Add(cls);
2294 object_store->set_int_type(type);
2295 type = type.ToNullability(Nullability::kLegacy, Heap::kOld);
2296 object_store->set_legacy_int_type(type);
2298 object_store->set_non_nullable_int_type(type);
2299 type = type.ToNullability(Nullability::kNullable, Heap::kOld);
2300 object_store->set_nullable_int_type(type);
2301
2302 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2303 /*register_class=*/true,
2304 /*is_abstract=*/true);
2305 RegisterClass(cls, Symbols::Double(), core_lib);
2306 cls.set_num_type_arguments_unsafe(0);
2307 cls.set_is_prefinalized();
2308 pending_classes.Add(cls);
2310 object_store->set_double_type(type);
2311 type = type.ToNullability(Nullability::kNullable, Heap::kOld);
2312 object_store->set_nullable_double_type(type);
2313
2314 name = Symbols::_String().ptr();
2315 cls = Class::New<Instance, RTN::Instance>(kIllegalCid, isolate_group,
2316 /*register_class=*/true,
2317 /*is_abstract=*/true);
2318 RegisterClass(cls, name, core_lib);
2319 cls.set_num_type_arguments_unsafe(0);
2320 cls.set_is_prefinalized();
2321 pending_classes.Add(cls);
2323 object_store->set_string_type(type);
2324 type = type.ToNullability(Nullability::kLegacy, Heap::kOld);
2325 object_store->set_legacy_string_type(type);
2326
2327 cls = object_store->bool_class();
2329 object_store->set_bool_type(type);
2330
2331 cls = object_store->smi_class();
2333 object_store->set_smi_type(type);
2334 type = type.ToNullability(Nullability::kLegacy, Heap::kOld);
2335
2336 cls = object_store->mint_class();
2338 object_store->set_mint_type(type);
2339
2340 // The classes 'void' and 'dynamic' are phony classes to make type checking
2341 // more regular; they live in the VM isolate. The class 'void' is not
2342 // registered in the class dictionary because its name is a reserved word.
2343 // The class 'dynamic' is registered in the class dictionary because its
2344 // name is a built-in identifier (this is wrong). The corresponding types
2345 // are stored in the object store.
2346 cls = object_store->null_class();
2347 type =
2348 Type::New(cls, Object::null_type_arguments(), Nullability::kNullable);
2349 type.SetIsFinalized();
2350 type ^= type.Canonicalize(thread);
2351 object_store->set_null_type(type);
2352 cls.set_declaration_type(type);
2353 ASSERT(type.IsNullable());
2354
2355 // Consider removing when/if Null becomes an ordinary class.
2356 type = object_store->object_type();
2357 cls.set_super_type(type);
2358
2359 cls = object_store->never_class();
2360 type = Type::New(cls, Object::null_type_arguments(),
2362 type.SetIsFinalized();
2363 type ^= type.Canonicalize(thread);
2364 object_store->set_never_type(type);
2365 type_args = TypeArguments::New(1);
2366 type_args.SetTypeAt(0, type);
2367 type_args = type_args.Canonicalize(thread);
2368 object_store->set_type_argument_never(type_args);
2369
2370 // Create and cache commonly used type arguments <int>, <double>,
2371 // <String>, <String, dynamic> and <String, String>.
2372 type_args = TypeArguments::New(1);
2373 type = object_store->int_type();
2374 type_args.SetTypeAt(0, type);
2375 type_args = type_args.Canonicalize(thread);
2376 object_store->set_type_argument_int(type_args);
2377 type_args = TypeArguments::New(1);
2378 type = object_store->legacy_int_type();
2379 type_args.SetTypeAt(0, type);
2380 type_args = type_args.Canonicalize(thread);
2381 object_store->set_type_argument_legacy_int(type_args);
2382
2383 type_args = TypeArguments::New(1);
2384 type = object_store->double_type();
2385 type_args.SetTypeAt(0, type);
2386 type_args = type_args.Canonicalize(thread);
2387 object_store->set_type_argument_double(type_args);
2388
2389 type_args = TypeArguments::New(1);
2390 type = object_store->string_type();
2391 type_args.SetTypeAt(0, type);
2392 type_args = type_args.Canonicalize(thread);
2393 object_store->set_type_argument_string(type_args);
2394 type_args = TypeArguments::New(1);
2395 type = object_store->legacy_string_type();
2396 type_args.SetTypeAt(0, type);
2397 type_args = type_args.Canonicalize(thread);
2398 object_store->set_type_argument_legacy_string(type_args);
2399
2400 type_args = TypeArguments::New(2);
2401 type = object_store->string_type();
2402 type_args.SetTypeAt(0, type);
2403 type_args.SetTypeAt(1, Object::dynamic_type());
2404 type_args = type_args.Canonicalize(thread);
2405 object_store->set_type_argument_string_dynamic(type_args);
2406
2407 type_args = TypeArguments::New(2);
2408 type = object_store->string_type();
2409 type_args.SetTypeAt(0, type);
2410 type_args.SetTypeAt(1, type);
2411 type_args = type_args.Canonicalize(thread);
2412 object_store->set_type_argument_string_string(type_args);
2413
2414 lib = Library::LookupLibrary(thread, Symbols::DartFfi());
2415 if (lib.IsNull()) {
2416 lib = Library::NewLibraryHelper(Symbols::DartFfi(), true);
2417 lib.SetLoadRequested();
2418 lib.Register(thread);
2419 }
2420 object_store->set_bootstrap_library(ObjectStore::kFfi, lib);
2421
2422 cls = Class::New<Instance, RTN::Instance>(kFfiNativeTypeCid, isolate_group);
2423 cls.set_num_type_arguments_unsafe(0);
2424 cls.set_is_prefinalized();
2425 pending_classes.Add(cls);
2426 object_store->set_ffi_native_type_class(cls);
2427 RegisterClass(cls, Symbols::FfiNativeType(), lib);
2428
2429#define REGISTER_FFI_TYPE_MARKER(clazz) \
2430 cls = Class::New<Instance, RTN::Instance>(kFfi##clazz##Cid, isolate_group); \
2431 cls.set_num_type_arguments_unsafe(0); \
2432 cls.set_is_prefinalized(); \
2433 pending_classes.Add(cls); \
2434 RegisterClass(cls, Symbols::Ffi##clazz(), lib);
2436#undef REGISTER_FFI_TYPE_MARKER
2437
2438 cls = Class::New<Instance, RTN::Instance>(kFfiNativeFunctionCid,
2439 isolate_group);
2440 cls.set_type_arguments_field_offset(Instance::NextFieldOffset(),
2441 RTN::Instance::NextFieldOffset());
2442 cls.set_num_type_arguments_unsafe(1);
2443 cls.set_is_prefinalized();
2444 pending_classes.Add(cls);
2445 RegisterClass(cls, Symbols::FfiNativeFunction(), lib);
2446
2447 cls = Class::NewPointerClass(kPointerCid, isolate_group);
2448 object_store->set_ffi_pointer_class(cls);
2449 pending_classes.Add(cls);
2450 RegisterClass(cls, Symbols::FfiPointer(), lib);
2451
2452 cls = Class::New<DynamicLibrary, RTN::DynamicLibrary>(kDynamicLibraryCid,
2453 isolate_group);
2454 cls.set_instance_size(DynamicLibrary::InstanceSize(),
2455 compiler::target::RoundedAllocationSize(
2456 RTN::DynamicLibrary::InstanceSize()));
2457 cls.set_is_prefinalized();
2458 pending_classes.Add(cls);
2459 RegisterClass(cls, Symbols::FfiDynamicLibrary(), lib);
2460
2461 cls = Class::New<NativeFinalizer, RTN::NativeFinalizer>(isolate_group);
2462 object_store->set_native_finalizer_class(cls);
2463 RegisterPrivateClass(cls, Symbols::_NativeFinalizer(), lib);
2464
2465 cls = Class::New<Finalizer, RTN::Finalizer>(isolate_group);
2466 cls.set_type_arguments_field_offset(
2468 RTN::Finalizer::type_arguments_offset());
2469 cls.set_num_type_arguments_unsafe(1);
2470 object_store->set_finalizer_class(cls);
2471 pending_classes.Add(cls);
2472 RegisterPrivateClass(cls, Symbols::_FinalizerImpl(), core_lib);
2473
2474 // Pre-register the internal library so we can place the vm class
2475 // FinalizerEntry there rather than the core library.
2476 lib = Library::LookupLibrary(thread, Symbols::DartInternal());
2477 if (lib.IsNull()) {
2478 lib = Library::NewLibraryHelper(Symbols::DartInternal(), true);
2479 lib.SetLoadRequested();
2480 lib.Register(thread);
2481 }
2482 object_store->set_bootstrap_library(ObjectStore::kInternal, lib);
2483 ASSERT(!lib.IsNull());
2484 ASSERT(lib.ptr() == Library::InternalLibrary());
2485
2486 cls = Class::New<FinalizerEntry, RTN::FinalizerEntry>(isolate_group);
2487 object_store->set_finalizer_entry_class(cls);
2488 pending_classes.Add(cls);
2489 RegisterClass(cls, Symbols::FinalizerEntry(), lib);
2490
2491 // Finish the initialization by compiling the bootstrap scripts containing
2492 // the base interfaces and the implementation of the internal classes.
2493 const Error& error = Error::Handle(
2494 zone, Bootstrap::DoBootstrapping(kernel_buffer, kernel_buffer_size));
2495 if (!error.IsNull()) {
2496 return error.ptr();
2497 }
2498
2499 isolate_group->class_table()->CopySizesFromClassObjects();
2500
2502
2503 // Set up the intrinsic state of all functions (core, math and typed data).
2505
2506 // Adds static const fields (class ids) to the class 'ClassID');
2507 lib = Library::LookupLibrary(thread, Symbols::DartInternal());
2508 ASSERT(!lib.IsNull());
2509 cls = lib.LookupClassAllowPrivate(Symbols::ClassID());
2510 ASSERT(!cls.IsNull());
2511 const bool injected = cls.InjectCIDFields();
2512 ASSERT(injected);
2513
2514 // Set up recognized state of all functions (core, math and typed data).
2516#endif // !defined(DART_PRECOMPILED_RUNTIME)
2517 } else {
2518 // Object::Init version when we are running in a version of dart that has a
2519 // full snapshot linked in and an isolate is initialized using the full
2520 // snapshot.
2521 ObjectStore* object_store = isolate_group->object_store();
2522 SafepointWriteRwLocker ml(thread, isolate_group->program_lock());
2523
2524 Class& cls = Class::Handle(zone);
2525
2526 // Set up empty classes in the object store, these will get initialized
2527 // correctly when we read from the snapshot. This is done to allow
2528 // bootstrapping of reading classes from the snapshot. Some classes are not
2529 // stored in the object store. Yet we still need to create their Class
2530 // object so that they get put into the class_table (as a side effect of
2531 // Class::New()).
2532 cls = Class::New<Instance, RTN::Instance>(kInstanceCid, isolate_group);
2533 object_store->set_object_class(cls);
2534
2535 cls = Class::New<LibraryPrefix, RTN::LibraryPrefix>(isolate_group);
2536 cls = Class::New<Type, RTN::Type>(isolate_group);
2537 cls = Class::New<FunctionType, RTN::FunctionType>(isolate_group);
2538 cls = Class::New<RecordType, RTN::RecordType>(isolate_group);
2539 cls = Class::New<TypeParameter, RTN::TypeParameter>(isolate_group);
2540
2541 cls = Class::New<Array, RTN::Array>(isolate_group);
2542 object_store->set_array_class(cls);
2543
2544 cls = Class::New<Array, RTN::Array>(kImmutableArrayCid, isolate_group);
2545 object_store->set_immutable_array_class(cls);
2546
2547 cls = Class::New<GrowableObjectArray, RTN::GrowableObjectArray>(
2548 isolate_group);
2549 object_store->set_growable_object_array_class(cls);
2550
2551 cls = Class::New<Map, RTN::Map>(isolate_group);
2552 object_store->set_map_impl_class(cls);
2553
2554 cls = Class::New<Map, RTN::Map>(kConstMapCid, isolate_group);
2555 object_store->set_const_map_impl_class(cls);
2556
2557 cls = Class::New<Set, RTN::Set>(isolate_group);
2558 object_store->set_set_impl_class(cls);
2559
2560 cls = Class::New<Set, RTN::Set>(kConstSetCid, isolate_group);
2561 object_store->set_const_set_impl_class(cls);
2562
2563 cls = Class::New<Float32x4, RTN::Float32x4>(isolate_group);
2564 object_store->set_float32x4_class(cls);
2565
2566 cls = Class::New<Int32x4, RTN::Int32x4>(isolate_group);
2567 object_store->set_int32x4_class(cls);
2568
2569 cls = Class::New<Float64x2, RTN::Float64x2>(isolate_group);
2570 object_store->set_float64x2_class(cls);
2571
2572#define REGISTER_TYPED_DATA_CLASS(clazz) \
2573 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid, isolate_group);
2575#undef REGISTER_TYPED_DATA_CLASS
2576#define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \
2577 cls = \
2578 Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid, isolate_group); \
2579 cls = Class::NewUnmodifiableTypedDataViewClass( \
2580 kUnmodifiableTypedData##clazz##ViewCid, isolate_group);
2582#undef REGISTER_TYPED_DATA_VIEW_CLASS
2583 cls = Class::NewTypedDataViewClass(kByteDataViewCid, isolate_group);
2585 isolate_group);
2586#define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \
2587 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid, \
2588 isolate_group);
2590#undef REGISTER_EXT_TYPED_DATA_CLASS
2591
2592 cls = Class::New<Instance, RTN::Instance>(kFfiNativeTypeCid, isolate_group);
2593 object_store->set_ffi_native_type_class(cls);
2594
2595#define REGISTER_FFI_CLASS(clazz) \
2596 cls = Class::New<Instance, RTN::Instance>(kFfi##clazz##Cid, isolate_group);
2598#undef REGISTER_FFI_CLASS
2599
2600 cls = Class::New<Instance, RTN::Instance>(kFfiNativeFunctionCid,
2601 isolate_group);
2602
2603 cls = Class::NewPointerClass(kPointerCid, isolate_group);
2604 object_store->set_ffi_pointer_class(cls);
2605
2606 cls = Class::New<DynamicLibrary, RTN::DynamicLibrary>(kDynamicLibraryCid,
2607 isolate_group);
2608
2609 cls = Class::New<Instance, RTN::Instance>(kByteBufferCid, isolate_group,
2610 /*register_isolate_group=*/false);
2611 cls.set_instance_size_in_words(0, 0);
2612 isolate_group->class_table()->Register(cls);
2613
2614 cls = Class::New<Integer, RTN::Integer>(isolate_group);
2615 object_store->set_integer_implementation_class(cls);
2616
2617 cls = Class::New<Smi, RTN::Smi>(isolate_group);
2618 object_store->set_smi_class(cls);
2619
2620 cls = Class::New<Mint, RTN::Mint>(isolate_group);
2621 object_store->set_mint_class(cls);
2622
2623 cls = Class::New<Double, RTN::Double>(isolate_group);
2624 object_store->set_double_class(cls);
2625
2626 cls = Class::New<Closure, RTN::Closure>(isolate_group);
2627 object_store->set_closure_class(cls);
2628
2629 cls = Class::New<Record, RTN::Record>(isolate_group);
2630
2631 cls = Class::NewStringClass(kOneByteStringCid, isolate_group);
2632 object_store->set_one_byte_string_class(cls);
2633
2634 cls = Class::NewStringClass(kTwoByteStringCid, isolate_group);
2635 object_store->set_two_byte_string_class(cls);
2636
2637 cls = Class::New<Bool, RTN::Bool>(isolate_group);
2638 object_store->set_bool_class(cls);
2639
2640 cls = Class::New<Instance, RTN::Instance>(kNullCid, isolate_group);
2641 object_store->set_null_class(cls);
2642
2643 cls = Class::New<Instance, RTN::Instance>(kNeverCid, isolate_group);
2644 object_store->set_never_class(cls);
2645
2646 cls = Class::New<Capability, RTN::Capability>(isolate_group);
2647 cls = Class::New<ReceivePort, RTN::ReceivePort>(isolate_group);
2648 cls = Class::New<SendPort, RTN::SendPort>(isolate_group);
2649 cls = Class::New<StackTrace, RTN::StackTrace>(isolate_group);
2650 cls = Class::New<SuspendState, RTN::SuspendState>(isolate_group);
2651 cls = Class::New<RegExp, RTN::RegExp>(isolate_group);
2652 cls = Class::New<Number, RTN::Number>(isolate_group);
2653
2654 cls = Class::New<WeakProperty, RTN::WeakProperty>(isolate_group);
2655 object_store->set_weak_property_class(cls);
2656 cls = Class::New<WeakReference, RTN::WeakReference>(isolate_group);
2657 object_store->set_weak_reference_class(cls);
2658 cls = Class::New<Finalizer, RTN::Finalizer>(isolate_group);
2659 object_store->set_finalizer_class(cls);
2660 cls = Class::New<NativeFinalizer, RTN::NativeFinalizer>(isolate_group);
2661 object_store->set_native_finalizer_class(cls);
2662 cls = Class::New<FinalizerEntry, RTN::FinalizerEntry>(isolate_group);
2663 object_store->set_finalizer_entry_class(cls);
2664
2665 cls = Class::New<MirrorReference, RTN::MirrorReference>(isolate_group);
2666 cls = Class::New<UserTag, RTN::UserTag>(isolate_group);
2667 cls = Class::New<FutureOr, RTN::FutureOr>(isolate_group);
2668 object_store->set_future_or_class(cls);
2669 cls = Class::New<TransferableTypedData, RTN::TransferableTypedData>(
2670 isolate_group);
2671 }
2672 return Error::null();
2673}
#define CLASS_LIST_FFI_TYPE_MARKER(V)
Definition class_id.h:165
#define CLASS_LIST_TYPED_DATA(V)
Definition class_id.h:137
#define DART_CLASS_LIST_TYPED_DATA(V)
Definition class_id.h:177
static ErrorPtr DoBootstrapping(const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
Definition bootstrap.cc:219
static void VerifyBootstrapClasses()
static ClassPtr NewTypedDataViewClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition object.cc:5333
static ClassPtr NewPointerClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition object.cc:5393
static ClassPtr NewUnmodifiableTypedDataViewClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition object.cc:5353
static Snapshot::Kind vm_snapshot_kind()
Definition dart.h:95
static intptr_t InstanceSize()
Definition object.h:11900
static intptr_t type_arguments_offset()
Definition object.h:13046
static intptr_t type_arguments_offset()
Definition object.h:13181
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition object.h:11118
static intptr_t NextFieldOffset()
Definition object.h:8326
static LibraryPtr CoreLibrary()
Definition object.cc:14834
static LibraryPtr MirrorsLibrary()
Definition object.cc:14863
static LibraryPtr IsolateLibrary()
Definition object.cc:14854
static LibraryPtr CollectionLibrary()
Definition object.cc:14838
static LibraryPtr AsyncLibrary()
Definition object.cc:14826
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
Definition object.cc:14646
static LibraryPtr InternalLibrary()
Definition object.cc:14850
static void InitNativeWrappersLibrary(IsolateGroup *isolate_group, bool is_kernel_file)
Definition object.cc:14590
static void InitCoreLibrary(IsolateGroup *isolate_group)
Definition object.cc:14349
static LibraryPtr DeveloperLibrary()
Definition object.cc:14842
static LibraryPtr TypedDataLibrary()
Definition object.cc:14872
static intptr_t type_arguments_offset()
Definition object.h:11960
static void SetupSymbolTable(IsolateGroup *isolate_group)
Definition symbols.cc:168
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition object.cc:7733
static TypePtr NewNonParameterizedType(const Class &type_class)
Definition object.cc:21946
static intptr_t type_arguments_offset()
Definition object.h:12926
const uint8_t uint32_t uint32_t GError ** error
const char *const name
@ kByteDataViewCid
Definition class_id.h:244
@ kByteBufferCid
Definition class_id.h:247
@ kUnmodifiableByteDataViewCid
Definition class_id.h:245
#define TIMELINE_DURATION(thread, stream, name)
Definition timeline.h:39
#define REGISTER_TYPED_DATA_CLASS(clazz)
#define REGISTER_FFI_CLASS(clazz)
#define REGISTER_EXT_TYPED_DATA_CLASS(clazz)
#define REGISTER_TYPED_DATA_VIEW_CLASS(clazz)
#define REGISTER_FFI_TYPE_MARKER(clazz)

◆ InitNullAndBool()

void dart::Object::InitNullAndBool ( IsolateGroup isolate_group)
static

Definition at line 554 of file object.cc.

554 {
555 // Should only be run by the vm isolate.
556 ASSERT(isolate_group == Dart::vm_isolate_group());
557 Thread* thread = Thread::Current();
558 auto heap = isolate_group->heap();
559
560 // TODO(iposva): NoSafepointScope needs to be added here.
561 ASSERT(class_class() == null_);
562
563 // Allocate and initialize the null instance.
564 // 'null_' must be the first object allocated as it is used in allocation to
565 // clear the pointer fields of objects.
566 {
567 uword address =
568 heap->Allocate(thread, Instance::InstanceSize(), Heap::kOld);
569 null_ = static_cast<InstancePtr>(address + kHeapObjectTag);
570 InitializeObjectVariant<Instance>(address, kNullCid);
571 null_->untag()->SetCanonical();
572 }
573
574 // Allocate and initialize the bool instances.
575 // These must be allocated such that at kBoolValueBitPosition, the address
576 // of true is 0 and the address of false is 1, and their addresses are
577 // otherwise identical.
578 {
579 // Allocate a dummy bool object to give true the desired alignment.
580 uword address = heap->Allocate(thread, Bool::InstanceSize(), Heap::kOld);
581 InitializeObject<Bool>(address);
582 static_cast<BoolPtr>(address + kHeapObjectTag)->untag()->value_ = false;
583 }
584 {
585 // Allocate true.
586 uword address = heap->Allocate(thread, Bool::InstanceSize(), Heap::kOld);
587 true_ = static_cast<BoolPtr>(address + kHeapObjectTag);
588 InitializeObject<Bool>(address);
589 true_->untag()->value_ = true;
590 true_->untag()->SetCanonical();
591 }
592 {
593 // Allocate false.
594 uword address = heap->Allocate(thread, Bool::InstanceSize(), Heap::kOld);
595 false_ = static_cast<BoolPtr>(address + kHeapObjectTag);
596 InitializeObject<Bool>(address);
597 false_->untag()->value_ = false;
598 false_->untag()->SetCanonical();
599 }
600
601 // Check that the objects have been allocated at appropriate addresses.
602 ASSERT(static_cast<uword>(true_) ==
603 static_cast<uword>(null_) + kTrueOffsetFromNull);
604 ASSERT(static_cast<uword>(false_) ==
605 static_cast<uword>(null_) + kFalseOffsetFromNull);
606 ASSERT((static_cast<uword>(true_) & kBoolValueMask) == 0);
607 ASSERT((static_cast<uword>(false_) & kBoolValueMask) != 0);
608 ASSERT(static_cast<uword>(false_) ==
609 (static_cast<uword>(true_) | kBoolValueMask));
610 ASSERT((static_cast<uword>(null_) & kBoolVsNullMask) == 0);
611 ASSERT((static_cast<uword>(true_) & kBoolVsNullMask) != 0);
612 ASSERT((static_cast<uword>(false_) & kBoolVsNullMask) != 0);
613}
static intptr_t InstanceSize()
Definition object.h:10772
static intptr_t InstanceSize()
Definition object.h:8308
static constexpr intptr_t kBoolValueMask
static constexpr intptr_t kFalseOffsetFromNull
static constexpr intptr_t kBoolVsNullMask
static constexpr intptr_t kTrueOffsetFromNull

◆ InitVtables()

void dart::Object::InitVtables ( )
static

Definition at line 615 of file object.cc.

615 {
616 {
617 Object fake_handle;
618 builtin_vtables_[kObjectCid] = fake_handle.vtable();
619 }
620
621#define INIT_VTABLE(clazz) \
622 { \
623 clazz fake_handle; \
624 builtin_vtables_[k##clazz##Cid] = fake_handle.vtable(); \
625 }
627 INIT_VTABLE(GrowableObjectArray)
628#undef INIT_VTABLE
629
630#define INIT_VTABLE(clazz) \
631 { \
632 Map fake_handle; \
633 builtin_vtables_[k##clazz##Cid] = fake_handle.vtable(); \
634 }
636#undef INIT_VTABLE
637
638#define INIT_VTABLE(clazz) \
639 { \
640 Set fake_handle; \
641 builtin_vtables_[k##clazz##Cid] = fake_handle.vtable(); \
642 }
644#undef INIT_VTABLE
645
646#define INIT_VTABLE(clazz) \
647 { \
648 Array fake_handle; \
649 builtin_vtables_[k##clazz##Cid] = fake_handle.vtable(); \
650 }
652#undef INIT_VTABLE
653
654#define INIT_VTABLE(clazz) \
655 { \
656 String fake_handle; \
657 builtin_vtables_[k##clazz##Cid] = fake_handle.vtable(); \
658 }
660#undef INIT_VTABLE
661
662 {
663 Instance fake_handle;
664 builtin_vtables_[kFfiNativeTypeCid] = fake_handle.vtable();
665 }
666
667#define INIT_VTABLE(clazz) \
668 { \
669 Instance fake_handle; \
670 builtin_vtables_[kFfi##clazz##Cid] = fake_handle.vtable(); \
671 }
673#undef INIT_VTABLE
674
675 {
676 Instance fake_handle;
677 builtin_vtables_[kFfiNativeFunctionCid] = fake_handle.vtable();
678 }
679
680 {
681 Pointer fake_handle;
682 builtin_vtables_[kPointerCid] = fake_handle.vtable();
683 }
684
685 {
686 DynamicLibrary fake_handle;
687 builtin_vtables_[kDynamicLibraryCid] = fake_handle.vtable();
688 }
689
690#define INIT_VTABLE(clazz) \
691 { \
692 TypedData fake_internal_handle; \
693 builtin_vtables_[kTypedData##clazz##Cid] = fake_internal_handle.vtable(); \
694 TypedDataView fake_view_handle; \
695 builtin_vtables_[kTypedData##clazz##ViewCid] = fake_view_handle.vtable(); \
696 builtin_vtables_[kUnmodifiableTypedData##clazz##ViewCid] = \
697 fake_view_handle.vtable(); \
698 ExternalTypedData fake_external_handle; \
699 builtin_vtables_[kExternalTypedData##clazz##Cid] = \
700 fake_external_handle.vtable(); \
701 }
703#undef INIT_VTABLE
704
705 {
706 TypedDataView fake_handle;
707 builtin_vtables_[kByteDataViewCid] = fake_handle.vtable();
708 builtin_vtables_[kUnmodifiableByteDataViewCid] = fake_handle.vtable();
709 }
710
711 {
712 Instance fake_handle;
713 builtin_vtables_[kByteBufferCid] = fake_handle.vtable();
714 builtin_vtables_[kNullCid] = fake_handle.vtable();
715 builtin_vtables_[kDynamicCid] = fake_handle.vtable();
716 builtin_vtables_[kVoidCid] = fake_handle.vtable();
717 builtin_vtables_[kNeverCid] = fake_handle.vtable();
718 }
719}
#define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY_NOR_MAP(V)
Definition class_id.h:113
#define CLASS_LIST_MAPS(V)
Definition class_id.h:116
#define CLASS_LIST_STRINGS(V)
Definition class_id.h:132
#define CLASS_LIST_SETS(V)
Definition class_id.h:120
#define CLASS_LIST_FIXED_LENGTH_ARRAYS(V)
Definition class_id.h:124
#define INIT_VTABLE(clazz)

◆ InstanceSize()

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

Definition at line 592 of file object.h.

592 {
593 return RoundedAllocationSize(sizeof(UntaggedObject));
594 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ instructions_class()

static ClassPtr dart::Object::instructions_class ( )
inlinestatic

Definition at line 532 of file object.h.

532{ return instructions_class_; }

◆ instructions_section_class()

static ClassPtr dart::Object::instructions_section_class ( )
inlinestatic

Definition at line 533 of file object.h.

533 {
534 return instructions_section_class_;
535 }

◆ instructions_table_class()

static ClassPtr dart::Object::instructions_table_class ( )
inlinestatic

Definition at line 536 of file object.h.

536 {
537 return instructions_table_class_;
538 }

◆ InVMIsolateHeap()

bool dart::Object::InVMIsolateHeap ( ) const
inline

Definition at line 395 of file object.h.

395{ return ptr()->untag()->InVMIsolateHeap(); }
bool InVMIsolateHeap() const
Definition raw_object.cc:20

◆ IsCanonical()

bool dart::Object::IsCanonical ( ) const
inline

Definition at line 335 of file object.h.

335{ return ptr()->untag()->IsCanonical(); }
bool IsCanonical() const
Definition raw_object.h:329

◆ IsImmutable()

bool dart::Object::IsImmutable ( ) const
inline

Definition at line 338 of file object.h.

338{ return ptr()->untag()->IsImmutable(); }
bool IsImmutable() const
Definition raw_object.h:333

◆ IsNew()

bool dart::Object::IsNew ( ) const
inline

Definition at line 390 of file object.h.

390{ return ptr()->IsNewObject(); }

◆ IsNull()

bool dart::Object::IsNull ( ) const
inline

Definition at line 363 of file object.h.

363{ return ptr_ == null_; }

◆ IsOld()

bool dart::Object::IsOld ( ) const
inline

Definition at line 391 of file object.h.

391{ return ptr()->IsOldObject(); }

◆ JSONType()

virtual const char * dart::Object::JSONType ( ) const
inlinevirtual

Definition at line 380 of file object.h.

380{ return IsNull() ? "null" : "Object"; }

◆ kernel_program_info_class()

static ClassPtr dart::Object::kernel_program_info_class ( )
inlinestatic

Definition at line 528 of file object.h.

528 {
529 return kernel_program_info_class_;
530 }

◆ language_error_class()

static ClassPtr dart::Object::language_error_class ( )
inlinestatic

Definition at line 553 of file object.h.

553{ return language_error_class_; }

◆ library_class()

static ClassPtr dart::Object::library_class ( )
inlinestatic

Definition at line 526 of file object.h.

526{ return library_class_; }

◆ loadingunit_class()

static ClassPtr dart::Object::loadingunit_class ( )
inlinestatic

Definition at line 566 of file object.h.

566{ return loadingunit_class_; }

◆ LoadNonPointer() [1/2]

template<typename FieldType >
FieldType dart::Object::LoadNonPointer ( const FieldType *  addr) const
inlineprotected

Definition at line 806 of file object.h.

806 {
807 return *const_cast<FieldType*>(addr);
808 }

◆ LoadNonPointer() [2/2]

template<typename FieldType , std::memory_order order>
FieldType dart::Object::LoadNonPointer ( const FieldType *  addr) const
inlineprotected

Definition at line 811 of file object.h.

811 {
812 return reinterpret_cast<std::atomic<FieldType>*>(
813 const_cast<FieldType*>(addr))
814 ->load(order);
815 }

◆ LoadPointer()

template<typename type , std::memory_order order = std::memory_order_relaxed>
type dart::Object::LoadPointer ( type const *  addr) const
inlineprotected

Definition at line 771 of file object.h.

771 {
772 return ptr()->untag()->LoadPointer<type, order>(addr);
773 }
type LoadPointer(type const *addr) const
Definition raw_object.h:555

◆ MakeUnusedSpaceTraversable()

void dart::Object::MakeUnusedSpaceTraversable ( const Object obj,
intptr_t  original_size,
intptr_t  used_size 
)
static

Definition at line 1610 of file object.cc.

1612 {
1613 ASSERT(Thread::Current()->no_safepoint_scope_depth() > 0);
1614 ASSERT(!obj.IsNull());
1615 ASSERT(original_size >= used_size);
1616 if (original_size > used_size) {
1617 intptr_t leftover_size = original_size - used_size;
1618
1619 uword addr = UntaggedObject::ToAddr(obj.ptr()) + used_size;
1620 if (leftover_size >= TypedData::InstanceSize(0)) {
1621 // Update the leftover space as a TypedDataInt8Array object.
1622 TypedDataPtr raw =
1623 static_cast<TypedDataPtr>(UntaggedObject::FromAddr(addr));
1624 uword new_tags =
1625 UntaggedObject::ClassIdTag::update(kTypedDataInt8ArrayCid, 0);
1626 new_tags = UntaggedObject::SizeTag::update(leftover_size, new_tags);
1627 const bool is_old = obj.ptr()->IsOldObject();
1628 new_tags = UntaggedObject::AlwaysSetBit::update(true, new_tags);
1629 new_tags = UntaggedObject::NotMarkedBit::update(true, new_tags);
1630 new_tags =
1632 new_tags = UntaggedObject::NewBit::update(!is_old, new_tags);
1633 // On architectures with a relaxed memory model, the concurrent marker may
1634 // observe the write of the filler object's header before observing the
1635 // new array length, and so treat it as a pointer. Ensure it is a Smi so
1636 // the marker won't dereference it.
1637 ASSERT((new_tags & kSmiTagMask) == kSmiTag);
1638
1639 intptr_t leftover_len = (leftover_size - TypedData::InstanceSize(0));
1640 ASSERT(TypedData::InstanceSize(leftover_len) == leftover_size);
1641 raw->untag()->set_length<std::memory_order_release>(
1642 Smi::New(leftover_len));
1643 raw->untag()->tags_ = new_tags;
1644 raw->untag()->RecomputeDataField();
1645 } else {
1646 // Update the leftover space as a basic object.
1647 ASSERT(leftover_size == Object::InstanceSize());
1648 ObjectPtr raw = static_cast<ObjectPtr>(UntaggedObject::FromAddr(addr));
1649 uword new_tags = UntaggedObject::ClassIdTag::update(kInstanceCid, 0);
1650 new_tags = UntaggedObject::SizeTag::update(leftover_size, new_tags);
1651 const bool is_old = obj.ptr()->IsOldObject();
1652 new_tags = UntaggedObject::AlwaysSetBit::update(true, new_tags);
1653 new_tags = UntaggedObject::NotMarkedBit::update(true, new_tags);
1654 new_tags =
1656 new_tags = UntaggedObject::NewBit::update(!is_old, new_tags);
1657 // On architectures with a relaxed memory model, the concurrent marker may
1658 // observe the write of the filler object's header before observing the
1659 // new array length, and so treat it as a pointer. Ensure it is a Smi so
1660 // the marker won't dereference it.
1661 ASSERT((new_tags & kSmiTagMask) == kSmiTag);
1662
1663 // The array might have an uninitialized alignment gap since the visitors
1664 // for Arrays are precise based on element count, but the visitors for
1665 // Instance are based on the size rounded to the allocation unit, so we
1666 // need to ensure the alignment gap is initialized.
1667 for (intptr_t offset = Instance::UnroundedSize();
1668 offset < Instance::InstanceSize(); offset += sizeof(uword)) {
1669 reinterpret_cast<std::atomic<uword>*>(addr + offset)
1670 ->store(0, std::memory_order_release);
1671 }
1672 raw->untag()->tags_ = new_tags;
1673 }
1674 }
1675}
SI void store(P *ptr, const T &val)
static intptr_t UnroundedSize()
Definition object.h:8307
static intptr_t InstanceSize()
Definition object.h:592
static intptr_t InstanceSize()
Definition object.h:11647
static constexpr uword update(intptr_t size, uword tag)
Definition raw_object.h:209
static ObjectPtr FromAddr(uword addr)
Definition raw_object.h:495
Point offset

◆ megamorphic_cache_class()

static ClassPtr dart::Object::megamorphic_cache_class ( )
inlinestatic

Definition at line 564 of file object.h.

564{ return megamorphic_cache_class_; }

◆ monomorphicsmiablecall_class()

static ClassPtr dart::Object::monomorphicsmiablecall_class ( )
inlinestatic

Definition at line 560 of file object.h.

560 {
561 return monomorphicsmiablecall_class_;
562 }

◆ namespace_class()

static ClassPtr dart::Object::namespace_class ( )
inlinestatic

Definition at line 527 of file object.h.

527{ return namespace_class_; }

◆ null()

static ObjectPtr dart::Object::null ( )
inlinestatic

Definition at line 433 of file object.h.

433{ return null_; }

◆ object_pool_class()

static ClassPtr dart::Object::object_pool_class ( )
inlinestatic

Definition at line 539 of file object.h.

539{ return object_pool_class_; }

◆ operator=()

void dart::Object::operator= ( ObjectPtr  value)
inline

Definition at line 333 of file object.h.

333{ initializeHandle(this, value); }

◆ patch_class_class()

static ClassPtr dart::Object::patch_class_class ( )
inlinestatic

Definition at line 518 of file object.h.

518{ return patch_class_class_; }

◆ pc_descriptors_class()

static ClassPtr dart::Object::pc_descriptors_class ( )
inlinestatic

Definition at line 540 of file object.h.

540{ return pc_descriptors_class_; }

◆ Print()

void dart::Object::Print ( ) const

Definition at line 2681 of file object.cc.

2681 {
2682 THR_Print("%s\n", ToCString());
2683}
virtual const char * ToCString() const
Definition object.h:366
#define THR_Print(format,...)
Definition log.h:20

◆ PrintImplementationFields()

void dart::Object::PrintImplementationFields ( JSONStream stream) const

Definition at line 82 of file object_service.cc.

82 {
83 JSONObject jsobj(stream);
84 jsobj.AddProperty("type", "ImplementationFields");
85 JSONArray jsarr_fields(&jsobj, "fields");
86 if (!IsNull()) {
88 }
89}
virtual void PrintImplementationFieldsImpl(const JSONArray &jsarr_fields) const

◆ PrintImplementationFieldsImpl()

void dart::Object::PrintImplementationFieldsImpl ( const JSONArray jsarr_fields) const
virtual

Definition at line 77 of file object_service.cc.

78 {
80}

◆ PrintJSON()

void dart::Object::PrintJSON ( JSONStream stream,
bool  ref = true 
) const

Definition at line 65 of file object_service.cc.

65 {
66 if (IsNull()) {
67 JSONObject jsobj(stream);
68 AddCommonObjectProperties(&jsobj, "Instance", ref);
69 jsobj.AddProperty("kind", "Null");
70 jsobj.AddFixedServiceId("objects/null");
71 jsobj.AddProperty("valueAsString", "null");
72 } else {
73 PrintJSONImpl(stream, ref);
74 }
75}
void AddCommonObjectProperties(JSONObject *jsobj, const char *protocol_type, bool ref) const
virtual void PrintJSONImpl(JSONStream *stream, bool ref) const

◆ PrintJSONImpl()

void dart::Object::PrintJSONImpl ( JSONStream stream,
bool  ref 
) const
virtual

Definition at line 56 of file object_service.cc.

56 {
57 JSONObject jsobj(stream);
58 AddCommonObjectProperties(&jsobj, "Object", ref);
59 jsobj.AddServiceId(*this);
60 if (ref) {
61 return;
62 }
63}

◆ ptr()

ObjectPtr dart::Object::ptr ( ) const
inline

Definition at line 332 of file object.h.

332{ return ptr_; }

◆ raw_value()

uword dart::Object::raw_value ( ) const
inlineprotected

Definition at line 670 of file object.h.

670{ return static_cast<uword>(ptr()); }

◆ RawCast()

static ObjectPtr dart::Object::RawCast ( ObjectPtr  obj)
inlinestatic

Definition at line 325 of file object.h.

325{ return obj; }

◆ ReadOnlyHandle()

static Object * dart::Object::ReadOnlyHandle ( )
inlinestatic

Definition at line 431 of file object.h.

431{ return ReadOnlyHandleImpl(kObjectCid); }
static DART_NOINLINE Object * ReadOnlyHandleImpl(intptr_t cid)
Definition object.h:689

◆ ReadOnlyHandleImpl()

static DART_NOINLINE Object * dart::Object::ReadOnlyHandleImpl ( intptr_t  cid)
inlinestaticprotected

Definition at line 689 of file object.h.

689 {
690 Object* obj = reinterpret_cast<Object*>(Dart::AllocateReadOnlyHandle());
691 obj->setPtr(Object::null(), cid);
692 return obj;
693 }
static uword AllocateReadOnlyHandle()
Definition dart.cc:1123

◆ RoundedAllocationSize()

static constexpr intptr_t dart::Object::RoundedAllocationSize ( intptr_t  size)
inlinestaticconstexprprotected

Definition at line 758 of file object.h.

758 {
759 return Utils::RoundUp(size, kObjectAlignment);
760 }
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition utils.h:105

◆ script_class()

static ClassPtr dart::Object::script_class ( )
inlinestatic

Definition at line 525 of file object.h.

525{ return script_class_; }

◆ sentinel_class()

static ClassPtr dart::Object::sentinel_class ( )
inlinestatic

Definition at line 551 of file object.h.

551{ return sentinel_class_; }

◆ set_vm_isolate_snapshot_object_table()

void dart::Object::set_vm_isolate_snapshot_object_table ( const Array table)
static

Definition at line 1601 of file object.cc.

1601 {
1603 *vm_isolate_snapshot_object_table_ = table.ptr();
1604}
static Isolate * vm_isolate()
Definition dart.h:68
static Isolate * Current()
Definition isolate.h:939

◆ set_vtable()

void dart::Object::set_vtable ( cpp_vtable  value)
inlineprotected

Definition at line 706 of file object.h.

706 {
707 memcpy(reinterpret_cast<void*>(this), &value, // NOLINT
708 sizeof(cpp_vtable));
709 }
uword cpp_vtable
Definition globals.h:163

◆ SetCanonical()

void dart::Object::SetCanonical ( ) const
inline

Definition at line 336 of file object.h.

336{ ptr()->untag()->SetCanonical(); }

◆ SetImmutable()

void dart::Object::SetImmutable ( ) const
inline

Definition at line 339 of file object.h.

339{ ptr()->untag()->SetImmutable(); }

◆ setPtr()

DART_FORCE_INLINE void dart::Object::setPtr ( ObjectPtr  value,
intptr_t  default_cid 
)
inlineprotected

Definition at line 13201 of file object.h.

13201 {
13202 ptr_ = value;
13203 intptr_t cid = value->GetClassIdMayBeSmi();
13204 // Free-list elements cannot be wrapped in a handle.
13207 if (cid == kNullCid) {
13208 cid = default_cid;
13209 } else if (cid >= kNumPredefinedCids) {
13210 cid = kInstanceCid;
13211 }
13212 set_vtable(builtin_vtables_[cid]);
13213}
void set_vtable(cpp_vtable value)
Definition object.h:706
uint8_t value

◆ ShouldHaveImmutabilityBitSet()

bool dart::Object::ShouldHaveImmutabilityBitSet ( classid_t  class_id)
static

Definition at line 2689 of file object.cc.

2689 {
2690 if (class_id < kNumPredefinedCids) {
2691 return ShouldHaveImmutabilityBitSetCid(class_id);
2692 } else {
2694 IsolateGroup::Current()->class_table()->At(class_id));
2695 }
2696}
static bool IsDeeplyImmutable(ClassPtr clazz)
Definition object.h:2167
bool ShouldHaveImmutabilityBitSetCid(intptr_t predefined_cid)
Definition class_id.h:507

◆ singletargetcache_class()

static ClassPtr dart::Object::singletargetcache_class ( )
inlinestatic

Definition at line 558 of file object.h.

558{ return singletargetcache_class_; }

◆ StoreCompressedPointer()

template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void dart::Object::StoreCompressedPointer ( compressed_type const *  addr,
type  value 
) const
inlineprotected

Definition at line 782 of file object.h.

782 {
783 ptr()->untag()->StoreCompressedPointer<type, compressed_type, order>(addr,
784 value);
785 }
void StoreCompressedPointer(compressed_type const *addr, type value)
Definition raw_object.h:585

◆ StoreNonPointer() [1/2]

template<typename FieldType , typename ValueType >
void dart::Object::StoreNonPointer ( const FieldType *  addr,
ValueType  value 
) const
inlineprotected

Definition at line 819 of file object.h.

819 {
820 // Can't use Contains, as it uses tags_, which is set through this method.
821 ASSERT(reinterpret_cast<uword>(addr) >= UntaggedObject::ToAddr(ptr()));
822 *const_cast<FieldType*>(addr) = value;
823 }

◆ StoreNonPointer() [2/2]

template<typename FieldType , typename ValueType , std::memory_order order>
void dart::Object::StoreNonPointer ( const FieldType *  addr,
ValueType  value 
) const
inlineprotected

Definition at line 826 of file object.h.

826 {
827 // Can't use Contains, as it uses tags_, which is set through this method.
828 ASSERT(reinterpret_cast<uword>(addr) >= UntaggedObject::ToAddr(ptr()));
829 reinterpret_cast<std::atomic<FieldType>*>(const_cast<FieldType*>(addr))
830 ->store(value, order);
831 }

◆ StorePointer()

template<typename type , std::memory_order order = std::memory_order_relaxed>
void dart::Object::StorePointer ( type const *  addr,
type  value 
) const
inlineprotected

Definition at line 776 of file object.h.

776 {
777 ptr()->untag()->StorePointer<type, order>(addr, value);
778 }
void StorePointer(type const *addr, type value)
Definition raw_object.h:574

◆ StorePointerUnaligned()

template<typename type >
void dart::Object::StorePointerUnaligned ( type const *  addr,
type  value,
Thread thread 
) const
inlineprotected

Definition at line 787 of file object.h.

789 {
790 ptr()->untag()->StorePointerUnaligned<type>(addr, value, thread);
791 }
void StorePointerUnaligned(type const *addr, type value, Thread *thread)
Definition raw_object.h:613

◆ StoreSimd128()

template<typename FieldType >
void dart::Object::StoreSimd128 ( const FieldType *  addr,
simd128_value_t  value 
) const
inlineprotected

Definition at line 800 of file object.h.

800 {
801 ASSERT(Contains(reinterpret_cast<uword>(addr)));
802 value.writeTo(const_cast<FieldType*>(addr));
803 }
bool Contains(uword addr) const
Definition object.h:762

◆ StoreSmi()

void dart::Object::StoreSmi ( SmiPtr const *  addr,
SmiPtr  value 
) const
inlineprotected

Definition at line 795 of file object.h.

795 {
796 ptr()->untag()->StoreSmi(addr, value);
797 }
void StoreSmi(type const *addr, type value)
Definition raw_object.h:702

◆ subtypetestcache_class()

static ClassPtr dart::Object::subtypetestcache_class ( )
inlinestatic

Definition at line 565 of file object.h.

565{ return subtypetestcache_class_; }

◆ tags_offset()

static intptr_t dart::Object::tags_offset ( )
inlinestatic

Definition at line 346 of file object.h.

346{ return OFFSET_OF(UntaggedObject, tags_); }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ to_offset()

template<typename T >
static DART_FORCE_INLINE uword dart::Object::to_offset ( intptr_t  length = 0)
inlinestaticprotected

Definition at line 893 of file object.h.

893 {
894 return UntaggedObject::to_offset<typename T::UntaggedObjectType>(length);
895 }
size_t length

◆ ToCString()

virtual const char * dart::Object::ToCString ( ) const
inlinevirtual

Definition at line 366 of file object.h.

366 {
367 if (IsNull()) {
368 return "null";
369 } else {
370 return "Object";
371 }
372 }

◆ type_arguments_class()

static ClassPtr dart::Object::type_arguments_class ( )
inlinestatic

Definition at line 517 of file object.h.

517{ return type_arguments_class_; }

◆ type_parameters_class()

static ClassPtr dart::Object::type_parameters_class ( )
inlinestatic

Definition at line 516 of file object.h.

516{ return type_parameters_class_; }

◆ unhandled_exception_class()

static ClassPtr dart::Object::unhandled_exception_class ( )
inlinestatic

Definition at line 554 of file object.h.

554 {
555 return unhandled_exception_class_;
556 }

◆ UnimplementedMethod()

void dart::Object::UnimplementedMethod ( ) const
protected

◆ unlinkedcall_class()

static ClassPtr dart::Object::unlinkedcall_class ( )
inlinestatic

Definition at line 559 of file object.h.

559{ return unlinkedcall_class_; }

◆ UnsafeMutableNonPointer()

template<typename FieldType >
FieldType * dart::Object::UnsafeMutableNonPointer ( const FieldType *  addr) const
inlineprotected

Definition at line 837 of file object.h.

837 {
838 // Allow pointers at the end of variable-length data, and disallow pointers
839 // within the header word.
840 ASSERT(Contains(reinterpret_cast<uword>(addr) - 1) &&
841 Contains(reinterpret_cast<uword>(addr) - kWordSize));
842 // At least check that there is a NoSafepointScope and hope it's big enough.
843 ASSERT(Thread::Current()->no_safepoint_scope_depth() > 0);
844 return const_cast<FieldType*>(addr);
845 }

◆ unwind_error_class()

static ClassPtr dart::Object::unwind_error_class ( )
inlinestatic

Definition at line 557 of file object.h.

557{ return unwind_error_class_; }

◆ var_descriptors_class()

static ClassPtr dart::Object::var_descriptors_class ( )
inlinestatic

Definition at line 545 of file object.h.

545{ return var_descriptors_class_; }

◆ VerifyBuiltinVtable()

template<class FakeObject >
static void dart::Object::VerifyBuiltinVtable ( intptr_t  cid)
inlinestatic

Definition at line 597 of file object.h.

597 {
598 FakeObject fake;
599 if (cid >= kNumPredefinedCids) {
600 cid = kInstanceCid;
601 }
602 ASSERT(builtin_vtables_[cid] == fake.vtable());
603 }

◆ VerifyBuiltinVtables()

void dart::Object::VerifyBuiltinVtables ( )
static

Definition at line 1677 of file object.cc.

1677 {
1678#if defined(DEBUG)
1679 ASSERT(builtin_vtables_[kIllegalCid] == 0);
1680 ASSERT(builtin_vtables_[kFreeListElement] == 0);
1681 ASSERT(builtin_vtables_[kForwardingCorpse] == 0);
1682 ClassTable* table = IsolateGroup::Current()->class_table();
1683 for (intptr_t cid = kObjectCid; cid < kNumPredefinedCids; cid++) {
1684 if (table->HasValidClassAt(cid)) {
1685 ASSERT(builtin_vtables_[cid] != 0);
1686 }
1687 }
1688#endif
1689}

◆ void_class()

static ClassPtr dart::Object::void_class ( )
inlinestatic

Definition at line 515 of file object.h.

515{ return void_class_; }

◆ vtable()

cpp_vtable dart::Object::vtable ( ) const
inlineprotected

Definition at line 700 of file object.h.

700 {
702 memcpy(&result, reinterpret_cast<const void*>(this), // NOLINT
703 sizeof(result));
704 return result;
705 }
GAsyncResult * result

◆ weak_array_class()

static ClassPtr dart::Object::weak_array_class ( )
inlinestatic

Definition at line 570 of file object.h.

570{ return weak_array_class_; }

◆ weak_serialization_reference_class()

static ClassPtr dart::Object::weak_serialization_reference_class ( )
inlinestatic

Definition at line 567 of file object.h.

567 {
568 return weak_serialization_reference_class_;
569 }

◆ ZoneHandle() [1/4]

static Object & dart::Object::ZoneHandle ( )
inlinestatic

Definition at line 419 of file object.h.

419 {
420 return ZoneHandleImpl(Thread::Current()->zone(), null_, kObjectCid);
421 }
static DART_NOINLINE Object & ZoneHandleImpl(Zone *zone, ObjectPtr ptr, intptr_t default_cid)
Definition object.h:681

◆ ZoneHandle() [2/4]

static Object & dart::Object::ZoneHandle ( ObjectPtr  ptr)
inlinestatic

Definition at line 425 of file object.h.

425 {
426 return ZoneHandleImpl(Thread::Current()->zone(), ptr, kObjectCid);
427 }

◆ ZoneHandle() [3/4]

static Object & dart::Object::ZoneHandle ( Zone zone)
inlinestatic

Definition at line 422 of file object.h.

422 {
423 return ZoneHandleImpl(zone, null_, kObjectCid);
424 }

◆ ZoneHandle() [4/4]

static Object & dart::Object::ZoneHandle ( Zone zone,
ObjectPtr  ptr 
)
inlinestatic

Definition at line 428 of file object.h.

428 {
429 return ZoneHandleImpl(zone, ptr, kObjectCid);
430 }

◆ ZoneHandleImpl()

static DART_NOINLINE Object & dart::Object::ZoneHandleImpl ( Zone zone,
ObjectPtr  ptr,
intptr_t  default_cid 
)
inlinestaticprotected

Definition at line 681 of file object.h.

683 {
684 Object* obj =
685 reinterpret_cast<Object*>(VMHandles::AllocateZoneHandle(zone));
686 obj->setPtr(ptr, default_cid);
687 return *obj;
688 }
static uword AllocateZoneHandle(Zone *zone)
Definition handles.cc:42

Friends And Related Symbol Documentation

◆ AllocateObject

ObjectPtr AllocateObject ( intptr_t  cid,
intptr_t  size,
intptr_t  allocated_bytes 
)
friend

Definition at line 248 of file object_graph_copy.cc.

250 {
251#if defined(DART_COMPRESSED_POINTERS)
252 const bool compressed = true;
253#else
254 const bool compressed = false;
255#endif
256 const intptr_t kLargeMessageThreshold = 16 * MB;
257 const Heap::Space space =
258 allocated_bytes > kLargeMessageThreshold ? Heap::kOld : Heap::kNew;
259 // Mimic the old initialization behavior of Object::InitializeObject where
260 // the contents are initialized to Object::null(), except for TypedDataBase
261 // subclasses which are initialized to 0, as the contents of the original
262 // are translated and copied over prior to returning the object graph root.
264 return Object::Allocate(cid, size, space, compressed,
265 Object::from_offset<TypedDataBase>(),
266 Object::to_offset<TypedDataBase>());
267
268 } else {
269 // Remember that ptr_field_end_offset is the offset to the last Ptr
270 // field, not the offset just past it.
271 const uword ptr_field_end_offset =
272 size - (compressed ? kCompressedWordSize : kWordSize);
273 return Object::Allocate(cid, size, space, compressed,
274 Object::from_offset<Object>(),
275 ptr_field_end_offset);
276 }
277}
constexpr intptr_t MB
Definition globals.h:530
bool IsTypedDataBaseClassId(intptr_t index)
Definition class_id.h:429
static constexpr intptr_t kCompressedWordSize
Definition globals.h:42

◆ ClassTable::Register

void ClassTable::Register ( const Class cls)
friend

◆ Closure

friend class Closure
friend

Definition at line 1019 of file object.h.

◆ InstanceDeserializationCluster

friend class InstanceDeserializationCluster
friend

Definition at line 1020 of file object.h.

◆ ObjectGraphCopier

friend class ObjectGraphCopier
friend

Definition at line 1021 of file object.h.

◆ OneByteString

friend class OneByteString
friend

Definition at line 1023 of file object.h.

◆ Simd128MessageDeserializationCluster

Definition at line 1022 of file object.h.

◆ Thread

friend class Thread
friend

Definition at line 1025 of file object.h.

◆ TwoByteString

friend class TwoByteString
friend

Definition at line 1024 of file object.h.

◆ UntaggedObject::Validate

void UntaggedObject::Validate ( IsolateGroup isolate_group) const
friend

Member Data Documentation

◆ kClassId

const ClassId dart::Object::kClassId = kObjectCid
static

Definition at line 606 of file object.h.

◆ kHashBits

constexpr intptr_t dart::Object::kHashBits = 30
staticconstexpr

Definition at line 323 of file object.h.

◆ ptr_

ObjectPtr dart::Object::ptr_
protected

Definition at line 870 of file object.h.


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