cppgc: Introduce trace method for containers
Introduce `TraceStrongContainer()` to retain containers strongly. This makes the use of `Trace(T*)` obsolete as all other use cases should refer to Member overloads. Bug: v8:13089 Change-Id: Ib0e762bf3298f1818528e45cc842d14a63f2c684 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3779680 Reviewed-by: Anton Bikineev <bikineev@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#81864}
This commit is contained in:
parent
91f98a8f7c
commit
d188467bf8
@ -230,19 +230,29 @@ class V8_EXPORT Visitor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Trace method for weak containers.
|
||||
* Trace method for retaining containers strongly.
|
||||
*
|
||||
* \param object reference of the weak container.
|
||||
* \param object reference to the container.
|
||||
*/
|
||||
template <typename T>
|
||||
void TraceStrongContainer(const T* object) {
|
||||
TraceImpl(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trace method for retaining containers weakly.
|
||||
*
|
||||
* \param object reference to the container.
|
||||
* \param callback to be invoked.
|
||||
* \param data custom data that is passed to the callback.
|
||||
* \param callback_data custom data that is passed to the callback.
|
||||
*/
|
||||
template <typename T>
|
||||
void TraceWeakContainer(const T* object, WeakCallback callback,
|
||||
const void* data) {
|
||||
const void* callback_data) {
|
||||
if (!object) return;
|
||||
VisitWeakContainer(object, TraceTrait<T>::GetTraceDescriptor(object),
|
||||
TraceTrait<T>::GetWeakTraceDescriptor(object), callback,
|
||||
data);
|
||||
callback_data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,11 @@ class VisitorFactory {
|
||||
// use its internals.
|
||||
class VisitorBase : public cppgc::Visitor {
|
||||
public:
|
||||
template <typename T>
|
||||
static void TraceRawForTesting(cppgc::Visitor* visitor, const T* t) {
|
||||
visitor->TraceImpl(t);
|
||||
}
|
||||
|
||||
VisitorBase() : cppgc::Visitor(VisitorFactory::CreateKey()) {}
|
||||
~VisitorBase() override = default;
|
||||
|
||||
@ -34,11 +39,6 @@ class VisitorBase : public cppgc::Visitor {
|
||||
void TraceRootForTesting(const Persistent& p, const SourceLocation& loc) {
|
||||
TraceRoot(p, loc);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void TraceRawForTesting(cppgc::Visitor* visitor, const T* t) {
|
||||
visitor->TraceImpl(t);
|
||||
}
|
||||
};
|
||||
|
||||
// Regular visitor that additionally allows for conservative tracing.
|
||||
|
Loading…
Reference in New Issue
Block a user