libv8-node 20.12.1.0-x86_64-linux-musl → 21.7.2.0-x86_64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/internal/api-constants.h +23 -4
  4. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +16 -6
  5. data/vendor/v8/include/cppgc/internal/caged-heap.h +12 -5
  6. data/vendor/v8/include/cppgc/internal/gc-info.h +82 -91
  7. data/vendor/v8/include/cppgc/internal/member-storage.h +16 -8
  8. data/vendor/v8/include/cppgc/member.h +25 -0
  9. data/vendor/v8/include/cppgc/persistent.h +4 -0
  10. data/vendor/v8/include/cppgc/platform.h +6 -1
  11. data/vendor/v8/include/cppgc/sentinel-pointer.h +7 -0
  12. data/vendor/v8/include/cppgc/source-location.h +2 -78
  13. data/vendor/v8/include/cppgc/trace-trait.h +8 -0
  14. data/vendor/v8/include/cppgc/visitor.h +82 -4
  15. data/vendor/v8/include/libplatform/libplatform.h +7 -1
  16. data/vendor/v8/include/v8-callbacks.h +52 -8
  17. data/vendor/v8/include/v8-context.h +10 -13
  18. data/vendor/v8/include/v8-embedder-heap.h +12 -0
  19. data/vendor/v8/include/v8-fast-api-calls.h +23 -5
  20. data/vendor/v8/include/v8-function-callback.h +11 -15
  21. data/vendor/v8/include/v8-function.h +6 -0
  22. data/vendor/v8/include/v8-handle-base.h +185 -0
  23. data/vendor/v8/include/v8-inspector.h +31 -1
  24. data/vendor/v8/include/v8-internal.h +109 -77
  25. data/vendor/v8/include/v8-isolate.h +130 -89
  26. data/vendor/v8/include/v8-local-handle.h +134 -89
  27. data/vendor/v8/include/v8-object.h +71 -69
  28. data/vendor/v8/include/v8-persistent-handle.h +65 -89
  29. data/vendor/v8/include/v8-platform.h +140 -9
  30. data/vendor/v8/include/v8-primitive.h +12 -8
  31. data/vendor/v8/include/v8-profiler.h +16 -2
  32. data/vendor/v8/include/v8-script.h +27 -3
  33. data/vendor/v8/include/v8-snapshot.h +4 -1
  34. data/vendor/v8/include/v8-source-location.h +92 -0
  35. data/vendor/v8/include/v8-statistics.h +36 -1
  36. data/vendor/v8/include/v8-traced-handle.h +37 -54
  37. data/vendor/v8/include/v8-unwinder.h +1 -1
  38. data/vendor/v8/include/v8-util.h +15 -13
  39. data/vendor/v8/include/v8-value-serializer.h +14 -0
  40. data/vendor/v8/include/v8-value.h +14 -0
  41. data/vendor/v8/include/v8-version.h +3 -3
  42. data/vendor/v8/include/v8config.h +19 -10
  43. data/vendor/v8/x86_64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
  44. metadata +4 -2
@@ -9,29 +9,42 @@
9
9
 
10
10
  #include <type_traits>
11
11
 
12
- #include "v8-internal.h" // NOLINT(build/include_directory)
12
+ #include "v8-handle-base.h" // NOLINT(build/include_directory)
13
13
 
