Flutter Engine
The Flutter Engine
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.

657 {
658 kYes,
659 kNo,
660 };
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

◆ 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:13218
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)
Definition: raw_object.cc:558

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

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

2764 {
2766 Thread* thread = Thread::Current();
2767 ASSERT(thread->execution_state() == Thread::kThreadInVM);
2768 ASSERT(thread->no_safepoint_scope_depth() == 0);
2769 ASSERT(thread->no_callback_scope_depth() == 0);
2770 Heap* heap = thread->heap();
2771
2772 uword address = heap->Allocate(thread, size, space);
2773 if (UNLIKELY(address == 0)) {
2774 // SuspendLongJumpScope during Dart entry ensures that if a longjmp base is
2775 // available, it is the innermost error handler, so check for a longjmp base
2776 // before checking for an exit frame.
2777 if (thread->long_jump_base() != nullptr) {
2778 Report::LongJump(Object::out_of_memory_error());
2779 UNREACHABLE();
2780 } else if (thread->top_exit_frame_info() != 0) {
2781 // Use the preallocated out of memory exception to avoid calling
2782 // into dart code or allocating any code.
2784 UNREACHABLE();
2785 } else {
2786 // Nowhere to propagate an exception to.
2787 OUT_OF_MEMORY();
2788 }
2789 }
2790
2791 ObjectPtr raw_obj;
2792 NoSafepointScope no_safepoint(thread);
2793 InitializeObject(address, cls_id, size, compressed, ptr_field_start_offset,
2794 ptr_field_end_offset);
2795 raw_obj = static_cast<ObjectPtr>(address + kHeapObjectTag);
2796 ASSERT(cls_id == UntaggedObject::ClassIdTag::decode(raw_obj->untag()->tags_));
2797 if (raw_obj->IsOldObject() && UNLIKELY(thread->is_marking())) {
2798 // Black allocation. Prevents a data race between the mutator and
2799 // concurrent marker on ARM and ARM64 (the marker may observe a
2800 // publishing store of this object before the stores that initialize its
2801 // slots), and helps the collection to finish sooner.
2802 // release: Setting the mark bit must not be ordered after a publishing
2803 // store of this object. Compare Scavenger::ScavengePointer.
2804 raw_obj->untag()->SetMarkBitRelease();
2805 heap->old_space()->AllocateBlack(size);
2806 }
2807
2808#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
2809 HeapProfileSampler& heap_sampler = thread->heap_sampler();
2810 if (heap_sampler.HasOutstandingSample()) {
2811 thread->IncrementNoCallbackScopeDepth();
2812 void* data = heap_sampler.InvokeCallbackForLastSample(cls_id);
2813 heap->SetHeapSamplingData(raw_obj, data);
2814 thread->DecrementNoCallbackScopeDepth();
2815 }
2816#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
2817
2818#if !defined(PRODUCT)
2819 auto class_table = thread->isolate_group()->class_table();
2820 if (class_table->ShouldTraceAllocationFor(cls_id)) {
2821 uint32_t hash =
2822 HeapSnapshotWriter::GetHeapSnapshotIdentityHash(thread, raw_obj);
2823 Profiler::SampleAllocation(thread, cls_id, hash);
2824 }
2825#endif // !defined(PRODUCT)
2826 return raw_obj;
2827}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
#define UNREACHABLE()
Definition: assert.h:248
#define OUT_OF_MEMORY()
Definition: assert.h:250
static constexpr ClassIdTagType decode(uword value)
Definition: bitfield.h:171
static DART_NORETURN void ThrowOOM()
Definition: exceptions.cc:1066
friend class Thread
Definition: object.h:1025
static void SampleAllocation(Thread *thread, intptr_t cid, uint32_t identity_hash)
Definition: profiler.cc:1271
static DART_NORETURN void LongJump(const Error &error)
Definition: report.cc:86
static Thread * Current()
Definition: thread.h:362
static constexpr bool IsAligned(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:92
#define ASSERT(E)
uintptr_t uword
Definition: globals.h:501
static constexpr intptr_t kObjectAlignment
static int8_t data[kExtLength]
@ kHeapObjectTag
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
#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 2747 of file object.cc.

2747 {
2748#if defined(DEBUG)
2749 if (ptr_ != Object::null()) {
2750 intptr_t cid = ptr_->GetClassIdMayBeSmi();
2751 if (cid >= kNumPredefinedCids) {
2752 cid = kInstanceCid;
2753 }
2754 ASSERT(vtable() == builtin_vtables_[cid]);
2755 }
2756#endif
2757}
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 13218 of file object.h.

13218 {
13219 uword raw_value = static_cast<uword>(ptr_);
13220 if ((raw_value & kSmiTagMask) == kSmiTag) {
13221 return Smi::Class();
13222 }
13224}
ClassPtr At(intptr_t cid) const
Definition: class_table.h:362
static IsolateGroup * Current()
Definition: isolate.h:539
ClassTable * class_table() const
Definition: isolate.h:496
intptr_t GetClassId() const
Definition: object.h:341
uword raw_value() const
Definition: object.h:670
friend class Class
Definition: object.h:10047
@ kSmiTagMask

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

2901 {
2902 // Generic function types should be cloned with FunctionType::Clone.
2903 ASSERT(!orig.IsFunctionType() || !FunctionType::Cast(orig).IsGeneric());
2904 const Class& cls = Class::Handle(orig.clazz());
2905 intptr_t size = orig.ptr()->untag()->HeapSize();
2906 // All fields (including non-SmiPtr fields) will be initialized with Smi 0,
2907 // but the contents of the original object are copied over before the thread
2908 // is allowed to reach a safepoint.
2909 ObjectPtr raw_clone =
2910 Object::Allocate(cls.id(), size, space, cls.HasCompressedPointers(),
2911 from_offset<Object>(), to_offset<Object>());
2912 NoSafepointScope no_safepoint;
2913 // Copy the body of the original into the clone.
2914 uword orig_addr = UntaggedObject::ToAddr(orig.ptr());
2915 uword clone_addr = UntaggedObject::ToAddr(raw_clone);
2916 const intptr_t kHeaderSizeInBytes = sizeof(UntaggedObject);
2917 if (load_with_relaxed_atomics) {
2918 auto orig_atomics_ptr = reinterpret_cast<std::atomic<uword>*>(orig_addr);
2919 auto clone_ptr = reinterpret_cast<uword*>(clone_addr);
2920 for (intptr_t i = kHeaderSizeInBytes / kWordSize; i < size / kWordSize;
2921 i++) {
2922 *(clone_ptr + i) =
2923 (orig_atomics_ptr + i)->load(std::memory_order_relaxed);
2924 }
2925 } else {
2926 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes),
2927 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes),
2928 size - kHeaderSizeInBytes);
2929 }
2930
2931 if (IsTypedDataClassId(raw_clone->GetClassId())) {
2932 auto raw_typed_data = TypedData::RawCast(raw_clone);
2933 raw_typed_data.untag()->RecomputeDataField();
2934 }
2935
2936 // Add clone to store buffer, if needed.
2937 if (!raw_clone->IsOldObject()) {
2938 // No need to remember an object in new space.
2939 return raw_clone;
2940 }
2941 WriteBarrierUpdateVisitor visitor(Thread::Current(), raw_clone);
2942 raw_clone->untag()->VisitPointers(&visitor);
2943 return raw_clone;
2944}
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
static uword ToAddr(const UntaggedObject *raw_obj)
Definition: raw_object.h:522
bool IsTypedDataClassId(intptr_t index)
Definition: class_id.h:433
constexpr intptr_t kWordSize
Definition: globals.h:509

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

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

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

