node-linux-arm64 24.10.0 → 25.0.0

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 (47) hide show
  1. package/CHANGELOG.md +177 -1818
  2. package/bin/node +0 -0
  3. package/include/node/common.gypi +1 -13
  4. package/include/node/config.gypi +10 -9
  5. package/include/node/cppgc/allocation.h +3 -3
  6. package/include/node/cppgc/cross-thread-persistent.h +25 -29
  7. package/include/node/cppgc/internal/finalizer-trait.h +1 -1
  8. package/include/node/cppgc/internal/gc-info.h +3 -3
  9. package/include/node/cppgc/internal/logging.h +2 -2
  10. package/include/node/cppgc/internal/name-trait.h +1 -1
  11. package/include/node/cppgc/internal/pointer-policies.h +3 -3
  12. package/include/node/cppgc/member.h +10 -4
  13. package/include/node/cppgc/persistent.h +14 -15
  14. package/include/node/cppgc/platform.h +1 -1
  15. package/include/node/cppgc/trace-trait.h +1 -2
  16. package/include/node/cppgc/visitor.h +14 -9
  17. package/include/node/js_native_api.h +12 -0
  18. package/include/node/node.h +34 -78
  19. package/include/node/node_version.h +3 -3
  20. package/include/node/v8-array-buffer.h +1 -1
  21. package/include/node/v8-callbacks.h +3 -4
  22. package/include/node/v8-context.h +15 -5
  23. package/include/node/v8-data.h +5 -0
  24. package/include/node/v8-debug.h +11 -0
  25. package/include/node/v8-function-callback.h +26 -26
  26. package/include/node/v8-internal.h +136 -36
  27. package/include/node/v8-isolate.h +75 -16
  28. package/include/node/v8-json.h +8 -1
  29. package/include/node/v8-local-handle.h +112 -13
  30. package/include/node/v8-maybe.h +34 -10
  31. package/include/node/v8-memory-span.h +9 -4
  32. package/include/node/v8-message.h +3 -0
  33. package/include/node/v8-object.h +87 -24
  34. package/include/node/v8-persistent-handle.h +4 -4
  35. package/include/node/v8-platform.h +92 -28
  36. package/include/node/v8-primitive.h +22 -9
  37. package/include/node/v8-profiler.h +4 -0
  38. package/include/node/v8-sandbox.h +16 -0
  39. package/include/node/v8-source-location.h +19 -26
  40. package/include/node/v8-template.h +37 -15
  41. package/include/node/v8-traced-handle.h +6 -6
  42. package/include/node/v8-unwinder.h +13 -0
  43. package/include/node/v8-version.h +4 -4
  44. package/include/node/v8config.h +65 -5
  45. package/package.json +5 -1
  46. package/share/doc/node/gdbinit +221 -4
  47. package/share/man/man1/node.1 +21 -4
@@ -42,6 +42,7 @@ class BasicTracedReference;
42
42
  template <class F>
43
43
  class TracedReference;
44
44
 
45
+ class ArrayBuffer;
45
46
  class Boolean;
46
47
  class Context;
47
48
  class EscapableHandleScope;
@@ -62,6 +63,8 @@ template <class F>
62
63
  class Traced;
63
64
  class TypecheckWitness;
64
65
  class Utils;
66
+ class Uint32;
67
+ class Value;
65
68
 
