cppgc: Advance deprecation arounds write barrier

Advance deprecations and remove fully deprecated code.

Bug: v8:12165
Change-Id: I2cf1715d6878ff65e5b9beaddb8df7aec780b21e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3328781
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78329}
This commit is contained in:
Michael Lippautz 2021-12-09 21:25:04 +01:00 committed by V8 LUCI CQ
parent b51a100dbd
commit 3afcbf5c3c
3 changed files with 2 additions and 115 deletions

View File

@ -180,43 +180,6 @@ class V8_EXPORT JSHeapConsistency final {
using WriteBarrierParams = cppgc::internal::WriteBarrier::Params;
using WriteBarrierType = cppgc::internal::WriteBarrier::Type;
/**
* Gets the required write barrier type for a specific write.
*
* Note: Handling for C++ to JS references.
*
* \param ref The reference being written to.
* \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.
* \param callback Callback returning the corresponding heap handle. The
* callback is only invoked if the heap cannot otherwise be figured out. The
* callback must not allocate.
* \returns whether a write barrier is needed and which barrier to invoke.
*/
template <typename HeapHandleCallback>
V8_DEPRECATED("Write barriers automatically emitted by TracedReference.")
static V8_INLINE WriteBarrierType
GetWriteBarrierType(const TracedReferenceBase& ref,
WriteBarrierParams& params,
HeapHandleCallback callback) {
if (ref.IsEmpty()) return WriteBarrierType::kNone;
if (V8_LIKELY(!cppgc::internal::WriteBarrier::
IsAnyIncrementalOrConcurrentMarking())) {
return cppgc::internal::WriteBarrier::Type::kNone;
}
cppgc::HeapHandle& handle = callback();
if (!cppgc::subtle::HeapState::IsMarking(handle)) {
return cppgc::internal::WriteBarrier::Type::kNone;
}
params.heap = &handle;
#if V8_ENABLE_CHECKS
params.type = cppgc::internal::WriteBarrier::Type::kMarking;
#endif // !V8_ENABLE_CHECKS
return cppgc::internal::WriteBarrier::Type::kMarking;
}
/**
* Gets the required write barrier type for a specific write.
*
@ -235,7 +198,7 @@ class V8_EXPORT JSHeapConsistency final {
* \returns whether a write barrier is needed and which barrier to invoke.
*/
template <typename HeapHandleCallback>
V8_DEPRECATE_SOON(
V8_DEPRECATED(
"Write barriers automatically emitted when using "
"`SetAlignedPointerInInternalFields()`.")
static V8_INLINE WriteBarrierType
@ -250,22 +213,6 @@ class V8_EXPORT JSHeapConsistency final {
callback);
}
/**
* Conservative Dijkstra-style write barrier that processes an object if it
* has not yet been processed.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param ref The reference being written to.
*/
V8_DEPRECATED("Write barriers automatically emitted by TracedReference.")
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
cppgc::HeapHandle& heap_handle,
const TracedReferenceBase& ref) {
cppgc::internal::WriteBarrier::CheckParams(WriteBarrierType::kMarking,
params);
DijkstraMarkingBarrierSlow(heap_handle, ref);
}
/**
* Conservative Dijkstra-style write barrier that processes an object if it
* has not yet been processed.
@ -274,7 +221,7 @@ class V8_EXPORT JSHeapConsistency final {
* \param object The pointer to the object. May be an interior pointer to a
* an interface of the actual object.
*/
V8_DEPRECATE_SOON(
V8_DEPRECATED(
"Write barriers automatically emitted when using "
"`SetAlignedPointerInInternalFields()`.")
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
@ -283,24 +230,10 @@ class V8_EXPORT JSHeapConsistency final {
cppgc::internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
}
/**
* Generational barrier for maintaining consistency when running with multiple
* generations.
*
* \param params The parameters retrieved from `GetWriteBarrierType()`.
* \param ref The reference being written to.
*/
V8_DEPRECATED("Write barriers automatically emitted by TracedReference.")
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
const TracedReferenceBase& ref) {}
private:
JSHeapConsistency() = delete;
static void CheckWrapper(v8::Local<v8::Object>&, int, const void*);
static void DijkstraMarkingBarrierSlow(cppgc::HeapHandle&,
const TracedReferenceBase& ref);
};
/**

View File

@ -91,12 +91,6 @@ void CppHeap::CollectGarbageForTesting(cppgc::EmbedderStackState stack_state) {
return internal::CppHeap::From(this)->CollectGarbageForTesting(stack_state);
}
void JSHeapConsistency::DijkstraMarkingBarrierSlow(
cppgc::HeapHandle& heap_handle, const TracedReferenceBase& ref) {
auto& heap_base = cppgc::internal::HeapBase::From(heap_handle);
static_cast<JSVisitor*>(&heap_base.marker()->Visitor())->Trace(ref);
}
void JSHeapConsistency::CheckWrapper(v8::Local<v8::Object>& wrapper,
int wrapper_index, const void* wrappable) {
CHECK_EQ(wrappable,

View File

@ -126,46 +126,6 @@ TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReferenceWithExplicitAPI) {
#pragma GCC diagnostic pop
}
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;
v8::HandleScope scope(v8_isolate());
v8::Local<v8::Context> context = v8::Context::New(v8_isolate());
v8::Context::Scope context_scope(context);
cppgc::Persistent<Wrappable> wrappable =
cppgc::MakeGarbageCollected<Wrappable>(allocation_handle());
Wrappable::destructor_callcount = 0;
SimulateIncrementalMarking();
// Pick a sentinel to compare against.
void* kMagicAddress = &Wrappable::destructor_callcount;
{
// The following snippet shows the embedder code for implementing a GC-safe
// setter for C++ to JS references.
v8::HandleScope nested_scope(v8_isolate());
v8::Local<v8::Object> api_object =
WrapperHelper::CreateWrapper(context, nullptr, nullptr);
// Setting only one field to avoid treating this as wrappable backref, see
// `LocalEmbedderHeapTracer::ExtractWrapperInfo`.
api_object->SetAlignedPointerInInternalField(1, kMagicAddress);
wrappable->SetWrapper(v8_isolate(), api_object);
JSHeapConsistency::WriteBarrierParams params;
auto barrier_type = JSHeapConsistency::GetWriteBarrierType(
wrappable->wrapper(), params,
[this]() -> cppgc::HeapHandle& { return cpp_heap().GetHeapHandle(); });
EXPECT_EQ(JSHeapConsistency::WriteBarrierType::kMarking, barrier_type);
JSHeapConsistency::DijkstraMarkingBarrier(
params, cpp_heap().GetHeapHandle(), wrappable->wrapper());
}
CollectGarbageWithoutEmbedderStack(cppgc::Heap::SweepingType::kAtomic);
EXPECT_EQ(0u, Wrappable::destructor_callcount);
EXPECT_EQ(kMagicAddress,
wrappable->wrapper()->GetAlignedPointerFromInternalField(1));
#pragma GCC diagnostic pop
}
#endif // !_MSC_VER || __clang__
#if DEBUG