Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::InstanceSerializationCluster Class Reference
Inheritance diagram for dart::InstanceSerializationCluster:
dart::SerializationCluster dart::ZoneAllocated

Public Member Functions

 InstanceSerializationCluster (bool is_canonical, intptr_t cid)
 
 ~InstanceSerializationCluster ()
 
void Trace (Serializer *s, ObjectPtr object)
 
void WriteAlloc (Serializer *s)
 
void WriteFill (Serializer *s)
 
- Public Member Functions inherited from dart::SerializationCluster
 SerializationCluster (const char *name, intptr_t cid, intptr_t target_instance_size=kSizeVaries, bool is_canonical=false)
 
virtual ~SerializationCluster ()
 
virtual void Trace (Serializer *serializer, ObjectPtr object)=0
 
virtual void WriteAlloc (Serializer *serializer)=0
 
virtual void WriteFill (Serializer *serializer)=0
 
void WriteAndMeasureAlloc (Serializer *serializer)
 
void WriteAndMeasureFill (Serializer *serializer)
 
const char * name () const
 
intptr_t cid () const
 
bool is_canonical () const
 
bool is_immutable () const
 
intptr_t size () const
 
intptr_t num_objects () const
 
intptr_t target_memory_size () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Additional Inherited Members

- Static Public Attributes inherited from dart::SerializationCluster
static constexpr intptr_t kSizeVaries = -1
 
- Protected Attributes inherited from dart::SerializationCluster
const char *const name_
 
const intptr_t cid_
 
const intptr_t target_instance_size_
 
const bool is_canonical_
 
const bool is_immutable_
 
intptr_t size_ = 0
 
intptr_t num_objects_ = 0
 
intptr_t target_memory_size_ = 0
 

Detailed Description

Definition at line 4452 of file app_snapshot.cc.

Constructor & Destructor Documentation

◆ InstanceSerializationCluster()

dart::InstanceSerializationCluster::InstanceSerializationCluster ( bool  is_canonical,
intptr_t  cid 
)
inline

Definition at line 4454 of file app_snapshot.cc.

4456 ClassPtr cls = IsolateGroup::Current()->class_table()->At(cid);
4457 host_next_field_offset_in_words_ =
4458 cls->untag()->host_next_field_offset_in_words_;
4459 ASSERT(host_next_field_offset_in_words_ > 0);
4460#if defined(DART_PRECOMPILER)
4461 target_next_field_offset_in_words_ =
4462 cls->untag()->target_next_field_offset_in_words_;
4463 target_instance_size_in_words_ =
4464 cls->untag()->target_instance_size_in_words_;
4465#else
4466 target_next_field_offset_in_words_ =
4467 cls->untag()->host_next_field_offset_in_words_;
4468 target_instance_size_in_words_ = cls->untag()->host_instance_size_in_words_;
4469#endif // defined(DART_PRECOMPILER)
4470 ASSERT(target_next_field_offset_in_words_ > 0);
4471 ASSERT(target_instance_size_in_words_ > 0);
4472 }
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
static constexpr intptr_t kSizeVaries
SerializationCluster(const char *name, intptr_t cid, intptr_t target_instance_size=kSizeVaries, bool is_canonical=false)
#define ASSERT(E)

◆ ~InstanceSerializationCluster()

dart::InstanceSerializationCluster::~InstanceSerializationCluster ( )
inline

Definition at line 4473 of file app_snapshot.cc.

4473{}

Member Function Documentation

◆ Trace()

void dart::InstanceSerializationCluster::Trace ( Serializer s,
ObjectPtr  object 
)
inlinevirtual

Implements dart::SerializationCluster.

Definition at line 4475 of file app_snapshot.cc.

