Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Protected Member Functions | Protected Attributes | List of all members
dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet > Class Template Reference
Inheritance diagram for dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >:
dart::SerializationCluster dart::ZoneAllocated

Protected Member Functions

 CanonicalSetSerializationCluster (intptr_t cid, bool is_canonical, bool represents_canonical_set, const char *name, intptr_t target_instance_size=0)
 
virtual bool IsInCanonicalSet (Serializer *s, PointerType ptr)
 
void ReorderObjects (Serializer *s)
 
void WriteCanonicalSetLayout (Serializer *s)
 

Protected Attributes

GrowableArray< PointerType > objects_
 
- 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
 

Additional Inherited Members

- 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)
 
- Static Public Attributes inherited from dart::SerializationCluster
static constexpr intptr_t kSizeVaries = -1
 

Detailed Description

template<typename SetType, typename HandleType, typename PointerType, bool kAllCanonicalObjectsAreIncludedIntoSet = true>
class dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >

Definition at line 1223 of file app_snapshot.cc.

Constructor & Destructor Documentation

◆ CanonicalSetSerializationCluster()

template<typename SetType , typename HandleType , typename PointerType , bool kAllCanonicalObjectsAreIncludedIntoSet = true>
dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >::CanonicalSetSerializationCluster ( intptr_t  cid,
bool  is_canonical,
bool  represents_canonical_set,
const char *  name,
intptr_t  target_instance_size = 0 
)
inlineprotected

Definition at line 1225 of file app_snapshot.cc.

1230 : SerializationCluster(name, cid, target_instance_size, is_canonical),
1231 represents_canonical_set_(represents_canonical_set) {}
const char * name() const
SerializationCluster(const char *name, intptr_t cid, intptr_t target_instance_size=kSizeVaries, bool is_canonical=false)

Member Function Documentation

◆ IsInCanonicalSet()

template<typename SetType , typename HandleType , typename PointerType , bool kAllCanonicalObjectsAreIncludedIntoSet = true>
virtual bool dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >::IsInCanonicalSet ( Serializer s,
PointerType  ptr 
)
inlineprotectedvirtual

Reimplemented in dart::TypeSerializationCluster.

Definition at line 1233 of file app_snapshot.cc.

1233 {
1234 // Must override this function if kAllCanonicalObjectsAreIncludedIntoSet
1235 // is set to |false|.
1236 ASSERT(kAllCanonicalObjectsAreIncludedIntoSet);
1237 return true;
1238 }
#define ASSERT(E)

◆ ReorderObjects()

template<typename SetType , typename HandleType , typename PointerType , bool kAllCanonicalObjectsAreIncludedIntoSet = true>
void dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >::ReorderObjects ( Serializer s)
inlineprotected

Definition at line 1240 of file app_snapshot.cc.

1240 {
1241 if (!represents_canonical_set_) {
1242 return;
1243 }
1244
1245 // Sort objects before writing them out so that they appear in the same
1246 // order as they would appear in a CanonicalStringSet.
1247 using ZoneCanonicalSet =
1248 HashTable<typename SetType::Traits, 0, 0, GrowableArrayStorageTraits>;
1249
1250 // Compute required capacity for the hashtable (to avoid overallocating).
1251 intptr_t required_capacity = 0;
1252 for (auto ptr : objects_) {
1253 if (kAllCanonicalObjectsAreIncludedIntoSet || IsInCanonicalSet(s, ptr)) {
1254 required_capacity++;
1255 }
1256 }
1257 // Over-allocate capacity so a few inserts can happen at startup without
1258 // causing a rehash.
1259 const intptr_t kSpareCapacity = 32;
1260 required_capacity = static_cast<intptr_t>(
1261 static_cast<double>(required_capacity + kSpareCapacity) /
1263
1264 intptr_t num_occupied = 0;
1265
1266 // Build canonical set out of objects that should belong to it.
1267 // Objects that don't belong to it are copied to the prefix of objects_.
1268 ZoneCanonicalSet table(
1269 s->zone(), HashTables::New<ZoneCanonicalSet>(required_capacity));
1270 HandleType& element = HandleType::Handle(s->zone());
1271 for (auto ptr : objects_) {
1272 if (kAllCanonicalObjectsAreIncludedIntoSet || IsInCanonicalSet(s, ptr)) {
1273 element ^= ptr;
1274 intptr_t entry = -1;
1275 const bool present = table.FindKeyOrDeletedOrUnused(element, &entry);
1276 ASSERT(!present);
1277 table.InsertKey(entry, element);
1278 } else {
1279 objects_[num_occupied++] = ptr;
1280 }
1281 }
1282
1283 const auto prefix_length = num_occupied;
1284
1285 // Compute objects_ order and gaps based on canonical set layout.
1286 auto& arr = table.Release();
1287 intptr_t last_occupied = ZoneCanonicalSet::kFirstKeyIndex - 1;
1288 for (intptr_t i = ZoneCanonicalSet::kFirstKeyIndex, length = arr.Length();
1289 i < length; i++) {
1290 ObjectPtr v = arr.At(i);
1291 ASSERT(v != ZoneCanonicalSet::DeletedMarker().ptr());
1292 if (v != ZoneCanonicalSet::UnusedMarker().ptr()) {
1293 const intptr_t unused_run_length = (i - 1) - last_occupied;
1294 gaps_.Add(unused_run_length);
1295 objects_[num_occupied++] = static_cast<PointerType>(v);
1296 last_occupied = i;
1297 }
1298 }
1299 ASSERT(num_occupied == objects_.length());
1300 ASSERT(prefix_length == (objects_.length() - gaps_.length()));
1301 table_length_ = arr.Length();
1302 }
SI F table(const skcms_Curve *curve, F v)
void Add(const T &value)
intptr_t length() const
GrowableArray< PointerType > objects_
virtual bool IsInCanonicalSet(Serializer *s, PointerType ptr)
static constexpr double kMaxLoadFactor
Definition hash_table.h:617
struct MyStruct s
size_t length

◆ WriteCanonicalSetLayout()

template<typename SetType , typename HandleType , typename PointerType , bool kAllCanonicalObjectsAreIncludedIntoSet = true>
void dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >::WriteCanonicalSetLayout ( Serializer s)
inlineprotected

Definition at line 1304 of file app_snapshot.cc.

1304 {
1305 if (represents_canonical_set_) {
1306 s->WriteUnsigned(table_length_);
1307 s->WriteUnsigned(objects_.length() - gaps_.length());
1308 for (auto gap : gaps_) {
1309 s->WriteUnsigned(gap);
1310 }
1312 compiler::target::Array::InstanceSize(table_length_);
1313 }
1314 }

Member Data Documentation

◆ objects_

template<typename SetType , typename HandleType , typename PointerType , bool kAllCanonicalObjectsAreIncludedIntoSet = true>
GrowableArray<PointerType> dart::CanonicalSetSerializationCluster< SetType, HandleType, PointerType, kAllCanonicalObjectsAreIncludedIntoSet >::objects_
protected

Definition at line 1316 of file app_snapshot.cc.


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