libv8-node 20.2.0.0-x86_64-linux → 21.7.2.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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-cppgc.h +5 -0
  19. data/vendor/v8/include/v8-embedder-heap.h +12 -0
  20. data/vendor/v8/include/v8-fast-api-calls.h +23 -5
  21. data/vendor/v8/include/v8-function-callback.h +11 -15
  22. data/vendor/v8/include/v8-function.h +6 -0
  23. data/vendor/v8/include/v8-handle-base.h +185 -0
  24. data/vendor/v8/include/v8-inspector.h +31 -1
  25. data/vendor/v8/include/v8-internal.h +109 -77
  26. data/vendor/v8/include/v8-isolate.h +130 -89
  27. data/vendor/v8/include/v8-local-handle.h +134 -89
  28. data/vendor/v8/include/v8-object.h +71 -52
  29. data/vendor/v8/include/v8-persistent-handle.h +65 -89
  30. data/vendor/v8/include/v8-platform.h +140 -9
  31. data/vendor/v8/include/v8-primitive.h +12 -8
  32. data/vendor/v8/include/v8-profiler.h +26 -2
  33. data/vendor/v8/include/v8-script.h +30 -7
  34. data/vendor/v8/include/v8-snapshot.h +4 -1
  35. data/vendor/v8/include/v8-source-location.h +92 -0
  36. data/vendor/v8/include/v8-statistics.h +36 -1
  37. data/vendor/v8/include/v8-traced-handle.h +37 -54
  38. data/vendor/v8/include/v8-unwinder.h +1 -1
  39. data/vendor/v8/include/v8-util.h +15 -13
  40. data/vendor/v8/include/v8-value-serializer.h +14 -0
  41. data/vendor/v8/include/v8-value.h +14 -0
  42. data/vendor/v8/include/v8-version.h +3 -3
  43. data/vendor/v8/include/v8config.h +19 -10
  44. data/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a +0 -0
  45. 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
 
@@ -165,17 +165,16 @@ using AccessorNameSetterCallback =
165
165
  /**
166
166
  * Access control specifications.
167
167
  *
168
- * Some accessors should be accessible across contexts. These
168
+ * Some accessors should be accessible across contexts. These
169
169
  * accessors have an explicit access control parameter which specifies
170
170
  * the kind of cross-context access that should be allowed.
171
171
  *
172
- * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused.
173
172
  */
174
173
  enum AccessControl {
175
174
  DEFAULT = 0,
176
175
  ALL_CAN_READ = 1,
177
176
  ALL_CAN_WRITE = 1 << 1,
178
- PROHIBITS_OVERWRITING = 1 << 2
177
+ PROHIBITS_OVERWRITING V8_ENUM_DEPRECATE_SOON("unused") = 1 << 2
179
178
  };
180
179
 
181
180
  /**
@@ -247,13 +246,16 @@ class V8_EXPORT Object : public Value {
247
246
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
248
247
  Local<Value> value);
249
248
 
250
- // Implements CreateDataProperty (ECMA-262, 7.3.4).
251
- //
252
- // Defines a configurable, writable, enumerable property with the given value
253
- // on the object unless the property already exists and is not configurable
254
- // or the object is not extensible.
255
- //
256
- // 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
+ */
257
259
  V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context,
258
260
  Local<Name> key,
259
261
  Local<Value> value);
@@ -261,29 +263,35 @@ class V8_EXPORT Object : public Value {
261
263
  uint32_t index,
262
264
  Local<Value> value);
263
265
 
264
- // Implements DefineOwnProperty.
265
- //
266
- // In general, CreateDataProperty will be faster, however, does not allow
267
- // for specifying attributes.
268
- //
269
- // 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
+ */
270
275
  V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
271
276
  Local<Context> context, Local<Name> key, Local<Value> value,
272
277
  PropertyAttribute attributes = None);
273
278
 
274
- // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4.
275
- //
276
- // The defineProperty function is used to add an own property or
277
- // update the attributes of an existing own property of an object.
278
- //
279
- // Both data and accessor descriptors can be used.
280
- //
281
- // In general, CreateDataProperty is faster, however, does not allow
282
- // for specifying attributes or an accessor descriptor.
283
- //
284
- // The PropertyDescriptor can change when redefining a property.
285
- //
286
- // 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
+ */
287
295
  V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
288
296
  Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
289
297
 
@@ -302,14 +310,15 @@ class V8_EXPORT Object : public Value {
302
310
  Local<Context> context, Local<Value> key);
303
311
 
304
312
  /**
305
- * 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.
306
315
  */
307
316
  V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor(
308
317
  Local<Context> context, Local<Name> key);
309
318
 
