27 return heap->old_space()->ContainsUnsafe(
ToAddr(
this));
32 if (!IsHeapObject()) {
37 FATAL(
"RAW_NULL encountered");
52 FATAL(
"New object missing kNewBit: %" Px "\n",
tags);
55 FATAL(
"New object has kOldAndNotRememberedBit: %" Px "\n",
tags);
60 FATAL(
"Invalid class id encountered %" Pd "\n", class_id);
68 intptr_t size_from_class = HeapSizeFromClass(
tags);
69 if ((size_from_tags != 0) && (size_from_tags != size_from_class)) {
71 "Inconsistent size encountered "
72 "cid: %" Pd ", size_from_tags: %" Pd ", size_from_class: %" Pd "\n",
73 class_id, size_from_tags, size_from_class);
81intptr_t UntaggedObject::HeapSizeFromClass(
uword tags)
const {
83 intptr_t instance_size = 0;
86 const CodePtr raw_code =
static_cast<const CodePtr
>(
this);
87 intptr_t pointer_offsets_length =
92 case kInstructionsCid: {
93 const InstructionsPtr raw_instructions =
94 static_cast<const InstructionsPtr
>(
this);
99 case kInstructionsSectionCid: {
100 const InstructionsSectionPtr raw_section =
101 static_cast<const InstructionsSectionPtr
>(
this);
107 const ContextPtr raw_context =
static_cast<const ContextPtr
>(
this);
108 intptr_t num_variables = raw_context->untag()->num_variables_;
112 case kContextScopeCid: {
113 const ContextScopePtr raw_context_scope =
114 static_cast<const ContextScopePtr
>(
this);
115 intptr_t num_variables = raw_context_scope->untag()->num_variables_;
119 case kOneByteStringCid: {
120 const OneByteStringPtr raw_string =
121 static_cast<const OneByteStringPtr
>(
this);
122 intptr_t string_length =
Smi::Value(raw_string->untag()->length());
126 case kTwoByteStringCid: {
127 const TwoByteStringPtr raw_string =
128 static_cast<const TwoByteStringPtr
>(
this);
129 intptr_t string_length =
Smi::Value(raw_string->untag()->length());
134 case kImmutableArrayCid: {
135 const ArrayPtr raw_array =
static_cast<const ArrayPtr
>(
this);
136 intptr_t array_length =
137 Smi::Value(raw_array->untag()->length<std::memory_order_acquire>());
141 case kWeakArrayCid: {
142 const WeakArrayPtr raw_array =
static_cast<const WeakArrayPtr
>(
this);
143 intptr_t array_length =
Smi::Value(raw_array->untag()->length());
147 case kObjectPoolCid: {
148 const ObjectPoolPtr raw_object_pool =
149 static_cast<const ObjectPoolPtr
>(
this);
150 intptr_t
len = raw_object_pool->untag()->length_;
155 const RecordPtr raw_record =
static_cast<const RecordPtr
>(
this);
156 intptr_t num_fields =
157 RecordShape(raw_record->untag()->shape()).num_fields();
161#define SIZE_FROM_CLASS(clazz) case kTypedData##clazz##Cid:
163 const TypedDataPtr raw_obj =
static_cast<const TypedDataPtr
>(
this);
164 intptr_t array_len =
Smi::Value(raw_obj->untag()->length());
165 intptr_t lengthInBytes =
170#undef SIZE_FROM_CLASS
174 case kSuspendStateCid: {
175 const SuspendStatePtr raw_suspend_state =
176 static_cast<const SuspendStatePtr
>(
this);
177 intptr_t frame_capacity = raw_suspend_state->untag()->frame_capacity();
181 case kTypeArgumentsCid: {
182 const TypeArgumentsPtr raw_array =
183 static_cast<const TypeArgumentsPtr
>(
this);
184 intptr_t array_length =
Smi::Value(raw_array->untag()->length());
188 case kPcDescriptorsCid: {
189 const PcDescriptorsPtr raw_descriptors =
190 static_cast<const PcDescriptorsPtr
>(
this);
191 intptr_t
length = raw_descriptors->untag()->length_;
195 case kCodeSourceMapCid: {
196 const CodeSourceMapPtr raw_code_source_map =
197 static_cast<const CodeSourceMapPtr
>(
this);
198 intptr_t
length = raw_code_source_map->untag()->length_;
202 case kCompressedStackMapsCid: {
203 const CompressedStackMapsPtr maps =
204 static_cast<const CompressedStackMapsPtr
>(
this);
209 case kLocalVarDescriptorsCid: {
210 const LocalVarDescriptorsPtr raw_descriptors =
211 static_cast<const LocalVarDescriptorsPtr
>(
this);
212 intptr_t num_descriptors = raw_descriptors->untag()->num_entries_;
216 case kExceptionHandlersCid: {
217 const ExceptionHandlersPtr raw_handlers =
218 static_cast<const ExceptionHandlersPtr
>(
this);
219 intptr_t num_handlers = raw_handlers->untag()->num_entries();
226 instance_size = element->HeapSize(
tags);
231 ForwardingCorpse* element =
reinterpret_cast<ForwardingCorpse*
>(
addr);
232 instance_size = element->HeapSize(
tags);
235 case kWeakSerializationReferenceCid: {
244 auto class_table = isolate_group->heap_walk_class_table();
245 if (!class_table->IsValidIndex(class_id) ||
246 !class_table->HasValidClassAt(class_id)) {
247 FATAL(
"Invalid cid: %" Pd ", obj: %p, tags: %x. Corrupt heap?",
248 class_id,
this,
static_cast<uint32_t
>(
tags));
250 ASSERT(class_table->SizeAt(class_id) > 0);
252 instance_size = isolate_group->heap_walk_class_table()->SizeAt(class_id);
255 ASSERT(instance_size != 0);
258 if ((class_id == kArrayCid) && (instance_size > tags_size && tags_size > 0)) {
262 int retries_remaining = 1000;
265 const ArrayPtr raw_array =
static_cast<const ArrayPtr
>(
this);
266 intptr_t array_length =
Smi::Value(raw_array->untag()->length());
268 }
while ((instance_size > tags_size) && (--retries_remaining > 0));
270 if ((instance_size != tags_size) && (tags_size != 0)) {
271 FATAL(
"Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n",
272 instance_size, tags_size,
tags);
275 return instance_size;
278intptr_t UntaggedObject::VisitPointersPredefined(ObjectPointerVisitor* visitor,
285#define RAW_VISITPOINTERS(clazz) \
286 case k##clazz##Cid: { \
287 clazz##Ptr raw_obj = static_cast<clazz##Ptr>(this); \
288 size = Untagged##clazz::Visit##clazz##Pointers(raw_obj, visitor); \
292#undef RAW_VISITPOINTERS
293#define RAW_VISITPOINTERS(clazz) case kTypedData##clazz##Cid:
295 TypedDataPtr raw_obj =
static_cast<TypedDataPtr
>(
this);
296 size = UntaggedTypedData::VisitTypedDataPointers(raw_obj, visitor);
299#undef RAW_VISITPOINTERS
300#define RAW_VISITPOINTERS(clazz) case kExternalTypedData##clazz##Cid:
302 auto raw_obj =
static_cast<ExternalTypedDataPtr
>(
this);
303 size = UntaggedExternalTypedData::VisitExternalTypedDataPointers(raw_obj,
307#undef RAW_VISITPOINTERS
310#define RAW_VISITPOINTERS(clazz) \
311 case kTypedData##clazz##ViewCid: \
312 case kUnmodifiableTypedData##clazz##ViewCid:
314 auto raw_obj =
static_cast<TypedDataViewPtr
>(
this);
316 UntaggedTypedDataView::VisitTypedDataViewPointers(raw_obj, visitor);
319#undef RAW_VISITPOINTERS
321 InstancePtr raw_obj =
static_cast<InstancePtr
>(
this);
322 size = UntaggedInstance::VisitInstancePointers(raw_obj, visitor);
325#define RAW_VISITPOINTERS(clazz) case kFfi##clazz##Cid:
331#undef RAW_VISITPOINTERS
335 size = element->HeapSize();
340 ForwardingCorpse* forwarder =
reinterpret_cast<ForwardingCorpse*
>(
addr);
341 size = forwarder->HeapSize();
349 FATAL(
"Invalid cid: %" Pd ", obj: %p, tags: %x. Corrupt heap?", class_id,
350 this,
static_cast<uint32_t
>(tags_));
356 const intptr_t expected_size =
HeapSize();
364 (class_id == kArrayCid &&
size > expected_size));
374 VisitPointersPredefined(visitor, class_id);
382 ->host_next_field_offset_in_words_
384 ASSERT(next_field_offset > 0);
391 const auto unboxed_fields_bitmap =
394 if (!unboxed_fields_bitmap.IsEmpty()) {
397 if (!unboxed_fields_bitmap.Get(bit++)) {
409#define REGULAR_VISITOR(Type) \
410 intptr_t Untagged##Type::Visit##Type##Pointers( \
411 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
413 ASSERT(raw_obj->IsHeapObject()); \
414 ASSERT_UNCOMPRESSED(Type); \
415 visitor->VisitPointers(raw_obj->untag()->from(), raw_obj->untag()->to()); \
416 return Type::InstanceSize(); \
419#if !defined(DART_COMPRESSED_POINTERS)
420#define COMPRESSED_VISITOR(Type) REGULAR_VISITOR(Type)
422#define COMPRESSED_VISITOR(Type) \
423 intptr_t Untagged##Type::Visit##Type##Pointers( \
424 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
426 ASSERT(raw_obj->IsHeapObject()); \
427 ASSERT_COMPRESSED(Type); \
428 visitor->VisitCompressedPointers(raw_obj->heap_base(), \
429 raw_obj->untag()->from(), \
430 raw_obj->untag()->to()); \
431 return Type::InstanceSize(); \
440#define TYPED_DATA_VIEW_VISITOR(Type) \
441 intptr_t Untagged##Type::Visit##Type##Pointers( \
442 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
444 ASSERT(raw_obj->IsHeapObject()); \
445 ASSERT_COMPRESSED(Type); \
446 visitor->VisitTypedDataViewPointers(raw_obj, raw_obj->untag()->from(), \
447 raw_obj->untag()->to()); \
448 return Type::InstanceSize(); \
453#define VARIABLE_VISITOR(Type, get_length) \
454 intptr_t Untagged##Type::Visit##Type##Pointers( \
455 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
457 ASSERT(raw_obj->IsHeapObject()); \
458 intptr_t length = get_length; \
459 visitor->VisitPointers(raw_obj->untag()->from(), \
460 raw_obj->untag()->to(length)); \
461 return Type::InstanceSize(length); \
464#if !defined(DART_COMPRESSED_POINTERS)
465#define VARIABLE_COMPRESSED_VISITOR(Type, get_length) \
466 VARIABLE_VISITOR(Type, get_length)
468#define VARIABLE_COMPRESSED_VISITOR(Type, get_length) \
469 intptr_t Untagged##Type::Visit##Type##Pointers( \
470 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
472 ASSERT(raw_obj->IsHeapObject()); \
473 intptr_t length = get_length; \
474 visitor->VisitCompressedPointers(raw_obj->heap_base(), \
475 raw_obj->untag()->from(), \
476 raw_obj->untag()->to(length)); \
477 return Type::InstanceSize(length); \
482#define NULL_VISITOR(Type) \
483 intptr_t Untagged##Type::Visit##Type##Pointers( \
484 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
486 ASSERT(raw_obj->IsHeapObject()); \
487 ASSERT_NOTHING_TO_VISIT(Type); \
488 return Type::InstanceSize(); \
493#define VARIABLE_NULL_VISITOR(Type, get_length) \
494 intptr_t Untagged##Type::Visit##Type##Pointers( \
495 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
497 ASSERT(raw_obj->IsHeapObject()); \
498 ASSERT_NOTHING_TO_VISIT(Type); \
499 intptr_t length = get_length; \
500 return Type::InstanceSize(length); \
504#define UNREACHABLE_VISITOR(Type) \
505 intptr_t Untagged##Type::Visit##Type##Pointers( \
506 Type##Ptr raw_obj, ObjectPointerVisitor* visitor) { \
563 TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *
604 ASSERT(raw_obj->IsHeapObject());
606 visitor->VisitCompressedPointers(
607 raw_obj->heap_base(), raw_obj->untag()->from(), raw_obj->untag()->to());
609 if (visitor->trace_values_through_fields()) {
611 visitor->isolate_group()->ForEachIsolate(
614 Smi::Value(raw_obj->untag()->host_offset_or_field_id());
623intptr_t UntaggedSuspendState::VisitSuspendStatePointers(
624 SuspendStatePtr raw_obj,
625 ObjectPointerVisitor* visitor) {
626 ASSERT(raw_obj->IsHeapObject());
629 if (visitor->CanVisitSuspendStatePointers(raw_obj)) {
630 visitor->VisitCompressedPointers(
631 raw_obj->heap_base(), raw_obj->untag()->from(), raw_obj->untag()->to());
633 const uword pc = raw_obj->untag()->pc_;
636 ASSERT(thread !=
nullptr);
637 ASSERT(thread->isolate_group() == visitor->isolate_group());
638 const uword sp =
reinterpret_cast<uword>(raw_obj->untag()->payload());
642 frame.fp_ = sp + raw_obj->untag()->frame_size_;
643 frame.VisitObjectPointers(visitor);
650bool UntaggedCode::ContainsPC(
const ObjectPtr raw_obj,
uword pc) {
651 if (!raw_obj->IsCode())
return false;
652 auto const raw_code =
static_cast<const CodePtr
>(raw_obj);
655 return (pc - start) <=
size;
658intptr_t UntaggedCode::VisitCodePointers(CodePtr raw_obj,
659 ObjectPointerVisitor* visitor) {
660 visitor->VisitPointers(raw_obj->untag()->from(), raw_obj->untag()->to());
662 UntaggedCode* obj = raw_obj->untag();
664#if defined(TARGET_ARCH_IA32)
671 int32_t
offset = obj->data()[
i];
672 visitor->VisitPointer(
reinterpret_cast<ObjectPtr*
>(entry_point +
offset));
684intptr_t UntaggedObjectPool::VisitObjectPoolPointers(
685 ObjectPoolPtr raw_obj,
686 ObjectPointerVisitor* visitor) {
687 const intptr_t
length = raw_obj->untag()->length_;
689 uint8_t* entry_bits = raw_obj->untag()->entry_bits();
693 if (entry_type == ObjectPool::EntryType::kTaggedObject) {
694 visitor->VisitPointer(&entries[
i].raw_obj_);
700bool UntaggedInstructions::ContainsPC(
const InstructionsPtr raw_instr,
707 return (pc - start) <=
size;
710intptr_t UntaggedInstance::VisitInstancePointers(
712 ObjectPointerVisitor* visitor) {
714 ASSERT(raw_obj->IsHeapObject());
717 if (instance_size == 0) {
718 instance_size = visitor->class_table()->SizeAt(raw_obj->GetClassId());
723 uword from = obj_addr +
sizeof(UntaggedObject);
725 visitor->VisitCompressedPointers(raw_obj->heap_base(),
728 return instance_size;
731intptr_t UntaggedImmutableArray::VisitImmutableArrayPointers(
732 ImmutableArrayPtr raw_obj,
733 ObjectPointerVisitor* visitor) {
734 return UntaggedArray::VisitArrayPointers(raw_obj, visitor);
737intptr_t UntaggedConstMap::VisitConstMapPointers(
739 ObjectPointerVisitor* visitor) {
740 return UntaggedMap::VisitMapPointers(raw_obj, visitor);
743intptr_t UntaggedConstSet::VisitConstSetPointers(
745 ObjectPointerVisitor* visitor) {
746 return UntaggedSet::VisitSetPointers(raw_obj, visitor);
749void UntaggedObject::RememberCard(ObjectPtr
const* slot) {
753#if defined(DART_COMPRESSED_POINTERS)
765 ASSERT(object->IsOldObject());
773#define ENUM_CASE(name, init) \
774 case Kind::k##name: \
784 ASSERT(cstr !=
nullptr &&
out !=
nullptr);
785#define ENUM_CASE(name, init) \
786 if (strcmp(#name, cstr) == 0) { \
787 *out = Kind::k##name; \
#define CLASS_LIST_NO_OBJECT(V)
#define CLASS_LIST_FFI_TYPE_MARKER(V)
#define CLASS_LIST_TYPED_DATA(V)
static intptr_t InstanceSize()
static constexpr bool decode(uword value)
ClassPtr At(intptr_t cid) const
bool IsValidIndex(intptr_t cid) const
UnboxedFieldBitmap GetUnboxedFieldsMapAt(intptr_t cid) const
bool HasValidClassAt(intptr_t cid) const
static intptr_t InstanceSize()
static uword PayloadSizeOf(const CodePtr code)
static intptr_t InstanceSize()
static uword PayloadStartOf(const CodePtr code)
static intptr_t InstanceSize()
static uintptr_t PayloadSizeOf(const CompressedStackMapsPtr raw)
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static IsolateGroup * vm_isolate_group()
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static intptr_t Size(const InstructionsSectionPtr instr)
static intptr_t InstanceSize()
uword PayloadStart() const
static IsolateGroup * Current()
ClassTable * class_table() const
FieldTable * field_table() const
static intptr_t InstanceSize()
static void Sleep(int64_t millis)
const ClassTable * class_table() const
void VisitCompressedPointers(uword heap_base, CompressedObjectPtr *first, CompressedObjectPtr *last)
compiler::ObjectPoolBuilderEntry::EntryType EntryType
static intptr_t InstanceSize()
void Validate(IsolateGroup *isolate_group) const
UntaggedObject * untag() const
static intptr_t InstanceSize()
static Page * Of(ObjectPtr obj)
void RememberCard(ObjectPtr const *slot)
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static Thread * Current()
static intptr_t InstanceSize()
static intptr_t InstanceSize()
intptr_t ElementSizeInBytes() const
static intptr_t InstanceSize()
static constexpr uword decode(uword tag)
void Validate(IsolateGroup *isolate_group) const
bool IsCardRemembered() const
static uword ToAddr(const UntaggedObject *raw_obj)
intptr_t HeapSize() const
bool InVMIsolateHeap() const
void VisitPointersPrecise(ObjectPointerVisitor *visitor)
intptr_t GetClassId() const
friend class FreeListElement
static const char * KindToCString(Kind k)
static bool ParseKind(const char *cstr, Kind *out)
static intptr_t InstanceSize()
static intptr_t InstanceSize()
static constexpr intptr_t kCompressedWordSizeLog2
VARIABLE_COMPRESSED_VISITOR(WeakArray, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypeArguments
@ kUnmodifiableByteDataViewCid
static constexpr intptr_t kCompressedWordSize
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)
DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, 1, Thread *thread)
ObjectPtr CompressedObjectPtr
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
static DecodeResult decode(std::string path)
#define SIZE_FROM_CLASS(clazz)
#define TYPED_DATA_VIEW_VISITOR(Type)
#define COMPRESSED_VISITOR(Type)
#define REGULAR_VISITOR(Type)
#define ENUM_CASE(name, init)
#define RAW_VISITPOINTERS(clazz)
#define NULL_VISITOR(Type)
#define UNREACHABLE_VISITOR(Type)
#define VARIABLE_NULL_VISITOR(Type, get_length)
#define FOR_EACH_RAW_PC_DESCRIPTOR(V)
#define ASSERT_COMPRESSED(Type)
#define END_LEAF_RUNTIME_ENTRY