14
14
  namespace v8 {
15
15
 
16
- class Boolean;
17
16
  template <class T>
18
- class BasicTracedReference;
19
- class Context;
20
- class EscapableHandleScope;
21
- template <class F>
22
- class Eternal;
23
- template <class F>
24
- class FunctionCallbackInfo;
25
- class Isolate;
17
+ class LocalBase;
18
+ template <class T>
19
+ class Local;
26
20
  template <class F>
27
21
  class MaybeLocal;
22
+
23
+ template <class T>
24
+ class Eternal;
25
+ template <class T>
26
+ class Global;
27
+
28
28
  template <class T>
29
29
  class NonCopyablePersistentTraits;
30
- class Object;
30
+ template <class T>
31
+ class PersistentBase;
31
32
  template <class T, class M = NonCopyablePersistentTraits<T>>
32
33
  class Persistent;
34
+
35
+ class TracedReferenceBase;
33
36
  template <class T>
34
- class PersistentBase;
37
+ class BasicTracedReference;
38
+ template <class F>
39
+ class TracedReference;
40
+
41
+ class Boolean;
42
+ class Context;
43
+ class EscapableHandleScope;
44
+ template <class F>
45
+ class FunctionCallbackInfo;
46
+ class Isolate;
47
+ class Object;
35
48
  template <class F1, class F2, class F3>
36
49
  class PersistentValueMapBase;
37
50
  template <class F1, class F2>
@@ -45,9 +58,6 @@ class ReturnValue;
45
58
  class String;
46
59
  template <class F>
47
60
  class Traced;
48
- template <class F>
49
- class TracedReference;
50
- class TracedReferenceBase;
51
61
  class Utils;
52
62
 
53
63
  namespace debug {
@@ -120,9 +130,9 @@ class V8_EXPORT V8_NODISCARD HandleScope {
120
130
  internal::Address* prev_next_;
121
131
  internal::Address* prev_limit_;
122
132
 
123
- // Local::New uses CreateHandle with an Isolate* parameter.
124
- template <class F>
125
- friend class Local;
133
+ // LocalBase<T>::New uses CreateHandle with an Isolate* parameter.
134
+ template <typename T>
135
+ friend class LocalBase;
126
136
 
127
137
  // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with
128
138
  // a HeapObject in their shortcuts.
@@ -130,32 +140,74 @@ class V8_EXPORT V8_NODISCARD HandleScope {
130
140
  friend class Context;
131
141
  };
132
142
 
133
- namespace internal {
134
-
135
143
  /**
136
- * Helper functions about handles.
144
+ * A base class for local handles.
145
+ * Its implementation depends on whether direct local support is enabled.
146
+ * When it is, a local handle contains a direct pointer to the referenced
147
+ * object, otherwise it contains an indirect pointer.
137
148
  */
138
- class HandleHelper final {
139
- public:
140
- /**
141
- * Checks whether two handles are equal.
142
- * They are equal iff they are both empty or they are both non-empty and the
143
- * objects to which they refer are physically equal.
144
- *
145
- * If both handles refer to JS objects, this is the same as strict equality.
146
- * For primitives, such as numbers or strings, a `false` return value does not
147
- * indicate that the values aren't equal in the JavaScript sense.
148
- * Use `Value::StrictEquals()` to check primitives for equality.
149
- */
150
- template <typename T1, typename T2>
151
- V8_INLINE static bool EqualHandles(const T1& lhs, const T2& rhs) {
152
- if (lhs.IsEmpty()) return rhs.IsEmpty();
153
- if (rhs.IsEmpty()) return false;
154
- return lhs.address() == rhs.address();
149
+ #ifdef V8_ENABLE_DIRECT_LOCAL
150
+
151
+ template <typename T>
152
+ class LocalBase : public DirectHandleBase {
153
+ protected:
154
+ template <class F>
155
+ friend class Local;
156
+
157
+ V8_INLINE LocalBase() = default;
158
+
159
+ V8_INLINE explicit LocalBase(internal::Address ptr) : DirectHandleBase(ptr) {}
160
+
161
+ template <typename S>
162
+ V8_INLINE LocalBase(const LocalBase<S>& other) : DirectHandleBase(other) {}
163
+
164
+ V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
165
+ return LocalBase<T>(value);
166
+ }
167
+
168
+ V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
169
+ return LocalBase<T>::New(isolate,
170
+ internal::ValueHelper::ValueAsAddress(that));
171
+ }
172
+
173
+ V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
174
+ return LocalBase<T>(*slot);
155
175
  }
156
176
  };
157
177
 
158
- } // namespace internal
178
+ #else // !V8_ENABLE_DIRECT_LOCAL
179
+
180
+ template <typename T>
181
+ class LocalBase : public IndirectHandleBase {
182
+ protected:
183
+ template <class F>
184
+ friend class Local;
185
+
186
+ V8_INLINE LocalBase() = default;
187
+
188
+ V8_INLINE explicit LocalBase(internal::Address* location)
189
+ : IndirectHandleBase(location) {}
190
+
191
+ template <typename S>
192
+ V8_INLINE LocalBase(const LocalBase<S>& other) : IndirectHandleBase(other) {}
193
+
194
+ V8_INLINE static LocalBase<T> New(Isolate* isolate, internal::Address value) {
195
+ return LocalBase(HandleScope::CreateHandle(
196
+ reinterpret_cast<internal::Isolate*>(isolate), value));
197
+ }
198
+
199
+ V8_INLINE static LocalBase<T> New(Isolate* isolate, T* that) {
200
+ if (internal::ValueHelper::IsEmpty(that)) return LocalBase<T>();
201
+ return LocalBase<T>::New(isolate,
202
+ internal::ValueHelper::ValueAsAddress(that));
203
+ }
204
+
205
+ V8_INLINE static LocalBase<T> FromSlot(internal::Address* slot) {
206
+ return LocalBase<T>(slot);
207
+ }
208
+ };
209
+
210
+ #endif // V8_ENABLE_DIRECT_LOCAL
159
211
 
160
212
  /**
161
213
  * An object reference managed by the v8 garbage collector.
@@ -187,12 +239,12 @@ class HandleHelper final {
187
239
  * to these values as to their handles.
188
240
  */
189
241
  template <class T>
190
- class Local {
242
+ class Local : public LocalBase<T> {
191
243
  public:
192
- V8_INLINE Local() : val_(internal::ValueHelper::EmptyValue<T>()) {}
244
+ V8_INLINE Local() = default;
193
245
 
194
246
  template <class S>
195
- V8_INLINE Local(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
247
+ V8_INLINE Local(Local<S> that) : LocalBase<T>(that) {
196
248
  /**
197
249
  * This check fails when trying to convert between incompatible
198
250
  * handles. For example, converting from a Local<String> to a
@@ -201,21 +253,9 @@ class Local {
201
253
  static_assert(std::is_base_of<T, S>::value, "type check");
202
254
  }
203
255
 
204
- /**
205
- * Returns true if the handle is empty.
206
- */
207
- V8_INLINE bool IsEmpty() const {
208
- return val_ == internal::ValueHelper::EmptyValue<T>();
209
- }
210
-
211
- /**
212
- * Sets the handle to be empty. IsEmpty() will then return true.
213
- */
214
- V8_INLINE void Clear() { val_ = internal::ValueHelper::EmptyValue<T>(); }
215
-
216
- V8_INLINE T* operator->() const { return val_; }
256
+ V8_INLINE T* operator->() const { return this->template value<T>(); }
217
257
 
218
- V8_INLINE T* operator*() const { return val_; }
258
+ V8_INLINE T* operator*() const { return this->operator->(); }
219
259
 
220
260
  /**
221
261
  * Checks whether two handles are equal or different.
@@ -259,8 +299,9 @@ class Local {
259
299
  // If we're going to perform the type check then we have to check
260
300
  // that the handle isn't empty before doing the checked cast.
261
301
  if (that.IsEmpty()) return Local<T>();
302
+ T::Cast(that.template value<S>());
262
303
  #endif
263
- return Local<T>(T::Cast(*that));
304
+ return Local<T>(LocalBase<T>(that));
264
305
  }
265
306
 
266
307
  /**
@@ -279,17 +320,17 @@ class Local {
279
320
  * the original handle is destroyed/disposed.
280
321
  */
281
322
  V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that) {
282
- return New(isolate, that.val_);
323
+ return New(isolate, that.template value<T>());
283
324
  }
284
325
 
285
326
  V8_INLINE static Local<T> New(Isolate* isolate,
286
327
  const PersistentBase<T>& that) {
287
- return New(isolate, internal::ValueHelper::SlotAsValue<T>(that.val_));
328
+ return New(isolate, that.template value<T>());
288
329
  }
289
330
 
290
331
  V8_INLINE static Local<T> New(Isolate* isolate,
291
332
  const BasicTracedReference<T>& that) {
292
- return New(isolate, internal::ValueHelper::SlotAsValue<T>(*that));
333
+ return New(isolate, that.template value<T>());
293
334
  }
294
335
 
295
336
  private:
@@ -298,7 +339,13 @@ class Local {
298
339
  template <class F>
299
340
  friend class Eternal;
300
341
  template <class F>
342
+ friend class Global;
343
+ template <class F>
344
+ friend class Local;
345
+ template <class F>
301
346
  friend class MaybeLocal;
347
+ template <class F, class M>
348
+ friend class Persistent;
302
349
  template <class F>
303
350
  friend class FunctionCallbackInfo;
304
351
  template <class F>
@@ -328,28 +375,32 @@ class Local {
328
375
  friend class internal::HandleHelper;
329
376
  friend class debug::ConsoleCallArguments;
330
377
 
331
- explicit V8_INLINE Local(T* that) : val_(that) {}
378
+ V8_INLINE explicit Local<T>(const LocalBase<T>& other)
379
+ : LocalBase<T>(other) {}
332
380
 
333
- V8_INLINE internal::Address address() const {
334
- return internal::ValueHelper::ValueAsAddress(val_);
381
+ V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
382
+ return Local<T>(LocalBase<T>::FromSlot(slot));
335
383
  }
336
384
 
337
- V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
338
- return Local<T>(internal::ValueHelper::SlotAsValue<T>(slot));
385
+ #ifdef V8_ENABLE_DIRECT_LOCAL
386
+ V8_INLINE static Local<T> FromAddress(internal::Address ptr) {
387
+ return Local<T>(LocalBase<T>(ptr));
388
+ }
389
+ #endif // V8_ENABLE_DIRECT_LOCAL
390
+
391
+ V8_INLINE static Local<T> New(Isolate* isolate, internal::Address value) {
392
+ return Local<T>(LocalBase<T>::New(isolate, value));
339
393
  }
340
394
 
341
395
  V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
342
- #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
343
- return Local<T>(that);
344
- #else
345
- if (that == nullptr) return Local<T>();
346
- internal::Address* p = reinterpret_cast<internal::Address*>(that);
347
- return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
348
- reinterpret_cast<internal::Isolate*>(isolate), *p)));
349
- #endif
396
+ return Local<T>(LocalBase<T>::New(isolate, that));
350
397
  }
351
398
 
352
- T* val_;
399
+ // Unsafe cast, should be avoided.
400
+ template <class S>
401
+ V8_INLINE Local<S> UnsafeAs() const {
402
+ return Local<S>(LocalBase<S>(*this));
403
+ }
353
404
  };
354
405
 
355
406
  #if !defined(V8_IMMINENT_DEPRECATION_WARNINGS)
@@ -371,15 +422,11 @@ using Handle = Local<T>;
371
422
  template <class T>
372
423
  class MaybeLocal {
373
424
  public:
374
- V8_INLINE MaybeLocal() : val_(internal::ValueHelper::EmptyValue<T>()) {}
425
+ V8_INLINE MaybeLocal() : local_() {}
375
426
  template <class S>
376
- V8_INLINE MaybeLocal(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
377
- static_assert(std::is_base_of<T, S>::value, "type check");
378
- }
427
+ V8_INLINE MaybeLocal(Local<S> that) : local_(that) {}
379
428
 
380
- V8_INLINE bool IsEmpty() const {
381
- return val_ == internal::ValueHelper::EmptyValue<T>();
382
- }
429
+ V8_INLINE bool IsEmpty() const { return local_.IsEmpty(); }
383
430
 
384
431
  /**
385
432
  * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
@@ -387,7 +434,7 @@ class MaybeLocal {
387
434
  */
388
435
  template <class S>
389
436
  V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
390
- out->val_ = IsEmpty() ? internal::ValueHelper::EmptyValue<T>() : this->val_;
437
+ *out = local_;
391
438
  return !IsEmpty();
392
439
  }
393
440
 
@@ -397,7 +444,7 @@ class MaybeLocal {
397
444
  */
398
445
  V8_INLINE Local<T> ToLocalChecked() {
399
446
  if (V8_UNLIKELY(IsEmpty())) api_internal::ToLocalEmpty();
400
- return Local<T>(val_);
447
+ return local_;
401
448
  }
402
449
 
403
450
  /**
@@ -406,11 +453,11 @@ class MaybeLocal {
406
453
  */
407
454
  template <class S>
408
455
  V8_INLINE Local<S> FromMaybe(Local<S> default_value) const {
409
- return IsEmpty() ? default_value : Local<S>(val_);
456
+ return IsEmpty() ? default_value : Local<S>(local_);
410
457
  }
411
458
 
412
459
  private:
413
- T* val_;
460
+ Local<T> local_;
414
461
  };
415
462
 
416
463
  /**
@@ -428,12 +475,10 @@ class V8_EXPORT V8_NODISCARD EscapableHandleScope : public HandleScope {
428
475
  */
429
476
  template <class T>
430
477
  V8_INLINE Local<T> Escape(Local<T> value) {
431
- #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
478
+ #ifdef V8_ENABLE_DIRECT_LOCAL
432
479
  return value;
433
480
  #else
434
- internal::Address* slot =
435
- Escape(reinterpret_cast<internal::Address*>(*value));
436
- return Local<T>(reinterpret_cast<T*>(slot));
481
+ return Local<T>::FromSlot(Escape(value.slot()));
437
482
  #endif
438
483
  }
439
484
 
@@ -20,8 +20,6 @@ class Function;
20
20
  class FunctionTemplate;
21
21
  template <typename T>
22
22
  class PropertyCallbackInfo;
23
- class Module;
24
- class UnboundScript;
25
23
 
26
24
  /**
27
25
  * A private symbol
@@ -167,17 +165,16 @@ using AccessorNameSetterCallback =
167
165
  /**
168
166
  * Access control specifications.
169
167
  *
170
- * Some accessors should be accessible across contexts. These
168
+ * Some accessors should be accessible across contexts. These
171
169
  * accessors have an explicit access control parameter which specifies
172
170
  * the kind of cross-context access that should be allowed.
173
171
  *
174
- * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
175
172
  */
176
173
  enum AccessControl {
177
174
  DEFAULT = 0,
178
175
  ALL_CAN_READ = 1,
179
176
  ALL_CAN_WRITE = 1 << 1,
180
- PROHIBITS_OVERWRITING = 1 << 2
177
+ PROHIBITS_OVERWRITING V8_ENUM_DEPRECATE_SOON("unused") = 1 << 2
181
178
  };
182
179
 
183
180
  /**
@@ -249,13 +246,16 @@ class V8_EXPORT Object : public Value {
249
246
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
250
247
  Local<Value> value);
251
248
 
252
- // Implements CreateDataProperty (ECMA-262, 7.3.4).
253
- //
254
- // Defines a configurable, writable, enumerable property with the given value
255
- // on the object unless the property already exists and is not configurable
256
- // or the object is not extensible.
257
- //
258
- // Returns true on success.
249
+ /**
250
+ * Implements CreateDataProperty(O, P, V), see
251
+ * https://tc39.es/ecma262/#sec-createdataproperty.
252
+ *
253
+ * Defines a configurable, writable, enumerable property with the given value
254
+ * on the object unless the property already exists and is not configurable
255
+ * or the object is not extensible.
256
+ *
257
+ * Returns true on success.
258
+ */
259
259
  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
260
260
  Local<Name> key,
261
261
  Local<Value> value);
@@ -263,29 +263,35 @@ class V8_EXPORT Object : public Value {
263
263
  uint32_t index,
264
264
  Local<Value> value);
265
265
 
266
- // Implements DefineOwnProperty.
267
- //
268
- // In general, CreateDataProperty will be faster, however, does not allow
269
- // for specifying attributes.
270
- //
271
- // Returns true on success.
266
+ /**
267
+ * Implements [[DefineOwnProperty]] for data property case, see
268
+ * https://tc39.es/ecma262/#table-essential-internal-methods.
269
+ *
270
+ * In general, CreateDataProperty will be faster, however, does not allow
271
+ * for specifying attributes.
272
+ *
273
+ * Returns true on success.
274
+ */
272
275
  V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
273
276
  Local<Context> context, Local<Name> key, Local<Value> value,
274
277
  PropertyAttribute attributes = None);