310
319
  /**
311
- * Object::Has() calls the abstract operation HasProperty(O, P) described
312
- * 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
313
322
  * true, if the object has the property, either own or on the prototype chain.
314
323
  * Interceptors, i.e., PropertyQueryCallbacks, are called if present.
315
324
  *
@@ -347,7 +356,7 @@ class V8_EXPORT Object : public Value {
347
356
 
348
357
  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
349
358
  Local<Function> setter = Local<Function>(),
350
- PropertyAttribute attribute = None,
359
+ PropertyAttribute attributes = None,
351
360
  AccessControl settings = DEFAULT);
352
361
 
353
362
  /**
@@ -465,20 +474,29 @@ class V8_EXPORT Object : public Value {
465
474
  /** Same as above, but works for PersistentBase. */
466
475
  V8_INLINE static int InternalFieldCount(
467
476
  const PersistentBase<Object>& object) {
468
- return object.val_->InternalFieldCount();
477
+ return object.template value<Object>()->InternalFieldCount();
469
478
  }
470
479
 
471
480
  /** Same as above, but works for BasicTracedReference. */
472
481
  V8_INLINE static int InternalFieldCount(
473
482
  const BasicTracedReference<Object>& object) {
474
- return object->InternalFieldCount();
483
+ return object.template value<Object>()->InternalFieldCount();
475
484
  }
476
485
 
477
- /** Gets the value from an internal field. */
478
- V8_INLINE Local<Value> GetInternalField(int index);
486
+ /**
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);
479
497
 
480
- /** Sets the value in an internal field. */
481
- void SetInternalField(int index, Local<Value> value);
498
+ /** Sets the data in an internal field. */
499
+ void SetInternalField(int index, Local<Data> data);
482
500
 
483
501
  /**
484
502
  * Gets a 2-byte-aligned native pointer from an internal field. This field
@@ -490,13 +508,15 @@ class V8_EXPORT Object : public Value {
490
508
  /** Same as above, but works for PersistentBase. */
491
509
  V8_INLINE static void* GetAlignedPointerFromInternalField(
492
510
  const PersistentBase<Object>& object, int index) {
493
- return object.val_->GetAlignedPointerFromInternalField(index);
511
+ return object.template value<Object>()->GetAlignedPointerFromInternalField(
512
+ index);
494
513
  }
495
514
 
496
515
  /** Same as above, but works for TracedReference. */
497
516
  V8_INLINE static void* GetAlignedPointerFromInternalField(
498
517
  const BasicTracedReference<Object>& object, int index) {
499
- return object->GetAlignedPointerFromInternalField(index);
518
+ return object.template value<Object>()->GetAlignedPointerFromInternalField(
519
+ index);
500
520
  }
501
521
 
502
522
  /**
@@ -604,7 +624,7 @@ class V8_EXPORT Object : public Value {
604
624
  /** Same as above, but works for Persistents */
605
625
  V8_INLINE static MaybeLocal<Context> GetCreationContext(
606
626
  const PersistentBase<Object>& object) {
607
- return object.val_->GetCreationContext();
627
+ return object.template value<Object>()->GetCreationContext();
608
628
  }
609
629
 
610
630
  /**
@@ -670,6 +690,10 @@ class V8_EXPORT Object : public Value {
670
690
  */
671
691
  Isolate* GetIsolate();
672
692
 
693
+ V8_INLINE static Isolate* GetIsolate(const TracedReference<Object>& handle) {
694
+ return handle.template value<Object>()->GetIsolate();
695
+ }
696
+
673
697
  /**
674
698
  * If this object is a Set, Map, WeakSet or WeakMap, this returns a
675
699
  * representation of the elements of this object as an array.
@@ -710,13 +734,13 @@ class V8_EXPORT Object : public Value {
710
734
  private:
711
735
  Object();
712
736
  static void CheckCast(Value* obj);
713
- Local<Value> SlowGetInternalField(int index);
737
+ Local<Data> SlowGetInternalField(int index);
714
738
  void* SlowGetAlignedPointerFromInternalField(int index);
715
739
  };
716
740
 
717
741
  // --- Implementation ---
718
742
 
719
- Local<Value> Object::GetInternalField(int index) {
743
+ Local<Data> Object::GetInternalField(int index) {
720
744
  #ifndef V8_ENABLE_CHECKS
721
745
  using A = internal::Address;
722
746
  using I = internal::Internals;
@@ -733,14 +757,9 @@ Local<Value> Object::GetInternalField(int index) {
733
757
  value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
734
758
  #endif
735
759
 
736
- #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
737
- return Local<Value>(reinterpret_cast<Value*>(value));
738
- #else
739
- internal::Isolate* isolate =
740
- internal::IsolateFromNeverReadOnlySpaceObject(obj);
741
- A* result = HandleScope::CreateHandle(isolate, value);
742
- return Local<Value>(reinterpret_cast<Value*>(result));
743
- #endif
760
+ auto isolate = reinterpret_cast<v8::Isolate*>(
761
+ internal::IsolateFromNeverReadOnlySpaceObject(obj));
762
+ return Local<Data>::New(isolate, value);
744
763
  }
745
764
  #endif
746
765
  return SlowGetInternalField(index);