2624 {
2625 return String::null();
2626}

◆ 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);
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);
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:6225
static intptr_t UnroundedSize(CompressedStackMapsPtr maps)
Definition: object.h:6293
static intptr_t UnroundedSize(OneByteStringPtr str)
Definition: object.h:10558
static intptr_t UnroundedSize(PcDescriptorsPtr desc)
Definition: object.h:6085
static uint32_t SetCachedHashIfNotSet(StringPtr obj, uint32_t hash)
Definition: object.h:10449
uword Hash() const
Definition: object.h:10216
static uint32_t GetCachedHash(const StringPtr obj)
Definition: object.h:10445
static intptr_t UnroundedSize(TwoByteStringPtr str)
Definition: object.h:10698
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:692
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 }
intptr_t GetClassId() const
Definition: raw_object.h:392

◆ 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(
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,
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(),
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(),
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(
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:10928
static intptr_t InstanceSize()
Definition: object.h:10936
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.h:10959
static constexpr S update(T value, S original)
Definition: bitfield.h:188
static intptr_t InstanceSize()
Definition: object.h:1685
static ClassPtr NewExternalTypedDataClass(intptr_t class_id, IsolateGroup *isolate)
Definition: object.cc:5318
static ClassPtr NewTypedDataClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition: object.cc:5259
static constexpr intptr_t kNoTypeArguments
Definition: object.h:1374
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
Definition: object.cc:3053
static ClassPtr NewStringClass(intptr_t class_id, IsolateGroup *isolate_group)
Definition: object.cc:5232
static intptr_t InstanceSize()
Definition: object.h:6299
static intptr_t InstanceSize()
Definition: object.h:7535
static intptr_t InstanceSize()
Definition: object.h:6606
static intptr_t type_arguments_offset()
Definition: object.h:11129
@ kOld
Definition: heap.h:39
static intptr_t InstanceSize()
Definition: object.h:6055
static intptr_t InstanceSize()
Definition: object.h:5649
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:6089
@ kBailout
Definition: report.h:26
static SentinelPtr New()
Definition: object.cc:18729
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
static SmiPtr Sentinel()
Definition: object.cc:7173
static intptr_t InstanceSize()
Definition: object.h:8988
static TypePtr New(const Class &clazz, const TypeArguments &arguments, Nullability nullability=Nullability::kNonNullable, Heap::Space space=Heap::kOld)
static UnwindErrorPtr New(const String &message, Heap::Space space=Heap::kNew)
Definition: object.cc:20005
static word type_arguments_offset()
static const word kNoTypeArguments
Definition: runtime_api.h:486
intptr_t RoundedAllocationSize(intptr_t size)
Definition: runtime_api.h:333
ArrayOfTuplesView< TypeArguments::Cache::Entry, std::tuple< Object, TypeArguments, TypeArguments >, TypeArguments::Cache::kHeaderSize > InstantiationsCacheTable
Definition: object.h:13566
@ 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:13558
#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 1678 of file object.cc.

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

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

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

◆ 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 uword addr = UntaggedObject::ToAddr(obj.ptr()) + used_size;
1619 if (obj.ptr()->IsNewObject()) {
1620 FreeListElement::AsElementNew(addr, leftover_size);
1621 } else {
1622 FreeListElement::AsElement(addr, leftover_size);
1623 }
1624 // On architectures with a relaxed memory model, the concurrent marker may
1625 // observe the write of the filler object's header before observing the
1626 // new array length, and so treat it as a pointer. Ensure it is a Smi so
1627 // the marker won't dereference it.
1628 ASSERT((*reinterpret_cast<uword*>(addr) & kSmiTagMask) == kSmiTag);
1629 ASSERT((*reinterpret_cast<uword*>(addr + kWordSize) & kSmiTagMask) ==
1630 kSmiTag);
1631 }
1632}
static FreeListElement * AsElementNew(uword addr, intptr_t size)
Definition: freelist.cc:43
static FreeListElement * AsElement(uword addr, intptr_t size)
Definition: freelist.cc:16

