cppgc: Add GetWriteBarrierType that ignores slots
GetWriteBarrierType used to consider the slot so that a barrier is not triggered for on-stack slots. For strongifying weak collections we want the write barrier to trigger even if the backing store is only reachable from stack. Blink counterpart: crrev.com/c/3162170 Bug: chromium:1244057 Change-Id: I75b1ca62ad5de7bae3d2f4c1a9acce839f3ccdc1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3162127 Commit-Queue: Omer Katz <omerkatz@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#76872}
This commit is contained in:
parent
b2fa5f335d
commit
ed0459770f
@ -68,6 +68,23 @@ class HeapConsistency final {
|
||||
return internal::WriteBarrier::GetWriteBarrierType(slot, params, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the required write barrier type for a specific write.
|
||||
* This version is meant to be used in conjunction with with a marking write
|
||||
* barrier barrier which doesn't consider the slot.
|
||||
*
|
||||
* \param value The pointer to the object. May be an interior pointer to an
|
||||
* interface of the actual object.
|
||||
* \param params Parameters that may be used for actual write barrier calls.
|
||||
* Only filled if return value indicates that a write barrier is needed. The
|
||||
* contents of the `params` are an implementation detail.
|
||||
* \returns whether a write barrier is needed and which barrier to invoke.
|
||||
*/
|
||||
static V8_INLINE WriteBarrierType
|
||||
GetWriteBarrierType(const void* value, WriteBarrierParams& params) {
|
||||
return internal::WriteBarrier::GetWriteBarrierType(value, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conservative Dijkstra-style write barrier that processes an object if it
|
||||
* has not yet been processed.
|
||||
|
@ -67,6 +67,8 @@ class V8_EXPORT WriteBarrier final {
|
||||
template <typename HeapHandleCallback>
|
||||
static V8_INLINE Type GetWriteBarrierType(const void* slot, Params& params,
|
||||
HeapHandleCallback callback);
|
||||
// Returns the required write barrier for a given `value`.
|
||||
static V8_INLINE Type GetWriteBarrierType(const void* value, Params& params);
|
||||
|
||||
template <typename HeapHandleCallback>
|
||||
static V8_INLINE Type GetWriteBarrierTypeForExternallyReferencedObject(
|
||||
@ -148,9 +150,27 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final {
|
||||
return ValueModeDispatch<value_mode>::Get(slot, value, params, callback);
|
||||
}
|
||||
|
||||
template <WriteBarrier::ValueMode value_mode, typename HeapHandleCallback>
|
||||
static V8_INLINE WriteBarrier::Type Get(const void* value,
|
||||
WriteBarrier::Params& params,
|
||||
HeapHandleCallback callback) {
|
||||
return GetNoSlot(value, params, callback);
|
||||
}
|
||||
|
||||
template <typename HeapHandleCallback>
|
||||
static V8_INLINE WriteBarrier::Type GetForExternallyReferenced(
|
||||
const void* value, WriteBarrier::Params& params, HeapHandleCallback) {
|
||||
const void* value, WriteBarrier::Params& params,
|
||||
HeapHandleCallback callback) {
|
||||
return GetNoSlot(value, params, callback);
|
||||
}
|
||||
|
||||
private:
|
||||
WriteBarrierTypeForCagedHeapPolicy() = delete;
|
||||
|
||||
template <typename HeapHandleCallback>
|
||||
static V8_INLINE WriteBarrier::Type GetNoSlot(const void* value,
|
||||
WriteBarrier::Params& params,
|
||||
HeapHandleCallback) {
|
||||
if (!TryGetCagedHeap(value, value, params)) {
|
||||
return WriteBarrier::Type::kNone;
|
||||
}
|
||||
@ -160,9 +180,6 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final {
|
||||
return SetAndReturnType<WriteBarrier::Type::kNone>(params);
|
||||
}
|
||||
|
||||
private:
|
||||
WriteBarrierTypeForCagedHeapPolicy() = delete;
|
||||
|
||||
template <WriteBarrier::ValueMode value_mode>
|
||||
struct ValueModeDispatch;
|
||||
|
||||
@ -261,6 +278,15 @@ class V8_EXPORT WriteBarrierTypeForNonCagedHeapPolicy final {
|
||||
return ValueModeDispatch<value_mode>::Get(slot, value, params, callback);
|
||||
}
|
||||
|
||||
template <WriteBarrier::ValueMode value_mode, typename HeapHandleCallback>
|
||||
static V8_INLINE WriteBarrier::Type Get(const void* value,
|
||||
WriteBarrier::Params& params,
|
||||
HeapHandleCallback callback) {
|
||||
// The slot will never be used in `Get()` below.
|
||||
return Get<WriteBarrier::ValueMode::kValuePresent>(nullptr, value, params,
|
||||
callback);
|
||||
}
|
||||
|
||||
template <typename HeapHandleCallback>
|
||||
static V8_INLINE WriteBarrier::Type GetForExternallyReferenced(
|
||||
const void* value, WriteBarrier::Params& params,
|
||||
@ -334,6 +360,13 @@ WriteBarrier::Type WriteBarrier::GetWriteBarrierType(
|
||||
slot, nullptr, params, callback);
|
||||
}
|
||||
|
||||
// static
|
||||
WriteBarrier::Type WriteBarrier::GetWriteBarrierType(
|
||||
const void* value, WriteBarrier::Params& params) {
|
||||
return WriteBarrierTypePolicy::Get<ValueMode::kValuePresent>(value, params,
|
||||
[]() {});
|
||||
}
|
||||
|
||||
// static
|
||||
template <typename HeapHandleCallback>
|
||||
WriteBarrier::Type
|
||||
|
Loading…
Reference in New Issue
Block a user