Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::Deduper< T, S > Class Template Reference
Inheritance diagram for dart::Deduper< T, S >:
dart::ValueObject

Public Member Functions

 Deduper (Zone *zone)
 
virtual ~Deduper ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Protected Member Functions

virtual bool IsCorrectType (const Object &obj) const
 
virtual bool CanCanonicalize (const T &t) const
 
bool ShouldAdd (const Object &obj) const
 
void AddCanonical (const T &obj)
 
void AddVMBaseObjects ()
 
T::ObjectPtrType Dedup (const T &obj)
 

Protected Attributes

Zone *const zone_
 
DirectChainedHashMap< Scanonical_objects_
 

Detailed Description

template<typename T, typename S>
class dart::Deduper< T, S >

Definition at line 294 of file program_visitor.cc.

Constructor & Destructor Documentation

◆ Deduper()

template<typename T , typename S >
dart::Deduper< T, S >::Deduper ( Zone zone)
inlineexplicit

Definition at line 296 of file program_visitor.cc.

296: zone_(zone), canonical_objects_(zone) {}
DirectChainedHashMap< S > canonical_objects_
Zone *const zone_

◆ ~Deduper()

template<typename T , typename S >
virtual dart::Deduper< T, S >::~Deduper ( )
inlinevirtual

Definition at line 297 of file program_visitor.cc.

297{}

Member Function Documentation

◆ AddCanonical()

template<typename T , typename S >
void dart::Deduper< T, S >::AddCanonical ( const T obj)
inlineprotected

Definition at line 315 of file program_visitor.cc.

315 {
316 if (!ShouldAdd(obj)) return;
318 canonical_objects_.Insert(&T::ZoneHandle(zone_, obj.ptr()));
319 }
void Insert(typename KeyValueTrait::Pair kv)
Definition hash_map.h:230
bool HasKey(typename KeyValueTrait::Key key) const
Definition hash_map.h:52
bool ShouldAdd(const Object &obj) const
#define ASSERT(E)

◆ AddVMBaseObjects()

template<typename T , typename S >
void dart::Deduper< T, S >::AddVMBaseObjects ( )
inlineprotected

Definition at line 321 of file program_visitor.cc.

321 {
322 const auto& object_table = Object::vm_isolate_snapshot_object_table();
323 auto& obj = Object::Handle(zone_);
324 for (intptr_t i = 0; i < object_table.Length(); i++) {
325 obj = object_table.At(i);
326 if (!ShouldAdd(obj)) continue;
327 AddCanonical(T::Cast(obj));
328 }
329 }
void AddCanonical(const T &obj)
static Object & Handle()
Definition object.h:407

◆ CanCanonicalize()

template<typename T , typename S >
virtual bool dart::Deduper< T, S >::CanCanonicalize ( const T t) const
inlineprotectedvirtual

Definition at line 307 of file program_visitor.cc.

307{ return true; }

◆ Dedup()

template<typename T , typename S >
T::ObjectPtrType dart::Deduper< T, S >::Dedup ( const T obj)
inlineprotected

Definition at line 331 of file program_visitor.cc.

331 {
332 if (ShouldAdd(obj)) {
333 if (auto const canonical = canonical_objects_.LookupValue(&obj)) {
334 return canonical->ptr();
335 }
336 AddCanonical(obj);
337 }
338 return obj.ptr();
339 }
KeyValueTrait::Value LookupValue(typename KeyValueTrait::Key key) const
Definition hash_map.h:159

◆ IsCorrectType()

template<typename T , typename S >
virtual bool dart::Deduper< T, S >::IsCorrectType ( const Object obj) const
inlineprotectedvirtual

Definition at line 302 of file program_visitor.cc.

302 {
303 return obj.GetClassId() == T::kClassId;
304 }

◆ ShouldAdd()

template<typename T , typename S >
bool dart::Deduper< T, S >::ShouldAdd ( const Object obj) const
inlineprotected

Definition at line 311 of file program_visitor.cc.

311 {
312 return !obj.IsNull() && IsCorrectType(obj) && CanCanonicalize(T::Cast(obj));
313 }
virtual bool IsCorrectType(const Object &obj) const
virtual bool CanCanonicalize(const T &t) const

Member Data Documentation

◆ canonical_objects_

template<typename T , typename S >
DirectChainedHashMap<S> dart::Deduper< T, S >::canonical_objects_
protected

Definition at line 342 of file program_visitor.cc.

◆ zone_

template<typename T , typename S >
Zone* const dart::Deduper< T, S >::zone_
protected

Definition at line 341 of file program_visitor.cc.


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