libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
  6. data/vendor/v8/include/cppgc/allocation.h +184 -47
  7. data/vendor/v8/include/cppgc/common.h +9 -6
  8. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  9. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  10. data/vendor/v8/include/cppgc/default-platform.h +40 -49
  11. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  12. data/vendor/v8/include/cppgc/explicit-management.h +100 -0
  13. data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
  14. data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
  15. data/vendor/v8/include/cppgc/heap-state.h +82 -0
  16. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  17. data/vendor/v8/include/cppgc/heap.h +73 -6
  18. data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
  19. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
  20. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  21. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
  22. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  23. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  24. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  25. data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
  26. data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
  27. data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -35
  28. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  29. data/vendor/v8/include/cppgc/macros.h +2 -0
  30. data/vendor/v8/include/cppgc/member.h +91 -26
  31. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  32. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  33. data/vendor/v8/include/cppgc/persistent.h +70 -41
  34. data/vendor/v8/include/cppgc/platform.h +52 -26
  35. data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
  36. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  37. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  38. data/vendor/v8/include/cppgc/source-location.h +2 -1
  39. data/vendor/v8/include/cppgc/testing.h +106 -0
  40. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  41. data/vendor/v8/include/cppgc/type-traits.h +163 -32
  42. data/vendor/v8/include/cppgc/visitor.h +194 -28
  43. data/vendor/v8/include/libplatform/libplatform.h +11 -11
  44. data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
  45. data/vendor/v8/include/v8-array-buffer.h +445 -0
  46. data/vendor/v8/include/v8-callbacks.h +397 -0
  47. data/vendor/v8/include/v8-container.h +129 -0
  48. data/vendor/v8/include/v8-context.h +407 -0
  49. data/vendor/v8/include/v8-cppgc.h +151 -159
  50. data/vendor/v8/include/v8-data.h +80 -0
  51. data/vendor/v8/include/v8-date.h +43 -0
  52. data/vendor/v8/include/v8-debug.h +168 -0
  53. data/vendor/v8/include/v8-embedder-heap.h +218 -0
  54. data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
  55. data/vendor/v8/include/v8-exception.h +217 -0
  56. data/vendor/v8/include/v8-extension.h +62 -0
  57. data/vendor/v8/include/v8-external.h +37 -0
  58. data/vendor/v8/include/v8-fast-api-calls.h +703 -152
  59. data/vendor/v8/include/v8-forward.h +81 -0
  60. data/vendor/v8/include/v8-function-callback.h +475 -0
  61. data/vendor/v8/include/v8-function.h +125 -0
  62. data/vendor/v8/include/v8-initialization.h +315 -0
  63. data/vendor/v8/include/v8-inspector.h +76 -27
  64. data/vendor/v8/include/v8-internal.h +285 -51
  65. data/vendor/v8/include/v8-isolate.h +1709 -0
  66. data/vendor/v8/include/v8-json.h +47 -0
  67. data/vendor/v8/include/v8-local-handle.h +455 -0
  68. data/vendor/v8/include/v8-locker.h +149 -0
  69. data/vendor/v8/include/v8-maybe.h +137 -0
  70. data/vendor/v8/include/v8-memory-span.h +43 -0
  71. data/vendor/v8/include/v8-message.h +216 -0
  72. data/vendor/v8/include/v8-metrics.h +131 -9
  73. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  74. data/vendor/v8/include/v8-microtask.h +28 -0
  75. data/vendor/v8/include/v8-object.h +775 -0
  76. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  77. data/vendor/v8/include/v8-platform.h +433 -25
  78. data/vendor/v8/include/v8-primitive-object.h +118 -0
  79. data/vendor/v8/include/v8-primitive.h +866 -0
  80. data/vendor/v8/include/v8-profiler.h +149 -10
  81. data/vendor/v8/include/v8-promise.h +174 -0
  82. data/vendor/v8/include/v8-proxy.h +50 -0
  83. data/vendor/v8/include/v8-regexp.h +105 -0
  84. data/vendor/v8/include/v8-script.h +747 -0
  85. data/vendor/v8/include/v8-snapshot.h +196 -0
  86. data/vendor/v8/include/v8-statistics.h +217 -0
  87. data/vendor/v8/include/v8-template.h +1079 -0
  88. data/vendor/v8/include/v8-traced-handle.h +420 -0
  89. data/vendor/v8/include/v8-typed-array.h +282 -0
  90. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  91. data/vendor/v8/include/v8-unwinder.h +132 -0
  92. data/vendor/v8/include/v8-util.h +8 -2
  93. data/vendor/v8/include/v8-value-serializer-version.h +1 -1
  94. data/vendor/v8/include/v8-value-serializer.h +279 -0
  95. data/vendor/v8/include/v8-value.h +526 -0
  96. data/vendor/v8/include/v8-version.h +4 -4
  97. data/vendor/v8/include/v8-wasm.h +257 -0
  98. data/vendor/v8/include/v8-weak-callback-info.h +87 -0
  99. data/vendor/v8/include/v8.h +41 -12051
  100. data/vendor/v8/include/v8config.h +142 -21
  101. metadata +64 -10
  102. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
  103. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -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,38 +15,26 @@ namespace cppgc {
12
15
  class Visitor;
13
16
 
14
17
  namespace internal {
15
-
16
- // Pre-C++17 custom implementation of std::void_t.
17
- template <typename... Ts>
18
- struct make_void {
19
- typedef void type;
20
- };
21
- template <typename... Ts>
22
- using void_t = typename make_void<Ts...>::type;
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;
23
26
 
24
27
  // Not supposed to be specialized by the user.
25
28
  template <typename T>
26
29
  struct IsWeak : std::false_type {};
27
30
 
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
31
  // IsTraceMethodConst is used to verify that all Trace methods are marked as
41
32
  // const. It is equivalent to IsTraceable but for a non-const object.
42
33
  template <typename T, typename = void>
43
34
  struct IsTraceMethodConst : std::false_type {};
44
35
 
45
36
  template <typename T>
46
- struct IsTraceMethodConst<T, void_t<decltype(std::declval<const T>().Trace(
37
+ struct IsTraceMethodConst<T, std::void_t<decltype(std::declval<const T>().Trace(
47
38
  std::declval<Visitor*>()))>> : std::true_type {
48
39
  };
49
40
 
@@ -54,7 +45,7 @@ struct IsTraceable : std::false_type {
54
45
 
55
46
  template <typename T>
56
47
  struct IsTraceable<
57
- T, void_t<decltype(std::declval<T>().Trace(std::declval<Visitor*>()))>>
48
+ T, std::void_t<decltype(std::declval<T>().Trace(std::declval<Visitor*>()))>>
58
49
  : std::true_type {
59
50
  // All Trace methods should be marked as const. If an object of type
60
51
  // 'T' is traceable then any object of type 'const T' should also
@@ -67,43 +58,183 @@ template <typename T>
67
58
  constexpr bool IsTraceableV = IsTraceable<T>::value;
68
59
 
69
60
  template <typename T, typename = void>
70
- struct IsGarbageCollectedMixinType : std::false_type {
61
+ struct HasGarbageCollectedMixinTypeMarker : std::false_type {
71
62
  static_assert(sizeof(T), "T must be fully defined");
72
63
  };
73
64
 
74
65
  template <typename T>
75
- struct IsGarbageCollectedMixinType<
76
- T,
77
- void_t<typename std::remove_const_t<T>::IsGarbageCollectedMixinTypeMarker>>
66
+ struct HasGarbageCollectedMixinTypeMarker<
67
+ T, std::void_t<
68
+ typename std::remove_const_t<T>::IsGarbageCollectedMixinTypeMarker>>
78
69
  : std::true_type {
79
70
  static_assert(sizeof(T), "T must be fully defined");
80
71
  };
81
72
 
82
73
  template <typename T, typename = void>
83
- struct IsGarbageCollectedType : IsGarbageCollectedMixinType<T> {
74
+ struct HasGarbageCollectedTypeMarker : std::false_type {
84
75
  static_assert(sizeof(T), "T must be fully defined");
85
76
  };
86
77
 
87
78
  template <typename T>
88
- struct IsGarbageCollectedType<
89
- T, void_t<typename std::remove_const_t<T>::IsGarbageCollectedTypeMarker>>
79
+ struct HasGarbageCollectedTypeMarker<
80
+ T,
81
+ std::void_t<typename std::remove_const_t<T>::IsGarbageCollectedTypeMarker>>
90
82
  : std::true_type {
91
83
  static_assert(sizeof(T), "T must be fully defined");
92
84
  };
93
85
 
86
+ template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value,
87
+ bool = HasGarbageCollectedMixinTypeMarker<T>::value>
88
+ struct IsGarbageCollectedMixinType : std::false_type {
89
+ static_assert(sizeof(T), "T must be fully defined");
90
+ };
91
+
94
92
  template <typename T>
95
- constexpr bool IsGarbageCollectedTypeV =
96
- internal::IsGarbageCollectedType<T>::value;
93
+ struct IsGarbageCollectedMixinType<T, false, true> : std::true_type {
94
+ static_assert(sizeof(T), "T must be fully defined");
95
+ };
96
+
97
+ template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value>
98
+ struct IsGarbageCollectedType : std::false_type {
99
+ static_assert(sizeof(T), "T must be fully defined");
100
+ };
101
+
102
+ template <typename T>
103
+ struct IsGarbageCollectedType<T, true> : std::true_type {
104
+ static_assert(sizeof(T), "T must be fully defined");
105
+ };
106
+
107
+ template <typename T>
108
+ struct IsGarbageCollectedOrMixinType
109
+ : std::integral_constant<bool, IsGarbageCollectedType<T>::value ||
110
+ IsGarbageCollectedMixinType<T>::value> {
111
+ static_assert(sizeof(T), "T must be fully defined");
112
+ };
113
+
114
+ template <typename T, bool = (HasGarbageCollectedTypeMarker<T>::value &&
115
+ HasGarbageCollectedMixinTypeMarker<T>::value)>
116
+ struct IsGarbageCollectedWithMixinType : std::false_type {
117
+ static_assert(sizeof(T), "T must be fully defined");
118
+ };
97
119
 
120
+ template <typename T>
121
+ struct IsGarbageCollectedWithMixinType<T, true> : std::true_type {
122
+ static_assert(sizeof(T), "T must be fully defined");
123
+ };
124
+
125
+ template <typename BasicMemberCandidate, typename WeaknessTag,
126
+ typename WriteBarrierPolicy>
127
+ struct IsSubclassOfBasicMemberTemplate {
128
+ private:
129
+ template <typename T, typename CheckingPolicy>
130
+ static std::true_type SubclassCheck(
131
+ BasicMember<T, WeaknessTag, WriteBarrierPolicy, CheckingPolicy>*);
132
+ static std::false_type SubclassCheck(...);
133
+
134
+ public:
135
+ static constexpr bool value =
136
+ decltype(SubclassCheck(std::declval<BasicMemberCandidate*>()))::value;
137
+ };
138
+
139
+ template <typename T,
140
+ bool = IsSubclassOfBasicMemberTemplate<
141
+ T, StrongMemberTag, DijkstraWriteBarrierPolicy>::value>
142
+ struct IsMemberType : std::false_type {};
143
+
144
+ template <typename T>
145
+ struct IsMemberType<T, true> : std::true_type {};
146
+
147
+ template <typename T, bool = IsSubclassOfBasicMemberTemplate<
148
+ T, WeakMemberTag, DijkstraWriteBarrierPolicy>::value>
149
+ struct IsWeakMemberType : std::false_type {};
150
+
151
+ template <typename T>
152
+ struct IsWeakMemberType<T, true> : std::true_type {};
153
+
154
+ template <typename T, bool = IsSubclassOfBasicMemberTemplate<
155
+ T, UntracedMemberTag, NoWriteBarrierPolicy>::value>
156
+ struct IsUntracedMemberType : std::false_type {};
157
+
158
+ template <typename T>
159
+ struct IsUntracedMemberType<T, true> : std::true_type {};
160
+
161
+ template <typename T>
162
+ struct IsComplete {
163
+ private:
164
+ template <typename U, size_t = sizeof(U)>
165
+ static std::true_type IsSizeOfKnown(U*);
166
+ static std::false_type IsSizeOfKnown(...);
167
+
168
+ public:
169
+ static constexpr bool value =
170
+ decltype(IsSizeOfKnown(std::declval<T*>()))::value;
171
+ };
172
+
173
+ } // namespace internal
174
+
175
+ /**
176
+ * Value is true for types that inherit from `GarbageCollectedMixin` but not
177
+ * `GarbageCollected<T>` (i.e., they are free mixins), and false otherwise.
178
+ */
98
179
  template <typename T>
99
180
  constexpr bool IsGarbageCollectedMixinTypeV =
100
181
  internal::IsGarbageCollectedMixinType<T>::value;
101
182
 
102
- } // namespace internal
183
+ /**
184
+ * Value is true for types that inherit from `GarbageCollected<T>`, and false
185
+ * otherwise.
186
+ */
187
+ template <typename T>
188
+ constexpr bool IsGarbageCollectedTypeV =
189
+ internal::IsGarbageCollectedType<T>::value;
103
190
 
191
+ /**
192
+ * Value is true for types that inherit from either `GarbageCollected<T>` or
193
+ * `GarbageCollectedMixin`, and false otherwise.
194
+ */
195
+ template <typename T>
196
+ constexpr bool IsGarbageCollectedOrMixinTypeV =
197
+ internal::IsGarbageCollectedOrMixinType<T>::value;
198
+
199
+ /**
200
+ * Value is true for types that inherit from `GarbageCollected<T>` and
201
+ * `GarbageCollectedMixin`, and false otherwise.
202
+ */
203
+ template <typename T>
204
+ constexpr bool IsGarbageCollectedWithMixinTypeV =
205
+ internal::IsGarbageCollectedWithMixinType<T>::value;
206
+
207
+ /**
208
+ * Value is true for types of type `Member<T>`, and false otherwise.
209
+ */
210
+ template <typename T>
211
+ constexpr bool IsMemberTypeV = internal::IsMemberType<T>::value;
212
+
213
+ /**
214
+ * Value is true for types of type `UntracedMember<T>`, and false otherwise.
215
+ */
216
+ template <typename T>
217
+ constexpr bool IsUntracedMemberTypeV = internal::IsUntracedMemberType<T>::value;
218
+
219
+ /**
220
+ * Value is true for types of type `WeakMember<T>`, and false otherwise.
221
+ */
222
+ template <typename T>
223
+ constexpr bool IsWeakMemberTypeV = internal::IsWeakMemberType<T>::value;
224
+
225
+ /**
226
+ * Value is true for types that are considered weak references, and false
227
+ * otherwise.
228
+ */
104
229
  template <typename T>
105
230
  constexpr bool IsWeakV = internal::IsWeak<T>::value;
106
231
 
232
+ /**
233
+ * Value is true for types that are complete, and false otherwise.
234
+ */
235
+ template <typename T>
236
+ constexpr bool IsCompleteV = internal::IsComplete<T>::value;
237
+
107
238
  } // namespace cppgc
108
239
 
109
240
  #endif // INCLUDE_CPPGC_TYPE_TRAITS_H_
@@ -5,24 +5,30 @@
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"
11
13
  #include "cppgc/liveness-broker.h"
12
14
  #include "cppgc/member.h"
15
+ #include "cppgc/sentinel-pointer.h"
13
16
  #include "cppgc/source-location.h"
14
17
  #include "cppgc/trace-trait.h"
18
+ #include "cppgc/type-traits.h"
15
19
 
16
20
  namespace cppgc {
17
21
 
18
22
  namespace internal {
23
+ template <typename T, typename WeaknessPolicy, typename LocationPolicy,
24
+ typename CheckingPolicy>
25
+ class BasicCrossThreadPersistent;
19
26
  template <typename T, typename WeaknessPolicy, typename LocationPolicy,
20
27
  typename CheckingPolicy>
21
28
  class BasicPersistent;
22
29
  class ConservativeTracingVisitor;
23
30
  class VisitorBase;
24
31
  class VisitorFactory;
25
-
26
32
  } // namespace internal
27
33
 
28
34
  using WeakCallback = void (*)(const LivenessBroker&, const void*);
@@ -44,7 +50,7 @@ using WeakCallback = void (*)(const LivenessBroker&, const void*);
44
50
  * };
45
51
  * \endcode
46
52
  */
47
- class Visitor {
53
+ class V8_EXPORT Visitor {
48
54
  public:
49
55
  class Key {
50
56
  private:
@@ -56,6 +62,22 @@ class Visitor {
56
62
 
57
63
  virtual ~Visitor() = default;
58
64
 
65
+ /**
66
+ * Trace method for raw pointers. Prefer the versions for managed pointers.
67
+ *
68
+ * \param member Reference retaining an object.
69
+ */
70
+ template <typename T>
71
+ void Trace(const T* t) {
72
+ static_assert(sizeof(T), "Pointee type must be fully defined.");
73
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
74
+ "T must be GarbageCollected or GarbageCollectedMixin type");
75
+ if (!t) {
76
+ return;
77
+ }
78
+ Visit(t, TraceTrait<T>::GetTraceDescriptor(t));
79
+ }
80
+
59
81
  /**
60
82
  * Trace method for Member.
61
83
  *
@@ -76,8 +98,10 @@ class Visitor {
76
98
  template <typename T>
77
99
  void Trace(const WeakMember<T>& weak_member) {
78
100
  static_assert(sizeof(T), "Pointee type must be fully defined.");
79
- static_assert(internal::IsGarbageCollectedType<T>::value,
101
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
80
102
  "T must be GarbageCollected or GarbageCollectedMixin type");
103
+ static_assert(!internal::IsAllocatedOnCompactableSpace<T>::value,
104
+ "Weak references to compactable objects are not allowed");
81
105
 
82
106
  const T* value = weak_member.GetRawAtomic();
83
107
 
@@ -86,8 +110,7 @@ class Visitor {
86
110
  return;
87
111
  }
88
112
 
89
- // TODO(chromium:1056170): DCHECK (or similar) for deleted values as they
90
- // should come in at a different path.
113
+ CPPGC_DCHECK(value != kSentinelPointer);
91
114
  VisitWeak(value, TraceTrait<T>::GetTraceDescriptor(value),
92
115
  &HandleWeak<WeakMember<T>>, &weak_member);
93
116
  }
@@ -121,6 +144,128 @@ class Visitor {
121
144
  RegisterWeakCallback(&WeakCallbackMethodDelegate<T, method>, object);
122
145
  }
123
146
 
147
+ /**
148
+ * Trace method for EphemeronPair.
149
+ *
150
+ * \param ephemeron_pair EphemeronPair reference weakly retaining a key object
151
+ * and strongly retaining a value object in case the key object is alive.
152
+ */
153
+ template <typename K, typename V>
154
+ void Trace(const EphemeronPair<K, V>& ephemeron_pair) {
155
+ TraceEphemeron(ephemeron_pair.key, &ephemeron_pair.value);
156
+ RegisterWeakCallbackMethod<EphemeronPair<K, V>,
157
+ &EphemeronPair<K, V>::ClearValueIfKeyIsDead>(
158
+ &ephemeron_pair);
159
+ }
160
+
161
+ /**
162
+ * Trace method for a single ephemeron. Used for tracing a raw ephemeron in
163
+ * which the `key` and `value` are kept separately.
164
+ *
165
+ * \param weak_member_key WeakMember reference weakly retaining a key object.
166
+ * \param member_value Member reference with ephemeron semantics.
167
+ */
168
+ template <typename KeyType, typename ValueType>
169
+ void TraceEphemeron(const WeakMember<KeyType>& weak_member_key,
170
+ const Member<ValueType>* member_value) {
171
+ const KeyType* key = weak_member_key.GetRawAtomic();
172
+ if (!key) return;
173
+
174
+ // `value` must always be non-null.
175
+ CPPGC_DCHECK(member_value);
176
+ const ValueType* value = member_value->GetRawAtomic();
177
+ if (!value) return;
178
+
179
+ // KeyType and ValueType may refer to GarbageCollectedMixin.
180
+ TraceDescriptor value_desc =
181
+ TraceTrait<ValueType>::GetTraceDescriptor(value);
182
+ CPPGC_DCHECK(value_desc.base_object_payload);
183
+ const void* key_base_object_payload =
184
+ TraceTrait<KeyType>::GetTraceDescriptor(key).base_object_payload;
185
+ CPPGC_DCHECK(key_base_object_payload);
186
+
187
+ VisitEphemeron(key_base_object_payload, value, value_desc);
188
+ }
189
+
190
+ /**
191
+ * Trace method for a single ephemeron. Used for tracing a raw ephemeron in
192
+ * which the `key` and `value` are kept separately. Note that this overload
193
+ * is for non-GarbageCollected `value`s that can be traced though.
194
+ *
195
+ * \param key `WeakMember` reference weakly retaining a key object.
196
+ * \param value Reference weakly retaining a value object. Note that
197
+ * `ValueType` here should not be `Member`. It is expected that
198
+ * `TraceTrait<ValueType>::GetTraceDescriptor(value)` returns a
199
+ * `TraceDescriptor` with a null base pointer but a valid trace method.
200
+ */
201
+ template <typename KeyType, typename ValueType>
202
+ void TraceEphemeron(const WeakMember<KeyType>& weak_member_key,
203
+ const ValueType* value) {
204
+ static_assert(!IsGarbageCollectedOrMixinTypeV<ValueType>,
205
+ "garbage-collected types must use WeakMember and Member");
206
+ const KeyType* key = weak_member_key.GetRawAtomic();
207
+ if (!key) return;
208
+
209
+ // `value` must always be non-null.
210
+ CPPGC_DCHECK(value);
211
+ TraceDescriptor value_desc =
212
+ TraceTrait<ValueType>::GetTraceDescriptor(value);
213
+ // `value_desc.base_object_payload` must be null as this override is only
214
+ // taken for non-garbage-collected values.
215
+ CPPGC_DCHECK(!value_desc.base_object_payload);
216
+
217
+ // KeyType might be a GarbageCollectedMixin.
218
+ const void* key_base_object_payload =
219
+ TraceTrait<KeyType>::GetTraceDescriptor(key).base_object_payload;
220
+ CPPGC_DCHECK(key_base_object_payload);
221
+
222
+ VisitEphemeron(key_base_object_payload, value, value_desc);
223
+ }
224
+
225
+ /**
226
+ * Trace method that strongifies a WeakMember.
227
+ *
228
+ * \param weak_member WeakMember reference retaining an object.
229
+ */
230
+ template <typename T>
231
+ void TraceStrongly(const WeakMember<T>& weak_member) {
232
+ const T* value = weak_member.GetRawAtomic();
233
+ CPPGC_DCHECK(value != kSentinelPointer);
234
+ Trace(value);
235
+ }
236
+
237
+ /**
238
+ * Trace method for weak containers.
239
+ *
240
+ * \param object reference of the weak container.
241
+ * \param callback to be invoked.
242
+ * \param data custom data that is passed to the callback.
243
+ */
244
+ template <typename T>
245
+ void TraceWeakContainer(const T* object, WeakCallback callback,
246
+ const void* data) {
247
+ if (!object) return;
248
+ VisitWeakContainer(object, TraceTrait<T>::GetTraceDescriptor(object),
249
+ TraceTrait<T>::GetWeakTraceDescriptor(object), callback,
250
+ data);
251
+ }
252
+
253
+ /**
254
+ * Registers a slot containing a reference to an object allocated on a
255
+ * compactable space. Such references maybe be arbitrarily moved by the GC.
256
+ *
257
+ * \param slot location of reference to object that might be moved by the GC.
258
+ */
259
+ template <typename T>
260
+ void RegisterMovableReference(const T** slot) {
261
+ static_assert(internal::IsAllocatedOnCompactableSpace<T>::value,
262
+ "Only references to objects allocated on compactable spaces "
263
+ "should be registered as movable slots.");
264
+ static_assert(!IsGarbageCollectedMixinTypeV<T>,
265
+ "Mixin types do not support compaction.");
266
+ HandleMovableReference(reinterpret_cast<const void**>(slot));
267
+ }
268
+
124
269
  /**
125
270
  * Registers a weak callback that is invoked during garbage collection.
126
271
  *
@@ -129,13 +274,38 @@ class Visitor {
129
274
  */
130
275
  virtual void RegisterWeakCallback(WeakCallback callback, const void* data) {}
131
276
 
277
+ /**
278
+ * Defers tracing an object from a concurrent thread to the mutator thread.
279
+ * Should be called by Trace methods of types that are not safe to trace
280
+ * concurrently.
281
+ *
282
+ * \param parameter tells the trace callback which object was deferred.
283
+ * \param callback to be invoked for tracing on the mutator thread.
284
+ * \param deferred_size size of deferred object.
285
+ *
286
+ * \returns false if the object does not need to be deferred (i.e. currently
287
+ * traced on the mutator thread) and true otherwise (i.e. currently traced on
288
+ * a concurrent thread).
289
+ */
290
+ virtual V8_WARN_UNUSED_RESULT bool DeferTraceToMutatorThreadIfConcurrent(
291
+ const void* parameter, TraceCallback callback, size_t deferred_size) {
292
+ // By default tracing is not deferred.
293
+ return false;
294
+ }
295
+
132
296
  protected:
133
297
  virtual void Visit(const void* self, TraceDescriptor) {}
134
298
  virtual void VisitWeak(const void* self, TraceDescriptor, WeakCallback,
135
299
  const void* weak_member) {}
136
- virtual void VisitRoot(const void*, TraceDescriptor) {}
300
+ virtual void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) {}
137
301
  virtual void VisitWeakRoot(const void* self, TraceDescriptor, WeakCallback,
138
- const void* weak_root) {}
302
+ const void* weak_root, const SourceLocation&) {}
303
+ virtual void VisitEphemeron(const void* key, const void* value,
304
+ TraceDescriptor value_desc) {}
305
+ virtual void VisitWeakContainer(const void* self, TraceDescriptor strong_desc,
306
+ TraceDescriptor weak_desc,
307
+ WeakCallback callback, const void* data) {}
308
+ virtual void HandleMovableReference(const void**) {}
139
309
 
140
310
  private:
141
311
  template <typename T, void (T::*method)(const LivenessBroker&)>
@@ -149,10 +319,10 @@ class Visitor {
149
319
  template <typename PointerType>
150
320
  static void HandleWeak(const LivenessBroker& info, const void* object) {
151
321
  const PointerType* weak = static_cast<const PointerType*>(object);
322
+ auto* raw_ptr = weak->GetFromGC();
152
323
  // Sentinel values are preserved for weak pointers.
153
- if (*weak == kSentinelPointer) return;
154
- const auto* raw = weak->Get();
155
- if (!info.IsHeapObjectAlive(raw)) {
324
+ if (raw_ptr == kSentinelPointer) return;
325
+ if (!info.IsHeapObjectAlive(raw_ptr)) {
156
326
  weak->ClearFromGC();
157
327
  }
158
328
  }
@@ -163,13 +333,14 @@ class Visitor {
163
333
  using PointeeType = typename Persistent::PointeeType;
164
334
  static_assert(sizeof(PointeeType),
165
335
  "Persistent's pointee type must be fully defined");
166
- static_assert(internal::IsGarbageCollectedType<PointeeType>::value,
336
+ static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
167
337
  "Persistent's pointee type must be GarbageCollected or "
168
338
  "GarbageCollectedMixin");
169
- if (!p.Get()) {
339
+ auto* ptr = p.GetFromGC();
340
+ if (!ptr) {
170
341
  return;
171
342
  }
172
- VisitRoot(p.Get(), TraceTrait<PointeeType>::GetTraceDescriptor(p.Get()));
343
+ VisitRoot(ptr, TraceTrait<PointeeType>::GetTraceDescriptor(ptr), loc);
173
344
  }
174
345
 
175
346
  template <
@@ -179,28 +350,23 @@ class Visitor {
179
350
  using PointeeType = typename WeakPersistent::PointeeType;
180
351
  static_assert(sizeof(PointeeType),
181
352
  "Persistent's pointee type must be fully defined");
182
- static_assert(internal::IsGarbageCollectedType<PointeeType>::value,
353
+ static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
183
354
  "Persistent's pointee type must be GarbageCollected or "
184
355
  "GarbageCollectedMixin");
185
- 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));
356
+ static_assert(!internal::IsAllocatedOnCompactableSpace<PointeeType>::value,
357
+ "Weak references to compactable objects are not allowed");
358
+ auto* ptr = p.GetFromGC();
359
+ VisitWeakRoot(ptr, TraceTrait<PointeeType>::GetTraceDescriptor(ptr),
360
+ &HandleWeak<WeakPersistent>, &p, loc);
198
361
  }
199
362
 
200
363
  #if V8_ENABLE_CHECKS
201
- V8_EXPORT void CheckObjectNotInConstruction(const void* address);
364
+ void CheckObjectNotInConstruction(const void* address);
202
365
  #endif // V8_ENABLE_CHECKS
203
366
 
367
+ template <typename T, typename WeaknessPolicy, typename LocationPolicy,
368
+ typename CheckingPolicy>
369
+ friend class internal::BasicCrossThreadPersistent;
204
370
  template <typename T, typename WeaknessPolicy, typename LocationPolicy,
205
371
  typename CheckingPolicy>
206
372
  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
  *
@@ -78,17 +89,6 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
78
89
  v8::Isolate* isolate,
79
90
  double idle_time_in_seconds);
80
91
 
81
- /**
82
- * Attempts to set the tracing controller for the given platform.
83
- *
84
- * The |platform| has to be created using |NewDefaultPlatform|.
85
- *
86
- */
87
- V8_DEPRECATE_SOON("Access the DefaultPlatform directly")
88
- V8_PLATFORM_EXPORT void SetTracingController(
89
- v8::Platform* platform,
90
- v8::platform::tracing::TracingController* tracing_controller);
91
-
92
92
  /**
93
93
  * Notifies the given platform about the Isolate getting deleted soon. Has to be
94
94
  * called for all Isolates which are deleted - unless we're shutting down the
@@ -37,7 +37,6 @@ const int kTraceMaxNumArgs = 2;
37
37
  class V8_PLATFORM_EXPORT TraceObject {
38
38
  public:
39
39
  union ArgValue {
40
- V8_DEPRECATED("use as_uint ? true : false") bool as_bool;
41
40
  uint64_t as_uint;
42
41
  int64_t as_int;
43
42
  double as_double;
@@ -125,6 +124,8 @@ class V8_PLATFORM_EXPORT TraceWriter {
125
124
  static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
126
125
  const std::string& tag);
127
126
 
127
+ static TraceWriter* CreateSystemInstrumentationTraceWriter();
128
+
128
129
  private:
129
130
  // Disallow copy and assign
130
131
  TraceWriter(const TraceWriter&) = delete;