libv8-node 22.7.0.4-x86_64-linux-musl → 24.1.0.0-x86_64-linux-musl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/allocation.h +11 -13
  4. data/vendor/v8/include/cppgc/default-platform.h +3 -2
  5. data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
  6. data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
  7. data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
  8. data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
  9. data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
  10. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
  11. data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
  12. data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
  13. data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
  14. data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
  15. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  16. data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
  17. data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
  18. data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
  19. data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
  20. data/vendor/v8/include/cppgc/macros.h +21 -0
  21. data/vendor/v8/include/cppgc/member.h +70 -36
  22. data/vendor/v8/include/cppgc/name-provider.h +10 -0
  23. data/vendor/v8/include/cppgc/platform.h +11 -0
  24. data/vendor/v8/include/cppgc/type-traits.h +1 -0
  25. data/vendor/v8/include/cppgc/visitor.h +25 -1
  26. data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
  27. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  28. data/vendor/v8/include/v8-array-buffer.h +143 -46
  29. data/vendor/v8/include/v8-callbacks.h +94 -31
  30. data/vendor/v8/include/v8-context.h +48 -15
  31. data/vendor/v8/include/v8-cppgc.h +5 -56
  32. data/vendor/v8/include/v8-data.h +5 -0
  33. data/vendor/v8/include/v8-date.h +9 -0
  34. data/vendor/v8/include/v8-debug.h +11 -0
  35. data/vendor/v8/include/v8-embedder-heap.h +1 -29
  36. data/vendor/v8/include/v8-exception.h +72 -0
  37. data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
  38. data/vendor/v8/include/v8-fast-api-calls.h +41 -206
  39. data/vendor/v8/include/v8-function-callback.h +190 -78
  40. data/vendor/v8/include/v8-function.h +11 -3
  41. data/vendor/v8/include/v8-handle-base.h +20 -2
  42. data/vendor/v8/include/v8-initialization.h +26 -1
  43. data/vendor/v8/include/v8-inspector.h +10 -3
  44. data/vendor/v8/include/v8-internal.h +638 -315
  45. data/vendor/v8/include/v8-isolate.h +275 -189
  46. data/vendor/v8/include/v8-local-handle.h +69 -42
  47. data/vendor/v8/include/v8-maybe.h +2 -1
  48. data/vendor/v8/include/v8-memory-span.h +149 -24
  49. data/vendor/v8/include/v8-message.h +9 -22
  50. data/vendor/v8/include/v8-metrics.h +14 -0
  51. data/vendor/v8/include/v8-microtask-queue.h +0 -5
  52. data/vendor/v8/include/v8-object.h +291 -37
  53. data/vendor/v8/include/v8-persistent-handle.h +17 -36
  54. data/vendor/v8/include/v8-platform.h +66 -45
  55. data/vendor/v8/include/v8-primitive.h +221 -5
  56. data/vendor/v8/include/v8-profiler.h +51 -2
  57. data/vendor/v8/include/v8-promise.h +2 -2
  58. data/vendor/v8/include/v8-proxy.h +0 -1
  59. data/vendor/v8/include/v8-regexp.h +0 -1
  60. data/vendor/v8/include/v8-sandbox.h +173 -0
  61. data/vendor/v8/include/v8-script.h +65 -17
  62. data/vendor/v8/include/v8-snapshot.h +38 -2
  63. data/vendor/v8/include/v8-source-location.h +6 -1
  64. data/vendor/v8/include/v8-template.h +111 -263
  65. data/vendor/v8/include/v8-trace-categories.h +23 -0
  66. data/vendor/v8/include/v8-traced-handle.h +20 -32
  67. data/vendor/v8/include/v8-typed-array.h +6 -10
  68. data/vendor/v8/include/v8-unwinder-state.h +2 -3
  69. data/vendor/v8/include/v8-unwinder.h +2 -1
  70. data/vendor/v8/include/v8-util.h +1 -117
  71. data/vendor/v8/include/v8-value-serializer-version.h +3 -3
  72. data/vendor/v8/include/v8-value.h +21 -2
  73. data/vendor/v8/include/v8-version.h +4 -4
  74. data/vendor/v8/include/v8-wasm.h +27 -0
  75. data/vendor/v8/include/v8-weak-callback-info.h +20 -12
  76. data/vendor/v8/include/v8.h +3 -3
  77. data/vendor/v8/include/v8config.h +83 -45
  78. data/vendor/v8/x86_64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
  79. metadata +6 -3
  80. data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -37,15 +37,13 @@ enum class TracedReferenceHandling {
37
37
  kDroppable
38
38
  };
