libv8-node 22.7.0.4-aarch64-linux → 24.1.0.0-aarch64-linux

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/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/allocation.h +11 -13
  5. data/vendor/v8/include/cppgc/default-platform.h +3 -2
  6. data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
  7. data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
  8. data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
  9. data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
  10. data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
  11. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
  12. data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
  13. data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
  14. data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
  15. data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
  16. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  17. data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
  18. data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
  19. data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
  20. data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
  21. data/vendor/v8/include/cppgc/macros.h +21 -0
  22. data/vendor/v8/include/cppgc/member.h +70 -36
  23. data/vendor/v8/include/cppgc/name-provider.h +10 -0
  24. data/vendor/v8/include/cppgc/platform.h +11 -0
  25. data/vendor/v8/include/cppgc/type-traits.h +1 -0
  26. data/vendor/v8/include/cppgc/visitor.h +25 -1
  27. data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
  28. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  29. data/vendor/v8/include/v8-array-buffer.h +143 -46
  30. data/vendor/v8/include/v8-callbacks.h +94 -31
  31. data/vendor/v8/include/v8-context.h +48 -15
  32. data/vendor/v8/include/v8-cppgc.h +5 -56
  33. data/vendor/v8/include/v8-data.h +5 -0
  34. data/vendor/v8/include/v8-date.h +9 -0
  35. data/vendor/v8/include/v8-debug.h +11 -0
  36. data/vendor/v8/include/v8-embedder-heap.h +1 -29
  37. data/vendor/v8/include/v8-exception.h +72 -0
  38. data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
  39. data/vendor/v8/include/v8-fast-api-calls.h +41 -206
  40. data/vendor/v8/include/v8-function-callback.h +190 -78
  41. data/vendor/v8/include/v8-function.h +11 -3
  42. data/vendor/v8/include/v8-handle-base.h +20 -2
  43. data/vendor/v8/include/v8-initialization.h +26 -1
  44. data/vendor/v8/include/v8-inspector.h +10 -3
  45. data/vendor/v8/include/v8-internal.h +638 -315
  46. data/vendor/v8/include/v8-isolate.h +275 -189
  47. data/vendor/v8/include/v8-local-handle.h +69 -42
  48. data/vendor/v8/include/v8-maybe.h +2 -1
  49. data/vendor/v8/include/v8-memory-span.h +149 -24
  50. data/vendor/v8/include/v8-message.h +9 -22
  51. data/vendor/v8/include/v8-metrics.h +14 -0
  52. data/vendor/v8/include/v8-microtask-queue.h +0 -5
  53. data/vendor/v8/include/v8-object.h +291 -37
  54. data/vendor/v8/include/v8-persistent-handle.h +17 -36
  55. data/vendor/v8/include/v8-platform.h +66 -45
  56. data/vendor/v8/include/v8-primitive.h +221 -5
  57. data/vendor/v8/include/v8-profiler.h +51 -2
  58. data/vendor/v8/include/v8-promise.h +2 -2
  59. data/vendor/v8/include/v8-proxy.h +0 -1
  60. data/vendor/v8/include/v8-regexp.h +0 -1
  61. data/vendor/v8/include/v8-sandbox.h +173 -0
  62. data/vendor/v8/include/v8-script.h +65 -17
  63. data/vendor/v8/include/v8-snapshot.h +38 -2
  64. data/vendor/v8/include/v8-source-location.h +6 -1
  65. data/vendor/v8/include/v8-template.h +111 -263
  66. data/vendor/v8/include/v8-trace-categories.h +23 -0
  67. data/vendor/v8/include/v8-traced-handle.h +20 -32
  68. data/vendor/v8/include/v8-typed-array.h +6 -10
  69. data/vendor/v8/include/v8-unwinder-state.h +2 -3
  70. data/vendor/v8/include/v8-unwinder.h +2 -1
  71. data/vendor/v8/include/v8-util.h +1 -117
  72. data/vendor/v8/include/v8-value-serializer-version.h +3 -3
  73. data/vendor/v8/include/v8-value.h +21 -2
  74. data/vendor/v8/include/v8-version.h +4 -4
  75. data/vendor/v8/include/v8-wasm.h +27 -0
  76. data/vendor/v8/include/v8-weak-callback-info.h +20 -12
  77. data/vendor/v8/include/v8.h +3 -3
  78. data/vendor/v8/include/v8config.h +83 -45
  79. metadata +6 -3
  80. data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -5,10 +5,12 @@
