Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
cppgc::Visitor Class Reference

#include <visitor.h>

Inheritance diagram for cppgc::Visitor:
[legend]

Classes

class  Key
 

Public Member Functions

 Visitor (Key)
 
virtual ~Visitor ()=default
 
template<typename T >
void Trace (const Member< T > &member)
 
template<typename T >
void Trace (const WeakMember< T > &weak_member)
 
template<typename T >
void TraceMultiple (const subtle::UncompressedMember< T > *start, size_t len)
 
template<typename T , std::enable_if_t<!std::is_same_v< Member< T >, subtle::UncompressedMember< T > > > * = nullptr>
void TraceMultiple (const Member< T > *start, size_t len)
 
template<typename T >
void Trace (const T &object)
 
template<typename T >
void TraceMultiple (const T *start, size_t len)
 
template<typename T , void(T::*)(const LivenessBroker &) method>
void RegisterWeakCallbackMethod (const T *object)
 
template<typename K , typename V >
void Trace (const EphemeronPair< K, V > &ephemeron_pair)
 
template<typename KeyType , typename ValueType >
void TraceEphemeron (const WeakMember< KeyType > &weak_member_key, const Member< ValueType > *member_value)
 
template<typename KeyType , typename ValueType >
void TraceEphemeron (const WeakMember< KeyType > &weak_member_key, const ValueType *value)
 
template<typename T >
void TraceStrongly (const WeakMember< T > &weak_member)
 
template<typename T >
void TraceStrongContainer (const T *object)
 
template<typename T >
void TraceWeakContainer (const T *object, WeakCallback callback, const void *callback_data)
 
template<typename T >
void RegisterMovableReference (const T **slot)
 
virtual void RegisterWeakCallback (WeakCallback callback, const void *data)
 
virtual bool DeferTraceToMutatorThreadIfConcurrent (const void *parameter, TraceCallback callback, size_t deferred_size)
 

Protected Member Functions

virtual void Visit (const void *self, TraceDescriptor)
 
virtual void VisitWeak (const void *self, TraceDescriptor, WeakCallback, const void *weak_member)
 
virtual void VisitEphemeron (const void *key, const void *value, TraceDescriptor value_desc)
 
virtual void VisitWeakContainer (const void *self, TraceDescriptor strong_desc, TraceDescriptor weak_desc, WeakCallback callback, const void *data)
 
virtual void HandleMovableReference (const void **)
 
virtual void VisitMultipleUncompressedMember (const void *start, size_t len, TraceDescriptorCallback get_trace_descriptor)
 

Friends

template<typename T , typename WeaknessPolicy , typename LocationPolicy , typename CheckingPolicy >
class internal::BasicCrossThreadPersistent
 
template<typename T , typename WeaknessPolicy , typename LocationPolicy , typename CheckingPolicy >
class internal::BasicPersistent
 
class internal::ConservativeTracingVisitor
 
class internal::VisitorBase
 

Detailed Description

Visitor passed to trace methods. All managed pointers must have called the Visitor's trace method on them.

class Foo final : public GarbageCollected<Foo> {
public:
void Trace(Visitor* visitor) const {
visitor->Trace(foo_);
visitor->Trace(weak_foo_);
}
private:
WeakMember<Foo> weak_foo_;
};
Definition: garbage-collected.h:53
Definition: visitor.h:56
void Trace(const Member< T > &member)
Definition: visitor.h:74
Definition: member.h:77

Constructor & Destructor Documentation

◆ Visitor()

cppgc::Visitor::Visitor ( Key  )
inlineexplicit

◆ ~Visitor()

virtual cppgc::Visitor::~Visitor ( )
virtualdefault

Member Function Documentation

◆ DeferTraceToMutatorThreadIfConcurrent()

virtual bool cppgc::Visitor::DeferTraceToMutatorThreadIfConcurrent ( const void *  parameter,
TraceCallback  callback,
size_t  deferred_size 
)
inlinevirtual

Defers tracing an object from a concurrent thread to the mutator thread. Should be called by Trace methods of types that are not safe to trace concurrently.

Parameters
parametertells the trace callback which object was deferred.
callbackto be invoked for tracing on the mutator thread.
deferred_sizesize of deferred object.
Returns
false if the object does not need to be deferred (i.e. currently traced on the mutator thread) and true otherwise (i.e. currently traced on a concurrent thread).

◆ HandleMovableReference()

virtual void cppgc::Visitor::HandleMovableReference ( const void **  )
inlineprotectedvirtual

◆ RegisterMovableReference()

template<typename T >
void cppgc::Visitor::RegisterMovableReference ( const T **  slot)
inline

Registers a slot containing a reference to an object allocated on a compactable space. Such references maybe be arbitrarily moved by the GC.

Parameters
slotlocation of reference to object that might be moved by the GC. The slot must contain an uncompressed pointer.

◆ RegisterWeakCallback()

virtual void cppgc::Visitor::RegisterWeakCallback ( WeakCallback  callback,
const void *  data 
)
inlinevirtual

Registers a weak callback that is invoked during garbage collection.

Parameters
callbackto be invoked.
datacustom data that is passed to the callback.

◆ RegisterWeakCallbackMethod()

template<typename T , void(T::*)(const LivenessBroker &) method>
void cppgc::Visitor::RegisterWeakCallbackMethod ( const T *  object)
inline

Registers a weak callback method on the object of type T. See LivenessBroker for an usage example.

