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

Public Member Functions

 ArraySerializationCluster (bool is_canonical, intptr_t cid)
 
 ~ArraySerializationCluster ()
 
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 6371 of file app_snapshot.cc.

Constructor & Destructor Documentation

◆ ArraySerializationCluster()

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

Definition at line 6373 of file app_snapshot.cc.

static constexpr intptr_t kSizeVaries
SerializationCluster(const char *name, intptr_t cid, intptr_t target_instance_size=kSizeVaries, bool is_canonical=false)

◆ ~ArraySerializationCluster()

dart::ArraySerializationCluster::~ArraySerializationCluster ( )
inline

Definition at line 6375 of file app_snapshot.cc.

6375{}

Member Function Documentation

◆ Trace()

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

Implements dart::SerializationCluster.

Definition at line 6377 of file app_snapshot.cc.

6377 {
6378 ArrayPtr array = Array::RawCast(object);
6379 objects_.Add(array);
6380
6381 s->Push(array->untag()->type_arguments());
6382 const intptr_t length = Smi::Value(array->untag()->length());
6383 for (intptr_t i = 0; i < length; i++) {
6384 s->Push(array->untag()->element(i));
6385 }
6386 }
void Add(const T &value)
static ObjectPtr RawCast(ObjectPtr obj)
Definition: object.h:325
intptr_t Value() const
Definition: object.h:9990
struct MyStruct s
size_t length

◆ WriteAlloc()

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

Implements dart::SerializationCluster.

Definition at line 6403 of file app_snapshot.cc.

6403 {
6404#if defined(DART_PRECOMPILER)
6405 if (FLAG_print_array_optimization_candidates) {
6406 intptr_t array_count = objects_.length();
6407 intptr_t array_count_allsmi = 0;
6408 intptr_t array_count_allro = 0;
6409 intptr_t array_count_empty = 0;
6410 intptr_t element_count = 0;
6411 intptr_t element_count_allsmi = 0;
6412 intptr_t element_count_allro = 0;
6413 for (intptr_t i = 0; i < array_count; i++) {
6414 ArrayPtr array = objects_[i];
6415 bool allsmi = true;
6416 bool allro = true;
6417 const intptr_t length = Smi::Value(array->untag()->length());
6418 for (intptr_t i = 0; i < length; i++) {
6419 ObjectPtr element = array->untag()->element(i);
6420 intptr_t cid = element->GetClassIdMayBeSmi();
6421 if (!IsReadOnlyCid(cid)) allro = false;
6422 if (cid != kSmiCid) allsmi = false;
6423 }
6424 element_count += length;
6425 if (length == 0) {
6426 array_count_empty++;
6427 } else if (allsmi) {
6428 array_count_allsmi++;
6429 element_count_allsmi += length;
6430 } else if (allro) {
6431 array_count_allro++;
6432 element_count_allro += length;
6433 }
6434 }
6435 OS::PrintErr("Arrays\n");
6436 OS::PrintErr(" total: %" Pd ", % " Pd " elements\n", array_count,
6437 element_count);
6438 OS::PrintErr(" smi-only:%" Pd ", % " Pd " elements\n",
6439 array_count_allsmi, element_count_allsmi);
6440 OS::PrintErr(" ro-only:%" Pd " , % " Pd " elements\n", array_count_allro,
6441 element_count_allro);
6442 OS::PrintErr(" empty:%" Pd "\n", array_count_empty);
6443 }
6444#endif // defined(DART_PRECOMPILER)
6445
6446 const intptr_t count = objects_.length();
6447 s->WriteUnsigned(count);
6448 for (intptr_t i = 0; i < count; i++) {
6449 ArrayPtr array = objects_[i];
6450 s->AssignRef(array);
6451 AutoTraceObject(array);
6452 const intptr_t length = Smi::Value(array->untag()->length());
6453 s->WriteUnsigned(length);
6455 }
6456 }
int count
Definition: FontMgrTest.cpp:50
#define AutoTraceObject(obj)
intptr_t length() const
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
#define Pd
Definition: globals.h:408

◆ WriteFill()

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

Implements dart::SerializationCluster.

Definition at line 6458 of file app_snapshot.cc.

6458 {
6459 const intptr_t count = objects_.length();
6460 for (intptr_t i = 0; i < count; i++) {
6461 ArrayPtr array = objects_[i];
6462 AutoTraceObject(array);
6463 const intptr_t length = Smi::Value(array->untag()->length());
6464 s->WriteUnsigned(length);
6465 WriteCompressedField(array, type_arguments);
6466 for (intptr_t j = 0; j < length; j++) {
6467 s->WriteElementRef(array->untag()->element(j), j);
6468 }
6469 }
6470 }
#define WriteCompressedField(obj, name)

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