5
5
  #ifndef INCLUDE_V8_OBJECT_H_
6
6
  #define INCLUDE_V8_OBJECT_H_
7
7
 
8
+ #include "v8-internal.h" // NOLINT(build/include_directory)
8
9
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
9
10
  #include "v8-maybe.h" // NOLINT(build/include_directory)
10
11
  #include "v8-persistent-handle.h" // NOLINT(build/include_directory)
11
12
  #include "v8-primitive.h" // NOLINT(build/include_directory)
13
+ #include "v8-sandbox.h" // NOLINT(build/include_directory)
12
14
  #include "v8-traced-handle.h" // NOLINT(build/include_directory)
13
15
  #include "v8-value.h" // NOLINT(build/include_directory)
14
16
  #include "v8config.h" // NOLINT(build/include_directory)
@@ -146,18 +148,13 @@ enum PropertyAttribute {
146
148
  };
147
149
 
148
150
  /**
149
- * Accessor[Getter|Setter] are used as callback functions when
150
- * setting|getting a particular property. See Object and ObjectTemplate's
151
- * method SetAccessor.
151
+ * Accessor[Getter|Setter] are used as callback functions when setting|getting
152
+ * a particular data property. See Object::SetNativeDataProperty and
153
+ * ObjectTemplate::SetNativeDataProperty methods.
152
154
  */
153
- using AccessorGetterCallback =
154
- void (*)(Local<String> property, const PropertyCallbackInfo<Value>& info);
155
155
  using AccessorNameGetterCallback =
156
156
  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
157
157
 
158
- using AccessorSetterCallback = void (*)(Local<String> property,
159
- Local<Value> value,
160
- const PropertyCallbackInfo<void>& info);
161
158
  using AccessorNameSetterCallback =
162
159
  void (*)(Local<Name> property, Local<Value> value,
163
160
  const PropertyCallbackInfo<void>& info);
@@ -170,9 +167,11 @@ using AccessorNameSetterCallback =
170
167
  * the kind of cross-context access that should be allowed.
171
168
  *
172
169
  */
173
- enum AccessControl {
174
- DEFAULT = 0,
175
- };
170
+ enum V8_DEPRECATE_SOON(
171
+ "This enum is no longer used and will be removed in V8 12.9.")
172
+ AccessControl {
173
+ DEFAULT V8_ENUM_DEPRECATE_SOON("not used") = 0,
174
+ };
176
175
 
177
176
  /**
178
177
  * Property filter bits. They can be or'ed to build a composite filter.
@@ -239,6 +238,9 @@ class V8_EXPORT Object : public Value {
239
238
  */
240
239
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
241
240
  Local<Value> key, Local<Value> value);
241
+ V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
242
+ Local<Value> key, Local<Value> value,
243
+ MaybeLocal<Object> receiver);
242
244
 
243
245
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
244
246
  Local<Value> value);
@@ -294,6 +296,9 @@ class V8_EXPORT Object : public Value {
294
296
 
295
297
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
296
298
  Local<Value> key);
299
+ V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
300
+ Local<Value> key,
301
+ MaybeLocal<Object> receiver);
297
302
 
298
303
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
299
304
  uint32_t index);
@@ -339,17 +344,10 @@ class V8_EXPORT Object : public Value {
339
344
  V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
340
345
  uint32_t index);
341
346
 
342
- V8_DEPRECATE_SOON("Use SetNativeDataProperty instead")
343
- V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
344
- Local<Context> context, Local<Name> name,
345
- AccessorNameGetterCallback getter,
346
- AccessorNameSetterCallback setter = nullptr,
347
- MaybeLocal<Value> data = MaybeLocal<Value>(),
348
- AccessControl deprecated_settings = DEFAULT,
349
- PropertyAttribute attribute = None,
350
- SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
351
- SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
352
-
347
+ /**
348
+ * Sets an accessor property like Template::SetAccessorProperty, but
349
+ * this method sets on this object directly.
350
+ */
353
351
  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
354
352
  Local<Function> setter = Local<Function>(),
355
353
  PropertyAttribute attributes = None);
@@ -429,16 +427,41 @@ class V8_EXPORT Object : public Value {
429
427
  * be skipped by __proto__ and it does not consult the security
430
428
  * handler.
431
429
  */
430
+ V8_DEPRECATE_SOON(
431
+ "V8 will stop providing access to hidden prototype (i.e. "
432
+ "JSGlobalObject). Use GetPrototypeV2() instead. "
433
+ "See http://crbug.com/333672197.")
432
434
  Local<Value> GetPrototype();
433
435
 
436
+ /**
437
+ * Get the prototype object (same as getting __proto__ property). This does
438
+ * not consult the security handler.
439
+ * TODO(333672197): rename back to GetPrototype() once the old version goes
440
+ * through the deprecation process and is removed.
441
+ */
442
+ Local<Value> GetPrototypeV2();
443
+
434
444
  /**
435
445
  * Set the prototype object. This does not skip objects marked to
436
446
  * be skipped by __proto__ and it does not consult the security
437
447
  * handler.
438
448
  */
449
+ V8_DEPRECATE_SOON(
450
+ "V8 will stop providing access to hidden prototype (i.e. "
451
+ "JSGlobalObject). Use SetPrototypeV2() instead. "
452
+ "See http://crbug.com/333672197.")
439
453
  V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context,
440
454
  Local<Value> prototype);
441
455
 
456
+ /**
457
+ * Set the prototype object (same as setting __proto__ property). This does
458
+ * does not consult the security handler.
459
+ * TODO(333672197): rename back to SetPrototype() once the old version goes
460
+ * through the deprecation process and is removed.
461
+ */
462
+ V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototypeV2(Local<Context> context,
463
+ Local<Value> prototype);
464
+
442
465
  /**
443
466
  * Finds an instance of the given function template in the prototype
444
467
  * chain.
@@ -526,7 +549,72 @@ class V8_EXPORT Object : public Value {
526
549
  void* values[]);
527
550
 
528
551
  /**
529
- * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty().
552
+ * Unwraps a JS wrapper object.
553
+ *
554
+ * \param tag The tag for retrieving the wrappable instance. Must match the
555
+ * tag that has been used for a previous `Wrap()` operation.
556
+ * \param isolate The Isolate for the `wrapper` object.
557
+ * \param wrapper The JS wrapper object that should be unwrapped.
558
+ * \returns the C++ wrappable instance, or nullptr if the JS object has never
559
+ * been wrapped.
560
+ */
561
+ template <CppHeapPointerTag tag, typename T = void>
562
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
563
+ const v8::Local<v8::Object>& wrapper);
564
+ template <CppHeapPointerTag tag, typename T = void>
565
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
566
+ const PersistentBase<Object>& wrapper);
567
+ template <CppHeapPointerTag tag, typename T = void>
568
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
569
+ const BasicTracedReference<Object>& wrapper);
570
+
571
+ template <typename T = void>
572
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
573
+ const v8::Local<v8::Object>& wrapper,
574
+ CppHeapPointerTagRange tag_range);
575
+ template <typename T = void>
576
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
577
+ const PersistentBase<Object>& wrapper,
578
+ CppHeapPointerTagRange tag_range);
579
+ template <typename T = void>
580
+ static V8_INLINE T* Unwrap(v8::Isolate* isolate,
581
+ const BasicTracedReference<Object>& wrapper,
582
+ CppHeapPointerTagRange tag_range);
583
+
584
+ /**
585
+ * Wraps a JS wrapper with a C++ instance.
586
+ *
587
+ * \param tag The pointer tag that should be used for storing this object.
588
+ * Future `Unwrap()` operations must provide a matching tag.
589
+ * \param isolate The Isolate for the `wrapper` object.
590
+ * \param wrapper The JS wrapper object.
591
+ * \param wrappable The C++ object instance that is wrapped by the JS object.
592
+ */
593
+ template <CppHeapPointerTag tag>
594
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
595
+ const v8::Local<v8::Object>& wrapper,
596
+ void* wrappable);
597
+ template <CppHeapPointerTag tag>
598
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
599
+ const PersistentBase<Object>& wrapper,
600
+ void* wrappable);
601
+ template <CppHeapPointerTag tag>
602
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
603
+ const BasicTracedReference<Object>& wrapper,
604
+ void* wrappable);
605
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
606
+ const v8::Local<v8::Object>& wrapper,
607
+ void* wrappable, CppHeapPointerTag tag);
608
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
609
+ const PersistentBase<Object>& wrapper,
610
+ void* wrappable, CppHeapPointerTag tag);
611
+ static V8_INLINE void Wrap(v8::Isolate* isolate,
612
+ const BasicTracedReference<Object>& wrapper,
613
+ void* wrappable, CppHeapPointerTag tag);
614
+
615
+ /**
616
+ * HasOwnProperty() is like JavaScript's
617
+ * Object.prototype.hasOwnProperty().
530
618
  *
531
619
  * See also v8::Object::Has() and v8::Object::HasRealNamedProperty().
532
620
  */
@@ -602,27 +690,40 @@ class V8_EXPORT Object : public Value {
602
690
  int GetIdentityHash();
603
691
 
604
692
  /**
605
- * Clone this object with a fast but shallow copy. Values will point
606
- * to the same values as the original object.
693
+ * Clone this object with a fast but shallow copy. Values will point to the
694
+ * same values as the original object.
695
+ *
696
+ * Prefer using version with Isolate parameter.
607
697
  */
608
- // TODO(dcarney): take an isolate and optionally bail out?
698
+ Local<Object> Clone(v8::Isolate* isolate);
609
699
  Local<Object> Clone();
610
700
 
611
701
  /**
612
702
  * Returns the context in which the object was created.
703
+ *
704
+ * Prefer using version with Isolate parameter.
613
705
  */
706
+ MaybeLocal<Context> GetCreationContext(v8::Isolate* isolate);
707
+ V8_DEPRECATE_SOON("Use the version with the isolate argument.")
614
708
  MaybeLocal<Context> GetCreationContext();
615
709
 
616
710
  /**
617
- * Shortcut for GetCreationContext().ToLocalChecked().
711
+ * Shortcut for GetCreationContext(...).ToLocalChecked().
712
+ *
713
+ * Prefer using version with Isolate parameter.
618
714
  **/
715
+ Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
716
+ V8_DEPRECATE_SOON("Use the version with the isolate argument.")
619
717
  Local<Context> GetCreationContextChecked();
620
718
 
621
719
  /** Same as above, but works for Persistents */
622
720
  V8_INLINE static MaybeLocal<Context> GetCreationContext(
623
- const PersistentBase<Object>& object) {
624
- return object.template value<Object>()->GetCreationContext();
721
+ v8::Isolate* isolate, const PersistentBase<Object>& object) {
722
+ return object.template value<Object>()->GetCreationContext(isolate);
625
723
  }
724
+ V8_DEPRECATE_SOON("Use the version with the isolate argument.")
725
+ V8_INLINE static MaybeLocal<Context> GetCreationContext(
726
+ const PersistentBase<Object>& object);
626
727
 
627
728
  /**
628
729
  * Gets the context in which the object was created (see GetCreationContext())
@@ -634,7 +735,12 @@ class V8_EXPORT Object : public Value {
634
735
  * try to expand the embedder data attached to the context.
635
736
  * In case the Local<Context> is already available because of other reasons,
636
737
  * it's fine to keep using Context::GetAlignedPointerFromEmbedderData().
738
+ *
739
+ * Prefer using version with Isolate parameter if you have an Isolate,
740
+ * otherwise use the other one.
637
741
  */
742
+ void* GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate* isolate,
743
+ int index);
638
744
  void* GetAlignedPointerFromEmbedderDataInCreationContext(int index);
639
745
 
640
746
  /**
@@ -650,11 +756,15 @@ class V8_EXPORT Object : public Value {
650
756
  bool IsConstructor() const;
651
757
 
652
758
  /**
653
- * True if this object can carry information relevant to the embedder in its
654
- * embedder fields, false otherwise. This is generally true for objects
655
- * constructed through function templates but also holds for other types where
656
- * V8 automatically adds internal fields at compile time, such as e.g.
657
- * v8::ArrayBuffer.
759
+ * Returns true if this object can be generally used to wrap object objects.
760
+ * This means that the object either follows the convention of using embedder
761
+ * fields to denote type/instance pointers or is using the Wrap()/Unwrap()
762
+ * APIs for the same purpose. Returns false otherwise.
763
+ *
764
+ * Note that there may be other objects that use embedder fields but are not
765
+ * used as API wrapper objects. E.g., v8::Promise may in certain configuration
766
+ * use embedder fields but promises are not generally supported as API
767
+ * wrappers. The method will return false in those cases.
658
768
  */
659
769
  bool IsApiWrapper() const;
660
770
 
@@ -729,6 +839,11 @@ class V8_EXPORT Object : public Value {
729
839
  bool IsCodeLike(Isolate* isolate) const;
730
840
 
731
841
  private:
842
+ static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
843
+ CppHeapPointerTagRange tag_range);
844
+ static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
845
+ CppHeapPointerTag tag, void* wrappable);
846
+
732
847
  Object();
733
848
  static void CheckCast(Value* obj);
734
849
  Local<Data> SlowGetInternalField(int index);
@@ -747,7 +862,8 @@ Local<Data> Object::GetInternalField(int index) {
747
862
  // know where to find the internal fields and can return the value directly.
748
863
  int instance_type = I::GetInstanceType(obj);
749
864
  if (I::CanHaveInternalField(instance_type)) {
750
- int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
865
+ int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
866
+ (I::kEmbedderDataSlotSize * index);
751
867
  A value = I::ReadRawField<A>(obj, offset);
752
868
  #ifdef V8_COMPRESS_POINTERS
753
869
  // We read the full pointer value and then decompress it in order to avoid
@@ -773,7 +889,8 @@ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate,
773
889
  // know where to find the internal fields and can return the value directly.
774
890
  auto instance_type = I::GetInstanceType(obj);
775
891
  if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
776
- int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) +
892
+ int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
893
+ (I::kEmbedderDataSlotSize * index) +
777
894
  I::kEmbedderDataSlotExternalPointerOffset;
778
895
  A value =
779
896
  I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
@@ -793,7 +910,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
793
910
  // know where to find the internal fields and can return the value directly.
794
911
  auto instance_type = I::GetInstanceType(obj);
795
912
  if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
796
- int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) +
913
+ int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
914
+ (I::kEmbedderDataSlotSize * index) +
797
915
  I::kEmbedderDataSlotExternalPointerOffset;
798
916
  Isolate* isolate = I::GetIsolateForSandbox(obj);
799
917
  A value =
@@ -805,6 +923,142 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
805
923
  return SlowGetAlignedPointerFromInternalField(index);
806
924
  }
807
925
 
