Commit d4bd7f96 authored by Michael Lippautz's avatar Michael Lippautz Committed by V8 LUCI CQ

cppgc-js: Deprecate explicit write barrier API

Write barriers are automatically emitted by v8::TracedReference.

Bug: v8:12165
Change-Id: I6ee9b95e9d25fe9606ce1b11b21b3905d47ee8cb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3253343Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77642}
parent 39cf100d
...@@ -195,9 +195,11 @@ class V8_EXPORT JSHeapConsistency final { ...@@ -195,9 +195,11 @@ class V8_EXPORT JSHeapConsistency final {
* \returns whether a write barrier is needed and which barrier to invoke. * \returns whether a write barrier is needed and which barrier to invoke.
*/ */
template <typename HeapHandleCallback> template <typename HeapHandleCallback>
V8_DEPRECATE_SOON("Write barriers automatically emitted by TracedReference.")
static V8_INLINE WriteBarrierType static V8_INLINE WriteBarrierType
GetWriteBarrierType(const TracedReferenceBase& ref, GetWriteBarrierType(const TracedReferenceBase& ref,
WriteBarrierParams& params, HeapHandleCallback callback) { WriteBarrierParams& params,
HeapHandleCallback callback) {
if (ref.IsEmpty()) return WriteBarrierType::kNone; if (ref.IsEmpty()) return WriteBarrierType::kNone;
if (V8_LIKELY(!cppgc::internal::WriteBarrier:: if (V8_LIKELY(!cppgc::internal::WriteBarrier::
...@@ -251,6 +253,7 @@ class V8_EXPORT JSHeapConsistency final { ...@@ -251,6 +253,7 @@ class V8_EXPORT JSHeapConsistency final {
* \param params The parameters retrieved from `GetWriteBarrierType()`. * \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param ref The reference being written to. * \param ref The reference being written to.
*/ */
V8_DEPRECATE_SOON("Write barriers automatically emitted by TracedReference.")
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params, static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
cppgc::HeapHandle& heap_handle, cppgc::HeapHandle& heap_handle,
const TracedReferenceBase& ref) { const TracedReferenceBase& ref) {
...@@ -280,6 +283,7 @@ class V8_EXPORT JSHeapConsistency final { ...@@ -280,6 +283,7 @@ class V8_EXPORT JSHeapConsistency final {
* \param params The parameters retrieved from `GetWriteBarrierType()`. * \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param ref The reference being written to. * \param ref The reference being written to.
*/ */
V8_DEPRECATE_SOON("Write barriers automatically emitted by TracedReference.")
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params, static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
const TracedReferenceBase& ref) {} const TracedReferenceBase& ref) {}
......
...@@ -104,6 +104,9 @@ TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReference) { ...@@ -104,6 +104,9 @@ TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReference) {
} }
TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) { TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) {
// TODO(v8:12165): Remove test when fully removing the deprecated API.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if (!FLAG_incremental_marking) return; if (!FLAG_incremental_marking) return;
v8::HandleScope scope(v8_isolate()); v8::HandleScope scope(v8_isolate());
v8::Local<v8::Context> context = v8::Context::New(v8_isolate()); v8::Local<v8::Context> context = v8::Context::New(v8_isolate());
...@@ -125,6 +128,7 @@ TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) { ...@@ -125,6 +128,7 @@ TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) {
api_object->SetAlignedPointerInInternalField(1, kMagicAddress); api_object->SetAlignedPointerInInternalField(1, kMagicAddress);
wrappable->SetWrapper(v8_isolate(), api_object); wrappable->SetWrapper(v8_isolate(), api_object);
JSHeapConsistency::WriteBarrierParams params; JSHeapConsistency::WriteBarrierParams params;
auto barrier_type = JSHeapConsistency::GetWriteBarrierType( auto barrier_type = JSHeapConsistency::GetWriteBarrierType(
wrappable->wrapper(), params, wrappable->wrapper(), params,
[this]() -> cppgc::HeapHandle& { return cpp_heap().GetHeapHandle(); }); [this]() -> cppgc::HeapHandle& { return cpp_heap().GetHeapHandle(); });
...@@ -136,6 +140,7 @@ TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) { ...@@ -136,6 +140,7 @@ TEST_F(UnifiedHeapTest, WriteBarrierCppToV8Reference) {
EXPECT_EQ(0u, Wrappable::destructor_callcount); EXPECT_EQ(0u, Wrappable::destructor_callcount);
EXPECT_EQ(kMagicAddress, EXPECT_EQ(kMagicAddress,
wrappable->wrapper()->GetAlignedPointerFromInternalField(1)); wrappable->wrapper()->GetAlignedPointerFromInternalField(1));
#pragma GCC diagnostic pop
} }
#if DEBUG #if DEBUG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment