libv8-node 15.5.1.0.beta1-x86_64-linux-musl → 16.10.0.0-x86_64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/.location.yml +0 -1
  3. data/ext/libv8-node/location.rb +23 -38
  4. data/ext/libv8-node/paths.rb +2 -2
  5. data/lib/libv8/node/version.rb +3 -3
  6. data/vendor/v8/include/cppgc/allocation.h +104 -45
  7. data/vendor/v8/include/cppgc/common.h +9 -6
  8. data/vendor/v8/include/cppgc/cross-thread-persistent.h +384 -0
  9. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  10. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  11. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  12. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  13. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  14. data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
  15. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  16. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  17. data/vendor/v8/include/cppgc/heap.h +68 -6
  18. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  19. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -1
  20. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  21. data/vendor/v8/include/cppgc/internal/gc-info.h +44 -13
  22. data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
  23. data/vendor/v8/include/cppgc/internal/persistent-node.h +57 -1
  24. data/vendor/v8/include/cppgc/internal/pointer-policies.h +69 -28
  25. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  26. data/vendor/v8/include/cppgc/internal/write-barrier.h +353 -35
  27. data/vendor/v8/include/cppgc/liveness-broker.h +7 -1
  28. data/vendor/v8/include/cppgc/macros.h +2 -0
  29. data/vendor/v8/include/cppgc/member.h +85 -25
  30. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  31. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  32. data/vendor/v8/include/cppgc/persistent.h +33 -9
  33. data/vendor/v8/include/cppgc/platform.h +48 -25
  34. data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
  35. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  36. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  37. data/vendor/v8/include/cppgc/source-location.h +2 -1
  38. data/vendor/v8/include/cppgc/testing.h +99 -0
  39. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  40. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  41. data/vendor/v8/include/cppgc/visitor.h +187 -23
  42. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  43. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  44. data/vendor/v8/include/v8-cppgc.h +258 -159
  45. data/vendor/v8/include/v8-fast-api-calls.h +562 -159
  46. data/vendor/v8/include/v8-inspector.h +23 -2
  47. data/vendor/v8/include/v8-internal.h +99 -27
  48. data/vendor/v8/include/v8-metrics.h +77 -8
  49. data/vendor/v8/include/v8-platform.h +47 -22
  50. data/vendor/v8/include/v8-profiler.h +75 -11
  51. data/vendor/v8/include/v8-unwinder-state.h +30 -0
  52. data/vendor/v8/include/v8-util.h +1 -1
  53. data/vendor/v8/include/v8-version.h +4 -4
  54. data/vendor/v8/include/v8.h +1192 -642
  55. data/vendor/v8/include/v8config.h +40 -9
  56. data/vendor/v8/{out.gn → x86_64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
  57. metadata +33 -7
  58. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -0,0 +1,65 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_NAME_PROVIDER_H_
6
+ #define INCLUDE_CPPGC_NAME_PROVIDER_H_
7
+
8
+ #include "v8config.h" // NOLINT(build/include_directory)
9
+
10
+ namespace cppgc {
11
+
12
+ /**
13
+ * NameProvider allows for providing a human-readable name for garbage-collected
14
+ * objects.
15
+ *
16
+ * There's two cases of names to distinguish:
17
+ * a. Explicitly specified names via using NameProvider. Such names are always
18
+ * preserved in the system.
19
+ * b. Internal names that Oilpan infers from a C++ type on the class hierarchy
20
+ * of the object. This is not necessarily the type of the actually
21
+ * instantiated object.
22
+ *
23
+ * Depending on the build configuration, Oilpan may hide names, i.e., represent
24
+ * them with kHiddenName, of case b. to avoid exposing internal details.
25
+ */
26
+ class V8_EXPORT NameProvider {
27
+ public:
28
+ /**
29
+ * Name that is used when hiding internals.
30
+ */
31
+ static constexpr const char kHiddenName[] = "InternalNode";
32
+
33
+ /**
34
+ * Name that is used in case compiler support is missing for composing a name
35
+ * from C++ types.
36
+ */
37
+ static constexpr const char kNoNameDeducible[] = "<No name>";
38
+
39
+ /**
40
+ * Indicating whether internal names are hidden or not.
41
+ *
42
+ * @returns true if C++ names should be hidden and represented by kHiddenName.
43
+ */
44
+ static constexpr bool HideInternalNames() {
45
+ #if CPPGC_SUPPORTS_OBJECT_NAMES
46
+ return false;
47
+ #else // !CPPGC_SUPPORTS_OBJECT_NAMES
48
+ return true;
49
+ #endif // !CPPGC_SUPPORTS_OBJECT_NAMES
50
+ }
51
+
52
+ virtual ~NameProvider() = default;
53
+
54
+ /**
55
+ * Specifies a name for the garbage-collected object. Such names will never
56
+ * be hidden, as they are explicitly specified by the user of this API.
57
+ *
58
+ * @returns a human readable name for the object.
59
+ */
60
+ virtual const char* GetHumanReadableName() const = 0;
61
+ };
62
+
63
+ } // namespace cppgc
64
+
65
+ #endif // INCLUDE_CPPGC_NAME_PROVIDER_H_
@@ -0,0 +1,58 @@
1
+ // Copyright 2021 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
6
+ #define INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
7
+
8
+ #include <cstddef>
9
+
10
+ #include "cppgc/type-traits.h"
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+
15
+ namespace internal {
16
+
17
+ struct V8_EXPORT BaseObjectSizeTrait {
18
+ protected:
19
+ static size_t GetObjectSizeForGarbageCollected(const void*);
20
+ static size_t GetObjectSizeForGarbageCollectedMixin(const void*);
21
+ };
22
+
23
+ } // namespace internal
24
+
25
+ namespace subtle {
26
+
27
+ /**
28
+ * Trait specifying how to get the size of an object that was allocated using
29
+ * `MakeGarbageCollected()`. Also supports querying the size with an inner
30
+ * pointer to a mixin.
31
+ */
32
+ template <typename T, bool = IsGarbageCollectedMixinTypeV<T>>
33
+ struct ObjectSizeTrait;
34
+
35
+ template <typename T>
36
+ struct ObjectSizeTrait<T, false> : cppgc::internal::BaseObjectSizeTrait {
37
+ static_assert(sizeof(T), "T must be fully defined");
38
+ static_assert(IsGarbageCollectedTypeV<T>,
39
+ "T must be of type GarbageCollected or GarbageCollectedMixin");
40
+
41
+ static size_t GetSize(const T& object) {
42
+ return GetObjectSizeForGarbageCollected(&object);
43
+ }
44
+ };
45
+
46
+ template <typename T>
47
+ struct ObjectSizeTrait<T, true> : cppgc::internal::BaseObjectSizeTrait {
48
+ static_assert(sizeof(T), "T must be fully defined");
49
+
50
+ static size_t GetSize(const T& object) {
51
+ return GetObjectSizeForGarbageCollectedMixin(&object);
52
+ }
53
+ };
54
+
55
+ } // namespace subtle
56
+ } // namespace cppgc
57
+
58
+ #endif // INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
@@ -9,6 +9,7 @@
9
9
 