275
278
 
276
- // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
277
- //
278
- // The defineProperty function is used to add an own property or
279
- // update the attributes of an existing own property of an object.
280
- //
281
- // Both data and accessor descriptors can be used.
282
- //
283
- // In general, CreateDataProperty is faster, however, does not allow
284
- // for specifying attributes or an accessor descriptor.
285
- //
286
- // The PropertyDescriptor can change when redefining a property.
287
- //
288
- // Returns true on success.
279
+ /**
280
+ * Implements Object.defineProperty(O, P, Attributes), see
281
+ * https://tc39.es/ecma262/#sec-object.defineproperty.
282
+ *
283
+ * The defineProperty function is used to add an own property or
284
+ * update the attributes of an existing own property of an object.
285
+ *
286
+ * Both data and accessor descriptors can be used.
287
+ *
288
+ * In general, CreateDataProperty is faster, however, does not allow
289
+ * for specifying attributes or an accessor descriptor.
290
+ *
291
+ * The PropertyDescriptor can change when redefining a property.
292
+ *
293
+ * Returns true on success.
294
+ */
289
295
  V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
290
296
  Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
291
297
 
@@ -304,14 +310,15 @@ class V8_EXPORT Object : public Value {
304
310
  Local<Context> context, Local<Value> key);
305
311
 
