libv8-node 15.14.0.1-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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +1 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/include/cppgc/allocation.h +104 -45
  6. data/vendor/v8/include/cppgc/common.h +9 -6
  7. data/vendor/v8/include/cppgc/cross-thread-persistent.h +384 -0
  8. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  9. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  10. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  11. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  12. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  13. data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
  14. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  15. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  16. data/vendor/v8/include/cppgc/heap.h +68 -6
  17. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  18. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -1
  19. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  20. data/vendor/v8/include/cppgc/internal/gc-info.h +44 -13
  21. data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
  22. data/vendor/v8/include/cppgc/internal/persistent-node.h +57 -1
  23. data/vendor/v8/include/cppgc/internal/pointer-policies.h +69 -28
  24. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  25. data/vendor/v8/include/cppgc/internal/write-barrier.h +353 -35
  26. data/vendor/v8/include/cppgc/liveness-broker.h +7 -1
  27. data/vendor/v8/include/cppgc/macros.h +2 -0
  28. data/vendor/v8/include/cppgc/member.h +85 -25
  29. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  30. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  31. data/vendor/v8/include/cppgc/persistent.h +33 -9
  32. data/vendor/v8/include/cppgc/platform.h +48 -25
  33. data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
  34. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  35. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  36. data/vendor/v8/include/cppgc/source-location.h +2 -1
  37. data/vendor/v8/include/cppgc/testing.h +99 -0
  38. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  39. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  40. data/vendor/v8/include/cppgc/visitor.h +187 -23
  41. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  42. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  43. data/vendor/v8/include/v8-cppgc.h +258 -159
  44. data/vendor/v8/include/v8-fast-api-calls.h +562 -159
  45. data/vendor/v8/include/v8-inspector.h +23 -2
  46. data/vendor/v8/include/v8-internal.h +99 -27
  47. data/vendor/v8/include/v8-metrics.h +77 -8
  48. data/vendor/v8/include/v8-platform.h +47 -22
  49. data/vendor/v8/include/v8-profiler.h +75 -11
  50. data/vendor/v8/include/v8-unwinder-state.h +30 -0
  51. data/vendor/v8/include/v8-util.h +1 -1
  52. data/vendor/v8/include/v8-version.h +4 -4
  53. data/vendor/v8/include/v8.h +1192 -642
  54. data/vendor/v8/include/v8config.h +40 -9
  55. data/vendor/v8/{out.gn → x86_64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
  56. metadata +17 -5
  57. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -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
  }
@@ -5,6 +5,9 @@
5
5
  #ifndef INCLUDE_CPPGC_TYPE_TRAITS_H_
6
6
  #define INCLUDE_CPPGC_TYPE_TRAITS_H_
7
7
 
8
+ // This file should stay with minimal dependencies to allow embedder to check
9
+ // against Oilpan types without including any other parts.
10
+ #include <cstddef>
8
11
  #include <type_traits>
9
12
 
