heap, cppgc: Add write barrier for TracedReference
Adds publicly callable version of write barrier for TracedReferenceBase. Bug: chromium:1056170 Change-Id: Ie45b4ebbe91d9f0e8f76b521dcbfd931232adcf6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565248 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#71524}
This commit is contained in:
parent
051f5493bd
commit
17ed49b560
@ -4,5 +4,6 @@ include_rules = [
|
|||||||
"+cppgc/common.h",
|
"+cppgc/common.h",
|
||||||
# Used by v8-cppgc.h to bridge to cppgc.
|
# Used by v8-cppgc.h to bridge to cppgc.
|
||||||
"+cppgc/custom-space.h",
|
"+cppgc/custom-space.h",
|
||||||
|
"+cppgc/internal/write-barrier.h",
|
||||||
"+cppgc/visitor.h",
|
"+cppgc/visitor.h",
|
||||||
]
|
]
|
||||||
|
@ -73,6 +73,12 @@ class V8_EXPORT WriteBarrier final {
|
|||||||
const void* slot) {}
|
const void* slot) {}
|
||||||
#endif // CPPGC_YOUNG_GENERATION
|
#endif // CPPGC_YOUNG_GENERATION
|
||||||
|
|
||||||
|
#if V8_ENABLE_CHECKS
|
||||||
|
static void CheckParams(Type expected_type, const Params& params);
|
||||||
|
#else // !V8_ENABLE_CHECKS
|
||||||
|
static void CheckParams(Type expected_type, const Params& params) {}
|
||||||
|
#endif // !V8_ENABLE_CHECKS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WriteBarrier() = delete;
|
WriteBarrier() = delete;
|
||||||
|
|
||||||
@ -92,12 +98,6 @@ class V8_EXPORT WriteBarrier final {
|
|||||||
static void SteeleMarkingBarrierSlow(const void* value);
|
static void SteeleMarkingBarrierSlow(const void* value);
|
||||||
static void SteeleMarkingBarrierSlowWithSentinelCheck(const void* value);
|
static void SteeleMarkingBarrierSlowWithSentinelCheck(const void* value);
|
||||||
|
|
||||||
#if V8_ENABLE_CHECKS
|
|
||||||
static void CheckParams(Type expected_type, const Params& params);
|
|
||||||
#else // !V8_ENABLE_CHECKS
|
|
||||||
static void CheckParams(Type expected_type, const Params& params) {}
|
|
||||||
#endif // !V8_ENABLE_CHECKS
|
|
||||||
|
|
||||||
#if defined(CPPGC_YOUNG_GENERATION)
|
#if defined(CPPGC_YOUNG_GENERATION)
|
||||||
static void GenerationalBarrierSlow(const CagedHeapLocalData& local_data,
|
static void GenerationalBarrierSlow(const CagedHeapLocalData& local_data,
|
||||||
const AgeTable& ageTable,
|
const AgeTable& ageTable,
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cppgc/custom-space.h"
|
#include "cppgc/custom-space.h"
|
||||||
|
#include "cppgc/internal/write-barrier.h"
|
||||||
#include "cppgc/visitor.h"
|
#include "cppgc/visitor.h"
|
||||||
#include "v8-internal.h" // NOLINT(build/include_directory)
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
||||||
#include "v8.h" // NOLINT(build/include_directory)
|
#include "v8.h" // NOLINT(build/include_directory)
|
||||||
@ -68,6 +69,64 @@ class JSVisitor : public cppgc::Visitor {
|
|||||||
virtual void Visit(const TracedReferenceBase& ref) {}
|
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 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.
|
||||||
|
*
|
||||||
|
* \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.
|
||||||
|
* \returns whether a write barrier is needed and which barrier to invoke.
|
||||||
|
*/
|
||||||
|
static V8_INLINE WriteBarrierType GetWriteBarrierType(
|
||||||
|
const TracedReferenceBase& ref, WriteBarrierParams& params) {
|
||||||
|
if (ref.IsEmpty()) return WriteBarrierType::kNone;
|
||||||
|
return cppgc::internal::WriteBarrier::GetWriteBarrierType(&ref, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generational barrier for maintaining consistency when running with multiple
|
||||||
|
* generations.
|
||||||
|
*
|
||||||
|
* \param params The parameters retrieved from `GetWriteBarrierType()`.
|
||||||
|
* \param ref The reference being written to.
|
||||||
|
*/
|
||||||
|
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
|
||||||
|
const TracedReferenceBase& ref) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
JSHeapConsistency() = delete;
|
||||||
|
|
||||||
|
static void DijkstraMarkingBarrierSlow(cppgc::HeapHandle&,
|
||||||
|
const TracedReferenceBase& ref);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace v8
|
} // namespace v8
|
||||||
|
|
||||||
namespace cppgc {
|
namespace cppgc {
|
||||||
|
@ -42,6 +42,12 @@ cppgc::HeapHandle& CppHeap::GetHeapHandle() {
|
|||||||
return *internal::CppHeap::From(this);
|
return *internal::CppHeap::From(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
Loading…
Reference in New Issue
Block a user