v8  9.4.146 (node 16.13.0)
V8 is Google's open source JavaScript engine
Visitor Class Reference

#include <visitor.h>

Inheritance diagram for Visitor:

Data Structures

class  Key
 

Public Member Functions

 Visitor (Key)
 
virtual ~Visitor ()=default
 
template<typename T >
void Trace (const T *t)
 
template<typename T >
void Trace (const Member< T > &member)
 
template<typename T >
void Trace (const WeakMember< T > &weak_member)
 
template<typename T >
void Trace (const T &object)
 
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 TraceWeakContainer (const T *object, WeakCallback callback, const void *data)
 
template<typename T >
void RegisterMovableReference (const T **slot)
 
virtual void RegisterWeakCallback (WeakCallback callback, const void *data)
 
virtual V8_WARN_UNUSED_RESULT 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 VisitRoot (const void *, TraceDescriptor, const SourceLocation &)
 
virtual void VisitWeakRoot (const void *self, TraceDescriptor, WeakCallback, const void *weak_root, const SourceLocation &)
 
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 **)
 

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:
Member<Foo> foo_;
WeakMember<Foo> weak_foo_;
};
Visitor(Key)
Definition: visitor.h:61
void Trace(const T *t)
Definition: visitor.h:71

Definition at line 53 of file visitor.h.

Constructor & Destructor Documentation

◆ Visitor()

Visitor ( Key  )
inlineexplicit

Definition at line 61 of file visitor.h.

Referenced by JSVisitor::JSVisitor().

◆ ~Visitor()

virtual ~Visitor ( )
virtualdefault

Member Function Documentation

◆ DeferTraceToMutatorThreadIfConcurrent()

virtual V8_WARN_UNUSED_RESULT bool 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).

Definition at line 290 of file visitor.h.

◆ HandleMovableReference()

virtual void HandleMovableReference ( const void **  )
inlineprotectedvirtual

Definition at line 308 of file visitor.h.

Referenced by Visitor::RegisterMovableReference().

◆ RegisterMovableReference()

void 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.

Definition at line 260 of file visitor.h.

References Visitor::HandleMovableReference().

◆ RegisterWeakCallback()

virtual void 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.

Definition at line 275 of file visitor.h.

Referenced by Visitor::RegisterWeakCallbackMethod().

◆ RegisterWeakCallbackMethod()

void 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.

Definition at line 143 of file visitor.h.

References Visitor::RegisterWeakCallback().

◆ Trace() [1/5]

void 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.

Definition at line 154 of file visitor.h.

◆ Trace() [2/5]

void Trace ( const Member< T > &  member)
inline

Trace method for Member.

Parameters
memberMember reference retaining an object.

Definition at line 87 of file visitor.h.

References cppgc::kSentinelPointer.

◆ Trace() [3/5]

void 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.

Definition at line 125 of file visitor.h.

◆ Trace() [4/5]

void Trace ( const T *  t)
inline

Trace method for raw pointers. Prefer the versions for managed pointers.

Parameters
memberReference retaining an object.

Definition at line 71 of file visitor.h.

References Visitor::Visit().

◆ Trace() [5/5]

void Trace ( const WeakMember< T > &  weak_member)
inline

Trace method for WeakMember.

Parameters
weak_memberWeakMember reference weakly retaining an object.

Definition at line 99 of file visitor.h.

References cppgc::kSentinelPointer, and Visitor::VisitWeak().

◆ TraceEphemeron() [1/2]

void 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.

Definition at line 169 of file visitor.h.

References TraceDescriptor::base_object_payload, and Visitor::VisitEphemeron().

◆ TraceEphemeron() [2/2]

void 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.

Definition at line 202 of file visitor.h.

References TraceDescriptor::base_object_payload, and Visitor::VisitEphemeron().

◆ TraceStrongly()

void TraceStrongly ( const WeakMember< T > &  weak_member)
inline

Trace method that strongifies a WeakMember.

Parameters
weak_memberWeakMember reference retaining an object.

Definition at line 231 of file visitor.h.

References cppgc::kSentinelPointer.

◆ TraceWeakContainer()

void TraceWeakContainer ( const T *  object,
WeakCallback  callback,
const void *  data 
)
inline

Trace method for weak containers.

Parameters
objectreference of the weak container.
callbackto be invoked.
datacustom data that is passed to the callback.

Definition at line 245 of file visitor.h.

References Visitor::VisitWeakContainer().

◆ Visit()

virtual void Visit ( const void *  self,
TraceDescriptor   
)
inlineprotectedvirtual

Definition at line 297 of file visitor.h.

Referenced by Visitor::Trace().

◆ VisitEphemeron()

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

Definition at line 303 of file visitor.h.

Referenced by Visitor::TraceEphemeron().

◆ VisitRoot()

virtual void VisitRoot ( const void *  ,
TraceDescriptor  ,
const SourceLocation  
)
inlineprotectedvirtual

Definition at line 300 of file visitor.h.

◆ VisitWeak()

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

Definition at line 298 of file visitor.h.

Referenced by Visitor::Trace().

◆ VisitWeakContainer()

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

Definition at line 305 of file visitor.h.

Referenced by Visitor::TraceWeakContainer().

◆ VisitWeakRoot()

virtual void VisitWeakRoot ( const void *  self,
TraceDescriptor  ,
WeakCallback  ,
const void *  weak_root,
const SourceLocation  
)
inlineprotectedvirtual

Definition at line 301 of file visitor.h.

Friends And Related Function Documentation

◆ internal::BasicCrossThreadPersistent

Definition at line 369 of file visitor.h.

◆ internal::BasicPersistent

◆ internal::ConservativeTracingVisitor

friend class internal::ConservativeTracingVisitor
friend

Definition at line 373 of file visitor.h.

◆ internal::VisitorBase

friend class internal::VisitorBase
friend

Definition at line 374 of file visitor.h.


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