◆ 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); }
uint8_t 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 2620 of file object.cc.

2620 {
2621 THR_Print("%s\n", ToCString());
2622}
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 {
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:1131

◆ RoundedAllocationSize()

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

Definition at line 758 of file object.h.

758 {
760 }
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120

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

◆ 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 13227 of file object.h.

13227 {
13228 ptr_ = value;
13229 intptr_t cid = value->GetClassIdMayBeSmi();
13230 // Free-list elements cannot be wrapped in a handle.
13233 if (cid == kNullCid) {
13234 cid = default_cid;
13235 } else if (cid >= kNumPredefinedCids) {
13236 cid = kInstanceCid;
13237 }
13238 set_vtable(builtin_vtables_[cid]);
13239}
void set_vtable(cpp_vtable value)
Definition: object.h:706

◆ ShouldHaveImmutabilityBitSet()

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

Definition at line 2628 of file object.cc.

2628 {
2629 if (class_id < kNumPredefinedCids) {
2630 return ShouldHaveImmutabilityBitSetCid(class_id);
2631 } else {
2633 IsolateGroup::Current()->class_table()->At(class_id));
2634 }
2635}
static bool IsDeeplyImmutable(ClassPtr clazz)
Definition: object.h:2177
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:606

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

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

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

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

1634 {
1635#if defined(DEBUG)
1636 ASSERT(builtin_vtables_[kIllegalCid] == 0);
1637 ASSERT(builtin_vtables_[kFreeListElement] == 0);
1638 ASSERT(builtin_vtables_[kForwardingCorpse] == 0);
1639 ClassTable* table = IsolateGroup::Current()->class_table();
1640 for (intptr_t cid = kObjectCid; cid < kNumPredefinedCids; cid++) {
1641 if (table->HasValidClassAt(cid)) {
1642 ASSERT(builtin_vtables_[cid] != 0);
1643 }
1644 }
1645#endif
1646}

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