10
10
  #include "cppgc/internal/persistent-node.h"
11
11
  #include "cppgc/internal/pointer-policies.h"
12
+ #include "cppgc/sentinel-pointer.h"
12
13
  #include "cppgc/source-location.h"
13
14
  #include "cppgc/type-traits.h"
14
15
  #include "cppgc/visitor.h"
@@ -20,13 +21,15 @@ class Visitor;
20
21
 
21
22
  namespace internal {
22
23
 
24
+ // PersistentBase always refers to the object as const object and defers to
25
+ // BasicPersistent on casting to the right type as needed.
23
26
  class PersistentBase {
24
27
  protected:
25
28
  PersistentBase() = default;
26
- explicit PersistentBase(void* raw) : raw_(raw) {}
29
+ explicit PersistentBase(const void* raw) : raw_(raw) {}
27
30
 
28
- void* GetValue() const { return raw_; }
29
- void SetValue(void* value) { raw_ = value; }
31
+ const void* GetValue() const { return raw_; }
32
+ void SetValue(const void* value) { raw_ = value; }
30
33
 
31
34
  PersistentNode* GetNode() const { return node_; }
32
35
  void SetNode(PersistentNode* node) { node_ = node; }
@@ -39,7 +42,7 @@ class PersistentBase {
39
42
  }
40
43
 
41
44
  private:
42
- mutable void* raw_ = nullptr;
45
+ mutable const void* raw_ = nullptr;
43
46
  mutable PersistentNode* node_ = nullptr;
44
47
 
45
48
  friend class PersistentRegion;
@@ -92,7 +95,7 @@ class BasicPersistent final : public PersistentBase,
92
95
  template <typename U, typename OtherWeaknessPolicy,
93
96
  typename OtherLocationPolicy, typename OtherCheckingPolicy,
94
97
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
95
- BasicPersistent( // NOLINT
98
+ BasicPersistent(
96
99
  const BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
97
100
  OtherCheckingPolicy>& other,
98
101
  const SourceLocation& loc = SourceLocation::Current())
@@ -115,7 +118,7 @@ class BasicPersistent final : public PersistentBase,
115
118
  template <typename U, typename MemberBarrierPolicy,
116
119
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
117
120
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
118
- BasicPersistent(internal::BasicMember<U, MemberBarrierPolicy, // NOLINT
121
+ BasicPersistent(internal::BasicMember<U, MemberBarrierPolicy,
119
122
  MemberWeaknessTag, MemberCheckingPolicy>
120
123
  member,
121
124
  const SourceLocation& loc = SourceLocation::Current())
@@ -138,7 +141,7 @@ class BasicPersistent final : public PersistentBase,
138
141
  }
139
142
 
140
143
  // Move assignment.
141
- BasicPersistent& operator=(BasicPersistent&& other) {
144
+ BasicPersistent& operator=(BasicPersistent&& other) noexcept {
142
145
  if (this == &other) return *this;
143
146
  Clear();
144
147
  PersistentBase::operator=(std::move(other));
@@ -186,10 +189,21 @@ class BasicPersistent final : public PersistentBase,
186
189
  // heterogeneous assignments between different Member and Persistent handles
187
190
  // based on their actual types.
188
191
  V8_CLANG_NO_SANITIZE("cfi-unrelated-cast") T* Get() const {
189
- return static_cast<T*>(GetValue());
192
+ // The const_cast below removes the constness from PersistentBase storage.
193
+ // The following static_cast re-adds any constness if specified through the
194
+ // user-visible template parameter T.
195
+ return static_cast<T*>(const_cast<void*>(GetValue()));
190
196
  }
191
197
 
192
- void Clear() { Assign(nullptr); }
198
+ void Clear() {
199
+ // Simplified version of `Assign()` to allow calling without a complete type
200
+ // `T`.
201
+ if (IsValid()) {
202
+ WeaknessPolicy::GetPersistentRegion(GetValue()).FreeNode(GetNode());
203
+ SetNode(nullptr);
204
+ }
205
+ SetValue(nullptr);
206
+ }
193
207
 
194
208
  T* Release() {
195
209
  T* result = Get();
@@ -197,6 +211,16 @@ class BasicPersistent final : public PersistentBase,
197
211
  return result;
198
212
  }
199
213
 
214
+ template <typename U, typename OtherWeaknessPolicy = WeaknessPolicy,
215
+ typename OtherLocationPolicy = LocationPolicy,
216
+ typename OtherCheckingPolicy = CheckingPolicy>
217
+ BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
218
+ OtherCheckingPolicy>
219
+ To() const {
220
+ return BasicPersistent<U, OtherWeaknessPolicy, OtherLocationPolicy,
221
+ OtherCheckingPolicy>(static_cast<U*>(Get()));
222
+ }
223
+
200
224
  private:
201
225
  static void Trace(Visitor* v, const void* ptr) {
202
226
  const auto* persistent = static_cast<const BasicPersistent*>(ptr);
@@ -5,6 +5,8 @@
5
5
  #ifndef INCLUDE_CPPGC_PLATFORM_H_
6
6
  #define INCLUDE_CPPGC_PLATFORM_H_
7
7
 
8
+ #include <memory>
9
+
8
10
  #include "v8-platform.h" // NOLINT(build/include_directory)
9
11
  #include "v8config.h" // NOLINT(build/include_directory)
10
12
 
@@ -20,6 +22,7 @@ using PageAllocator = v8::PageAllocator;
20
22
  using Task = v8::Task;
21
23
  using TaskPriority = v8::TaskPriority;
22
24
  using TaskRunner = v8::TaskRunner;
25
+ using TracingController = v8::TracingController;
23
26
 
24
27
  /**
25
28
  * Platform interface used by Heap. Contains allocators and executors.
@@ -51,22 +54,23 @@ class V8_EXPORT Platform {
51
54
  }
52
55
 
53
56
  /**
54
- * Posts |job_task| to run in parallel. Returns a JobHandle associated with
55
- * the Job, which can be joined or canceled.
57
+ * Posts `job_task` to run in parallel. Returns a `JobHandle` associated with
58
+ * the `Job`, which can be joined or canceled.
56
59
  * This avoids degenerate cases:
57
- * - Calling CallOnWorkerThread() for each work item, causing significant
60
+ * - Calling `CallOnWorkerThread()` for each work item, causing significant
58
61
  * overhead.
59
- * - Fixed number of CallOnWorkerThread() calls that split the work and might
60
- * run for a long time. This is problematic when many components post
62
+ * - Fixed number of `CallOnWorkerThread()` calls that split the work and
63
+ * might run for a long time. This is problematic when many components post
61
64
  * "num cores" tasks and all expect to use all the cores. In these cases,
62
65
  * the scheduler lacks context to be fair to multiple same-priority requests
63
66
  * and/or ability to request lower priority work to yield when high priority
64
67
  * work comes in.
65
- * A canonical implementation of |job_task| looks like:
68
+ * A canonical implementation of `job_task` looks like:
69
+ * \code
66
70
  * class MyJobTask : public JobTask {
67
71
  * public:
68
72
  * MyJobTask(...) : worker_queue_(...) {}
69
- * // JobTask:
73
+ * // JobTask implementation.
70
74
  * void Run(JobDelegate* delegate) override {
71
75
  * while (!delegate->ShouldYield()) {
72
76
  * // Smallest unit of work.
@@ -80,43 +84,62 @@ class V8_EXPORT Platform {
80
84
  * return worker_queue_.GetSize(); // Thread safe.
81
85
  * }
82
86
  * };
87
+ *
88
+ * // ...
83
89
  * auto handle = PostJob(TaskPriority::kUserVisible,
84
90
  * std::make_unique<MyJobTask>(...));
85
91
  * handle->Join();
92
+ * \endcode
86
93
  *
87
- * PostJob() and methods of the returned JobHandle/JobDelegate, must never be
88
- * called while holding a lock that could be acquired by JobTask::Run or
89
- * JobTask::GetMaxConcurrency -- that could result in a deadlock. This is
90
- * because [1] JobTask::GetMaxConcurrency may be invoked while holding
91
- * internal lock (A), hence JobTask::GetMaxConcurrency can only use a lock (B)
92
- * if that lock is *never* held while calling back into JobHandle from any
93
- * thread (A=>B/B=>A deadlock) and [2] JobTask::Run or
94
- * JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle
95
- * (B=>JobHandle::foo=>B deadlock).
94
+ * `PostJob()` and methods of the returned JobHandle/JobDelegate, must never
95
+ * be called while holding a lock that could be acquired by `JobTask::Run()`
96
+ * or `JobTask::GetMaxConcurrency()` -- that could result in a deadlock. This
97
+ * is because (1) `JobTask::GetMaxConcurrency()` may be invoked while holding
98
+ * internal lock (A), hence `JobTask::GetMaxConcurrency()` can only use a lock
99
+ * (B) if that lock is *never* held while calling back into `JobHandle` from
100
+ * any thread (A=>B/B=>A deadlock) and (2) `JobTask::Run()` or
101
+ * `JobTask::GetMaxConcurrency()` may be invoked synchronously from
102
+ * `JobHandle` (B=>JobHandle::foo=>B deadlock).
96
103
  *
97
- * A sufficient PostJob() implementation that uses the default Job provided in
98
- * libplatform looks like:
99
- * std::unique_ptr<JobHandle> PostJob(
100
- * TaskPriority priority, std::unique_ptr<JobTask> job_task) override {
101
- * return std::make_unique<DefaultJobHandle>(
102
- * std::make_shared<DefaultJobState>(
103
- * this, std::move(job_task), kNumThreads));
104
+ * A sufficient `PostJob()` implementation that uses the default Job provided
105
+ * in libplatform looks like:
106
+ * \code
107
+ * std::unique_ptr<JobHandle> PostJob(
108
+ * TaskPriority priority, std::unique_ptr<JobTask> job_task) override {
109
+ * return std::make_unique<DefaultJobHandle>(
110
+ * std::make_shared<DefaultJobState>(
111
+ * this, std::move(job_task), kNumThreads));
104
112
  * }
113
+ * \endcode
105
114
  */
106
115
  virtual std::unique_ptr<JobHandle> PostJob(
107
116
  TaskPriority priority, std::unique_ptr<JobTask> job_task) {
108
117
  return nullptr;
109
118
  }
119
+
120
+ /**
121
+ * Returns an instance of a `TracingController`. This must be non-nullptr. The
122
+ * default implementation returns an empty `TracingController` that consumes
123
+ * trace data without effect.
124
+ */
125
+ virtual TracingController* GetTracingController();
110
126
  };
111
127
 
112
128
  /**
113
129
  * Process-global initialization of the garbage collector. Must be called before
114
130
  * creating a Heap.
131
+ *
132
+ * Can be called multiple times when paired with `ShutdownProcess()`.
133
+ *
134
+ * \param page_allocator The allocator used for maintaining meta data. Must not
135
+ * change between multiple calls to InitializeProcess.
115
136
  */
116
- V8_EXPORT void InitializeProcess(PageAllocator*);
137
+ V8_EXPORT void InitializeProcess(PageAllocator* page_allocator);
117
138
 
118
139
  /**
119
- * Must be called after destroying the last used heap.
140
+ * Must be called after destroying the last used heap. Some process-global
141
+ * metadata may not be returned and reused upon a subsequent
142
+ * `InitializeProcess()` call.
120
143
  */
121
144
  V8_EXPORT void ShutdownProcess();
122
145
 
@@ -34,7 +34,7 @@ class PrefinalizerRegistration final {
34
34
  public: \
35
35
  static bool InvokePreFinalizer(const cppgc::LivenessBroker& liveness_broker, \
36
36
  void* object) { \
37
- static_assert(cppgc::internal::IsGarbageCollectedTypeV<Class>, \
37
+ static_assert(cppgc::IsGarbageCollectedOrMixinTypeV<Class>, \
38
38
  "Only garbage collected objects can have prefinalizers"); \
39
39
  Class* self = static_cast<Class*>(object); \
40
40
  if (liveness_broker.IsHeapObjectAlive(self)) return false; \
@@ -0,0 +1,36 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
6
+ #define INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
7
+
8
+ #include <atomic>
9
+ #include <cstddef>
10
+
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+ class ProcessHeapStatisticsUpdater;
16
+ } // namespace internal
17
+
18
+ class V8_EXPORT ProcessHeapStatistics final {
19
+ public:
20
+ static size_t TotalAllocatedObjectSize() {
21
+ return total_allocated_object_size_.load(std::memory_order_relaxed);
22
+ }
23
+ static size_t TotalAllocatedSpace() {
24
+ return total_allocated_space_.load(std::memory_order_relaxed);
25
+ }
26
+
27
+ private:
28
+ static std::atomic_size_t total_allocated_space_;
29
+ static std::atomic_size_t total_allocated_object_size_;
30
+
31
+ friend class internal::ProcessHeapStatisticsUpdater;
32
+ };
33
+
34
+ } // namespace cppgc
35
+
36
+ #endif // INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
@@ -0,0 +1,32 @@
1
+ // Copyright 2021 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_SENTINEL_POINTER_H_
6
+ #define INCLUDE_CPPGC_SENTINEL_POINTER_H_
7
+
8
+ #include <cstdint>
9
+
10
+ namespace cppgc {
11
+ namespace internal {
12
+
13
+ // Special tag type used to denote some sentinel member. The semantics of the
14
+ // sentinel is defined by the embedder.
15
+ struct SentinelPointer {
16
+ template <typename T>
17
+ operator T*() const {
18
+ static constexpr intptr_t kSentinelValue = 1;
19
+ return reinterpret_cast<T*>(kSentinelValue);
20
+ }
21
+ // Hidden friends.
22
+ friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
23
+ friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
24
+ };
25
+
26
+ } // namespace internal
27
+
28
+ constexpr internal::SentinelPointer kSentinelPointer;
29
+
30
+ } // namespace cppgc
31
+
32
+ #endif // INCLUDE_CPPGC_SENTINEL_POINTER_H_
@@ -5,6 +5,7 @@
5
5
  #ifndef INCLUDE_CPPGC_SOURCE_LOCATION_H_
6
6
  #define INCLUDE_CPPGC_SOURCE_LOCATION_H_
7
7
 
8
+ #include <cstddef>
8
9
  #include <string>
9
10
 
10
11
  #include "v8config.h" // NOLINT(build/include_directory)
@@ -25,7 +26,7 @@ namespace cppgc {
25
26
 
26
27
  /**
27
28
  * Encapsulates source location information. Mimics C++20's
28
- * std::source_location.
29
+ * `std::source_location`.
29
30
  */
30
31
  class V8_EXPORT SourceLocation final {
31
32
  public:
@@ -0,0 +1,99 @@
1
+ // Copyright 2021 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_TESTING_H_
6
+ #define INCLUDE_CPPGC_TESTING_H_
7
+
8
+ #include "cppgc/common.h"
9
+ #include "cppgc/macros.h"
10
+ #include "v8config.h" // NOLINT(build/include_directory)
11
+
12
+ namespace cppgc {
13
+
14
+ class HeapHandle;
15
+
16
+ /**
17
+ * Namespace contains testing helpers.
18
+ */
19
+ namespace testing {
20
+
21
+ /**
22
+ * Overrides the state of the stack with the provided value. Takes precedence
23
+ * over other parameters that set the stack state. Must no be nested.
24
+ */
25
+ class V8_EXPORT V8_NODISCARD OverrideEmbedderStackStateScope final {
26
+ CPPGC_STACK_ALLOCATED();
27
+
28
+ public:
29
+ /**
30
+ * Constructs a scoped object that automatically enters and leaves the scope.
31
+ *
32
+ * \param heap_handle The corresponding heap.
33
+ */
34
+ explicit OverrideEmbedderStackStateScope(HeapHandle& heap_handle,
35
+ EmbedderStackState state);
36
+ ~OverrideEmbedderStackStateScope();
37
+
38
+ OverrideEmbedderStackStateScope(const OverrideEmbedderStackStateScope&) =
39
+ delete;
40
+ OverrideEmbedderStackStateScope& operator=(
41
+ const OverrideEmbedderStackStateScope&) = delete;
42
+
43
+ private:
44
+ HeapHandle& heap_handle_;
45
+ };
46
+
47
+ /**
48
+ * Testing interface for managed heaps that allows for controlling garbage
49
+ * collection timings. Embedders should use this class when testing the
50
+ * interaction of their code with incremental/concurrent garbage collection.
51
+ */
52
+ class V8_EXPORT StandaloneTestingHeap final {
53
+ public:
54
+ explicit StandaloneTestingHeap(HeapHandle&);
55
+
56
+ /**
57
+ * Start an incremental garbage collection.
58
+ */
59
+ void StartGarbageCollection();
60
+
61
+ /**
62
+ * Perform an incremental step. This will also schedule concurrent steps if
63
+ * needed.
64
+ *
65
+ * \param stack_state The state of the stack during the step.
66
+ */
67
+ bool PerformMarkingStep(EmbedderStackState stack_state);
68
+
69
+ /**
70
+ * Finalize the current garbage collection cycle atomically.
71
+ * Assumes that garbage collection is in progress.
72
+ *
73
+ * \param stack_state The state of the stack for finalizing the garbage
74
+ * collection cycle.
75
+ */
76
+ void FinalizeGarbageCollection(EmbedderStackState stack_state);
77
+
78
+ /**
79
+ * Toggle main thread marking on/off. Allows to stress concurrent marking
80
+ * (e.g. to better detect data races).
81
+ *
82
+ * \param should_mark Denotes whether the main thread should contribute to
83
+ * marking. Defaults to true.
84
+ */
85
+ void ToggleMainThreadMarking(bool should_mark);
86
+
87
+ /**
88
+ * Force enable compaction for the next garbage collection cycle.
89
+ */
90
+ void ForceCompactionForNextGarbageCollection();
91
+
92
+ private:
93
+ HeapHandle& heap_handle_;
94
+ };
95
+
96
+ } // namespace testing
97
+ } // namespace cppgc
98
+
99
+ #endif // INCLUDE_CPPGC_TESTING_H_
@@ -55,8 +55,6 @@ struct V8_EXPORT TraceTraitFromInnerAddressImpl {
55
55
  static TraceDescriptor GetTraceDescriptor(const void* address);
56
56
  };
57
57
 
58
- } // namespace internal
59
-
60
58
  /**
61
59
  * Trait specifying how the garbage collector processes an object of type T.
62
60
  *
@@ -64,7 +62,7 @@ struct V8_EXPORT TraceTraitFromInnerAddressImpl {
64
62
  * type.
65
63
  */
66
64
  template <typename T>
67
- struct TraceTrait {
65
+ struct TraceTraitBase {
68
66
  static_assert(internal::IsTraceableV<T>, "T must have a Trace() method");
69
67
 
70
68
  /**
@@ -89,10 +87,17 @@ struct TraceTrait {
89
87
  }
90
88
  };
91
89
 
90
+ } // namespace internal
91
+
92
+ template <typename T>
93
+ struct TraceTrait : public internal::TraceTraitBase<T> {};
94
+
92
95
  namespace internal {
93
96
 
94
97
  template <typename T>
95
98
  struct TraceTraitImpl<T, false> {
99
+ static_assert(IsGarbageCollectedTypeV<T>,
100
+ "T must be of type GarbageCollected or GarbageCollectedMixin");
96
101
  static TraceDescriptor GetTraceDescriptor(const void* self) {
97
102
  return {self, TraceTrait<T>::Trace};
98
103
  }