66
69
  namespace debug {
67
70
  class ConsoleCallArguments;
@@ -78,6 +81,25 @@ class SamplingHeapProfiler;
78
81
  namespace api_internal {
79
82
  // Called when ToLocalChecked is called on an empty Local.
80
83
  V8_EXPORT void ToLocalEmpty();
84
+
85
+ #ifdef V8_ENABLE_CHECKS
86
+ template <typename T, typename V = Value>
87
+ void TypeCheckLocal(V* value) {
88
+ // If `T` does not provide a `Cast` method we cannot check anything.
89
+ if constexpr (requires { T::Cast(value); }) {
90
+ // TODO(419454582): Remove all these exceptions.
91
+ if (std::is_same_v<Array, T> && value->IsArgumentsObject()) return;
92
+ if (std::is_same_v<ArrayBuffer, T> && value->IsSharedArrayBuffer()) return;
93
+ if (std::is_same_v<Object, T> && value->IsNull()) return;
94
+ if (std::is_same_v<Object, T> && value->IsString()) return;
95
+ if (std::is_same_v<Object, T> && value->IsUndefined()) return;
96
+ if (std::is_same_v<Uint32, T> && value->IsInt32()) return;
97
+ if (std::is_same_v<Object, T> && value->IsNumber()) return;
98
+ // Execute the actual check (part of the cast).
99
+ T::Cast(value);
100
+ }
101
+ }
102
+ #endif
81
103
  } // namespace api_internal
82
104
 
83
105
  /**
@@ -96,18 +118,16 @@ V8_EXPORT void ToLocalEmpty();
96
118
  */
97
119
  class V8_EXPORT V8_NODISCARD HandleScope {
98
120
  public:
99
- explicit HandleScope(Isolate* isolate);
121
+ V8_INLINE explicit HandleScope(Isolate* isolate);
100
122
 
101
- ~HandleScope();
123
+ V8_INLINE ~HandleScope();
102
124
 
103
125
  /**
104
126
  * Counts the number of allocated handles.
105
127
  */
106
128
  static int NumberOfHandles(Isolate* isolate);
107
129
 
108
- V8_INLINE Isolate* GetIsolate() const {
109
- return reinterpret_cast<Isolate*>(i_isolate_);
110
- }
130
+ V8_INLINE Isolate* GetIsolate() const { return isolate_; }
111
131
 
112
132
  HandleScope(const HandleScope&) = delete;
113
133
  void operator=(const HandleScope&) = delete;
@@ -118,12 +138,29 @@ class V8_EXPORT V8_NODISCARD HandleScope {
118
138
  protected:
119
139
  V8_INLINE HandleScope() = default;
120
140
 
121
- void Initialize(Isolate* isolate);
141
+ V8_INLINE void Initialize(Isolate* isolate);
122
142
 
123
- static internal::Address* CreateHandle(internal::Isolate* i_isolate,
124
- internal::Address value);
143
+ V8_INLINE static internal::Address* CreateHandle(Isolate* i_isolate,
144
+ internal::Address value);
125
145
 
126
146
  private:
147
+ // Extend the HandleScope making room for more handles. Not inlined.
148
+ static internal::Address* Extend(Isolate* isolate);
149
+ // Delete any extensions in HandleScope destructor. Not called unless there
150
+ // are extensions. Not inlined.
151
+ void DeleteExtensions(Isolate* isolate);
152
+
153
+ #ifdef V8_ENABLE_CHECKS
154
+ // Non-inlined asserts on HandleScope constructor.
155
+ void DoInitializeAsserts(Isolate* isolate);
156
+ // Non-inlined assert for HandleScope destructor.
157
+ void AssertScopeLevelsMatch();
158
+ // Non-inlined asserts for HandleScope destructor. Also zaps the slots
159
+ // if this is enabled.
160
+ void DoCloseScopeAsserts(int before, internal::Address* limit,
161
+ internal::HandleScopeData* current);
162
+ #endif
163
+
127
164
  // Declaring operator new and delete as deleted is not spec compliant.
128
165
  // Therefore declare them private instead to disable dynamic alloc
129
166
  void* operator new(size_t size);
@@ -131,7 +168,7 @@ class V8_EXPORT V8_NODISCARD HandleScope {
131
168
  void operator delete(void*, size_t);
132
169
  void operator delete[](void*, size_t);
133
170
 
134
- internal::Isolate* i_isolate_;
171
+ Isolate* isolate_;
135
172
  internal::Address* prev_next_;
136
173
  internal::Address* prev_limit_;
137
174
  #ifdef V8_ENABLE_CHECKS
@@ -148,6 +185,61 @@ class V8_EXPORT V8_NODISCARD HandleScope {
148
185
  friend class Context;
149
186
  };
150
187
 
188
+ HandleScope::HandleScope(Isolate* v8_isolate) { Initialize(v8_isolate); }
189
+
190
+ void HandleScope::Initialize(Isolate* v8_isolate) {
191
+ using I = internal::Internals;
192
+ internal::HandleScopeData* current = I::GetHandleScopeData(v8_isolate);
193
+ isolate_ = v8_isolate;
194
+ prev_next_ = current->next;
195
+ prev_limit_ = current->limit;
196
+ current->level++;
197
+ #ifdef V8_ENABLE_CHECKS
198
+ DoInitializeAsserts(v8_isolate);
199
+ scope_level_ = current->level;
200
+ #endif
201
+ }
202
+
203
+ HandleScope::~HandleScope() {
204
+ if (V8_UNLIKELY(isolate_ == nullptr)) return;
205
+ #ifdef V8_ENABLE_CHECKS
206
+ AssertScopeLevelsMatch();
207
+ int handle_count_before = NumberOfHandles(isolate_);
208
+ #endif
209
+
210
+ using I = internal::Internals;
211
+ internal::HandleScopeData* current = I::GetHandleScopeData(isolate_);
212
+ std::swap(current->next, prev_next_);
213
+ current->level--;
214
+ internal::Address* limit = prev_next_;
215
+ if (V8_UNLIKELY(current->limit != prev_limit_)) {
216
+ current->limit = prev_limit_;
217
+ limit = prev_limit_;
218
+ DeleteExtensions(isolate_);
219
+ }
220
+ #ifdef V8_ENABLE_CHECKS
221
+ DoCloseScopeAsserts(handle_count_before, limit, current);
222
+ #else
223
+ (void)limit; // Avoid unused variable warning.
224
+ #endif
225
+ }
226
+
227
+ internal::Address* HandleScope::CreateHandle(Isolate* v8_isolate,
228
+ internal::Address value) {
229
+ using I = internal::Internals;
230
+ internal::HandleScopeData* data = I::GetHandleScopeData(v8_isolate);
231
+ internal::Address* result = data->next;
232
+ if (V8_UNLIKELY(result == data->limit)) {
233
+ result = Extend(v8_isolate);
234
+ }
235
+ // Update the current next field, set the value in the created handle,
236
+ // and return the result.
237
+ data->next = reinterpret_cast<internal::Address*>(
238
+ reinterpret_cast<internal::Address>(result) + sizeof(internal::Address));
239
+ *result = value;
240
+ return result;
241
+ }
242
+
151
243
  /**
152
244
  * A base class for local handles.
153
245
  * Its implementation depends on whether direct handle support is enabled.
@@ -164,7 +256,11 @@ class LocalBase : public api_internal::DirectHandleBase {
164
256
 
165
257
  V8_INLINE LocalBase() = default;
166
258
 
167
- V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {}
259
+ V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {
260
+ #ifdef V8_ENABLE_CHECKS
261
+ if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
262
+ #endif
263
+ }
168
264
 
169
265
  template <typename S>
170
266
  V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
@@ -200,14 +296,17 @@ class LocalBase : public api_internal::IndirectHandleBase {
200
296
  V8_INLINE LocalBase() = default;
201
297
 
202
298
  V8_INLINE explicit LocalBase(internal::Address* location)
203
- : IndirectHandleBase(location) {}
299
+ : IndirectHandleBase(location) {
300
+ #ifdef V8_ENABLE_CHECKS
301
+ if (!IsEmpty()) api_internal::TypeCheckLocal<T>(value<Value>());
302
+ #endif
303
+ }
204
304
 
205
305
  template <typename S>
206
306
  V8_INLINE LocalBase(const LocalBase<S>& other) : IndirectHandleBase(other) {}
207
307
 
208
308
  V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
209
- return LocalBase(HandleScope::CreateHandle(
210
- reinterpret_cast<internal::Isolate*>(isolate), value));
309
+ return LocalBase(HandleScope::CreateHandle(isolate, value));
211
310
  }
212
311
 
213
312
  V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
@@ -14,6 +14,12 @@
14
14
 
15
15
  namespace v8 {
16
16
 
17
+ namespace internal {
18
+ struct NullMaybeType {};
19
+
20
+ constexpr NullMaybeType kNullMaybe;
21
+ } // namespace internal
22
+
17
23
  namespace api_internal {
18
24
  // Called when ToChecked is called on an empty Maybe.
19
25
  V8_EXPORT void FromJustIsNothing();
@@ -32,9 +38,19 @@ V8_EXPORT void FromJustIsNothing();
32
38
  template <class T>
33
39
  class Maybe : public cppgc::internal::ConditionalStackAllocatedBase<T> {
34
40
  public:
41
+ constexpr Maybe() = default;
42
+
43
+ V8_INLINE Maybe(internal::NullMaybeType) {}
44
+
35
45
  V8_INLINE bool IsNothing() const { return !has_value_; }
36
46
  V8_INLINE bool IsJust() const { return has_value_; }
37
47
 
48
+ /**
49
+ * Same as IsNothing(). It's useful for unified handling of empty states
50
+ * with v8::MaybeLocal<T>.
51
+ */
52
+ V8_INLINE bool IsEmpty() const { return IsNothing(); }
53
+
38
54
  /**
39
55
  * An alias for |FromJust|. Will crash if the Maybe<> is nothing.
40
56
  */
@@ -57,6 +73,16 @@ class Maybe : public cppgc::internal::ConditionalStackAllocatedBase<T> {
57
73
  return IsJust();
58
74
  }
59
75
 
76
+ /**
77
+ * Converts this Maybe<> to a value of type T, moving out of it. If this
78
+ * Maybe<> is nothing (empty), |false| is returned and |out| is left
79
+ * untouched.
80
+ */
81
+ V8_WARN_UNUSED_RESULT V8_INLINE bool MoveTo(T* out) && {
82
+ if (V8_LIKELY(IsJust())) *out = std::move(value_);
83
+ return IsJust();
84
+ }
85
+
60
86
  /**
61
87
  * Converts this Maybe<> to a value of type T. If this Maybe<> is
62
88
  * nothing (empty), V8 will crash the process.
@@ -93,15 +119,12 @@ class Maybe : public cppgc::internal::ConditionalStackAllocatedBase<T> {
93
119
  }
94
120
 
95
121
  private:
96
- Maybe() : has_value_(false) {}
97
122
  explicit Maybe(const T& t) : has_value_(true), value_(t) {}
98
123
  explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
99
124
 
100
- bool has_value_;
125
+ bool has_value_ = false;
101
126
  T value_;
102
127
 
103
- template <class U>
104
- friend Maybe<U> Nothing();
105
128
  template <class U>
106
129
  friend Maybe<U> Just(const U& u);
107
130
  template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
@@ -109,8 +132,8 @@ class Maybe : public cppgc::internal::ConditionalStackAllocatedBase<T> {
109
132
  };
110
133
 
111
134
  template <class T>
112
- inline Maybe<T> Nothing() {
113
- return Maybe<T>();
135
+ inline constexpr Maybe<T> Nothing() {
136
+ return {};
114
137
  }
115
138
 
116
139
  template <class T>
@@ -130,7 +153,11 @@ inline Maybe<T> Just(T&& t) {
130
153
  template <>
131
154
  class Maybe<void> {
132
155
  public:
156
+ constexpr Maybe() = default;
157
+ constexpr Maybe(internal::NullMaybeType) {}
158
+
133
159
  V8_INLINE bool IsNothing() const { return !is_valid_; }
160
+ V8_INLINE bool IsEmpty() const { return IsNothing(); }
134
161
  V8_INLINE bool IsJust() const { return is_valid_; }
135
162
 
136
163
  V8_INLINE bool operator==(const Maybe& other) const {
@@ -144,13 +171,10 @@ class Maybe<void> {
144
171
  private:
145
172
  struct JustTag {};
146
173
 
147
- Maybe() : is_valid_(false) {}
148
174
  explicit Maybe(JustTag) : is_valid_(true) {}
149
175
 
150
- bool is_valid_;
176
+ bool is_valid_ = false;
151
177
 
152
- template <class U>
153
- friend Maybe<U> Nothing();
154
178
  friend Maybe<void> JustVoid();
155
179
  };
156
180
 
@@ -87,15 +87,20 @@ class V8_EXPORT MemorySpan {
87
87
  static constexpr bool is_compatible_iterator_v =
88
88
  is_compatible_iterator<It>::value;
89
89
 
90
+ // SFINAE-compatible wrapper for `std::to_address()`.
91
+ // Adapted from "base/types/to_address.h" in chromium.
90
92
  template <typename U>
93
+ requires(!std::is_function_v<U>)
91
94
  [[nodiscard]] static constexpr U* to_address(U* p) noexcept {
92
95
  return p;
93
96
  }
94
97
 
95
- template <typename It,
96
- typename = std::void_t<decltype(std::declval<It&>().operator->())>>
97
- [[nodiscard]] static constexpr auto to_address(It it) noexcept {
98
- return it.operator->();
98
+ template <typename It>
99
+ requires(
100
+ requires(const It& it) { std::pointer_traits<It>::to_address(it); } ||
101
+ requires(const It& it) { it.operator->(); })
102
+ [[nodiscard]] static constexpr auto to_address(const It& it) noexcept {
103
+ return std::to_address(it);
99
104
  }
100
105
 
101
106
  public:
@@ -111,6 +111,9 @@ class V8_EXPORT Message {
111
111
  /**
112
112
  * Return the isolate to which the Message belongs.
113
113
  */
114
+ V8_DEPRECATED(
115
+ "Use Isolate::GetCurrent() instead, which is guaranteed to return the "
116
+ "same isolate since https://crrev.com/c/6458560.")
114
117
  Isolate* GetIsolate() const;
115
118
 
116
119
  V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSource(
@@ -5,6 +5,8 @@
5
5
  #ifndef INCLUDE_V8_OBJECT_H_
6
6
  #define INCLUDE_V8_OBJECT_H_
7
7
 
8
+ #include "cppgc/garbage-collected.h"
9
+ #include "cppgc/name-provider.h"
8
10
  #include "v8-internal.h" // NOLINT(build/include_directory)
9
11
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
10
12
  #include "v8-maybe.h" // NOLINT(build/include_directory)
@@ -23,6 +25,14 @@ class FunctionTemplate;
23
25
  template <typename T>
24
26
  class PropertyCallbackInfo;
25
27
 
28
+ /**
29
+ * A tag for embedder data. Objects with different C++ types should use
30
+ * different values of EmbedderDataTypeTag when written to embedder data. The
31
+ * allowed range is 0..V8_EMBEDDER_DATA_TAG_COUNT - 1. If this is not
32
+ * sufficient, V8_EMBEDDER_DATA_TAG_COUNT can be increased.
33
+ */
34
+ using EmbedderDataTypeTag = uint16_t;
35
+
26
36
  /**
27
37
  * A private symbol
28
38
  *
@@ -427,15 +437,15 @@ class V8_EXPORT Object : public Value {
427
437
  * be skipped by __proto__ and it does not consult the security
428
438
  * handler.
429
439
  */
430
- V8_DEPRECATE_SOON(
440
+ V8_DEPRECATED(
431
441
  "V8 will stop providing access to hidden prototype (i.e. "
432
442
  "JSGlobalObject). Use GetPrototypeV2() instead. "
433
443
  "See http://crbug.com/333672197.")
434
444
  Local<Value> GetPrototype();
435
445
 
436
446
  /**
437
- * Get the prototype object (same as getting __proto__ property). This does
438
- * not consult the security handler.
447
+ * Get the prototype object (same as calling Object.getPrototypeOf(..)).
448
+ * This does not consult the security handler.
439
449
  * TODO(333672197): rename back to GetPrototype() once the old version goes
440
450
  * through the deprecation process and is removed.
441
451
  */
@@ -446,7 +456,7 @@ class V8_EXPORT Object : public Value {
446
456
  * be skipped by __proto__ and it does not consult the security
447
457
  * handler.
448
458
  */
449
- V8_DEPRECATE_SOON(
459
+ V8_DEPRECATED(
450
460
  "V8 will stop providing access to hidden prototype (i.e. "
451
461
  "JSGlobalObject). Use SetPrototypeV2() instead. "
452
462
  "See http://crbug.com/333672197.")
@@ -454,8 +464,8 @@ class V8_EXPORT Object : public Value {
454
464
  Local<Value> prototype);
455
465
 
456
466
  /**
457
- * Set the prototype object (same as setting __proto__ property). This does
458
- * does not consult the security handler.
467
+ * Set the prototype object (same as calling Object.setPrototypeOf(..)).
468
+ * This does not consult the security handler.
459
469
  * TODO(333672197): rename back to SetPrototype() once the old version goes
460
470
  * through the deprecation process and is removed.
461
471
  */
@@ -544,10 +554,43 @@ class V8_EXPORT Object : public Value {
544
554
  * a field, GetAlignedPointerFromInternalField must be used, everything else
545
555
  * leads to undefined behavior.
546
556
  */
557
+ V8_DEPRECATE_SOON(
558
+ "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag parameter "
559
+ "instead.")
547
560
  void SetAlignedPointerInInternalField(int index, void* value);
561
+
562
+ void SetAlignedPointerInInternalField(int index, void* value,
563
+ EmbedderDataTypeTag tag);
564
+
565
+ V8_DEPRECATE_SOON(
566
+ "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag "
567
+ "parameter instead.")
548
568
  void SetAlignedPointerInInternalFields(int argc, int indices[],
549
569
  void* values[]);
550
570
 
571
+ // Type information for a Wrappable object that got wrapped with
572
+ // `v8::Object::Wrap()`.
573
+ struct WrapperTypeInfo {
574
+ const int16_t type_id;
575
+ };
576
+
577
+ // v8::Object::Wrappable serves as the base class for all C++ objects that can
578
+ // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
579
+ //
580
+ // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
581
+ // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
582
+ class Wrappable : public cppgc::GarbageCollected<Wrappable>,
583
+ public cppgc::NameProvider {
584
+ public:
585
+ virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
586
+ return nullptr;
587
+ }
588
+
589
+ const char* GetHumanReadableName() const override { return "internal"; }
590
+
591
+ virtual void Trace(cppgc::Visitor* visitor) const {}
592
+ };
593
+
551
594
  /**
552
595
  * Unwraps a JS wrapper object.
553
596
  *
@@ -593,24 +636,37 @@ class V8_EXPORT Object : public Value {
593
636
  template <CppHeapPointerTag tag>
594
637
  static V8_INLINE void Wrap(v8::Isolate* isolate,
595
638
  const v8::Local<v8::Object>& wrapper,
596
- void* wrappable);
639
+ Wrappable* wrappable);
597
640
  template <CppHeapPointerTag tag>
598
641
  static V8_INLINE void Wrap(v8::Isolate* isolate,
599
642
  const PersistentBase<Object>& wrapper,
600
- void* wrappable);
643
+ Wrappable* wrappable);
601
644
  template <CppHeapPointerTag tag>
602
645
  static V8_INLINE void Wrap(v8::Isolate* isolate,
603
646
  const BasicTracedReference<Object>& wrapper,
604
- void* wrappable);
647
+ Wrappable* wrappable);
605
648
  static V8_INLINE void Wrap(v8::Isolate* isolate,
606
649
  const v8::Local<v8::Object>& wrapper,
607
- void* wrappable, CppHeapPointerTag tag);
650
+ Wrappable* wrappable, CppHeapPointerTag tag);
608
651
  static V8_INLINE void Wrap(v8::Isolate* isolate,
609
652
  const PersistentBase<Object>& wrapper,
610
- void* wrappable, CppHeapPointerTag tag);
653
+ Wrappable* wrappable, CppHeapPointerTag tag);
611
654
  static V8_INLINE void Wrap(v8::Isolate* isolate,
612
655
  const BasicTracedReference<Object>& wrapper,
613
- void* wrappable, CppHeapPointerTag tag);
656
+ Wrappable* wrappable, CppHeapPointerTag tag);
657
+
658
+ // Version of Wrap() function for v8::Context::Global() objects.
659
+ // Unlike the functions above it wraps both JSGlobalProxy and its hidden
660
+ // prototype (JSGlobalObject or remote object).
661
+ static void WrapGlobal(v8::Isolate* isolate,
662
+ const v8::Local<v8::Object>& wrapper,
663
+ Wrappable* wrappable, CppHeapPointerTag tag);
664
+
665
+ // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
666
+ // the same.
667
+ static bool CheckGlobalWrappable(v8::Isolate* isolate,
668
+ const v8::Local<v8::Object>& wrapper,
669
+ CppHeapPointerTagRange tag_range);
614
670
 
615
671
  /**
616
672
  * HasOwnProperty() is like JavaScript's
@@ -795,8 +851,14 @@ class V8_EXPORT Object : public Value {
795
851
  /**
796
852
  * Return the isolate to which the Object belongs to.
797
853
  */
854
+ V8_DEPRECATED(
855
+ "Use Isolate::GetCurrent() instead, which is guaranteed to return the "
856
+ "same isolate since https://crrev.com/c/6458560.")
798
857
  Isolate* GetIsolate();
799
858
 
859
+ V8_DEPRECATED(
860
+ "Use Isolate::GetCurrent() instead, which is guaranteed to return the "
861
+ "same isolate since https://crrev.com/c/6458560.")
800
862
  V8_INLINE static Isolate* GetIsolate(const TracedReference<Object>& handle) {
801
863
  return handle.template value<Object>()->GetIsolate();
802
864
  }
@@ -871,8 +933,7 @@ Local<Data> Object::GetInternalField(int index) {
871
933
  value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
872
934
  #endif
873
935
 
874
- auto isolate = reinterpret_cast<v8::Isolate*>(
875
- internal::IsolateFromNeverReadOnlySpaceObject(obj));
936
+ auto* isolate = I::GetCurrentIsolate();
876
937
  return Local<Data>::New(isolate, value);
877
938
  }
878
939
  #endif
@@ -893,7 +954,8 @@ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate,
893
954
  (I::kEmbedderDataSlotSize * index) +
894
955
  I::kEmbedderDataSlotExternalPointerOffset;
895
956
  A value =
896
- I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
957
+ I::ReadExternalPointerField<{internal::kFirstEmbedderDataTag,
958
+ internal::kLastEmbedderDataTag}>(
897
959
  isolate, obj, offset);
898
960
  return reinterpret_cast<void*>(value);
899
961
  }
@@ -913,9 +975,10 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
913
975
  int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
914
976
  (I::kEmbedderDataSlotSize * index) +
915
977
  I::kEmbedderDataSlotExternalPointerOffset;
916
- Isolate* isolate = I::GetIsolateForSandbox(obj);
978
+ Isolate* isolate = I::GetCurrentIsolateForSandbox();
917
979
  A value =
918
- I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
980
+ I::ReadExternalPointerField<{internal::kFirstEmbedderDataTag,
981
+ internal::kLastEmbedderDataTag}>(
919
982
  isolate, obj, offset);
920
983
  return reinterpret_cast<void*>(value);
921
984
  }
@@ -1011,7 +1074,7 @@ T* Object::Unwrap(v8::Isolate* isolate,
1011
1074
  // static
1012
1075
  template <CppHeapPointerTag tag>
1013
1076
  void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1014
- void* wrappable) {
1077
+ v8::Object::Wrappable* wrappable) {
1015
1078
  auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1016
1079
  Wrap(isolate, obj, tag, wrappable);
1017
1080
  }
@@ -1019,7 +1082,7 @@ void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1019
1082
  // static
1020
1083
  template <CppHeapPointerTag tag>
1021
1084
  void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1022
- void* wrappable) {
1085
+ v8::Object::Wrappable* wrappable) {
1023
1086
  auto obj =
1024
1087
  internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1025
1088
  Wrap(isolate, obj, tag, wrappable);
@@ -1029,7 +1092,7 @@ void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1029
1092
  template <CppHeapPointerTag tag>
1030
1093
  void Object::Wrap(v8::Isolate* isolate,
1031
1094
  const BasicTracedReference<Object>& wrapper,
1032
- void* wrappable) {
1095
+ v8::Object::Wrappable* wrappable) {
1033
1096
  auto obj =
1034
1097
  internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1035
1098
  Wrap(isolate, obj, tag, wrappable);
@@ -1037,14 +1100,14 @@ void Object::Wrap(v8::Isolate* isolate,
1037
1100
 
1038
1101
  // static
1039
1102
  void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1040
- void* wrappable, CppHeapPointerTag tag) {
1103
+ v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1041
1104
  auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1042
1105
  Wrap(isolate, obj, tag, wrappable);
1043
1106
  }
1044
1107
 
1045
1108
  // static
1046
1109
  void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1047
- void* wrappable, CppHeapPointerTag tag) {
1110
+ v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1048
1111
  auto obj =
1049
1112
  internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1050
1113
  Wrap(isolate, obj, tag, wrappable);
@@ -1052,8 +1115,8 @@ void Object::Wrap(v8::Isolate* isolate, const PersistentBase<Object>& wrapper,
1052
1115
 
1053
1116
  // static
1054
1117
  void Object::Wrap(v8::Isolate* isolate,
1055
- const BasicTracedReference<Object>& wrapper, void* wrappable,
1056
- CppHeapPointerTag tag) {
1118
+ const BasicTracedReference<Object>& wrapper,
1119
+ v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1057
1120
  auto obj =
1058
1121
  internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1059
1122
  Wrap(isolate, obj, tag, wrappable);
@@ -431,7 +431,7 @@ internal::Address* PersistentBase<T>::New(Isolate* isolate, T* that) {
431
431
  template <class T, class M>
432
432
  template <class S, class M2>
433
433
  void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
434
- static_assert(std::is_base_of<T, S>::value, "type check");
434
+ static_assert(std::is_base_of_v<T, S>, "type check");
435
435
  this->Reset();
436
436
  if (that.IsEmpty()) return;
437
437
  this->slot() = api_internal::CopyGlobalReference(that.slot());
@@ -459,7 +459,7 @@ void PersistentBase<T>::Reset() {
459
459
  template <class T>
460
460
  template <class S>
461
461
  void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) {
462
- static_assert(std::is_base_of<T, S>::value, "type check");
462
+ static_assert(std::is_base_of_v<T, S>, "type check");
463
463
  Reset();
464
464
  if (other.IsEmpty()) return;
465
465
  this->slot() = New(isolate, *other);
@@ -473,7 +473,7 @@ template <class T>
473
473
  template <class S>
474
474
  void PersistentBase<T>::Reset(Isolate* isolate,
475
475
  const PersistentBase<S>& other) {
476
- static_assert(std::is_base_of<T, S>::value, "type check");
476
+ static_assert(std::is_base_of_v<T, S>, "type check");
477
477
  Reset();
478
478
  if (other.IsEmpty()) return;
479
479
  this->slot() = New(isolate, other.template value<S>());
@@ -546,7 +546,7 @@ Global<T>::Global(Global&& other) : PersistentBase<T>(other.slot()) {
546
546
  template <class T>
547
547
  template <class S>
548
548
  Global<T>& Global<T>::operator=(Global<S>&& rhs) {
549
- static_assert(std::is_base_of<T, S>::value, "type check");
549
+ static_assert(std::is_base_of_v<T, S>, "type check");
550
550
  if (this != &rhs) {
551
551
  this->Reset();
552
552
  if (!rhs.IsEmpty()) {