libv8-node 18.13.0.1-aarch64-linux → 20.2.0.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/common.h +0 -1
  5. data/vendor/v8/include/cppgc/cross-thread-persistent.h +11 -10
  6. data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
  7. data/vendor/v8/include/cppgc/heap-handle.h +48 -0
  8. data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
  9. data/vendor/v8/include/cppgc/heap.h +3 -7
  10. data/vendor/v8/include/cppgc/internal/api-constants.h +14 -1
  11. data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
  12. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
  13. data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
  14. data/vendor/v8/include/cppgc/internal/gc-info.h +35 -34
  15. data/vendor/v8/include/cppgc/internal/member-storage.h +248 -0
  16. data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
  17. data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
  18. data/vendor/v8/include/cppgc/internal/pointer-policies.h +65 -8
  19. data/vendor/v8/include/cppgc/internal/write-barrier.h +153 -101
  20. data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
  21. data/vendor/v8/include/cppgc/macros.h +10 -1
  22. data/vendor/v8/include/cppgc/member.h +424 -111
  23. data/vendor/v8/include/cppgc/name-provider.h +4 -4
  24. data/vendor/v8/include/cppgc/persistent.h +27 -24
  25. data/vendor/v8/include/cppgc/platform.h +7 -5
  26. data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
  27. data/vendor/v8/include/cppgc/trace-trait.h +4 -0
  28. data/vendor/v8/include/cppgc/type-traits.h +13 -3
  29. data/vendor/v8/include/cppgc/visitor.h +104 -57
  30. data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
  31. data/vendor/v8/include/v8-array-buffer.h +59 -0
  32. data/vendor/v8/include/v8-callbacks.h +32 -5
  33. data/vendor/v8/include/v8-context.h +63 -11
  34. data/vendor/v8/include/v8-cppgc.h +22 -0
  35. data/vendor/v8/include/v8-data.h +1 -1
  36. data/vendor/v8/include/v8-date.h +5 -0
  37. data/vendor/v8/include/v8-embedder-heap.h +0 -164
  38. data/vendor/v8/include/v8-exception.h +1 -1
  39. data/vendor/v8/include/v8-fast-api-calls.h +49 -31
  40. data/vendor/v8/include/v8-function-callback.h +69 -42
  41. data/vendor/v8/include/v8-function.h +9 -0
  42. data/vendor/v8/include/v8-initialization.h +23 -49
  43. data/vendor/v8/include/v8-inspector.h +32 -11
  44. data/vendor/v8/include/v8-internal.h +480 -183
  45. data/vendor/v8/include/v8-isolate.h +52 -77
  46. data/vendor/v8/include/v8-local-handle.h +86 -53
  47. data/vendor/v8/include/v8-locker.h +0 -11
  48. data/vendor/v8/include/v8-maybe.h +24 -1
  49. data/vendor/v8/include/v8-message.h +2 -4
  50. data/vendor/v8/include/v8-metrics.h +48 -40
  51. data/vendor/v8/include/v8-microtask-queue.h +6 -1
  52. data/vendor/v8/include/v8-object.h +29 -18
  53. data/vendor/v8/include/v8-persistent-handle.h +25 -18
  54. data/vendor/v8/include/v8-platform.h +133 -35
  55. data/vendor/v8/include/v8-primitive.h +27 -20
  56. data/vendor/v8/include/v8-profiler.h +133 -53
  57. data/vendor/v8/include/v8-regexp.h +2 -1
  58. data/vendor/v8/include/v8-script.h +91 -7
  59. data/vendor/v8/include/v8-snapshot.h +4 -8
  60. data/vendor/v8/include/v8-template.h +16 -77
  61. data/vendor/v8/include/v8-traced-handle.h +22 -28
  62. data/vendor/v8/include/v8-unwinder-state.h +4 -4
  63. data/vendor/v8/include/v8-util.h +11 -7
  64. data/vendor/v8/include/v8-value-serializer.h +46 -23
  65. data/vendor/v8/include/v8-value.h +31 -4
  66. data/vendor/v8/include/v8-version.h +4 -4
  67. data/vendor/v8/include/v8-wasm.h +7 -63
  68. data/vendor/v8/include/v8-weak-callback-info.h +0 -7
  69. data/vendor/v8/include/v8config.h +353 -15
  70. metadata +5 -1