Parameters
objectof type T specifying a weak callback method.

◆ Trace() [1/4]

template<typename K , typename V >
void cppgc::Visitor::Trace ( const EphemeronPair< K, V > &  ephemeron_pair)
inline

Trace method for EphemeronPair.

Parameters
ephemeron_pairEphemeronPair reference weakly retaining a key object and strongly retaining a value object in case the key object is alive.

◆ Trace() [2/4]

template<typename T >
void cppgc::Visitor::Trace ( const Member< T > &  member)
inline

Trace method for Member.

Parameters
memberMember reference retaining an object.

◆ Trace() [3/4]

template<typename T >
void cppgc::Visitor::Trace ( const T &  object)
inline

Trace method for inlined objects that are not allocated themselves but otherwise follow managed heap layout and have a Trace() method.

Parameters
objectreference of the inlined object.

◆ Trace() [4/4]

template<typename T >
void cppgc::Visitor::Trace ( const WeakMember< T > &  weak_member)
inline

Trace method for WeakMember.

Parameters
weak_memberWeakMember reference weakly retaining an object.

◆ TraceEphemeron() [1/2]

template<typename KeyType , typename ValueType >
void cppgc::Visitor::TraceEphemeron ( const WeakMember< KeyType > &  weak_member_key,
const Member< ValueType > *  member_value 
)
inline

Trace method for a single ephemeron. Used for tracing a raw ephemeron in which the key and value are kept separately.

Parameters
weak_member_keyWeakMember reference weakly retaining a key object.
member_valueMember reference with ephemeron semantics.

◆ TraceEphemeron() [2/2]

template<typename KeyType , typename ValueType >
void cppgc::Visitor::TraceEphemeron ( const WeakMember< KeyType > &  weak_member_key,
const ValueType *  value 
)
inline

Trace method for a single ephemeron. Used for tracing a raw ephemeron in which the key and value are kept separately. Note that this overload is for non-GarbageCollected values that can be traced though.

Parameters
keyWeakMember reference weakly retaining a key object.
valueReference weakly retaining a value object. Note that ValueType here should not be Member. It is expected that TraceTrait<ValueType>::GetTraceDescriptor(value) returns a TraceDescriptor with a null base pointer but a valid trace method.

◆ TraceMultiple() [1/3]

template<typename T , std::enable_if_t<!std::is_same_v< Member< T >, subtle::UncompressedMember< T > > > * = nullptr>
void cppgc::Visitor::TraceMultiple ( const Member< T > *  start,
size_t  len 
)
inline

◆ TraceMultiple() [2/3]

template<typename T >
void cppgc::Visitor::TraceMultiple ( const subtle::UncompressedMember< T > *  start,
size_t  len 
)
inline

◆ TraceMultiple() [3/3]

template<typename T >
void cppgc::Visitor::TraceMultiple ( const T *  start,
size_t  len 
)
inline

◆ TraceStrongContainer()

template<typename T >
void cppgc::Visitor::TraceStrongContainer ( const T *  object)
inline

Trace method for retaining containers strongly.

Parameters
objectreference to the container.

◆ TraceStrongly()

template<typename T >
void cppgc::Visitor::TraceStrongly ( const WeakMember< T > &  weak_member)
inline

Trace method that strongifies a WeakMember.

Parameters
weak_memberWeakMember reference retaining an object.

◆ TraceWeakContainer()

template<typename T >
void cppgc::Visitor::TraceWeakContainer ( const T *  object,
WeakCallback  callback,
const void *  callback_data 
)
inline

Trace method for retaining containers weakly. Note that weak containers should emit write barriers.

Parameters
objectreference to the container.
callbackto be invoked.
callback_datacustom data that is passed to the callback.

◆ Visit()

virtual void cppgc::Visitor::Visit ( const void *  self,
TraceDescriptor   
)
inlineprotectedvirtual

◆ VisitEphemeron()

virtual void cppgc::Visitor::VisitEphemeron ( const void *  key,
const void *  value,
TraceDescriptor  value_desc 
)
inlineprotectedvirtual

◆ VisitMultipleUncompressedMember()

virtual void cppgc::Visitor::VisitMultipleUncompressedMember ( const void *  start,
size_t  len,
TraceDescriptorCallback  get_trace_descriptor 
)
inlineprotectedvirtual
Here is the call graph for this function:

◆ VisitWeak()

virtual void cppgc::Visitor::VisitWeak ( const void *  self,
TraceDescriptor  ,
WeakCallback  ,
const void *  weak_member 
)
inlineprotectedvirtual

◆ VisitWeakContainer()

virtual void cppgc::Visitor::VisitWeakContainer ( const void *  self,
TraceDescriptor  strong_desc,
TraceDescriptor  weak_desc,
WeakCallback  callback,
const void *  data 
)
inlineprotectedvirtual

Friends And Related Function Documentation

◆ internal::BasicCrossThreadPersistent

template<typename T , typename WeaknessPolicy , typename LocationPolicy , typename CheckingPolicy >
friend class internal::BasicCrossThreadPersistent
friend

◆ internal::BasicPersistent

template<typename T , typename WeaknessPolicy , typename LocationPolicy , typename CheckingPolicy >
friend class internal::BasicPersistent
friend

◆ internal::ConservativeTracingVisitor

friend class internal::ConservativeTracingVisitor
friend

◆ internal::VisitorBase

friend class internal::VisitorBase
friend

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