306
312
  /**
307
- * Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6.
313
+ * Implements Object.getOwnPropertyDescriptor(O, P), see
314
+ * https://tc39.es/ecma262/#sec-object.getownpropertydescriptor.
308
315
  */
309
316
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
310
317
  Local<Context> context, Local<Name> key);
311
318
 
312
319
  /**
313
- * Object::Has() calls the abstract operation HasProperty(O, P) described
314
- * in ECMA-262, 7.3.10. Has() returns
320
+ * Object::Has() calls the abstract operation HasProperty(O, P), see
321
+ * https://tc39.es/ecma262/#sec-hasproperty. Has() returns
315
322
  * true, if the object has the property, either own or on the prototype chain.
316
323
  * Interceptors, i.e., PropertyQueryCallbacks, are called if present.
317
324
  *
@@ -349,7 +356,7 @@ class V8_EXPORT Object : public Value {
349
356
 
350
357
  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
351
358
  Local<Function> setter = Local<Function>(),
352
- PropertyAttribute attribute = None,
359
+ PropertyAttribute attributes = None,
353
360
  AccessControl settings = DEFAULT);
354
361
 
355
362
  /**
@@ -467,35 +474,29 @@ class V8_EXPORT Object : public Value {
467
474
  /** Same as above, but works for PersistentBase. */
