api: Remove deprecated write barrier API

Bug: v8:12356
Change-Id: Ib9e99c8b05e24a8983c5ff3d36ca534a262738a0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3404774
Auto-Submit: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Omer Katz <omerkatz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78717}
This commit is contained in:
Michael Lippautz 2022-01-21 09:39:06 +01:00 committed by V8 LUCI CQ
parent 5ddf102904
commit 40db472a32
4 changed files with 0 additions and 138 deletions

View File

@ -70,10 +70,6 @@ class V8_EXPORT WriteBarrier final {
// 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(
const void* value, Params& params, HeapHandleCallback callback);
static V8_INLINE void DijkstraMarkingBarrier(const Params& params,
const void* object);
static V8_INLINE void DijkstraMarkingBarrierRange(
@ -157,13 +153,6 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final {
return GetNoSlot(value, params, callback);
}
template <typename HeapHandleCallback>
static V8_INLINE WriteBarrier::Type GetForExternallyReferenced(
const void* value, WriteBarrier::Params& params,
HeapHandleCallback callback) {
return GetNoSlot(value, params, callback);
}
private:
WriteBarrierTypeForCagedHeapPolicy() = delete;
@ -292,15 +281,6 @@ class V8_EXPORT WriteBarrierTypeForNonCagedHeapPolicy final {
callback);
}
template <typename HeapHandleCallback>
static V8_INLINE WriteBarrier::Type GetForExternallyReferenced(
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);
}
private:
template <WriteBarrier::ValueMode value_mode>
struct ValueModeDispatch;
@ -375,15 +355,6 @@ WriteBarrier::Type WriteBarrier::GetWriteBarrierType(
[]() {});
}
// static
template <typename HeapHandleCallback>
WriteBarrier::Type
WriteBarrier::GetWriteBarrierTypeForExternallyReferencedObject(
const void* value, Params& params, HeapHandleCallback callback) {
return WriteBarrierTypePolicy::GetForExternallyReferenced(value, params,
callback);
}
// static
void WriteBarrier::DijkstraMarkingBarrier(const Params& params,
const void* object) {

View File

@ -12,7 +12,6 @@
#include "cppgc/common.h"
#include "cppgc/custom-space.h"
#include "cppgc/heap-statistics.h"
#include "cppgc/internal/write-barrier.h"
#include "cppgc/visitor.h"
#include "v8-internal.h" // NOLINT(build/include_directory)
#include "v8-platform.h" // NOLINT(build/include_directory)
@ -166,73 +165,6 @@ class JSVisitor : public cppgc::Visitor {
virtual void Visit(const TracedReferenceBase& ref) {}
};
/**
* **DO NOT USE: Use the appropriate managed types.**
*
* Consistency helpers that aid in maintaining a consistent internal state of
* the garbage collector.
*/
class V8_EXPORT JSHeapConsistency final {
public:
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 JS to C++ references.
*
* \param wrapper The wrapper that has been written into.
* \param wrapper_index The wrapper index in `wrapper` that has been written
* into.
* \param wrappable The value that was written.
* \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 when using "
"`SetAlignedPointerInInternalFields()`.")
static V8_INLINE WriteBarrierType
GetWriteBarrierType(v8::Local<v8::Object>& wrapper, int wrapper_index,
const void* wrappable, WriteBarrierParams& params,
HeapHandleCallback callback) {
#if V8_ENABLE_CHECKS
CheckWrapper(wrapper, wrapper_index, wrappable);
#endif // V8_ENABLE_CHECKS
return cppgc::internal::WriteBarrier::
GetWriteBarrierTypeForExternallyReferencedObject(wrappable, params,
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 object The pointer to the object. May be an interior pointer to a
* an interface of the actual object.
*/
V8_DEPRECATED(
"Write barriers automatically emitted when using "
"`SetAlignedPointerInInternalFields()`.")
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
cppgc::HeapHandle& heap_handle,
const void* object) {
cppgc::internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
}
private:
JSHeapConsistency() = delete;
static void CheckWrapper(v8::Local<v8::Object>&, int, const void*);
};
/**
* Provided as input to `CppHeap::CollectCustomSpaceStatisticsAtLastGC()`.
*

View File

@ -92,12 +92,6 @@ void CppHeap::CollectGarbageForTesting(cppgc::EmbedderStackState stack_state) {
return internal::CppHeap::From(this)->CollectGarbageForTesting(stack_state);
}
void JSHeapConsistency::CheckWrapper(v8::Local<v8::Object>& wrapper,
int wrapper_index, const void* wrappable) {
CHECK_EQ(wrappable,
wrapper->GetAlignedPointerFromInternalField(wrapper_index));
}
namespace internal {
namespace {

View File

@ -94,41 +94,6 @@ TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReference) {
EXPECT_EQ(0u, Wrappable::destructor_callcount);
}
#if !defined(_MSC_VER) || defined(__clang__)
TEST_F(UnifiedHeapTest, WriteBarrierV8ToCppReferenceWithExplicitAPI) {
// TODO(v8:12356): 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);
void* wrappable = cppgc::MakeGarbageCollected<Wrappable>(allocation_handle());
v8::Local<v8::Object> api_object =
WrapperHelper::CreateWrapper(context, nullptr, nullptr);
Wrappable::destructor_callcount = 0;
WrapperHelper::ResetWrappableConnection(api_object);
SimulateIncrementalMarking();
{
// The following snippet shows the embedder code for implementing a GC-safe
// setter for JS to C++ references.
WrapperHelper::SetWrappableConnection(api_object, wrappable, wrappable);
JSHeapConsistency::WriteBarrierParams params;
auto barrier_type = JSHeapConsistency::GetWriteBarrierType(
api_object, 1, wrappable, params,
[this]() -> cppgc::HeapHandle& { return cpp_heap().GetHeapHandle(); });
EXPECT_EQ(JSHeapConsistency::WriteBarrierType::kMarking, barrier_type);
JSHeapConsistency::DijkstraMarkingBarrier(
params, cpp_heap().GetHeapHandle(), wrappable);
}
CollectGarbageWithoutEmbedderStack(cppgc::Heap::SweepingType::kAtomic);
EXPECT_EQ(0u, Wrappable::destructor_callcount);
#pragma GCC diagnostic pop
}
#endif // !_MSC_VER || __clang__
#if DEBUG
namespace {
class Unreferenced : public cppgc::GarbageCollected<Unreferenced> {