39
39
 
40
- V8_EXPORT internal::Address* GlobalizeTracedReference(
41
- internal::Isolate* isolate, internal::Address value,
42
- internal::Address* slot, TracedReferenceStoreMode store_mode,
43
- internal::TracedReferenceHandling reference_handling);
44
- V8_EXPORT void MoveTracedReference(internal::Address** from,
45
- internal::Address** to);
46
- V8_EXPORT void CopyTracedReference(const internal::Address* const* from,
47
- internal::Address** to);
48
- V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
40
+ V8_EXPORT Address* GlobalizeTracedReference(
41
+ Isolate* isolate, Address value, Address* slot,
42
+ TracedReferenceStoreMode store_mode,
43
+ TracedReferenceHandling reference_handling);
44
+ V8_EXPORT void MoveTracedReference(Address** from, Address** to);
45
+ V8_EXPORT void CopyTracedReference(const Address* const* from, Address** to);
46
+ V8_EXPORT void DisposeTracedReference(Address* global_handle);
49
47
 
50
48
  } // namespace internal
51
49
 
@@ -55,6 +53,9 @@ V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
55
53
  */
56
54
  class TracedReferenceBase : public api_internal::IndirectHandleBase {
57
55
  public:
56
+ static_assert(sizeof(std::atomic<internal::Address*>) ==
57
+ sizeof(internal::Address*));
58
+
58
59
  /**
59
60
  * If non-empty, destroy the underlying storage cell. |IsEmpty| will return
60
61
  * true after this call.
@@ -62,20 +63,18 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase {
62
63
  V8_INLINE void Reset();
63
64
 
64
65
  /**
65
- * Construct a Local<Value> from this handle.
66
+ * Construct a Local<Data> from this handle.
66
67
  */
67
- V8_INLINE Local<Value> Get(Isolate* isolate) const {
68
- if (IsEmpty()) return Local<Value>();
69
- return Local<Value>::New(isolate, this->value<Value>());
68
+ V8_INLINE Local<Data> Get(Isolate* isolate) const {
69
+ if (IsEmpty()) return Local<Data>();
70
+ return Local<Data>::New(isolate, this->value<Data>());
70
71
  }
71
72
 
72
73
  /**
73
74
  * Returns true if this TracedReference is empty, i.e., has not been
74
75
  * assigned an object. This version of IsEmpty is thread-safe.
75
76
  */
76
- bool IsEmptyThreadSafe() const {
77
- return this->GetSlotThreadSafe() == nullptr;
78
- }
77
+ bool IsEmptyThreadSafe() const { return GetSlotThreadSafe() == nullptr; }
79
78
 
80
79
  protected:
81
80
  V8_INLINE TracedReferenceBase() = default;
@@ -83,17 +82,17 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase {
83
82
  /**
84
83
  * Update this reference in a thread-safe way.
85
84
  */
86
- void SetSlotThreadSafe(void* new_val) {
87
- reinterpret_cast<std::atomic<void*>*>(&slot())->store(
85
+ void SetSlotThreadSafe(internal::Address* new_val) {
86
+ reinterpret_cast<std::atomic<internal::Address*>*>(&slot())->store(
88
87
  new_val, std::memory_order_relaxed);
89
88
  }
90
89
 
91
90
  /**
92
91
  * Get this reference in a thread-safe way
93
92
  */
94
- const void* GetSlotThreadSafe() const {
95
- return reinterpret_cast<std::atomic<const void*> const*>(&slot())->load(
96
- std::memory_order_relaxed);
93
+ const internal::Address* GetSlotThreadSafe() const {
94
+ return reinterpret_cast<const std::atomic<internal::Address*>*>(&slot())
95
+ ->load(std::memory_order_relaxed);
97
96
  }
98
97
 
99
98
  V8_EXPORT void CheckValue() const;
@@ -135,17 +134,6 @@ class BasicTracedReference : public TracedReferenceBase {
135
134
  const_cast<BasicTracedReference<T>&>(*this));
136
135
  }
137
136
 
138
- V8_DEPRECATE_SOON("Use Get to convert to Local instead")
139
- V8_INLINE T* operator->() const {
140
- #ifdef V8_ENABLE_CHECKS
141
- CheckValue();
142
- #endif // V8_ENABLE_CHECKS
143
- return this->template value<T>();
144
- }
145
-
146
- V8_DEPRECATE_SOON("Use Get to convert to Local instead")
147
- V8_INLINE T* operator*() const { return this->operator->(); }
148
-
149
137
  private:
150
138
  /**
151
139
  * An empty BasicTracedReference without storage cell.
@@ -23,15 +23,11 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
23
23
  * The largest supported typed array byte size. Each subclass defines a
24
24
  * type-specific kMaxLength for the maximum length that can be passed to New.
25
25
  */
26
- #if V8_ENABLE_SANDBOX
27
- static constexpr size_t kMaxByteLength =
28
- internal::kMaxSafeBufferSizeForSandbox;
29
- #elif V8_HOST_ARCH_32_BIT
30
- static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
31
- #else
32
- // The maximum safe integer (2^53 - 1).
33
- static constexpr size_t kMaxByteLength =
34
- static_cast<size_t>((uint64_t{1} << 53) - 1);
26
+ static constexpr size_t kMaxByteLength = ArrayBuffer::kMaxByteLength;
27
+
28
+ #ifdef V8_ENABLE_SANDBOX
29
+ static_assert(v8::TypedArray::kMaxByteLength <=
30
+ v8::internal::kMaxSafeBufferSizeForSandbox);
35
31
  #endif
36
32
 
37
33
  /**
@@ -253,10 +249,10 @@ class V8_EXPORT Int32Array : public TypedArray {
253
249
  * An instance of Float16Array constructor.
254
250
  */
255
251
  class V8_EXPORT Float16Array : public TypedArray {
252
+ public:
256
253
  static constexpr size_t kMaxLength =
257
254
  TypedArray::kMaxByteLength / sizeof(uint16_t);
258
255
 
259
- public:
260
256
  static Local<Float16Array> New(Local<ArrayBuffer> array_buffer,
261
257
  size_t byte_offset, size_t length);
262
258
  static Local<Float16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -18,9 +18,8 @@ struct CalleeSavedRegisters {
18
18
  void* arm_r10;
19
19
  };
20
20
  #elif V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 || \
21
- V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || \
22
- V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_LOONG64 || \
23
- V8_TARGET_ARCH_RISCV32
21
+ V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_RISCV64 || \
22
+ V8_TARGET_ARCH_S390X || V8_TARGET_ARCH_LOONG64 || V8_TARGET_ARCH_RISCV32
24
23
  struct CalleeSavedRegisters {};
25
24
  #else
26
25
  #error Target architecture was not detected as supported by v8
@@ -42,7 +42,8 @@ enum StateTag : uint16_t {
42
42
  OTHER,
43
43
  EXTERNAL,
44
44
  ATOMICS_WAIT,
45
- IDLE
45
+ IDLE,
46
+ LOGGING,
46
47
  };
47
48
 
48
49
  // The output structure filled up by GetStackSample API function.
@@ -182,7 +182,7 @@ class PersistentValueMapBase {
182
182
  */
183
183
  Local<V> Get(const K& key) {
184
184
  V* p = FromVal(Traits::Get(&impl_, key));
185
- #ifdef V8_ENABLE_DIRECT_LOCAL
185
+ #ifdef V8_ENABLE_DIRECT_HANDLE
186
186
  if (p == nullptr) return Local<V>();
187
187
  #endif
188
188
  return Local<V>::New(isolate_, p);
@@ -544,122 +544,6 @@ class StdGlobalValueMap : public GlobalValueMap<K, V, Traits> {
544
544
  : GlobalValueMap<K, V, Traits>(isolate) {}
545
545
  };
546
546
 
547
- class DefaultPersistentValueVectorTraits {
548
- public:
549
- typedef std::vector<PersistentContainerValue> Impl;
550
-
551
- static void Append(Impl* impl, PersistentContainerValue value) {
552
- impl->push_back(value);
553
- }
554
- static bool IsEmpty(const Impl* impl) {
555
- return impl->empty();
556
- }
557
- static size_t Size(const Impl* impl) {
558
- return impl->size();
559
- }
560
- static PersistentContainerValue Get(const Impl* impl, size_t i) {
561
- return (i < impl->size()) ? impl->at(i) : kPersistentContainerNotFound;
562
- }
563
- static void ReserveCapacity(Impl* impl, size_t capacity) {
564
- impl->reserve(capacity);
565
- }
566
- static void Clear(Impl* impl) {
567
- impl->clear();
568
- }
569
- };
570
-
571
- /**
572
- * A vector wrapper that safely stores Global values.
573
- * C++11 embedders don't need this class, as they can use Global
574
- * directly in std containers.
575
- *
576
- * This class relies on a backing vector implementation, whose type and methods
577
- * are described by the Traits class. The backing map will handle values of type
578
- * PersistentContainerValue, with all conversion into and out of V8
579
- * handles being transparently handled by this class.
580
- */
581
- template <typename V, typename Traits = DefaultPersistentValueVectorTraits>
582
- class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
583
- public:
584
- explicit PersistentValueVector(Isolate* isolate) : isolate_(isolate) { }
585
-
586
- ~PersistentValueVector() {
587
- Clear();
588
- }
589
-
590
- /**
591
- * Append a value to the vector.
592
- */
593
- void Append(Local<V> value) {
594
- Global<V> persistent(isolate_, value);
595
- Traits::Append(&impl_, ClearAndLeak(&persistent));
596
- }
597
-
598
- /**
599
- * Append a persistent's value to the vector.
600
- */
601
- void Append(Global<V> persistent) {
602
- Traits::Append(&impl_, ClearAndLeak(&persistent));
603
- }
604
-
605
- /**
606
- * Are there any values in the vector?
607
- */
608
- bool IsEmpty() const {
609
- return Traits::IsEmpty(&impl_);
610
- }
611
-
612
- /**
613
- * How many elements are in the vector?
614
- */
615
- size_t Size() const {
616
- return Traits::Size(&impl_);
617
- }
618
-
619
- /**
620
- * Retrieve the i-th value in the vector.
621
- */
622
- Local<V> Get(size_t index) const {
623
- return Local<V>::New(isolate_, internal::ValueHelper::SlotAsValue<V>(
624
- Traits::Get(&impl_, index)));
625
- }
626
-
627
- /**
628
- * Remove all elements from the vector.
629
- */
630
- void Clear() {
631
- size_t length = Traits::Size(&impl_);
632
- for (size_t i = 0; i < length; i++) {
633
- Global<V> p;
634
- p.slot() = reinterpret_cast<internal::Address>(Traits::Get(&impl_, i));
635
- }
636
- Traits::Clear(&impl_);
637
- }
638
-
639
- /**
640
- * Reserve capacity in the vector.
641
- * (Efficiency gains depend on the backing implementation.)
642
- */
643
- void ReserveCapacity(size_t capacity) {
644
- Traits::ReserveCapacity(&impl_, capacity);
645
- }
646
-
647
- private:
648
- static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
649
- auto slot = persistent->slot();
650
- persistent->Clear();
651
- return reinterpret_cast<PersistentContainerValue>(slot);
652
- }
653
-
654
- static V* FromVal(PersistentContainerValue v) {
655
- return internal::ValueHelper::SlotAsValue<V>(
656
- reinterpret_cast<internal::Address*>(v));
657
- }
658
-
659
- Isolate* isolate_;
660
- typename Traits::Impl impl_;
661
- };
662
-
663
547
  } // namespace v8
664
548
 
665
549
  #endif // V8_UTIL_H
@@ -2,6 +2,9 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ #ifndef INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
6
+ #define INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
7
+
5
8
  /**
6
9
  * Compile-time constants.
7
10
  *
@@ -10,9 +13,6 @@
10
13
  * to V8.
11
14
  */
12
15
 
13
- #ifndef INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
14
- #define INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
15
-
16
16
  #include <stdint.h>
17
17
 
18
18
  namespace v8 {
@@ -346,6 +346,11 @@ class V8_EXPORT Value : public Data {
346
346
  */
347
347
  bool IsWasmMemoryObject() const;
348
348
 
349
+ /**
350
+ * Returns true if this value is a WasmMemoryMapDescriptor.
351
+ */
352
+ bool IsWasmMemoryMapDescriptor() const;
353
+
349
354
  /**
350
355
  * Returns true if this value is a WasmModuleObject.
351
356
  */
@@ -361,6 +366,11 @@ class V8_EXPORT Value : public Data {
361
366
  */
362
367
  bool IsModuleNamespaceObject() const;
363
368
 
369
+ /**
370
+ * Returns true if the value is a primitive.
371
+ */
372
+ bool IsPrimitive() const;
373
+
364
374
  /**
365
375
  * Perform `ToPrimitive(value)` as specified in:
366
376
  * https://tc39.es/ecma262/#sec-toprimitive.
@@ -462,6 +472,14 @@ class V8_EXPORT Value : public Data {
462
472
 
463
473
  Maybe<bool> InstanceOf(Local<Context> context, Local<Object> object);
464
474
 
475
+ /**
476
+ * Get the hash of this value. The hash is not guaranteed to be
477
+ * unique. For |Object| and |Name| instances the result is equal to
478
+ * |GetIdentityHash|. Hashes are not guaranteed to be stable across
479
+ * different isolates or processes.
480
+ */
481
+ uint32_t GetHash();
482
+
465
483
  private:
466
484
  V8_INLINE bool QuickIsUndefined() const;
467
485
  V8_INLINE bool QuickIsNull() const;
@@ -635,8 +653,9 @@ bool Value::QuickIsString() const {
635
653
  A obj = internal::ValueHelper::ValueAsAddress(this);
636
654
  if (!I::HasHeapObjectTag(obj)) return false;
637
655
  #if V8_STATIC_ROOTS_BOOL && !V8_MAP_PACKING
638
- return I::CheckInstanceMapRange(obj, I::StaticReadOnlyRoot::kFirstStringMap,
639
- I::StaticReadOnlyRoot::kLastStringMap);
656
+ return I::CheckInstanceMapRange(obj,
657
+ I::StaticReadOnlyRoot::kStringMapLowerBound,
658
+ I::StaticReadOnlyRoot::kStringMapUpperBound);
640
659
  #else
641
660
  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
642
661
  #endif // V8_STATIC_ROOTS_BOOL
@@ -8,10 +8,10 @@
8
8
  // These macros define the version number for the current version.
9
9
  // NOTE these macros are used by some of the tool scripts and the build
10
10
  // system so their names cannot be changed without changing the scripts.
11
- #define V8_MAJOR_VERSION 12
12
- #define V8_MINOR_VERSION 4
13
- #define V8_BUILD_NUMBER 254
14
- #define V8_PATCH_LEVEL 21
11
+ #define V8_MAJOR_VERSION 13
12
+ #define V8_MINOR_VERSION 6
13
+ #define V8_BUILD_NUMBER 233
14
+ #define V8_PATCH_LEVEL 10
15
15
 
16
16
  // Use 1 for candidates and 0 otherwise.
17
17
  // (Boolean macro values are not supported by all preprocessors.)
@@ -9,6 +9,7 @@
9
9
  #include <memory>
10
10
  #include <string>
11
11
 
12
+ #include "v8-internal.h" // NOLINT(build/include_directory)
12
13
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
13
14
  #include "v8-memory-span.h" // NOLINT(build/include_directory)
14
15
  #include "v8-object.h" // NOLINT(build/include_directory)
@@ -129,6 +130,8 @@ class V8_EXPORT WasmModuleObject : public Object {
129
130
  */
130
131
  class V8_EXPORT WasmStreaming final {
131
132
  public:
133
+ static constexpr internal::ExternalPointerTag kManagedTag =
134
+ internal::kWasmWasmStreamingTag;
132
135
  class WasmStreamingImpl;
133
136
 
134
137
  explicit WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl);
@@ -196,6 +199,30 @@ class V8_EXPORT WasmStreaming final {
196
199
  std::unique_ptr<WasmStreamingImpl> impl_;
197
200
  };
198
201
 
202
+ /**
203
+ * The V8 interface for a WebAssembly memory map descriptor. This is an
204
+ * experimental feature that may change and be removed without further
205
+ * communication.
206
+ */
207
+ class V8_EXPORT WasmMemoryMapDescriptor : public Object {
208
+ public:
209
+ WasmMemoryMapDescriptor() = delete;
210
+
211
+ V8_INLINE static WasmMemoryMapDescriptor* Cast(Value* value) {
212
+ #ifdef V8_ENABLE_CHECKS
213
+ CheckCast(value);
214
+ #endif
215
+ return static_cast<WasmMemoryMapDescriptor*>(value);
216
+ }
217
+
218
+ using WasmFileDescriptor = int32_t;
219
+
220
+ static Local<WasmMemoryMapDescriptor> New(Isolate* isolate,
221
+ WasmFileDescriptor fd);
222
+
223
+ private:
224
+ static void CheckCast(Value* object);
225
+ };
199
226
  } // namespace v8
200
227
 
201
228
  #endif // INCLUDE_V8_WASM_H_
@@ -5,6 +5,9 @@
5
5
  #ifndef INCLUDE_V8_WEAK_CALLBACK_INFO_H_
6
6
  #define INCLUDE_V8_WEAK_CALLBACK_INFO_H_
7
7
 
8
+ #include <cstring>
9
+
10
+ #include "cppgc/internal/conditional-stack-allocated.h" // NOLINT(build/include_directory)
8
11
  #include "v8config.h" // NOLINT(build/include_directory)
9
12
 
10
13
  namespace v8 {
@@ -15,11 +18,12 @@ namespace api_internal {
15
18
  V8_EXPORT void InternalFieldOutOfBounds(int index);
16
19
  } // namespace api_internal
17
20
 
18
- static const int kInternalFieldsInWeakCallback = 2;
19
- static const int kEmbedderFieldsInWeakCallback = 2;
21
+ static constexpr int kInternalFieldsInWeakCallback = 2;
22
+ static constexpr int kEmbedderFieldsInWeakCallback = 2;
20
23
 
21
24
  template <typename T>
22
- class WeakCallbackInfo {
25
+ class WeakCallbackInfo
26
+ : public cppgc::internal::ConditionalStackAllocatedBase<T> {
23
27
  public:
24
28
  using Callback = void (*)(const WeakCallbackInfo<T>& data);
25
29
 
@@ -27,21 +31,25 @@ class WeakCallbackInfo {
27
31
  void* embedder_fields[kEmbedderFieldsInWeakCallback],
28
32
  Callback* callback)
29
33
  : isolate_(isolate), parameter_(parameter), callback_(callback) {
30
- for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) {
31
- embedder_fields_[i] = embedder_fields[i];
32
- }
34
+ memcpy(embedder_fields_, embedder_fields,
35
+ sizeof(embedder_fields[0]) * kEmbedderFieldsInWeakCallback);
33
36
  }
34
37
 
35
38
  V8_INLINE Isolate* GetIsolate() const { return isolate_; }
36
39
  V8_INLINE T* GetParameter() const { return parameter_; }
37
40
  V8_INLINE void* GetInternalField(int index) const;
38
41
 
39
- // When first called, the embedder MUST Reset() the Global which triggered the
40
- // callback. The Global itself is unusable for anything else. No v8 other api
41
- // calls may be called in the first callback. Should additional work be
42
- // required, the embedder must set a second pass callback, which will be
43
- // called after all the initial callbacks are processed.
44
- // Calling SetSecondPassCallback on the second pass will immediately crash.
42
+ /**
43
+ * When a weak callback is first invoked the embedders _must_ Reset() the
44
+ * handle which triggered the callback. The handle itself is unusable for
45
+ * anything else. No other V8 API calls may be called in the first callback.
46
+ * Additional work requires scheduling a second invocation via
47
+ * `SetSecondPassCallback()` which will be called some time after all the
48
+ * initial callbacks are processed.
49
+ *
50
+ * The second pass callback is prohibited from executing JavaScript. Embedders
51
+ * should schedule another callback in case this is required.
52
+ */
45
53
  void SetSecondPassCallback(Callback callback) const { *callback_ = callback; }
46
54
 
47
55
  private:
@@ -2,6 +2,9 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ #ifndef INCLUDE_V8_H_
6
+ #define INCLUDE_V8_H_
7
+
5
8
  /** \mainpage V8 API Reference Guide
6
9
  *
7
10
  * V8 is Google's open source JavaScript engine.
@@ -12,9 +15,6 @@
12
15
  * For other documentation see https://v8.dev/.
13
16
  */
14
17
 
15
- #ifndef INCLUDE_V8_H_
16
- #define INCLUDE_V8_H_
17
-
18
18
  #include <stddef.h>
19
19
  #include <stdint.h>
20
20