468
475
  V8_INLINE static int InternalFieldCount(
469
476
  const PersistentBase<Object>& object) {
470
- return object.val_->InternalFieldCount();
477
+ return object.template value<Object>()->InternalFieldCount();
471
478
  }
472
479
 
473
480
  /** Same as above, but works for BasicTracedReference. */
474
481
  V8_INLINE static int InternalFieldCount(
475
482
  const BasicTracedReference<Object>& object) {
476
- return object->InternalFieldCount();
483
+ return object.template value<Object>()->InternalFieldCount();
477
484
  }
478
485
 
479
- /** Gets the value from an internal field. */
480
- V8_INLINE Local<Value> GetInternalField(int index);
481
-
482
- /** Sets the value in an internal field. */
483
- void SetInternalField(int index, Local<Value> value);
484
-
485
486
  /**
486
- * Warning: These are Node.js-specific extentions used to avoid breaking
487
- * changes in Node.js v20.x. They do not exist in V8 upstream and will
488
- * not exist in Node.js v21.x. Node.js embedders and addon authors should
489
- * not use them from v20.x.
490
- */
491
- #ifndef NODE_WANT_INTERNALS
492
- V8_DEPRECATED("This extention should only be used by Node.js core")
493
- #endif
494
- void SetInternalFieldForNodeCore(int index, Local<Module> value);
495
- #ifndef NODE_WANT_INTERNALS
496
- V8_DEPRECATED("This extention should only be used by Node.js core")
497
- #endif
498
- void SetInternalFieldForNodeCore(int index, Local<UnboundScript> value);
487
+ * Gets the data from an internal field.
488
+ * To cast the return value into v8::Value subtypes, it needs to be
489
+ * casted to a v8::Value first. For example, to cast it into v8::External:
490
+ *
491
+ * object->GetInternalField(index).As<v8::Value>().As<v8::External>();
492
+ *
493
+ * The embedder should make sure that the internal field being retrieved
494
+ * using this method has already been set with SetInternalField() before.
495
+ **/
496
+ V8_INLINE Local<Data> GetInternalField(int index);
497
+
498
+ /** Sets the data in an internal field. */
499
+ void SetInternalField(int index, Local<Data> data);
499
500
 