926
+ // static
927
+ template <CppHeapPointerTag tag, typename T>
928
+ T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper) {
929
+ CppHeapPointerTagRange tag_range(tag, tag);
930
+ auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
931
+ #if !defined(V8_ENABLE_CHECKS)
932
+ return internal::ReadCppHeapPointerField<T>(
933
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
934
+ #else // defined(V8_ENABLE_CHECKS)
935
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
936
+ #endif // defined(V8_ENABLE_CHECKS)
937
+ }
938
+
939
+ // static
940
+ template <CppHeapPointerTag tag, typename T>
941
+ T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper) {
942
+ CppHeapPointerTagRange tag_range(tag, tag);
943
+ auto obj =
944
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
945
+ #if !defined(V8_ENABLE_CHECKS)
946
+ return internal::ReadCppHeapPointerField<T>(
947
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
948
+ #else // defined(V8_ENABLE_CHECKS)
949
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
950
+ #endif // defined(V8_ENABLE_CHECKS)
951
+ }
952
+
953
+ // static
954
+ template <CppHeapPointerTag tag, typename T>
955
+ T* Object::Unwrap(v8::Isolate* isolate,
956
+ const BasicTracedReference<Object>& wrapper) {
957
+ CppHeapPointerTagRange tag_range(tag, tag);
958
+ auto obj =
959
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
960
+ #if !defined(V8_ENABLE_CHECKS)
961
+ return internal::ReadCppHeapPointerField<T>(
962
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
963
+ #else // defined(V8_ENABLE_CHECKS)
964
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
965
+ #endif // defined(V8_ENABLE_CHECKS)
966
+ }
967
+
968
+ // static
969
+ template <typename T>
970
+ T* Object::Unwrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
971
+ CppHeapPointerTagRange tag_range) {
972
+ auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
973
+ #if !defined(V8_ENABLE_CHECKS)
974
+ return internal::ReadCppHeapPointerField<T>(
975
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
976
+ #else // defined(V8_ENABLE_CHECKS)
977
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
978
+ #endif // defined(V8_ENABLE_CHECKS)
979
+ }
980
+
981
+ // static
982
+ template <typename T>
983
+ T* Object::Unwrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
984
+ CppHeapPointerTagRange tag_range) {
985
+ auto obj =
986
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
987
+ #if !defined(V8_ENABLE_CHECKS)
988
+ return internal::ReadCppHeapPointerField<T>(
989
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
990
+ #else // defined(V8_ENABLE_CHECKS)
991
+
992
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
993
+ #endif // defined(V8_ENABLE_CHECKS)
994
+ }
995
+
996
+ // static
997
+ template <typename T>
998
+ T* Object::Unwrap(v8::Isolate* isolate,
999
+ const BasicTracedReference<Object>& wrapper,
1000
+ CppHeapPointerTagRange tag_range) {
1001
+ auto obj =
1002
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1003
+ #if !defined(V8_ENABLE_CHECKS)
1004
+ return internal::ReadCppHeapPointerField<T>(
1005
+ isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1006
+ #else // defined(V8_ENABLE_CHECKS)
1007
+ return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1008
+ #endif // defined(V8_ENABLE_CHECKS)
1009
+ }
1010
+
1011
+ // static
1012
+ template <CppHeapPointerTag tag>
1013
+ void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1014
+ void* wrappable) {
1015
+ auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1016
+ Wrap(isolate, obj, tag, wrappable);
1017
+ }
1018
+
1019
+ // static
1020
+ template <CppHeapPointerTag tag>
1021
+ void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1022
+ void* wrappable) {
1023
+ auto obj =
1024
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1025
+ Wrap(isolate, obj, tag, wrappable);
1026
+ }
1027
+
1028
+ // static
1029
+ template <CppHeapPointerTag tag>
1030
+ void Object::Wrap(v8::Isolate* isolate,
1031
+ const BasicTracedReference<Object>& wrapper,
1032
+ void* wrappable) {
1033
+ auto obj =
1034
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1035
+ Wrap(isolate, obj, tag, wrappable);
1036
+ }
1037
+
1038
+ // static
1039
+ void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1040
+ void* wrappable, CppHeapPointerTag tag) {
1041
+ auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1042
+ Wrap(isolate, obj, tag, wrappable);
1043
+ }
1044
+
1045
+ // static
1046
+ void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1047
+ void* wrappable, CppHeapPointerTag tag) {
1048
+ auto obj =
1049
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1050
+ Wrap(isolate, obj, tag, wrappable);
1051
+ }
1052
+
1053
+ // static
1054
+ void Object::Wrap(v8::Isolate* isolate,
1055
+ const BasicTracedReference<Object>& wrapper, void* wrappable,
1056
+ CppHeapPointerTag tag) {
1057
+ auto obj =
1058
+ internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1059
+ Wrap(isolate, obj, tag, wrappable);
1060
+ }
1061
+
808
1062
  Private* Private::Cast(Data* data) {
809
1063
  #ifdef V8_ENABLE_CHECKS
810
1064
  CheckCast(data);
@@ -15,8 +15,6 @@ namespace v8 {
15
15
  class Isolate;
16
16
  template <class K, class V, class T>
17
17
  class PersistentValueMapBase;
18
- template <class V, class T>
19
- class PersistentValueVector;
20
18
  template <class T>
21
19
  class Global;
22
20
  template <class T>
@@ -48,7 +46,11 @@ class Eternal : public api_internal::IndirectHandleBase {
48
46
  public:
49
47
  V8_INLINE Eternal() = default;
50
48
 
49
+ /**
50
+ * Constructor for handling automatic up casting.
51
+ */
51
52
  template <class S>
53
+ requires(std::is_base_of_v<T, S>)
52
54
  V8_INLINE Eternal(Isolate* isolate, Local<S> handle) {
53
55
  Set(isolate, handle);
54
56
  }
@@ -61,8 +63,8 @@ class Eternal : public api_internal::IndirectHandleBase {
61
63
  }
62
64
 
63
65
  template <class S>
66
+ requires(std::is_base_of_v<T, S>)
64
67
  void Set(Isolate* isolate, Local<S> handle) {
65
- static_assert(std::is_base_of<T, S>::value, "type check");
66
68
  slot() =
67
69
  api_internal::Eternalize(isolate, *handle.template UnsafeAs<Value>());
68
70
  }
@@ -204,8 +206,6 @@ class PersistentBase : public api_internal::IndirectHandleBase {
204
206
  friend class ReturnValue;
205
207
  template <class F1, class F2, class F3>
206
208
  friend class PersistentValueMapBase;
207
- template <class F1, class F2>
208
- friend class PersistentValueVector;
209
209
  friend class Object;
210
210
  friend class internal::ValueHelper;
211
211
 
@@ -236,21 +236,6 @@ class NonCopyablePersistentTraits {
236
236
  }
237
237
  };
238
238
 
239
- /**
240
- * Helper class traits to allow copying and assignment of Persistent.
241
- * This will clone the contents of storage cell, but not any of the flags, etc.
242
- */
243
- template <class T>
244
- struct CopyablePersistentTraits {
245
- using CopyablePersistent = Persistent<T, CopyablePersistentTraits<T>>;
246
- static const bool kResetInDestructor = true;
247
- template <class S, class M>
248
- static V8_INLINE void Copy(const Persistent<S, M>& source,
249
- CopyablePersistent* dest) {
250
- // do nothing, just allow copy
251
- }
252
- };
253
-
254
239
  /**
255
240
  * A PersistentBase which allows copy and assignment.
256
241
  *
@@ -270,28 +255,26 @@ class Persistent : public PersistentBase<T> {
270
255
  V8_INLINE Persistent() = default;
271
256
 
272
257
  /**
273
- * Construct a Persistent from a Local.
258
+ * Construct a Persistent from a Local with automatic up casting.
274
259
  * When the Local is non-empty, a new storage cell is created
275
260
  * pointing to the same object, and no flags are set.
276
261
  */
277
262
  template <class S>
263
+ requires(std::is_base_of_v<T, S>)
278
264
  V8_INLINE Persistent(Isolate* isolate, Local<S> that)
279
265
  : PersistentBase<T>(
280
- PersistentBase<T>::New(isolate, that.template value<S>())) {
281
- static_assert(std::is_base_of<T, S>::value, "type check");
282
- }
266
+ PersistentBase<T>::New(isolate, that.template value<S>())) {}
283
267
 
284
268
  /**
285
- * Construct a Persistent from a Persistent.
269
+ * Construct a Persistent from a Persistent with automatic up casting.
286
270
  * When the Persistent is non-empty, a new storage cell is created
287
271
  * pointing to the same object, and no flags are set.
288
272
  */
289
273
  template <class S, class M2>
274
+ requires(std::is_base_of_v<T, S>)
290
275
  V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
291
276
  : PersistentBase<T>(
292
- PersistentBase<T>::New(isolate, that.template value<S>())) {
293
- static_assert(std::is_base_of<T, S>::value, "type check");
294
- }
277
+ PersistentBase<T>::New(isolate, that.template value<S>())) {}
295
278
 
296
279
  /**
297
280
  * The copy constructors and assignment operator create a Persistent
@@ -371,28 +354,26 @@ class Global : public PersistentBase<T> {
371
354
  V8_INLINE Global() = default;
372
355
 
373
356
  /**
374
- * Construct a Global from a Local.
357
+ * Construct a Global from a Local with automatic up casting.
375
358
  * When the Local is non-empty, a new storage cell is created
376
359
  * pointing to the same object, and no flags are set.
377
360
  */
378
361
  template <class S>
362
+ requires(std::is_base_of_v<T, S>)
379
363
  V8_INLINE Global(Isolate* isolate, Local<S> that)
380
364
  : PersistentBase<T>(
381
- PersistentBase<T>::New(isolate, that.template value<S>())) {
382
- static_assert(std::is_base_of<T, S>::value, "type check");
383
- }
365
+ PersistentBase<T>::New(isolate, that.template value<S>())) {}
384
366
 
385
367
  /**
386
- * Construct a Global from a PersistentBase.
368
+ * Construct a Global from a PersistentBase with automatic up casting.
387
369
  * When the Persistent is non-empty, a new storage cell is created
388
370
  * pointing to the same object, and no flags are set.
389
371
  */
390
372
  template <class S>
373
+ requires(std::is_base_of_v<T, S>)
391
374
  V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that)
392
375
  : PersistentBase<T>(
393
- PersistentBase<T>::New(isolate, that.template value<S>())) {
394
- static_assert(std::is_base_of<T, S>::value, "type check");
395
- }
376
+ PersistentBase<T>::New(isolate, that.template value<S>())) {}
396
377
 
397
378
  /**
398
379
  * Move constructor.