summaryrefslogtreecommitdiff
path: root/deps/v8/include/cppgc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2021-07-14 11:30:07 +0200
committerMichaël Zasso <targos@protonmail.com>2021-07-20 15:24:51 +0200
commit6cdd310275bb0f8056aa0ae6d95614e9ca5b70c7 (patch)
tree9ed37b19cd668894854b7f469010f7621e63ef81 /deps/v8/include/cppgc
parentc0f10006c82d2d9896a552de98ed146f9542720d (diff)
downloadnode-new-6cdd310275bb0f8056aa0ae6d95614e9ca5b70c7.tar.gz
deps: update V8 to 9.2.230.21
PR-URL: https://github.com/nodejs/node/pull/38990 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/include/cppgc')
-rw-r--r--deps/v8/include/cppgc/allocation.h5
-rw-r--r--deps/v8/include/cppgc/cross-thread-persistent.h20
-rw-r--r--deps/v8/include/cppgc/explicit-management.h17
-rw-r--r--deps/v8/include/cppgc/heap-statistics.h4
-rw-r--r--deps/v8/include/cppgc/internal/compiler-specific.h4
-rw-r--r--deps/v8/include/cppgc/internal/pointer-policies.h39
-rw-r--r--deps/v8/include/cppgc/member.h31
-rw-r--r--deps/v8/include/cppgc/persistent.h6
-rw-r--r--deps/v8/include/cppgc/sentinel-pointer.h2
-rw-r--r--deps/v8/include/cppgc/type-traits.h19
10 files changed, 110 insertions, 37 deletions
diff --git a/deps/v8/include/cppgc/allocation.h b/deps/v8/include/cppgc/allocation.h
index f4f0e72bd5..7a803cf2cc 100644
--- a/deps/v8/include/cppgc/allocation.h
+++ b/deps/v8/include/cppgc/allocation.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <atomic>
+#include <type_traits>
#include "cppgc/custom-space.h"
#include "cppgc/garbage-collected.h"
@@ -103,6 +104,10 @@ class MakeGarbageCollectedTraitBase
* \returns the memory to construct an object of type T on.
*/
V8_INLINE static void* Allocate(AllocationHandle& handle, size_t size) {
+ static_assert(
+ std::is_base_of<typename T::ParentMostGarbageCollectedType, T>::value,
+ "U of GarbageCollected<U> must be a base of T. Check "
+ "GarbageCollected<T> base class inheritance.");
return SpacePolicy<
typename internal::GCInfoFolding<
T, typename T::ParentMostGarbageCollectedType>::ResultType,
diff --git a/deps/v8/include/cppgc/cross-thread-persistent.h b/deps/v8/include/cppgc/cross-thread-persistent.h
index 9cfcd23fdf..fe61e9acbc 100644
--- a/deps/v8/include/cppgc/cross-thread-persistent.h
+++ b/deps/v8/include/cppgc/cross-thread-persistent.h
@@ -28,19 +28,19 @@ class BasicCrossThreadPersistent final : public PersistentBase,
~BasicCrossThreadPersistent() { Clear(); }
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
const SourceLocation& loc = SourceLocation::Current())
: LocationPolicy(loc) {}
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
std::nullptr_t, const SourceLocation& loc = SourceLocation::Current())
: LocationPolicy(loc) {}
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
SentinelPointer s, const SourceLocation& loc = SourceLocation::Current())
: PersistentBase(s), LocationPolicy(loc) {}
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
T* raw, const SourceLocation& loc = SourceLocation::Current())
: PersistentBase(raw), LocationPolicy(loc) {
if (!IsValid(raw)) return;
@@ -58,7 +58,7 @@ class BasicCrossThreadPersistent final : public PersistentBase,
friend class BasicCrossThreadPersistent;
};
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
UnsafeCtorTag, T* raw,
const SourceLocation& loc = SourceLocation::Current())
: PersistentBase(raw), LocationPolicy(loc) {
@@ -68,14 +68,14 @@ class BasicCrossThreadPersistent final : public PersistentBase,
this->CheckPointer(raw);
}
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
T& raw, const SourceLocation& loc = SourceLocation::Current())
: BasicCrossThreadPersistent(&raw, loc) {}
template <typename U, typename MemberBarrierPolicy,
typename MemberWeaknessTag, typename MemberCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
MemberCheckingPolicy>
member,
@@ -94,7 +94,7 @@ class BasicCrossThreadPersistent final : public PersistentBase,
template <typename U, typename OtherWeaknessPolicy,
typename OtherLocationPolicy, typename OtherCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicCrossThreadPersistent( // NOLINT
+ BasicCrossThreadPersistent(
const BasicCrossThreadPersistent<U, OtherWeaknessPolicy,
OtherLocationPolicy,
OtherCheckingPolicy>& other,
@@ -139,7 +139,7 @@ class BasicCrossThreadPersistent final : public PersistentBase,
GetNode()->UpdateOwner(this);
other.SetValue(nullptr);
other.SetNode(nullptr);
- this->CheckPointer(GetValue());
+ this->CheckPointer(Get());
return *this;
}
@@ -236,7 +236,7 @@ class BasicCrossThreadPersistent final : public PersistentBase,
*
* \returns the object.
*/
- operator T*() const { return Get(); } // NOLINT
+ operator T*() const { return Get(); }
/**
* Dereferences the stored object.
diff --git a/deps/v8/include/cppgc/explicit-management.h b/deps/v8/include/cppgc/explicit-management.h
index 8fb321c08c..cdb6af4858 100644
--- a/deps/v8/include/cppgc/explicit-management.h
+++ b/deps/v8/include/cppgc/explicit-management.h
@@ -12,9 +12,12 @@
#include "cppgc/type-traits.h"
namespace cppgc {
+
+class HeapHandle;
+
namespace internal {
-V8_EXPORT void FreeUnreferencedObject(void*);
+V8_EXPORT void FreeUnreferencedObject(HeapHandle&, void*);
V8_EXPORT bool Resize(void*, size_t);
} // namespace internal
@@ -30,15 +33,19 @@ namespace subtle {
* to `object` after calling `FreeUnreferencedObject()`. In case such a
* reference exists, it's use results in a use-after-free.
*
+ * To aid in using the API, `FreeUnreferencedObject()` may be called from
+ * destructors on objects that would be reclaimed in the same garbage collection
+ * cycle.
+ *
+ * \param heap_handle The corresponding heap.
* \param object Reference to an object that is of type `GarbageCollected` and
* should be immediately reclaimed.
*/
template <typename T>
-void FreeUnreferencedObject(T* object) {
+void FreeUnreferencedObject(HeapHandle& heap_handle, T& object) {
static_assert(IsGarbageCollectedTypeV<T>,
"Object must be of type GarbageCollected.");
- if (!object) return;
- internal::FreeUnreferencedObject(object);
+ internal::FreeUnreferencedObject(heap_handle, &object);
}
/**
@@ -53,6 +60,8 @@ void FreeUnreferencedObject(T* object) {
* object down, the reclaimed area is not used anymore. Any subsequent use
* results in a use-after-free.
*
+ * The `object` must be live when calling `Resize()`.
+ *
* \param object Reference to an object that is of type `GarbageCollected` and
* should be resized.
* \param additional_bytes Bytes in addition to sizeof(T) that the object should
diff --git a/deps/v8/include/cppgc/heap-statistics.h b/deps/v8/include/cppgc/heap-statistics.h
index cf8d6633cc..2fe6e1ae58 100644
--- a/deps/v8/include/cppgc/heap-statistics.h
+++ b/deps/v8/include/cppgc/heap-statistics.h
@@ -57,7 +57,7 @@ struct HeapStatistics final {
};
/**
- * Stastistics of the freelist (used only in non-large object spaces). For
+ * Statistics of the freelist (used only in non-large object spaces). For
* each bucket in the freelist the statistics record the bucket size, the
* number of freelist entries in the bucket, and the overall allocated memory
* consumed by these freelist entries.
@@ -67,7 +67,7 @@ struct HeapStatistics final {
std::vector<size_t> bucket_size;
/** number of freelist entries per bucket. */
std::vector<size_t> free_count;
- /** memory size concumed by freelist entries per size. */
+ /** memory size consumed by freelist entries per size. */
std::vector<size_t> free_size;
};
diff --git a/deps/v8/include/cppgc/internal/compiler-specific.h b/deps/v8/include/cppgc/internal/compiler-specific.h
index c580894b35..595b6398cb 100644
--- a/deps/v8/include/cppgc/internal/compiler-specific.h
+++ b/deps/v8/include/cppgc/internal/compiler-specific.h
@@ -21,13 +21,13 @@ namespace cppgc {
// [[no_unique_address]] comes in C++20 but supported in clang with -std >=
// c++11.
-#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address) // NOLINTNEXTLINE
+#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address)
#define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
#else
#define CPPGC_NO_UNIQUE_ADDRESS
#endif
-#if CPPGC_HAS_ATTRIBUTE(unused) // NOLINTNEXTLINE
+#if CPPGC_HAS_ATTRIBUTE(unused)
#define CPPGC_UNUSED __attribute__((unused))
#else
#define CPPGC_UNUSED
diff --git a/deps/v8/include/cppgc/internal/pointer-policies.h b/deps/v8/include/cppgc/internal/pointer-policies.h
index ceb002f02d..e09b86199f 100644
--- a/deps/v8/include/cppgc/internal/pointer-policies.h
+++ b/deps/v8/include/cppgc/internal/pointer-policies.h
@@ -9,12 +9,15 @@
#include <type_traits>
#include "cppgc/internal/write-barrier.h"
+#include "cppgc/sentinel-pointer.h"
#include "cppgc/source-location.h"
+#include "cppgc/type-traits.h"
#include "v8config.h" // NOLINT(build/include_directory)
namespace cppgc {
namespace internal {
+class HeapBase;
class PersistentRegion;
class CrossThreadPersistentRegion;
@@ -50,11 +53,31 @@ struct NoWriteBarrierPolicy {
class V8_EXPORT EnabledCheckingPolicy {
protected:
- EnabledCheckingPolicy();
- void CheckPointer(const void* ptr);
+ template <typename T>
+ void CheckPointer(const T* ptr) {
+ if (!ptr || (kSentinelPointer == ptr)) return;
+
+ CheckPointersImplTrampoline<T>::Call(this, ptr);
+ }
private:
- void* impl_;
+ 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);
+ }
+ };
+
+ template <typename T>
+ struct CheckPointersImplTrampoline<T, true> {
+ static void Call(EnabledCheckingPolicy* policy, const T* ptr) {
+ policy->CheckPointerImpl(ptr, IsGarbageCollectedTypeV<T>);
+ }
+ };
+
+ const HeapBase* heap_ = nullptr;
};
class DisabledCheckingPolicy {
@@ -63,9 +86,11 @@ class DisabledCheckingPolicy {
};
#if V8_ENABLE_CHECKS
-using DefaultCheckingPolicy = EnabledCheckingPolicy;
+using DefaultMemberCheckingPolicy = EnabledCheckingPolicy;
+using DefaultPersistentCheckingPolicy = EnabledCheckingPolicy;
#else
-using DefaultCheckingPolicy = DisabledCheckingPolicy;
+using DefaultMemberCheckingPolicy = DisabledCheckingPolicy;
+using DefaultPersistentCheckingPolicy = DisabledCheckingPolicy;
#endif
class KeepLocationPolicy {
@@ -133,10 +158,10 @@ template <typename T, typename WeaknessPolicy,
class BasicCrossThreadPersistent;
template <typename T, typename WeaknessPolicy,
typename LocationPolicy = DefaultLocationPolicy,
- typename CheckingPolicy = DefaultCheckingPolicy>
+ typename CheckingPolicy = DefaultPersistentCheckingPolicy>
class BasicPersistent;
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
- typename CheckingPolicy = DefaultCheckingPolicy>
+ typename CheckingPolicy = DefaultMemberCheckingPolicy>
class BasicMember;
} // namespace internal
diff --git a/deps/v8/include/cppgc/member.h b/deps/v8/include/cppgc/member.h
index 7b76bc4f75..16aed06022 100644
--- a/deps/v8/include/cppgc/member.h
+++ b/deps/v8/include/cppgc/member.h
@@ -24,8 +24,11 @@ namespace internal {
// BasicMember on casting to the right type as needed.
class MemberBase {
protected:
+ struct AtomicInitializerTag {};
+
MemberBase() = default;
explicit MemberBase(const void* value) : raw_(value) {}
+ MemberBase(const void* value, AtomicInitializerTag) { SetRawAtomic(value); }
const void** GetRawSlot() const { return &raw_; }
const void* GetRaw() const { return raw_; }
@@ -61,6 +64,20 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
this->CheckPointer(Get());
}
BasicMember(T& raw) : BasicMember(&raw) {} // NOLINT
+ // Atomic ctor. Using the AtomicInitializerTag forces BasicMember to
+ // initialize using atomic assignments. This is required for preventing
+ // data races with concurrent marking.
+ using AtomicInitializerTag = MemberBase::AtomicInitializerTag;
+ BasicMember(std::nullptr_t, AtomicInitializerTag atomic)
+ : MemberBase(nullptr, atomic) {}
+ BasicMember(SentinelPointer s, AtomicInitializerTag atomic)
+ : MemberBase(s, atomic) {}
+ BasicMember(T* raw, AtomicInitializerTag atomic) : MemberBase(raw, atomic) {
+ InitializingWriteBarrier();
+ this->CheckPointer(Get());
+ }
+ BasicMember(T& raw, AtomicInitializerTag atomic)
+ : BasicMember(&raw, atomic) {}
// Copy ctor.
BasicMember(const BasicMember& other) : BasicMember(other.Get()) {}
// Allow heterogeneous construction.
@@ -79,9 +96,8 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
template <typename U, typename OtherBarrierPolicy, typename OtherWeaknessTag,
typename OtherCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicMember( // NOLINT
- BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
- OtherCheckingPolicy>&& other) noexcept
+ BasicMember(BasicMember<U, OtherWeaknessTag, OtherBarrierPolicy,
+ OtherCheckingPolicy>&& other) noexcept
: BasicMember(other.Get()) {
other.Clear();
}
@@ -90,10 +106,9 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
typename PersistentLocationPolicy,
typename PersistentCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicMember( // NOLINT
- const BasicPersistent<U, PersistentWeaknessPolicy,
- PersistentLocationPolicy, PersistentCheckingPolicy>&
- p)
+ BasicMember(const BasicPersistent<U, PersistentWeaknessPolicy,
+ PersistentLocationPolicy,
+ PersistentCheckingPolicy>& p)
: BasicMember(p.Get()) {}
// Copy assignment.
@@ -161,7 +176,7 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
}
explicit operator bool() const { return Get(); }
- operator T*() const { return Get(); } // NOLINT
+ operator T*() const { return Get(); }
T* operator->() const { return Get(); }
T& operator*() const { return *Get(); }
diff --git a/deps/v8/include/cppgc/persistent.h b/deps/v8/include/cppgc/persistent.h
index d7aac723c0..22cda7c6e8 100644
--- a/deps/v8/include/cppgc/persistent.h
+++ b/deps/v8/include/cppgc/persistent.h
@@ -95,7 +95,7 @@ class BasicPersistent final : public PersistentBase,
template <typename U, typename OtherWeaknessPolicy,
typename OtherLocationPolicy, typename OtherCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicPersistent( // NOLINT
+ BasicPersistent(
const BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
OtherCheckingPolicy>& other,
const SourceLocation& loc = SourceLocation::Current())
@@ -118,7 +118,7 @@ class BasicPersistent final : public PersistentBase,
template <typename U, typename MemberBarrierPolicy,
typename MemberWeaknessTag, typename MemberCheckingPolicy,
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
- BasicPersistent(internal::BasicMember<U, MemberBarrierPolicy, // NOLINT
+ BasicPersistent(internal::BasicMember<U, MemberBarrierPolicy,
MemberWeaknessTag, MemberCheckingPolicy>
member,
const SourceLocation& loc = SourceLocation::Current())
@@ -181,7 +181,7 @@ class BasicPersistent final : public PersistentBase,
}
explicit operator bool() const { return Get(); }
- operator T*() const { return Get(); } // NOLINT
+ operator T*() const { return Get(); }
T* operator->() const { return Get(); }
T& operator*() const { return *Get(); }
diff --git a/deps/v8/include/cppgc/sentinel-pointer.h b/deps/v8/include/cppgc/sentinel-pointer.h
index f7915834e5..b049d1a2b3 100644
--- a/deps/v8/include/cppgc/sentinel-pointer.h
+++ b/deps/v8/include/cppgc/sentinel-pointer.h
@@ -14,7 +14,7 @@ namespace internal {
// sentinel is defined by the embedder.
struct SentinelPointer {
template <typename T>
- operator T*() const { // NOLINT
+ operator T*() const {
static constexpr intptr_t kSentinelValue = 1;
return reinterpret_cast<T*>(kSentinelValue);
}
diff --git a/deps/v8/include/cppgc/type-traits.h b/deps/v8/include/cppgc/type-traits.h
index 2b50a2164b..56cd55d61e 100644
--- a/deps/v8/include/cppgc/type-traits.h
+++ b/deps/v8/include/cppgc/type-traits.h
@@ -7,6 +7,7 @@
// This file should stay with minimal dependencies to allow embedder to check
// against Oilpan types without including any other parts.
+#include <cstddef>
#include <type_traits>
namespace cppgc {
@@ -164,6 +165,18 @@ struct IsUntracedMemberType : std::false_type {};
template <typename T>
struct IsUntracedMemberType<T, true> : std::true_type {};
+template <typename T>
+struct IsComplete {
+ private:
+ template <typename U, size_t = sizeof(U)>
+ static std::true_type IsSizeOfKnown(U*);
+ static std::false_type IsSizeOfKnown(...);
+
+ public:
+ static constexpr bool value =
+ decltype(IsSizeOfKnown(std::declval<T*>()))::value;
+};
+
} // namespace internal
/**
@@ -223,6 +236,12 @@ constexpr bool IsWeakMemberTypeV = internal::IsWeakMemberType<T>::value;
template <typename T>
constexpr bool IsWeakV = internal::IsWeak<T>::value;
+/**
+ * Value is true for types that are complete, and false otherwise.
+ */
+template <typename T>
+constexpr bool IsCompleteV = internal::IsComplete<T>::value;
+
} // namespace cppgc
#endif // INCLUDE_CPPGC_TYPE_TRAITS_H_