10
13
  namespace cppgc {
@@ -12,6 +15,14 @@ namespace cppgc {
12
15
  class Visitor;
13
16
 
14
17
  namespace internal {
18
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
19
+ typename CheckingPolicy>
20
+ class BasicMember;
21
+ struct DijkstraWriteBarrierPolicy;
22
+ struct NoWriteBarrierPolicy;
23
+ class StrongMemberTag;
24
+ class UntracedMemberTag;
25
+ class WeakMemberTag;
15
26
 
16
27
  // Pre-C++17 custom implementation of std::void_t.
17
28
  template <typename... Ts>
@@ -25,18 +36,6 @@ using void_t = typename make_void<Ts...>::type;
25
36
  template <typename T>
26
37
  struct IsWeak : std::false_type {};
27
38
 
28
- template <typename T, template <typename... V> class U>
29
- struct IsSubclassOfTemplate {
30
- private:
31
- template <typename... W>
32
- static std::true_type SubclassCheck(U<W...>*);
33
- static std::false_type SubclassCheck(...);
34
-
35
- public:
36
- static constexpr bool value =
37
- decltype(SubclassCheck(std::declval<T*>()))::value;
38
- };
39
-
40
39
  // IsTraceMethodConst is used to verify that all Trace methods are marked as
41
40
  // const. It is equivalent to IsTraceable but for a non-const object.
42
41
  template <typename T, typename = void>
@@ -67,12 +66,12 @@ template <typename T>
67
66
  constexpr bool IsTraceableV = IsTraceable<T>::value;
68
67
 
69
68
  template <typename T, typename = void>
70
- struct IsGarbageCollectedMixinType : std::false_type {
69
+ struct HasGarbageCollectedMixinTypeMarker : std::false_type {
71
70
  static_assert(sizeof(T), "T must be fully defined");
72
71
  };
73
72
 
74
73
  template <typename T>
75
- struct IsGarbageCollectedMixinType<
74
+ struct HasGarbageCollectedMixinTypeMarker<
76
75
  T,
77
76
  void_t<typename std::remove_const_t<T>::IsGarbageCollectedMixinTypeMarker>>
78
77
  : std::true_type {
@@ -80,30 +79,169 @@ struct IsGarbageCollectedMixinType<
80
79
  };
81
80
 
82
81
  template <typename T, typename = void>
83
- struct IsGarbageCollectedType : IsGarbageCollectedMixinType<T> {
82
+ struct HasGarbageCollectedTypeMarker : std::false_type {
84
83
  static_assert(sizeof(T), "T must be fully defined");
85
84
  };
86
85
 
87
86
  template <typename T>
88
- struct IsGarbageCollectedType<
87
+ struct HasGarbageCollectedTypeMarker<
89
88
  T, void_t<typename std::remove_const_t<T>::IsGarbageCollectedTypeMarker>>
90
89
  : std::true_type {
91
90
  static_assert(sizeof(T), "T must be fully defined");
92
91
  };
93
92
 
93
+ template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value,
94
+ bool = HasGarbageCollectedMixinTypeMarker<T>::value>
95
+ struct IsGarbageCollectedMixinType : std::false_type {
96
+ static_assert(sizeof(T), "T must be fully defined");
97
+ };
98
+
94
99
  template <typename T>
95
- constexpr bool IsGarbageCollectedTypeV =
96
- internal::IsGarbageCollectedType<T>::value;
100
+ struct IsGarbageCollectedMixinType<T, false, true> : std::true_type {
101
+ static_assert(sizeof(T), "T must be fully defined");
102
+ };
103
+
104
+ template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value>
105
+ struct IsGarbageCollectedType : std::false_type {
106
+ static_assert(sizeof(T), "T must be fully defined");
107
+ };
97
108
 
109
+ template <typename T>
110
+ struct IsGarbageCollectedType<T, true> : std::true_type {
111
+ static_assert(sizeof(T), "T must be fully defined");
112
+ };
113
+
114
+ template <typename T>
115
+ struct IsGarbageCollectedOrMixinType
116
+ : std::integral_constant<bool, IsGarbageCollectedType<T>::value ||
117
+ IsGarbageCollectedMixinType<T>::value> {
118
+ static_assert(sizeof(T), "T must be fully defined");
119
+ };
120
+
121
+ template <typename T, bool = (HasGarbageCollectedTypeMarker<T>::value &&
122
+ HasGarbageCollectedMixinTypeMarker<T>::value)>
123
+ struct IsGarbageCollectedWithMixinType : std::false_type {
124
+ static_assert(sizeof(T), "T must be fully defined");
125
+ };
126
+
127
+ template <typename T>
128
+ struct IsGarbageCollectedWithMixinType<T, true> : std::true_type {
129
+ static_assert(sizeof(T), "T must be fully defined");
130
+ };
131
+
132
+ template <typename BasicMemberCandidate, typename WeaknessTag,
133
+ typename WriteBarrierPolicy>
134
+ struct IsSubclassOfBasicMemberTemplate {
135
+ private:
136
+ template <typename T, typename CheckingPolicy>
137
+ static std::true_type SubclassCheck(
138
+ BasicMember<T, WeaknessTag, WriteBarrierPolicy, CheckingPolicy>*);
139
+ static std::false_type SubclassCheck(...);
140
+
141
+ public:
142
+ static constexpr bool value =
143
+ decltype(SubclassCheck(std::declval<BasicMemberCandidate*>()))::value;
144
+ };
145
+
146
+ template <typename T,
147
+ bool = IsSubclassOfBasicMemberTemplate<
148
+ T, StrongMemberTag, DijkstraWriteBarrierPolicy>::value>
149
+ struct IsMemberType : std::false_type {};
150
+
151
+ template <typename T>
152
+ struct IsMemberType<T, true> : std::true_type {};
153
+
154
+ template <typename T, bool = IsSubclassOfBasicMemberTemplate<
155
+ T, WeakMemberTag, DijkstraWriteBarrierPolicy>::value>
156
+ struct IsWeakMemberType : std::false_type {};
157
+
158
+ template <typename T>
159
+ struct IsWeakMemberType<T, true> : std::true_type {};
160
+
161
+ template <typename T, bool = IsSubclassOfBasicMemberTemplate<
162
+ T, UntracedMemberTag, NoWriteBarrierPolicy>::value>
163
+ struct IsUntracedMemberType : std::false_type {};
164
+
165
+ template <typename T>
166
+ struct IsUntracedMemberType<T, true> : std::true_type {};
167
+
168
+ template <typename T>
169
+ struct IsComplete {
170
+ private:
171
+ template <typename U, size_t = sizeof(U)>
172
+ static std::true_type IsSizeOfKnown(U*);
173
+ static std::false_type IsSizeOfKnown(...);
174
+
175
+ public:
176
+ static constexpr bool value =
177
+ decltype(IsSizeOfKnown(std::declval<T*>()))::value;
178
+ };
179
+
180
+ } // namespace internal
181
+
182
+ /**
183
+ * Value is true for types that inherit from `GarbageCollectedMixin` but not
184
+ * `GarbageCollected<T>` (i.e., they are free mixins), and false otherwise.
185
+ */
98
186
  template <typename T>
99
187
  constexpr bool IsGarbageCollectedMixinTypeV =
100
188
  internal::IsGarbageCollectedMixinType<T>::value;
101
189
 
102
- } // namespace internal
190
+ /**
191
+ * Value is true for types that inherit from `GarbageCollected<T>`, and false
192
+ * otherwise.
193
+ */
194
+ template <typename T>
195
+ constexpr bool IsGarbageCollectedTypeV =
196
+ internal::IsGarbageCollectedType<T>::value;
197
+
198
+ /**
199
+ * Value is true for types that inherit from either `GarbageCollected<T>` or
200
+ * `GarbageCollectedMixin`, and false otherwise.
201
+ */
202
+ template <typename T>
203
+ constexpr bool IsGarbageCollectedOrMixinTypeV =
204
+ internal::IsGarbageCollectedOrMixinType<T>::value;
205
+
206
+ /**
207
+ * Value is true for types that inherit from `GarbageCollected<T>` and
208
+ * `GarbageCollectedMixin`, and false otherwise.
209
+ */
210
+ template <typename T>
211
+ constexpr bool IsGarbageCollectedWithMixinTypeV =
212
+ internal::IsGarbageCollectedWithMixinType<T>::value;
213
+
214
+ /**
215
+ * Value is true for types of type `Member<T>`, and false otherwise.
216
+ */
217
+ template <typename T>
218
+ constexpr bool IsMemberTypeV = internal::IsMemberType<T>::value;
219
+
220
+ /**
221
+ * Value is true for types of type `UntracedMember<T>`, and false otherwise.
222
+ */
223
+ template <typename T>
224
+ constexpr bool IsUntracedMemberTypeV = internal::IsUntracedMemberType<T>::value;
103
225
 
226
+ /**
227
+ * Value is true for types of type `WeakMember<T>`, and false otherwise.
228
+ */
229
+ template <typename T>
230
+ constexpr bool IsWeakMemberTypeV = internal::IsWeakMemberType<T>::value;
231
+
232
+ /**
233
+ * Value is true for types that are considered weak references, and false
234
+ * otherwise.
235
+ */
104
236
  template <typename T>
105
237
  constexpr bool IsWeakV = internal::IsWeak<T>::value;
106
238
 
239
+ /**
240
+ * Value is true for types that are complete, and false otherwise.
241
+ */
242
+ template <typename T>
243
+ constexpr bool IsCompleteV = internal::IsComplete<T>::value;
244
+
107
245
  } // namespace cppgc
108
246
 
109
247
  #endif // INCLUDE_CPPGC_TYPE_TRAITS_H_
@@ -5,6 +5,8 @@
5
5
  #ifndef INCLUDE_CPPGC_VISITOR_H_
6
6
  #define INCLUDE_CPPGC_VISITOR_H_
7
7
 
8
+ #include "cppgc/custom-space.h"
9
+ #include "cppgc/ephemeron-pair.h"
8
10
  #include "cppgc/garbage-collected.h"
9
11
  #include "cppgc/internal/logging.h"
10
12
  #include "cppgc/internal/pointer-policies.h"
@@ -12,17 +14,20 @@
12
14
  #include "cppgc/member.h"
13
15
  #include "cppgc/source-location.h"
14
16
  #include "cppgc/trace-trait.h"
17
+ #include "cppgc/type-traits.h"
15
18
 
16
19
  namespace cppgc {
17
20
 
18
21
  namespace internal {
22
+ template <typename T, typename WeaknessPolicy, typename LocationPolicy,
23
+ typename CheckingPolicy>
24
+ class BasicCrossThreadPersistent;
19
25
  template <typename T, typename WeaknessPolicy, typename LocationPolicy,
20
26
  typename CheckingPolicy>
21
27
  class BasicPersistent;
22
28
  class ConservativeTracingVisitor;
23
29
  class VisitorBase;
24
30
  class VisitorFactory;
25
-
26
31
  } // namespace internal
27
32
 
28
33
  using WeakCallback = void (*)(const LivenessBroker&, const void*);
@@ -44,7 +49,7 @@ using WeakCallback = void (*)(const LivenessBroker&, const void*);
44
49
  * };
45
50
  * \endcode
46
51
  */
47
- class Visitor {
52
+ class V8_EXPORT Visitor {
48
53
  public:
49
54
  class Key {
50
55
  private:
@@ -56,6 +61,22 @@ class Visitor {
56
61
 
57
62
  virtual ~Visitor() = default;
58
63
 
64
+ /**
65
+ * Trace method for raw pointers. Prefer the versions for managed pointers.
66
+ *
67
+ * \param member Reference retaining an object.
68
+ */
69
+ template <typename T>
70
+ void Trace(const T* t) {
71
+ static_assert(sizeof(T), "Pointee type must be fully defined.");
72
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
73
+ "T must be GarbageCollected or GarbageCollectedMixin type");
74
+ if (!t) {
75
+ return;
76
+ }
77
+ Visit(t, TraceTrait<T>::GetTraceDescriptor(t));
78
+ }
79
+
59
80
  /**
60
81
  * Trace method for Member.
61
82
  *
@@ -76,8 +97,10 @@ class Visitor {
76
97
  template <typename T>
77
98
  void Trace(const WeakMember<T>& weak_member) {
78
99
  static_assert(sizeof(T), "Pointee type must be fully defined.");
79
- static_assert(internal::IsGarbageCollectedType<T>::value,
100
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
80
101
  "T must be GarbageCollected or GarbageCollectedMixin type");
102
+ static_assert(!internal::IsAllocatedOnCompactableSpace<T>::value,
103
+ "Weak references to compactable objects are not allowed");
81
104
 
82
105
  const T* value = weak_member.GetRawAtomic();
83
106
 
@@ -86,8 +109,7 @@ class Visitor {
86
109
  return;
87
110
  }
88
111
 
89
- // TODO(chromium:1056170): DCHECK (or similar) for deleted values as they
90
- // should come in at a different path.
112
+ CPPGC_DCHECK(value != kSentinelPointer);
91
113
  VisitWeak(value, TraceTrait<T>::GetTraceDescriptor(value),
92
114
  &HandleWeak<WeakMember<T>>, &weak_member);
93
115
  }
@@ -121,6 +143,128 @@ class Visitor {
121
143
  RegisterWeakCallback(&WeakCallbackMethodDelegate<T, method>, object);
122
144
  }
123
145
 
146
+ /**
147
+ * Trace method for EphemeronPair.
148
+ *
149
+ * \param ephemeron_pair EphemeronPair reference weakly retaining a key object
150
+ * and strongly retaining a value object in case the key object is alive.
151
+ */
152
+ template <typename K, typename V>
153
+ void Trace(const EphemeronPair<K, V>& ephemeron_pair) {
154
+ TraceEphemeron(ephemeron_pair.key, &ephemeron_pair.value);
155
+ RegisterWeakCallbackMethod<EphemeronPair<K, V>,
156
+ &EphemeronPair<K, V>::ClearValueIfKeyIsDead>(
157
+ &ephemeron_pair);
158
+ }
159
+
160
+ /**
161
+ * Trace method for a single ephemeron. Used for tracing a raw ephemeron in
162
+ * which the `key` and `value` are kept separately.
163
+ *
164
+ * \param weak_member_key WeakMember reference weakly retaining a key object.
165
+ * \param member_value Member reference with ephemeron semantics.
166
+ */
167
+ template <typename KeyType, typename ValueType>
168
+ void TraceEphemeron(const WeakMember<KeyType>& weak_member_key,
169
+ const Member<ValueType>* member_value) {
170
+ const KeyType* key = weak_member_key.GetRawAtomic();
171
+ if (!key) return;
172
+
173
+ // `value` must always be non-null.
174
+ CPPGC_DCHECK(member_value);
175
+ const ValueType* value = member_value->GetRawAtomic();
176
+ if (!value) return;
177
+
178
+ // KeyType and ValueType may refer to GarbageCollectedMixin.
179
+ TraceDescriptor value_desc =
180
+ TraceTrait<ValueType>::GetTraceDescriptor(value);
181
+ CPPGC_DCHECK(value_desc.base_object_payload);
182
+ const void* key_base_object_payload =
183
+ TraceTrait<KeyType>::GetTraceDescriptor(key).base_object_payload;
184
+ CPPGC_DCHECK(key_base_object_payload);
185
+
186
+ VisitEphemeron(key_base_object_payload, value, value_desc);
187
+ }
188
+
189
+ /**
190
+ * Trace method for a single ephemeron. Used for tracing a raw ephemeron in
191
+ * which the `key` and `value` are kept separately. Note that this overload
192
+ * is for non-GarbageCollected `value`s that can be traced though.
193
+ *
194
+ * \param key `WeakMember` reference weakly retaining a key object.
195
+ * \param value Reference weakly retaining a value object. Note that
196
+ * `ValueType` here should not be `Member`. It is expected that
197
+ * `TraceTrait<ValueType>::GetTraceDescriptor(value)` returns a
198
+ * `TraceDescriptor` with a null base pointer but a valid trace method.
199
+ */
200
+ template <typename KeyType, typename ValueType>
201
+ void TraceEphemeron(const WeakMember<KeyType>& weak_member_key,
202
+ const ValueType* value) {
203
+ static_assert(!IsGarbageCollectedOrMixinTypeV<ValueType>,
204
+ "garbage-collected types must use WeakMember and Member");
205
+ const KeyType* key = weak_member_key.GetRawAtomic();
206
+ if (!key) return;
207
+
208
+ // `value` must always be non-null.
209
+ CPPGC_DCHECK(value);
210
+ TraceDescriptor value_desc =
211
+ TraceTrait<ValueType>::GetTraceDescriptor(value);
212
+ // `value_desc.base_object_payload` must be null as this override is only
213
+ // taken for non-garbage-collected values.
214
+ CPPGC_DCHECK(!value_desc.base_object_payload);
215
+
216
+ // KeyType might be a GarbageCollectedMixin.
217
+ const void* key_base_object_payload =
218
+ TraceTrait<KeyType>::GetTraceDescriptor(key).base_object_payload;
219
+ CPPGC_DCHECK(key_base_object_payload);
220
+
221
+ VisitEphemeron(key_base_object_payload, value, value_desc);
222
+ }
223
+
224
+ /**
225
+ * Trace method that strongifies a WeakMember.
226
+ *
227
+ * \param weak_member WeakMember reference retaining an object.
228
+ */
229
+ template <typename T>
230
+ void TraceStrongly(const WeakMember<T>& weak_member) {
231
+ const T* value = weak_member.GetRawAtomic();
232
+ CPPGC_DCHECK(value != kSentinelPointer);
233
+ Trace(value);
234
+ }
235
+
236
+ /**
237
+ * Trace method for weak containers.
238
+ *
239
+ * \param object reference of the weak container.
240
+ * \param callback to be invoked.
241
+ * \param data custom data that is passed to the callback.
242
+ */
243
+ template <typename T>
244
+ void TraceWeakContainer(const T* object, WeakCallback callback,
245
+ const void* data) {
246
+ if (!object) return;
247
+ VisitWeakContainer(object, TraceTrait<T>::GetTraceDescriptor(object),
248
+ TraceTrait<T>::GetWeakTraceDescriptor(object), callback,
249
+ data);
250
+ }
251
+
252
+ /**
253
+ * Registers a slot containing a reference to an object allocated on a
254
+ * compactable space. Such references maybe be arbitrarily moved by the GC.
255
+ *
256
+ * \param slot location of reference to object that might be moved by the GC.
257
+ */
258
+ template <typename T>
259
+ void RegisterMovableReference(const T** slot) {
260
+ static_assert(internal::IsAllocatedOnCompactableSpace<T>::value,
261
+ "Only references to objects allocated on compactable spaces "
262
+ "should be registered as movable slots.");
263
+ static_assert(!IsGarbageCollectedMixinTypeV<T>,
264
+ "Mixin types do not support compaction.");
265
+ HandleMovableReference(reinterpret_cast<const void**>(slot));
266
+ }
267
+
124
268
  /**
125
269
  * Registers a weak callback that is invoked during garbage collection.
126
270
  *
@@ -129,13 +273,38 @@ class Visitor {
129
273
  */
130
274
  virtual void RegisterWeakCallback(WeakCallback callback, const void* data) {}
131
275
 
276
+ /**
277
+ * Defers tracing an object from a concurrent thread to the mutator thread.
278
+ * Should be called by Trace methods of types that are not safe to trace
279
+ * concurrently.
280
+ *
281
+ * \param parameter tells the trace callback which object was deferred.
282
+ * \param callback to be invoked for tracing on the mutator thread.
283
+ * \param deferred_size size of deferred object.
284
+ *
285
+ * \returns false if the object does not need to be deferred (i.e. currently
286
+ * traced on the mutator thread) and true otherwise (i.e. currently traced on
287
+ * a concurrent thread).
288
+ */
289
+ virtual V8_WARN_UNUSED_RESULT bool DeferTraceToMutatorThreadIfConcurrent(
290
+ const void* parameter, TraceCallback callback, size_t deferred_size) {
291
+ // By default tracing is not deferred.
292
+ return false;
293
+ }
294
+
132
295
  protected:
133
296
  virtual void Visit(const void* self, TraceDescriptor) {}
134
297
  virtual void VisitWeak(const void* self, TraceDescriptor, WeakCallback,
135
298
  const void* weak_member) {}
136
- virtual void VisitRoot(const void*, TraceDescriptor) {}
299
+ virtual void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) {}
137
300
  virtual void VisitWeakRoot(const void* self, TraceDescriptor, WeakCallback,
138
- const void* weak_root) {}
301
+ const void* weak_root, const SourceLocation&) {}
302
+ virtual void VisitEphemeron(const void* key, const void* value,
303
+ TraceDescriptor value_desc) {}
304
+ virtual void VisitWeakContainer(const void* self, TraceDescriptor strong_desc,
305
+ TraceDescriptor weak_desc,
306
+ WeakCallback callback, const void* data) {}
307
+ virtual void HandleMovableReference(const void**) {}
139
308
 
140
309
  private:
141
310
  template <typename T, void (T::*method)(const LivenessBroker&)>
@@ -163,13 +332,14 @@ class Visitor {
163
332
  using PointeeType = typename Persistent::PointeeType;
164
333
  static_assert(sizeof(PointeeType),
165
334
  "Persistent's pointee type must be fully defined");
166
- static_assert(internal::IsGarbageCollectedType<PointeeType>::value,
335
+ static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
167
336
  "Persistent's pointee type must be GarbageCollected or "
168
337
  "GarbageCollectedMixin");
169
338
  if (!p.Get()) {
170
339
  return;
171
340
  }
172
- VisitRoot(p.Get(), TraceTrait<PointeeType>::GetTraceDescriptor(p.Get()));
341
+ VisitRoot(p.Get(), TraceTrait<PointeeType>::GetTraceDescriptor(p.Get()),
342
+ loc);
173
343
  }
174
344
 
175
345
  template <
@@ -179,28 +349,22 @@ class Visitor {
179
349
  using PointeeType = typename WeakPersistent::PointeeType;
180
350
  static_assert(sizeof(PointeeType),
181
351
  "Persistent's pointee type must be fully defined");
182
- static_assert(internal::IsGarbageCollectedType<PointeeType>::value,
352
+ static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
183
353
  "Persistent's pointee type must be GarbageCollected or "
184
354
  "GarbageCollectedMixin");
355
+ static_assert(!internal::IsAllocatedOnCompactableSpace<PointeeType>::value,
356
+ "Weak references to compactable objects are not allowed");
185
357
  VisitWeakRoot(p.Get(), TraceTrait<PointeeType>::GetTraceDescriptor(p.Get()),
186
- &HandleWeak<WeakPersistent>, &p);
187
- }
188
-
189
- template <typename T>
190
- void Trace(const T* t) {
191
- static_assert(sizeof(T), "Pointee type must be fully defined.");
192
- static_assert(internal::IsGarbageCollectedType<T>::value,
193
- "T must be GarbageCollected or GarbageCollectedMixin type");
194
- if (!t) {
195
- return;
196
- }
197
- Visit(t, TraceTrait<T>::GetTraceDescriptor(t));
358
+ &HandleWeak<WeakPersistent>, &p, loc);
198
359
  }
199
360
 
200
361
  #if V8_ENABLE_CHECKS
201
- V8_EXPORT void CheckObjectNotInConstruction(const void* address);
362
+ void CheckObjectNotInConstruction(const void* address);
202
363
  #endif // V8_ENABLE_CHECKS
203
364
 
365
+ template <typename T, typename WeaknessPolicy, typename LocationPolicy,
366
+ typename CheckingPolicy>
367
+ friend class internal::BasicCrossThreadPersistent;
204
368
  template <typename T, typename WeaknessPolicy, typename LocationPolicy,
205
369
  typename CheckingPolicy>
206
370
  friend class internal::BasicPersistent;
@@ -43,6 +43,17 @@ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
43
43
  InProcessStackDumping::kDisabled,
44
44
  std::unique_ptr<v8::TracingController> tracing_controller = {});
45
45
 
46
+ /**
47
+ * The same as NewDefaultPlatform but disables the worker thread pool.
48
+ * It must be used with the --single-threaded V8 flag.
49
+ */
50
+ V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform>
51
+ NewSingleThreadedDefaultPlatform(
52
+ IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
53
+ InProcessStackDumping in_process_stack_dumping =
54
+ InProcessStackDumping::kDisabled,
55
+ std::unique_ptr<v8::TracingController> tracing_controller = {});
56
+
46
57
  /**
47
58
  * Returns a new instance of the default v8::JobHandle implementation.
48
59
  *