@@ -37,15 +37,15 @@ class V8_EXPORT NameProvider {
37
37
  static constexpr const char kNoNameDeducible[] = "<No name>";
38
38
 
39
39
  /**
40
- * Indicating whether internal names are hidden or not.
40
+ * Indicating whether the build supports extracting C++ names as object names.
41
41
  *
42
42
  * @returns true if C++ names should be hidden and represented by kHiddenName.
43
43
  */
44
- static constexpr bool HideInternalNames() {
44
+ static constexpr bool SupportsCppClassNamesAsObjectNames() {
45
45
  #if CPPGC_SUPPORTS_OBJECT_NAMES
46
- return false;
47
- #else // !CPPGC_SUPPORTS_OBJECT_NAMES
48
46
  return true;
47
+ #else // !CPPGC_SUPPORTS_OBJECT_NAMES
48
+ return false;
49
49
  #endif // !CPPGC_SUPPORTS_OBJECT_NAMES
50
50
  }
51
51
 
@@ -16,9 +16,6 @@
16
16
  #include "v8config.h" // NOLINT(build/include_directory)
17
17
 
18
18
  namespace cppgc {
19
-
20
- class Visitor;
21
-
22
19
  namespace internal {
23
20
 
24
21
  // PersistentBase always refers to the object as const object and defers to
@@ -78,7 +75,7 @@ class BasicPersistent final : public PersistentBase,
78
75
  : PersistentBase(raw), LocationPolicy(loc) {
79
76
  if (!IsValid()) return;
80
77
  SetNode(WeaknessPolicy::GetPersistentRegion(GetValue())
81
- .AllocateNode(this, &BasicPersistent::Trace));
78
+ .AllocateNode(this, &TraceAsRoot));
82
79
  this->CheckPointer(Get());
83
80
  }
84
81
 
@@ -117,11 +114,12 @@ class BasicPersistent final : public PersistentBase,
117
114
  // Constructor from member.
118
115
  template <typename U, typename MemberBarrierPolicy,
119
116
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
117
+ typename MemberStorageType,
120
118
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
121
- BasicPersistent(
122
- const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
123
- MemberCheckingPolicy>& member,
124
- const SourceLocation& loc = SourceLocation::Current())
119
+ BasicPersistent(const internal::BasicMember<
120
+ U, MemberBarrierPolicy, MemberWeaknessTag,
121
+ MemberCheckingPolicy, MemberStorageType>& member,
122
+ const SourceLocation& loc = SourceLocation::Current())
125
123
  : BasicPersistent(member.Get(), loc) {}
126
124
 
127
125
  ~BasicPersistent() { Clear(); }
@@ -157,10 +155,12 @@ class BasicPersistent final : public PersistentBase,
157
155
  // Assignment from member.
158
156
  template <typename U, typename MemberBarrierPolicy,
159
157
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
158
+ typename MemberStorageType,
160
159
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
161
160
  BasicPersistent& operator=(
162
161
  const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
163
- MemberCheckingPolicy>& member) {
162
+ MemberCheckingPolicy, MemberStorageType>&
163
+ member) {
164
164
  return operator=(member.Get());
165
165
  }
166
166
 
@@ -221,9 +221,8 @@ class BasicPersistent final : public PersistentBase,
221
221
  }
222
222
 
223
223
  private:
224
- static void Trace(Visitor* v, const void* ptr) {
225
- const auto* persistent = static_cast<const BasicPersistent*>(ptr);
226
- v->TraceRoot(*persistent, persistent->Location());
224
+ static void TraceAsRoot(RootVisitor& root_visitor, const void* ptr) {
225
+ root_visitor.Trace(*static_cast<const BasicPersistent*>(ptr));
227
226
  }
228
227
 
229
228
  bool IsValid() const {
@@ -247,7 +246,7 @@ class BasicPersistent final : public PersistentBase,
247
246
  SetValue(ptr);
248
247
  if (!IsValid()) return;
249
248
  SetNode(WeaknessPolicy::GetPersistentRegion(GetValue())
250
- .AllocateNode(this, &BasicPersistent::Trace));
249
+ .AllocateNode(this, &TraceAsRoot));
251
250
  this->CheckPointer(Get());
252
251
  }
253
252
 
@@ -264,7 +263,7 @@ class BasicPersistent final : public PersistentBase,
264
263
  return static_cast<T*>(const_cast<void*>(GetValue()));
265
264
  }
266
265
 
267
- friend class cppgc::Visitor;
266
+ friend class internal::RootVisitor;
268
267
  };