500
501
  /**
501
502
  * Gets a 2-byte-aligned native pointer from an internal field. This field
@@ -507,13 +508,15 @@ class V8_EXPORT Object : public Value {
507
508
  /** Same as above, but works for PersistentBase. */
508
509
  V8_INLINE static void* GetAlignedPointerFromInternalField(
509
510
  const PersistentBase<Object>& object, int index) {
510
- return object.val_->GetAlignedPointerFromInternalField(index);
511
+ return object.template value<Object>()->GetAlignedPointerFromInternalField(
512
+ index);
511
513
  }
512
514
 
513
515
  /** Same as above, but works for TracedReference. */
514
516
  V8_INLINE static void* GetAlignedPointerFromInternalField(
515
517
  const BasicTracedReference<Object>& object, int index) {
516
- return object->GetAlignedPointerFromInternalField(index);
518
+ return object.template value<Object>()->GetAlignedPointerFromInternalField(
519
+ index);
517
520
  }
518
521
 
519
522
  /**
@@ -621,7 +624,7 @@ class V8_EXPORT Object : public Value {
621
624
  /** Same as above, but works for Persistents */
622
625
  V8_INLINE static MaybeLocal<Context> GetCreationContext(
623
626
  const PersistentBase<Object>& object) {
624
- return object.val_->GetCreationContext();
627
+ return object.template value<Object>()->GetCreationContext();
625
628
  }
