diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-11-21 15:58:15 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-11-21 16:04:41 +0100 |
commit | 3e9939e38cb4ecc7c8a9bd7cff64baca3a897eb3 (patch) | |
tree | 036ca0e8d0971c009a181a0ad3a7a158ea7f7e86 /deps/v8/include/cppgc/internal | |
parent | 42543bcf478debf7a10f1f291e227ad57b0a38b6 (diff) | |
download | node-new-3e9939e38cb4ecc7c8a9bd7cff64baca3a897eb3.tar.gz |
deps: update V8 to 9.6.180.14
PR-URL: https://github.com/nodejs/node/pull/40488
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/v8/include/cppgc/internal')
-rw-r--r-- | deps/v8/include/cppgc/internal/persistent-node.h | 56 | ||||
-rw-r--r-- | deps/v8/include/cppgc/internal/pointer-policies.h | 33 | ||||
-rw-r--r-- | deps/v8/include/cppgc/internal/write-barrier.h | 10 |
3 files changed, 75 insertions, 24 deletions
diff --git a/deps/v8/include/cppgc/internal/persistent-node.h b/deps/v8/include/cppgc/internal/persistent-node.h index b5dba476a4..1fea667848 100644 --- a/deps/v8/include/cppgc/internal/persistent-node.h +++ b/deps/v8/include/cppgc/internal/persistent-node.h @@ -75,16 +75,16 @@ class PersistentNode final { TraceCallback trace_ = nullptr; }; -class V8_EXPORT PersistentRegion { +class V8_EXPORT PersistentRegionBase { using PersistentNodeSlots = std::array<PersistentNode, 256u>; public: - PersistentRegion() = default; + PersistentRegionBase() = default; // Clears Persistent fields to avoid stale pointers after heap teardown. - ~PersistentRegion(); + ~PersistentRegionBase(); - PersistentRegion(const PersistentRegion&) = delete; - PersistentRegion& operator=(const PersistentRegion&) = delete; + PersistentRegionBase(const PersistentRegionBase&) = delete; + PersistentRegionBase& operator=(const PersistentRegionBase&) = delete; PersistentNode* AllocateNode(void* owner, TraceCallback trace) { if (!free_list_head_) { @@ -126,8 +126,39 @@ class V8_EXPORT PersistentRegion { friend class CrossThreadPersistentRegion; }; -// CrossThreadPersistent uses PersistentRegion but protects it using this lock -// when needed. +// Variant of PersistentRegionBase that checks whether the allocation and +// freeing happens only on the thread that created the region. +class V8_EXPORT PersistentRegion final : public PersistentRegionBase { + public: + PersistentRegion(); + // Clears Persistent fields to avoid stale pointers after heap teardown. + ~PersistentRegion() = default; + + PersistentRegion(const PersistentRegion&) = delete; + PersistentRegion& operator=(const PersistentRegion&) = delete; + + V8_INLINE PersistentNode* AllocateNode(void* owner, TraceCallback trace) { +#if V8_ENABLE_CHECKS + CheckIsCreationThread(); +#endif // V8_ENABLE_CHECKS + return PersistentRegionBase::AllocateNode(owner, trace); + } + + V8_INLINE void FreeNode(PersistentNode* node) { +#if V8_ENABLE_CHECKS + CheckIsCreationThread(); +#endif // V8_ENABLE_CHECKS + PersistentRegionBase::FreeNode(node); + } + + private: + void CheckIsCreationThread(); + + int creation_thread_id_; +}; + +// CrossThreadPersistent uses PersistentRegionBase but protects it using this +// lock when needed. class V8_EXPORT PersistentRegionLock final { public: PersistentRegionLock(); @@ -136,9 +167,10 @@ class V8_EXPORT PersistentRegionLock final { static void AssertLocked(); }; -// Variant of PersistentRegion that checks whether the PersistentRegionLock is -// locked. -class V8_EXPORT CrossThreadPersistentRegion final : protected PersistentRegion { +// Variant of PersistentRegionBase that checks whether the PersistentRegionLock +// is locked. +class V8_EXPORT CrossThreadPersistentRegion final + : protected PersistentRegionBase { public: CrossThreadPersistentRegion() = default; // Clears Persistent fields to avoid stale pointers after heap teardown. @@ -150,12 +182,12 @@ class V8_EXPORT CrossThreadPersistentRegion final : protected PersistentRegion { V8_INLINE PersistentNode* AllocateNode(void* owner, TraceCallback trace) { PersistentRegionLock::AssertLocked(); - return PersistentRegion::AllocateNode(owner, trace); + return PersistentRegionBase::AllocateNode(owner, trace); } V8_INLINE void FreeNode(PersistentNode* node) { PersistentRegionLock::AssertLocked(); - PersistentRegion::FreeNode(node); + PersistentRegionBase::FreeNode(node); } void Trace(Visitor*); diff --git a/deps/v8/include/cppgc/internal/pointer-policies.h b/deps/v8/include/cppgc/internal/pointer-policies.h index cdf0bb693d..7c4f4a0862 100644 --- a/deps/v8/include/cppgc/internal/pointer-policies.h +++ b/deps/v8/include/cppgc/internal/pointer-policies.h @@ -51,7 +51,17 @@ struct NoWriteBarrierPolicy { static void AssigningBarrier(const void*, const void*) {} }; -class V8_EXPORT EnabledCheckingPolicy { +class V8_EXPORT SameThreadEnabledCheckingPolicyBase { + protected: + void CheckPointerImpl(const void* ptr, bool points_to_payload, + bool check_off_heap_assignments); + + const HeapBase* heap_ = nullptr; +}; + +template <bool kCheckOffHeapAssignments> +class V8_EXPORT SameThreadEnabledCheckingPolicy + : private SameThreadEnabledCheckingPolicyBase { protected: template <typename T> void CheckPointer(const T* ptr) { @@ -61,23 +71,20 @@ class V8_EXPORT EnabledCheckingPolicy { } private: - void CheckPointerImpl(const void* ptr, bool points_to_payload); - template <typename T, bool = IsCompleteV<T>> struct CheckPointersImplTrampoline { - static void Call(EnabledCheckingPolicy* policy, const T* ptr) { - policy->CheckPointerImpl(ptr, false); + static void Call(SameThreadEnabledCheckingPolicy* policy, const T* ptr) { + policy->CheckPointerImpl(ptr, false, kCheckOffHeapAssignments); } }; template <typename T> struct CheckPointersImplTrampoline<T, true> { - static void Call(EnabledCheckingPolicy* policy, const T* ptr) { - policy->CheckPointerImpl(ptr, IsGarbageCollectedTypeV<T>); + static void Call(SameThreadEnabledCheckingPolicy* policy, const T* ptr) { + policy->CheckPointerImpl(ptr, IsGarbageCollectedTypeV<T>, + kCheckOffHeapAssignments); } }; - - const HeapBase* heap_ = nullptr; }; class DisabledCheckingPolicy { @@ -86,8 +93,12 @@ class DisabledCheckingPolicy { }; #if V8_ENABLE_CHECKS -using DefaultMemberCheckingPolicy = EnabledCheckingPolicy; -using DefaultPersistentCheckingPolicy = EnabledCheckingPolicy; +// Off heap members are not connected to object graph and thus cannot ressurect +// dead objects. +using DefaultMemberCheckingPolicy = + SameThreadEnabledCheckingPolicy<false /* kCheckOffHeapAssignments*/>; +using DefaultPersistentCheckingPolicy = + SameThreadEnabledCheckingPolicy<true /* kCheckOffHeapAssignments*/>; #else using DefaultMemberCheckingPolicy = DisabledCheckingPolicy; using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy; diff --git a/deps/v8/include/cppgc/internal/write-barrier.h b/deps/v8/include/cppgc/internal/write-barrier.h index 28184dc9c8..67f039c658 100644 --- a/deps/v8/include/cppgc/internal/write-barrier.h +++ b/deps/v8/include/cppgc/internal/write-barrier.h @@ -214,6 +214,11 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch< static V8_INLINE WriteBarrier::Type Get(const void* slot, const void* value, WriteBarrier::Params& params, HeapHandleCallback) { +#if !defined(CPPGC_YOUNG_GENERATION) + if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { + return SetAndReturnType<WriteBarrier::Type::kNone>(params); + } +#endif // !CPPGC_YOUNG_GENERATION bool within_cage = TryGetCagedHeap(slot, value, params); if (!within_cage) { return WriteBarrier::Type::kNone; @@ -317,7 +322,10 @@ struct WriteBarrierTypeForNonCagedHeapPolicy::ValueModeDispatch< HeapHandleCallback callback) { // The following check covers nullptr as well as sentinel pointer. if (object <= static_cast<void*>(kSentinelPointer)) { - return WriteBarrier::Type::kNone; + return SetAndReturnType<WriteBarrier::Type::kNone>(params); + } + if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) { + return SetAndReturnType<WriteBarrier::Type::kNone>(params); } if (IsMarking(object, ¶ms.heap)) { return SetAndReturnType<WriteBarrier::Type::kMarking>(params); |