269
268
 
270
269
  template <typename T1, typename WeaknessPolicy1, typename LocationPolicy1,
@@ -290,36 +289,39 @@ bool operator!=(const BasicPersistent<T1, WeaknessPolicy1, LocationPolicy1,
290
289
  template <typename T1, typename PersistentWeaknessPolicy,
291
290
  typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
292
291
  typename T2, typename MemberWriteBarrierPolicy,
293
- typename MemberWeaknessTag, typename MemberCheckingPolicy>
292
+ typename MemberWeaknessTag, typename MemberCheckingPolicy,
293
+ typename MemberStorageType>
294
294
  bool operator==(
295
295
  const BasicPersistent<T1, PersistentWeaknessPolicy,
296
296
  PersistentLocationPolicy, PersistentCheckingPolicy>&
297
297
  p,
298
298
  const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
299
- MemberCheckingPolicy>& m) {
299
+ MemberCheckingPolicy, MemberStorageType>& m) {
300
300
  return p.Get() == m.Get();
301
301
  }
302
302
 
303
303
  template <typename T1, typename PersistentWeaknessPolicy,
304
304
  typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
305
305
  typename T2, typename MemberWriteBarrierPolicy,
306
- typename MemberWeaknessTag, typename MemberCheckingPolicy>
306
+ typename MemberWeaknessTag, typename MemberCheckingPolicy,
307
+ typename MemberStorageType>
307
308
  bool operator!=(
308
309
  const BasicPersistent<T1, PersistentWeaknessPolicy,
309
310
  PersistentLocationPolicy, PersistentCheckingPolicy>&
310
311
  p,
311
312
  const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
312
- MemberCheckingPolicy>& m) {
313
+ MemberCheckingPolicy, MemberStorageType>& m) {
313
314
  return !(p == m);
314
315
  }
315
316
 
316
317
  template <typename T1, typename MemberWriteBarrierPolicy,
317
318
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
318
- typename T2, typename PersistentWeaknessPolicy,
319
- typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
319
+ typename MemberStorageType, typename T2,
320
+ typename PersistentWeaknessPolicy, typename PersistentLocationPolicy,
321
+ typename PersistentCheckingPolicy>
320
322
  bool operator==(
321
323
  const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
322
- MemberCheckingPolicy>& m,
324
+ MemberCheckingPolicy, MemberStorageType>& m,
323
325
  const BasicPersistent<T1, PersistentWeaknessPolicy,
324
326
  PersistentLocationPolicy, PersistentCheckingPolicy>&
325
327
  p) {
@@ -328,11 +330,12 @@ bool operator==(
328
330
 
329
331
  template <typename T1, typename MemberWriteBarrierPolicy,
330
332
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
331
- typename T2, typename PersistentWeaknessPolicy,
332
- typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
333
+ typename MemberStorageType, typename T2,
334
+ typename PersistentWeaknessPolicy, typename PersistentLocationPolicy,
335
+ typename PersistentCheckingPolicy>
333
336
  bool operator!=(
334
337
  const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
335
- MemberCheckingPolicy>& m,
338
+ MemberCheckingPolicy, MemberStorageType>& m,
336
339
  const BasicPersistent<T1, PersistentWeaknessPolicy,
337
340
  PersistentLocationPolicy, PersistentCheckingPolicy>&
338
341
  p) {
@@ -33,8 +33,9 @@ class V8_EXPORT Platform {
33
33
  virtual ~Platform() = default;
34
34
 
35
35
  /**
36
- * Returns the allocator used by cppgc to allocate its heap and various
37
- * support structures.
36
+ * \returns the allocator used by cppgc to allocate its heap and various
37
+ * support structures. Returning nullptr results in using the `PageAllocator`
38
+ * provided by `cppgc::InitializeProcess()` instead.
38
39
  */
39
40
  virtual PageAllocator* GetPageAllocator() = 0;
40
41
 
@@ -132,10 +133,11 @@ class V8_EXPORT Platform {
132
133
  *
133
134
  * Can be called multiple times when paired with `ShutdownProcess()`.
134
135
  *
135
- * \param page_allocator The allocator used for maintaining meta data. Must not
136
- * change between multiple calls to InitializeProcess.
136
+ * \param page_allocator The allocator used for maintaining meta data. Must stay
137
+ * always alive and not change between multiple calls to InitializeProcess. If
138
+ * no allocator is provided, a default internal version will be used.
137
139
  */
138
- V8_EXPORT void InitializeProcess(PageAllocator* page_allocator);
140
+ V8_EXPORT void InitializeProcess(PageAllocator* page_allocator = nullptr);
139
141
 
140
142
  /**
141
143
  * Must be called after destroying the last used heap. Some process-global
@@ -13,9 +13,9 @@ namespace internal {
13
13
  // Special tag type used to denote some sentinel member. The semantics of the
14
14
  // sentinel is defined by the embedder.
15
15
  struct SentinelPointer {
16
+ static constexpr intptr_t kSentinelValue = 0b10;
16
17
  template <typename T>
17
18
  operator T*() const {
18
- static constexpr intptr_t kSentinelValue = 1;
19
19
  return reinterpret_cast<T*>(kSentinelValue);
20
20
  }
21
21
  // Hidden friends.
@@ -16,6 +16,10 @@ class Visitor;
16
16
 
17
17
  namespace internal {
18
18
 
19
+ class RootVisitor;
20
+
21
+ using TraceRootCallback = void (*)(RootVisitor&, const void* object);
22
+
19
23
  // Implementation of the default TraceTrait handling GarbageCollected and
20
24
  // GarbageCollectedMixin.
21
25
  template <typename T,
@@ -16,7 +16,7 @@ class Visitor;
16
16
 
17
17
  namespace internal {
18
18
  template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
19
- typename CheckingPolicy>
19
+ typename CheckingPolicy, typename StorageType>
20
20
  class BasicMember;
21
21
  struct DijkstraWriteBarrierPolicy;
22
22
  struct NoWriteBarrierPolicy;
@@ -126,9 +126,10 @@ template <typename BasicMemberCandidate, typename WeaknessTag,
126
126
  typename WriteBarrierPolicy>
127
127
  struct IsSubclassOfBasicMemberTemplate {
128
128
  private:
129
- template <typename T, typename CheckingPolicy>
129
+ template <typename T, typename CheckingPolicy, typename StorageType>
130
130
  static std::true_type SubclassCheck(
131
- BasicMember<T, WeaknessTag, WriteBarrierPolicy, CheckingPolicy>*);
131
+ BasicMember<T, WeaknessTag, WriteBarrierPolicy, CheckingPolicy,
132
+ StorageType>*);
132
133
  static std::false_type SubclassCheck(...);
133
134
 
134
135
  public:
@@ -170,6 +171,15 @@ struct IsComplete {
170
171
  decltype(IsSizeOfKnown(std::declval<T*>()))::value;
171
172
  };
172
173
 
174
+ template <typename T, typename U>
175
+ constexpr bool IsDecayedSameV =
176
+ std::is_same_v<std::decay_t<T>, std::decay_t<U>>;
177
+
178
+ template <typename B, typename D>
179
+ constexpr bool IsStrictlyBaseOfV =
180
+ std::is_base_of_v<std::decay_t<B>, std::decay_t<D>> &&
181
+ !IsDecayedSameV<B, D>;
182
+
173
183
  } // namespace internal
174
184
 
175
185
  /**
@@ -62,22 +62,6 @@ class V8_EXPORT Visitor {
62
62
 
63
63
  virtual ~Visitor() = default;
64
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
-
81
65
  /**
82
66
  * Trace method for Member.
83
67
  *
@@ -87,7 +71,7 @@ class V8_EXPORT Visitor {
87
71
  void Trace(const Member<T>& member) {
88
72
  const T* value = member.GetRawAtomic();
89
73
  CPPGC_DCHECK(value != kSentinelPointer);
90
- Trace(value);
74
+ TraceImpl(value);
91
75
  }
92
76
 
93
77
  /**
@@ -115,6 +99,20 @@ class V8_EXPORT Visitor {
115
99
  &HandleWeak<WeakMember<T>>, &weak_member);
116
100
  }
117
101
 
102
+ #if defined(CPPGC_POINTER_COMPRESSION)
103
+ /**
104
+ * Trace method for UncompressedMember.
105
+ *
106
+ * \param member UncompressedMember reference retaining an object.
107
+ */
108
+ template <typename T>
109
+ void Trace(const subtle::UncompressedMember<T>& member) {
110
+ const T* value = member.GetRawAtomic();
111
+ CPPGC_DCHECK(value != kSentinelPointer);
112
+ TraceImpl(value);
113
+ }
114
+ #endif // defined(CPPGC_POINTER_COMPRESSION)
115
+
118
116
  /**
119
117
  * Trace method for inlined objects that are not allocated themselves but
120
118
  * otherwise follow managed heap layout and have a Trace() method.
@@ -231,23 +229,34 @@ class V8_EXPORT Visitor {
231
229
  void TraceStrongly(const WeakMember<T>& weak_member) {
232
230
  const T* value = weak_member.GetRawAtomic();
233
231
  CPPGC_DCHECK(value != kSentinelPointer);
234
- Trace(value);
232
+ TraceImpl(value);
235
233
  }
236
234
 
237
235
  /**
238
- * Trace method for weak containers.
236
+ * Trace method for retaining containers strongly.
239
237
  *
240
- * \param object reference of the weak container.
238
+ * \param object reference to the container.
239
+ */
240
+ template <typename T>
241
+ void TraceStrongContainer(const T* object) {
242
+ TraceImpl(object);
243
+ }
244
+
245
+ /**
246
+ * Trace method for retaining containers weakly. Note that weak containers
247
+ * should emit write barriers.
248
+ *
249
+ * \param object reference to the container.
241
250
  * \param callback to be invoked.
242
- * \param data custom data that is passed to the callback.
251
+ * \param callback_data custom data that is passed to the callback.
243
252
  */
244
253
  template <typename T>
245
254
  void TraceWeakContainer(const T* object, WeakCallback callback,
246
- const void* data) {
255
+ const void* callback_data) {
247
256
  if (!object) return;
248
257
  VisitWeakContainer(object, TraceTrait<T>::GetTraceDescriptor(object),
249
258
  TraceTrait<T>::GetWeakTraceDescriptor(object), callback,
250
- data);
259
+ callback_data);
251
260
  }
252
261
 
253
262
  /**
@@ -255,6 +264,7 @@ class V8_EXPORT Visitor {
255
264
  * compactable space. Such references maybe be arbitrarily moved by the GC.
256
265
  *
257
266
  * \param slot location of reference to object that might be moved by the GC.
267
+ * The slot must contain an uncompressed pointer.
258
268
  */
259
269
  template <typename T>
260
270
  void RegisterMovableReference(const T** slot) {
@@ -297,9 +307,6 @@ class V8_EXPORT Visitor {
297
307
  virtual void Visit(const void* self, TraceDescriptor) {}
298
308
  virtual void VisitWeak(const void* self, TraceDescriptor, WeakCallback,
299
309
  const void* weak_member) {}
300
- virtual void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) {}
301
- virtual void VisitWeakRoot(const void* self, TraceDescriptor, WeakCallback,
302
- const void* weak_root, const SourceLocation&) {}
303
310
  virtual void VisitEphemeron(const void* key, const void* value,
304
311
  TraceDescriptor value_desc) {}
305
312
  virtual void VisitWeakContainer(const void* self, TraceDescriptor strong_desc,
@@ -320,44 +327,20 @@ class V8_EXPORT Visitor {
320
327
  static void HandleWeak(const LivenessBroker& info, const void* object) {
321
328
  const PointerType* weak = static_cast<const PointerType*>(object);
322
329
  auto* raw_ptr = weak->GetFromGC();
323
- // Sentinel values are preserved for weak pointers.
324
- if (raw_ptr == kSentinelPointer) return;
325
330
  if (!info.IsHeapObjectAlive(raw_ptr)) {
326
331
  weak->ClearFromGC();
327
332
  }
328
333
  }
329
334
 
330
- template <typename Persistent,
331
- std::enable_if_t<Persistent::IsStrongPersistent::value>* = nullptr>
332
- void TraceRoot(const Persistent& p, const SourceLocation& loc) {
333
- using PointeeType = typename Persistent::PointeeType;
334
- static_assert(sizeof(PointeeType),
335
- "Persistent's pointee type must be fully defined");
336
- static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
337
- "Persistent's pointee type must be GarbageCollected or "
338
- "GarbageCollectedMixin");
339
- auto* ptr = p.GetFromGC();
340
- if (!ptr) {
335
+ template <typename T>
336
+ void TraceImpl(const T* t) {
337
+ static_assert(sizeof(T), "Pointee type must be fully defined.");
338
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
339
+ "T must be GarbageCollected or GarbageCollectedMixin type");
340
+ if (!t) {
341
341
  return;
342
342
  }
343
- VisitRoot(ptr, TraceTrait<PointeeType>::GetTraceDescriptor(ptr), loc);
344
- }
345
-
346
- template <
347
- typename WeakPersistent,
348
- std::enable_if_t<!WeakPersistent::IsStrongPersistent::value>* = nullptr>
349
- void TraceRoot(const WeakPersistent& p, const SourceLocation& loc) {
350
- using PointeeType = typename WeakPersistent::PointeeType;
351
- static_assert(sizeof(PointeeType),
352
- "Persistent's pointee type must be fully defined");
353
- static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
354
- "Persistent's pointee type must be GarbageCollected or "
355
- "GarbageCollectedMixin");
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);
343
+ Visit(t, TraceTrait<T>::GetTraceDescriptor(t));
361
344
  }
362
345
 
363
346
  #if V8_ENABLE_CHECKS
@@ -374,6 +357,70 @@ class V8_EXPORT Visitor {
374
357
  friend class internal::VisitorBase;
375
358
  };
376
359
 
360
+ namespace internal {
361
+
362
+ class V8_EXPORT RootVisitor {
363
+ public:
364
+ explicit RootVisitor(Visitor::Key) {}
365
+
366
+ virtual ~RootVisitor() = default;
367
+
368
+ template <typename AnyStrongPersistentType,
369
+ std::enable_if_t<
370
+ AnyStrongPersistentType::IsStrongPersistent::value>* = nullptr>
371
+ void Trace(const AnyStrongPersistentType& p) {
372
+ using PointeeType = typename AnyStrongPersistentType::PointeeType;
373
+ const void* object = Extract(p);
374
+ if (!object) {
375
+ return;
376
+ }
377
+ VisitRoot(object, TraceTrait<PointeeType>::GetTraceDescriptor(object),
378
+ p.Location());
379
+ }
380
+
381
+ template <typename AnyWeakPersistentType,
382
+ std::enable_if_t<
383
+ !AnyWeakPersistentType::IsStrongPersistent::value>* = nullptr>
384
+ void Trace(const AnyWeakPersistentType& p) {
385
+ using PointeeType = typename AnyWeakPersistentType::PointeeType;
386
+ static_assert(!internal::IsAllocatedOnCompactableSpace<PointeeType>::value,
387
+ "Weak references to compactable objects are not allowed");
388
+ const void* object = Extract(p);
389
+ if (!object) {
390
+ return;
391
+ }
392
+ VisitWeakRoot(object, TraceTrait<PointeeType>::GetTraceDescriptor(object),
393
+ &HandleWeak<AnyWeakPersistentType>, &p, p.Location());
394
+ }
395
+
396
+ protected:
397
+ virtual void VisitRoot(const void*, TraceDescriptor, const SourceLocation&) {}
398
+ virtual void VisitWeakRoot(const void* self, TraceDescriptor, WeakCallback,
399
+ const void* weak_root, const SourceLocation&) {}
400
+
401
+ private:
402
+ template <typename AnyPersistentType>
403
+ static const void* Extract(AnyPersistentType& p) {
404
+ using PointeeType = typename AnyPersistentType::PointeeType;
405
+ static_assert(sizeof(PointeeType),
406
+ "Persistent's pointee type must be fully defined");
407
+ static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
408
+ "Persistent's pointee type must be GarbageCollected or "
409
+ "GarbageCollectedMixin");
410
+ return p.GetFromGC();
411
+ }
412
+
413
+ template <typename PointerType>
414
+ static void HandleWeak(const LivenessBroker& info, const void* object) {
415
+ const PointerType* weak = static_cast<const PointerType*>(object);
416
+ auto* raw_ptr = weak->GetFromGC();
417
+ if (!info.IsHeapObjectAlive(raw_ptr)) {
418
+ weak->ClearFromGC();
419
+ }
420
+ }
421
+ };
422
+
423
+ } // namespace internal
377
424
  } // namespace cppgc
378
425
 
379
426
  #endif // INCLUDE_CPPGC_VISITOR_H_
@@ -282,12 +282,12 @@ class V8_PLATFORM_EXPORT TracingController
282
282
  const char* name, uint64_t handle) override;
283
283
 
284
284
  static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
285
- #endif // !defined(V8_USE_PERFETTO)
286
285
 
287
286
  void AddTraceStateObserver(
288
287
  v8::TracingController::TraceStateObserver* observer) override;
289
288
  void RemoveTraceStateObserver(
290
289
  v8::TracingController::TraceStateObserver* observer) override;
290
+ #endif // !defined(V8_USE_PERFETTO)
291
291
 
292
292
  void StartTracing(TraceConfig* trace_config);
293
293
  void StopTracing();
@@ -307,7 +307,6 @@ class V8_PLATFORM_EXPORT TracingController
307
307
  std::unique_ptr<base::Mutex> mutex_;
308
308
  std::unique_ptr<TraceConfig> trace_config_;
309
309
  std::atomic_bool recording_{false};
310
- std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
311
310
 
312
311
  #if defined(V8_USE_PERFETTO)
313
312
  std::ostream* output_stream_ = nullptr;
@@ -316,6 +315,7 @@ class V8_PLATFORM_EXPORT TracingController
316
315
  TraceEventListener* listener_for_testing_ = nullptr;
317
316
  std::unique_ptr<perfetto::TracingSession> tracing_session_;
318
317
  #else // !defined(V8_USE_PERFETTO)
318
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
319
319
  std::unique_ptr<TraceBuffer> trace_buffer_;
320
320
  #endif // !defined(V8_USE_PERFETTO)
321
321
 
@@ -53,12 +53,28 @@ class V8_EXPORT BackingStore : public v8::internal::BackingStoreBase {
53
53
  */
54
54
  size_t ByteLength() const;
55
55
 
56
+ /**
57
+ * The maximum length (in bytes) that this backing store may grow to.
58
+ *
59
+ * If this backing store was created for a resizable ArrayBuffer or a growable
60
+ * SharedArrayBuffer, it is >= ByteLength(). Otherwise it is ==
61
+ * ByteLength().
62
+ */
63
+ size_t MaxByteLength() const;
64
+
56
65
  /**
57
66
  * Indicates whether the backing store was created for an ArrayBuffer or
58
67
  * a SharedArrayBuffer.
59
68
  */
60
69
  bool IsShared() const;
61
70
 
71
+ /**
72
+ * Indicates whether the backing store was created for a resizable ArrayBuffer
73
+ * or a growable SharedArrayBuffer, and thus may be resized by user JavaScript
74
+ * code.
75
+ */
76
+ bool IsResizableByUserJavaScript() const;
77
+
62
78
  /**
63
79
  * Prevent implicit instantiation of operator delete with size_t argument.
64
80
  * The size_t argument would be incorrect because ptr points to the
@@ -189,6 +205,11 @@ class V8_EXPORT ArrayBuffer : public Object {
189
205
  */
190
206
  size_t ByteLength() const;
191
207
 
208
+ /**
209
+ * Maximum length in bytes.
210
+ */
211
+ size_t MaxByteLength() const;
212
+
192
213
  /**
193
214
  * Create a new ArrayBuffer. Allocate |byte_length| bytes.
194
215
  * Allocated memory will be owned by a created ArrayBuffer and
@@ -235,6 +256,21 @@ class V8_EXPORT ArrayBuffer : public Object {
235
256
  void* data, size_t byte_length, v8::BackingStore::DeleterCallback deleter,
236
257
  void* deleter_data);
237
258
 
259
+ /**
260
+ * Returns a new resizable standalone BackingStore that is allocated using the
261
+ * array buffer allocator of the isolate. The result can be later passed to
262
+ * ArrayBuffer::New.
263
+ *
264
+ * |byte_length| must be <= |max_byte_length|.
265
+ *
266
+ * This function is usable without an isolate. Unlike |NewBackingStore| calls
267
+ * with an isolate, GCs cannot be triggered, and there are no
268
+ * retries. Allocation failure will cause the function to crash with an
269
+ * out-of-memory error.
270
+ */
271
+ static std::unique_ptr<BackingStore> NewResizableBackingStore(
272
+ size_t byte_length, size_t max_byte_length);
273
+
238
274
  /**
239
275
  * Returns true if this ArrayBuffer may be detached.
240
276
  */
@@ -251,8 +287,26 @@ class V8_EXPORT ArrayBuffer : public Object {
251
287
  * preventing JavaScript from ever accessing underlying backing store.
252
288
  * ArrayBuffer should have been externalized and must be detachable.
253
289
  */
290
+ V8_DEPRECATE_SOON(
291
+ "Use the version which takes a key parameter (passing a null handle is "
292
+ "ok).")
254
293
  void Detach();
255
294
 
295
+ /**
296
+ * Detaches this ArrayBuffer and all its views (typed arrays).
297
+ * Detaching sets the byte length of the buffer and all typed arrays to zero,
298
+ * preventing JavaScript from ever accessing underlying backing store.
299
+ * ArrayBuffer should have been externalized and must be detachable. Returns
300
+ * Nothing if the key didn't pass the [[ArrayBufferDetachKey]] check,
301
+ * Just(true) otherwise.
302
+ */
303
+ V8_WARN_UNUSED_RESULT Maybe<bool> Detach(v8::Local<v8::Value> key);
304
+
305
+ /**
306
+ * Sets the ArrayBufferDetachKey.
307
+ */
308
+ void SetDetachKey(v8::Local<v8::Value> key);
309
+
256
310
  /**
257
311
  * Get a shared pointer to the backing store of this array buffer. This
258
312
  * pointer coordinates the lifetime management of the internal storage
@@ -374,6 +428,11 @@ class V8_EXPORT SharedArrayBuffer : public Object {
374
428
  */
375
429
  size_t ByteLength() const;
376
430
 
431
+ /**
432
+ * Maximum length in bytes.
433
+ */
434
+ size_t MaxByteLength() const;
435
+
377
436
  /**
378
437
  * Create a new SharedArrayBuffer. Allocate |byte_length| bytes.
379
438
  * Allocated memory will be owned by a created SharedArrayBuffer and