626
629
 
627
630
  /**
@@ -687,6 +690,10 @@ class V8_EXPORT Object : public Value {
687
690
  */
688
691
  Isolate* GetIsolate();
689
692
 
693
+ V8_INLINE static Isolate* GetIsolate(const TracedReference<Object>& handle) {
694
+ return handle.template value<Object>()->GetIsolate();
695
+ }
696
+
690
697
  /**
691
698
  * If this object is a Set, Map, WeakSet or WeakMap, this returns a
692
699
  * representation of the elements of this object as an array.
@@ -727,13 +734,13 @@ class V8_EXPORT Object : public Value {
727
734
  private:
728
735
  Object();
729
736
  static void CheckCast(Value* obj);
730
- Local<Value> SlowGetInternalField(int index);
737
+ Local<Data> SlowGetInternalField(int index);
731
738
  void* SlowGetAlignedPointerFromInternalField(int index);
732
739
  };
733
740
 
734
741
  // --- Implementation ---
735
742
 
736
- Local<Value> Object::GetInternalField(int index) {
743
+ Local<Data> Object::GetInternalField(int index) {
737
744
  #ifndef V8_ENABLE_CHECKS
738
745
  using A = internal::Address;
739
746
  using I = internal::Internals;
@@ -750,14 +757,9 @@ Local<Value> Object::GetInternalField(int index) {
750
757
  value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
751
758
  #endif
752
759
 
753
- #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
754
- return Local<Value>(reinterpret_cast<Value*>(value));
755
- #else
756
- internal::Isolate* isolate =
757
- internal::IsolateFromNeverReadOnlySpaceObject(obj);
758
- A* result = HandleScope::CreateHandle(isolate, value);
759
- return Local<Value>(reinterpret_cast<Value*>(result));
760
- #endif
760
+ auto isolate = reinterpret_cast<v8::Isolate*>(
761
+ internal::IsolateFromNeverReadOnlySpaceObject(obj));
762
+ return Local<Data>::New(isolate, value);
761
763
  }
762
764
  #endif
763
765
  return SlowGetInternalField(index);