4475 {
4476 InstancePtr instance = Instance::RawCast(object);
4477 objects_.Add(instance);
4478 const intptr_t next_field_offset = host_next_field_offset_in_words_
4480 const auto unboxed_fields_bitmap =
4481 s->isolate_group()->class_table()->GetUnboxedFieldsMapAt(cid_);
4482 intptr_t offset = Instance::NextFieldOffset();
4483 while (offset < next_field_offset) {
4484 // Skips unboxed fields
4485 if (!unboxed_fields_bitmap.Get(offset / kCompressedWordSize)) {
4486 ObjectPtr raw_obj =
4487 reinterpret_cast<CompressedObjectPtr*>(
4488 reinterpret_cast<uword>(instance->untag()) + offset)
4489 ->Decompress(instance->untag()->heap_base());
4490 s->Push(raw_obj);
4491 }
4493 }
4494 }
void Add(const T &value)
static intptr_t NextFieldOffset()
Definition: object.h:8355
ObjectPtr Decompress(uword heap_base) const
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
VkInstance instance
Definition: main.cc:48
struct MyStruct s
static constexpr intptr_t kCompressedWordSizeLog2
Definition: globals.h:43
uintptr_t uword
Definition: globals.h:501
static constexpr intptr_t kCompressedWordSize
Definition: globals.h:42
ObjectPtr CompressedObjectPtr
SeparatedVector2 offset

◆ WriteAlloc()

void dart::InstanceSerializationCluster::WriteAlloc ( Serializer s)
inlinevirtual

Implements dart::SerializationCluster.

Definition at line 4496 of file app_snapshot.cc.

4496 {
4497 const intptr_t count = objects_.length();
4498 s->WriteUnsigned(count);
4499
4500 s->Write<int32_t>(target_next_field_offset_in_words_);
4501 s->Write<int32_t>(target_instance_size_in_words_);
4502
4503 for (intptr_t i = 0; i < count; i++) {
4504 InstancePtr instance = objects_[i];
4505 s->AssignRef(instance);
4506 }
4507
4508 const intptr_t instance_size = compiler::target::RoundedAllocationSize(
4509 target_instance_size_in_words_ * compiler::target::kCompressedWordSize);
4510 target_memory_size_ += instance_size * count;
4511 }
int count
Definition: FontMgrTest.cpp:50
intptr_t length() const
static constexpr intptr_t kCompressedWordSize
Definition: runtime_api.h:286
intptr_t RoundedAllocationSize(intptr_t size)
Definition: runtime_api.h:333

◆ WriteFill()

void dart::InstanceSerializationCluster::WriteFill ( Serializer s)
inlinevirtual

Implements dart::SerializationCluster.

Definition at line 4513 of file app_snapshot.cc.

4513 {
4514 intptr_t next_field_offset = host_next_field_offset_in_words_
4516 const intptr_t count = objects_.length();
4517 s->WriteUnsigned64(CalculateTargetUnboxedFieldsBitmap(s, cid_).Value());
4518 const auto unboxed_fields_bitmap =
4519 s->isolate_group()->class_table()->GetUnboxedFieldsMapAt(cid_);
4520
4521 for (intptr_t i = 0; i < count; i++) {
4522 InstancePtr instance = objects_[i];
4524#if defined(DART_PRECOMPILER)
4525 if (FLAG_write_v8_snapshot_profile_to != nullptr) {
4526 ClassPtr cls = s->isolate_group()->class_table()->At(cid_);
4527 s->AttributePropertyRef(cls, "<class>");
4528 }
4529#endif
4530 intptr_t offset = Instance::NextFieldOffset();
4531 while (offset < next_field_offset) {
4532 if (unboxed_fields_bitmap.Get(offset / kCompressedWordSize)) {
4533 // Writes 32 bits of the unboxed value at a time.
4534 const compressed_uword value = *reinterpret_cast<compressed_uword*>(
4535 reinterpret_cast<uword>(instance->untag()) + offset);
4536 s->WriteWordWith32BitWrites(value);
4537 } else {
4538 ObjectPtr raw_obj =
4539 reinterpret_cast<CompressedObjectPtr*>(
4540 reinterpret_cast<uword>(instance->untag()) + offset)
4541 ->Decompress(instance->untag()->heap_base());
4542 s->WriteElementRef(raw_obj, offset);
4543 }
4545 }
4546 }
4547 }
#define AutoTraceObject(obj)
uint8_t value
uintptr_t compressed_uword
Definition: globals.h:44
static UnboxedFieldBitmap CalculateTargetUnboxedFieldsBitmap(Serializer *s, intptr_t class_id)

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