libv8-node 21.7.2.0-aarch64-linux → 22.5.1.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) 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/internal/api-constants.h +1 -1
  5. data/vendor/v8/include/cppgc/type-traits.h +25 -4
  6. data/vendor/v8/include/v8-array-buffer.h +6 -0
  7. data/vendor/v8/include/v8-callbacks.h +6 -12
  8. data/vendor/v8/include/v8-container.h +54 -0
  9. data/vendor/v8/include/v8-context.h +51 -22
  10. data/vendor/v8/include/v8-embedder-heap.h +19 -3
  11. data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
  12. data/vendor/v8/include/v8-exception.h +15 -9
  13. data/vendor/v8/include/v8-fast-api-calls.h +35 -26
  14. data/vendor/v8/include/v8-forward.h +1 -0
  15. data/vendor/v8/include/v8-function-callback.h +129 -20
  16. data/vendor/v8/include/v8-handle-base.h +32 -80
  17. data/vendor/v8/include/v8-inspector.h +16 -24
  18. data/vendor/v8/include/v8-internal.h +472 -65
  19. data/vendor/v8/include/v8-isolate.h +86 -51
  20. data/vendor/v8/include/v8-local-handle.h +257 -31
  21. data/vendor/v8/include/v8-memory-span.h +157 -2
  22. data/vendor/v8/include/v8-message.h +22 -3
  23. data/vendor/v8/include/v8-metrics.h +1 -0
  24. data/vendor/v8/include/v8-object.h +29 -10
  25. data/vendor/v8/include/v8-persistent-handle.h +5 -3
  26. data/vendor/v8/include/v8-platform.h +81 -44
  27. data/vendor/v8/include/v8-script.h +61 -11
  28. data/vendor/v8/include/v8-snapshot.h +94 -23
  29. data/vendor/v8/include/v8-statistics.h +10 -24
  30. data/vendor/v8/include/v8-template.h +410 -131
  31. data/vendor/v8/include/v8-traced-handle.h +81 -46
  32. data/vendor/v8/include/v8-typed-array.h +115 -7
  33. data/vendor/v8/include/v8-util.h +13 -12
  34. data/vendor/v8/include/v8-value.h +92 -4
  35. data/vendor/v8/include/v8-version.h +4 -4
  36. data/vendor/v8/include/v8config.h +35 -10
  37. metadata +2 -2
@@ -27,14 +27,20 @@ namespace internal {
27
27
 
28
28
  class BasicTracedReferenceExtractor;
29
29
 
30
- enum class GlobalHandleStoreMode {
30
+ enum class TracedReferenceStoreMode {
31
31
  kInitializingStore,
32
32
  kAssigningStore,
33
33
  };
34
34
 
35
+ enum class TracedReferenceHandling {
36
+ kDefault, // See EmbedderRootsHandler::IsRoot().
37
+ kDroppable
38
+ };
39
+
35
40
  V8_EXPORT internal::Address* GlobalizeTracedReference(
36
41
  internal::Isolate* isolate, internal::Address value,
37
- internal::Address* slot, GlobalHandleStoreMode store_mode);
42
+ internal::Address* slot, TracedReferenceStoreMode store_mode,
43
+ internal::TracedReferenceHandling reference_handling);
38
44
  V8_EXPORT void MoveTracedReference(internal::Address** from,
39
45
  internal::Address** to);
40
46
  V8_EXPORT void CopyTracedReference(const internal::Address* const* from,
@@ -47,7 +53,7 @@ V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
47
53
  * An indirect handle, where the indirect pointer points to a GlobalHandles
48
54
  * node.
49
55
  */
50
- class TracedReferenceBase : public IndirectHandleBase {
56
+ class TracedReferenceBase : public api_internal::IndirectHandleBase {
51
57
  public:
52
58
  /**
53
59
  * If non-empty, destroy the underlying storage cell. |IsEmpty| will return
@@ -71,17 +77,6 @@ class TracedReferenceBase : public IndirectHandleBase {
71
77
  return this->GetSlotThreadSafe() == nullptr;
72
78
  }
73
79
 
74
- /**
75
- * Assigns a wrapper class ID to the handle.
76
- */
77
- V8_INLINE void SetWrapperClassId(uint16_t class_id);
78
-
79
- /**
80
- * Returns the class ID previously assigned to this handle or 0 if no class ID
81
- * was previously assigned.
82
- */
83
- V8_INLINE uint16_t WrapperClassId() const;
84
-
85
80
  protected:
86
81
  V8_INLINE TracedReferenceBase() = default;
87
82
 
@@ -157,9 +152,10 @@ class BasicTracedReference : public TracedReferenceBase {
157
152
  */
158
153
  BasicTracedReference() = default;
159
154
 
160
- V8_INLINE static internal::Address* New(
155
+ V8_INLINE static internal::Address* NewFromNonEmptyValue(
161
156
  Isolate* isolate, T* that, internal::Address** slot,
162
- internal::GlobalHandleStoreMode store_mode);
157
+ internal::TracedReferenceStoreMode store_mode,
158
+ internal::TracedReferenceHandling reference_handling);
163
159
 
164
160
  template <typename F>
165
161
  friend class Local;
@@ -180,6 +176,8 @@ class BasicTracedReference : public TracedReferenceBase {
180
176
  template <typename T>
181
177
  class TracedReference : public BasicTracedReference<T> {
182
178
  public:
179
+ struct IsDroppable {};
180
+
183
181
  using BasicTracedReference<T>::Reset;
184
182
 
185
183
  /**
@@ -195,10 +193,35 @@ class TracedReference : public BasicTracedReference<T> {
195
193
  */
196
194
  template <class S>
197
195
  TracedReference(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
198
- this->slot() =
199
- this->New(isolate, *that, &this->slot(),
200
- internal::GlobalHandleStoreMode::kInitializingStore);
201
196
  static_assert(std::is_base_of<T, S>::value, "type check");
197
+ if (V8_UNLIKELY(that.IsEmpty())) {
198
+ return;
199
+ }
200
+ this->slot() = this->NewFromNonEmptyValue(
201
+ isolate, *that, &this->slot(),
202
+ internal::TracedReferenceStoreMode::kInitializingStore,
203
+ internal::TracedReferenceHandling::kDefault);
204
+ }
205
+
206
+ /**
207
+ * Construct a droppable TracedReference from a Local. Droppable means that V8
208
+ * is free to reclaim the pointee if it is unmodified and otherwise
209
+ * unreachable
210
+ *
211
+ * When the Local is non-empty, a new storage cell is created
212
+ * pointing to the same object.
213
+ */
214
+ template <class S>
215
+ TracedReference(Isolate* isolate, Local<S> that, IsDroppable)
216
+ : BasicTracedReference<T>() {
217
+ static_assert(std::is_base_of<T, S>::value, "type check");
218
+ if (V8_UNLIKELY(that.IsEmpty())) {
219
+ return;
220
+ }
221
+ this->slot() = this->NewFromNonEmptyValue(
222
+ isolate, *that, &this->slot(),
223
+ internal::TracedReferenceStoreMode::kInitializingStore,
224
+ internal::TracedReferenceHandling::kDroppable);
202
225
  }
203
226
 
204
227
  /**
@@ -262,12 +285,19 @@ class TracedReference : public BasicTracedReference<T> {
262
285
  V8_INLINE TracedReference& operator=(const TracedReference<S>& rhs);
263
286
 
264
287
  /**
265
- * If non-empty, destroy the underlying storage cell and create a new one with
266
- * the contents of other if other is non empty
288
+ * Always resets the reference. Creates a new reference from `other` if it is
289
+ * non-empty.
267
290
  */
268
291
  template <class S>
269
292
  V8_INLINE void Reset(Isolate* isolate, const Local<S>& other);
270
293
 
294
+ /**
295
+ * Always resets the reference. Creates a new reference from `other` if it is
296
+ * non-empty. The new reference is droppable, see constructor.
297
+ */
298
+ template <class S>
299
+ V8_INLINE void Reset(Isolate* isolate, const Local<S>& other, IsDroppable);
300
+
271
301
  template <class S>
272
302
  V8_INLINE TracedReference<S>& As() const {
273
303
  return reinterpret_cast<TracedReference<S>&>(
@@ -277,18 +307,21 @@ class TracedReference : public BasicTracedReference<T> {
277
307
 
278
308
  // --- Implementation ---
279
309
  template <class T>
280
- internal::Address* BasicTracedReference<T>::New(
310
+ internal::Address* BasicTracedReference<T>::NewFromNonEmptyValue(
281
311
  Isolate* isolate, T* that, internal::Address** slot,
282
- internal::GlobalHandleStoreMode store_mode) {
283
- if (internal::ValueHelper::IsEmpty(that)) return nullptr;
312
+ internal::TracedReferenceStoreMode store_mode,
313
+ internal::TracedReferenceHandling reference_handling) {
284
314
  return internal::GlobalizeTracedReference(
285
315
  reinterpret_cast<internal::Isolate*>(isolate),
286
316
  internal::ValueHelper::ValueAsAddress(that),
287
- reinterpret_cast<internal::Address*>(slot), store_mode);
317
+ reinterpret_cast<internal::Address*>(slot), store_mode,
318
+ reference_handling);
288
319
  }
289
320
 
290
321
  void TracedReferenceBase::Reset() {
291
- if (IsEmpty()) return;
322
+ if (V8_UNLIKELY(IsEmpty())) {
323
+ return;
324
+ }
292
325
  internal::DisposeTracedReference(slot());
293
326
  SetSlotThreadSafe(nullptr);
294
327
  }
@@ -332,10 +365,28 @@ template <class S>
332
365
  void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
333
366
  static_assert(std::is_base_of<T, S>::value, "type check");
334
367
  this->Reset();
335
- if (other.IsEmpty()) return;
336
- this->SetSlotThreadSafe(
337
- this->New(isolate, *other, &this->slot(),
338
- internal::GlobalHandleStoreMode::kAssigningStore));
368
+ if (V8_UNLIKELY(other.IsEmpty())) {
369
+ return;
370
+ }
371
+ this->SetSlotThreadSafe(this->NewFromNonEmptyValue(
372
+ isolate, *other, &this->slot(),
373
+ internal::TracedReferenceStoreMode::kAssigningStore,
374
+ internal::TracedReferenceHandling::kDefault));
375
+ }
376
+
377
+ template <class T>
378
+ template <class S>
379
+ void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other,
380
+ IsDroppable) {
381
+ static_assert(std::is_base_of<T, S>::value, "type check");
382
+ this->Reset();
383
+ if (V8_UNLIKELY(other.IsEmpty())) {
384
+ return;
385
+ }
386
+ this->SetSlotThreadSafe(this->NewFromNonEmptyValue(
387
+ isolate, *other, &this->slot(),
388
+ internal::TracedReferenceStoreMode::kAssigningStore,
389
+ internal::TracedReferenceHandling::kDroppable));
339
390
  }
340
391
 
341
392
  template <class T>
@@ -376,22 +427,6 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
376
427
  return *this;
377
428
  }
378
429
 
379
- void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
380
- using I = internal::Internals;
381
- if (IsEmpty()) return;
382
- uint8_t* addr =
383
- reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
384
- *reinterpret_cast<uint16_t*>(addr) = class_id;
385
- }
386
-
387
- uint16_t TracedReferenceBase::WrapperClassId() const {
388
- using I = internal::Internals;
389
- if (IsEmpty()) return 0;
390
- uint8_t* addr =
391
- reinterpret_cast<uint8_t*>(slot()) + I::kTracedNodeClassIdOffset;
392
- return *reinterpret_cast<uint16_t*>(addr);
393
- }
394
-
395
430
  } // namespace v8
396
431
 
397
432
  #endif // INCLUDE_V8_TRACED_HANDLE_H_
@@ -5,14 +5,14 @@
5
5
  #ifndef INCLUDE_V8_TYPED_ARRAY_H_
6
6
  #define INCLUDE_V8_TYPED_ARRAY_H_
7
7
 
8
+ #include <limits>
9
+
8
10
  #include "v8-array-buffer.h" // NOLINT(build/include_directory)
9
11
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
10
12
  #include "v8config.h" // NOLINT(build/include_directory)
11
13
 
12
14
  namespace v8 {
13
15
 
14
- class SharedArrayBuffer;
15
-
16
16
  /**
17
17
  * A base class for an instance of TypedArray series of constructors
18
18
  * (ES6 draft 15.13.6).
@@ -20,12 +20,19 @@ class SharedArrayBuffer;
20
20
  class V8_EXPORT TypedArray : public ArrayBufferView {
21
21
  public:
22
22
  /*
23
- * The largest typed array size that can be constructed using New.
23
+ * The largest supported typed array byte size. Each subclass defines a
24
+ * type-specific kMaxLength for the maximum length that can be passed to New.
24
25
  */
25
- static constexpr size_t kMaxLength =
26
- internal::kApiSystemPointerSize == 4
27
- ? internal::kSmiMaxValue
28
- : static_cast<size_t>(uint64_t{1} << 32);
26
+ #if V8_ENABLE_SANDBOX
27
+ static constexpr size_t kMaxByteLength =
28
+ internal::kMaxSafeBufferSizeForSandbox;
29
+ #elif V8_HOST_ARCH_32_BIT
30
+ static constexpr size_t kMaxByteLength = std::numeric_limits<int>::max();
31
+ #else
32
+ // The maximum safe integer (2^53 - 1).
33
+ static constexpr size_t kMaxByteLength =
34
+ static_cast<size_t>((uint64_t{1} << 53) - 1);
35
+ #endif
29
36
 
30
37
  /**
31
38
  * Number of elements in this typed array
@@ -50,6 +57,13 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
50
57
  */
51
58
  class V8_EXPORT Uint8Array : public TypedArray {
52
59
  public:
60
+ /*
61
+ * The largest Uint8Array size that can be constructed using New.
62
+ */
63
+ static constexpr size_t kMaxLength =
64
+ TypedArray::kMaxByteLength / sizeof(uint8_t);
65
+ static_assert(sizeof(uint8_t) == 1);
66
+
53
67
  static Local<Uint8Array> New(Local<ArrayBuffer> array_buffer,
54
68
  size_t byte_offset, size_t length);
55
69
  static Local<Uint8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -71,6 +85,13 @@ class V8_EXPORT Uint8Array : public TypedArray {
71
85
  */
72
86
  class V8_EXPORT Uint8ClampedArray : public TypedArray {
73
87
  public:
88
+ /*
89
+ * The largest Uint8ClampedArray size that can be constructed using New.
90
+ */
91
+ static constexpr size_t kMaxLength =
92
+ TypedArray::kMaxByteLength / sizeof(uint8_t);
93
+ static_assert(sizeof(uint8_t) == 1);
94
+
74
95
  static Local<Uint8ClampedArray> New(Local<ArrayBuffer> array_buffer,
75
96
  size_t byte_offset, size_t length);
76
97
  static Local<Uint8ClampedArray> New(
@@ -93,6 +114,13 @@ class V8_EXPORT Uint8ClampedArray : public TypedArray {
93
114
  */
94
115
  class V8_EXPORT Int8Array : public TypedArray {
95
116
  public:
117
+ /*
118
+ * The largest Int8Array size that can be constructed using New.
119
+ */
120
+ static constexpr size_t kMaxLength =
121
+ TypedArray::kMaxByteLength / sizeof(int8_t);
122
+ static_assert(sizeof(int8_t) == 1);
123
+
96
124
  static Local<Int8Array> New(Local<ArrayBuffer> array_buffer,
97
125
  size_t byte_offset, size_t length);
98
126
  static Local<Int8Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -114,6 +142,13 @@ class V8_EXPORT Int8Array : public TypedArray {
114
142
  */
115
143
  class V8_EXPORT Uint16Array : public TypedArray {
116
144
  public:
145
+ /*
146
+ * The largest Uint16Array size that can be constructed using New.
147
+ */
148
+ static constexpr size_t kMaxLength =
149
+ TypedArray::kMaxByteLength / sizeof(uint16_t);
150
+ static_assert(sizeof(uint16_t) == 2);
151
+
117
152
  static Local<Uint16Array> New(Local<ArrayBuffer> array_buffer,
118
153
  size_t byte_offset, size_t length);
119
154
  static Local<Uint16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -135,6 +170,13 @@ class V8_EXPORT Uint16Array : public TypedArray {
135
170
  */
136
171
  class V8_EXPORT Int16Array : public TypedArray {
137
172
  public:
173
+ /*
174
+ * The largest Int16Array size that can be constructed using New.
175
+ */
176
+ static constexpr size_t kMaxLength =
177
+ TypedArray::kMaxByteLength / sizeof(int16_t);
178
+ static_assert(sizeof(int16_t) == 2);
179
+
138
180
  static Local<Int16Array> New(Local<ArrayBuffer> array_buffer,
139
181
  size_t byte_offset, size_t length);
140
182
  static Local<Int16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -156,6 +198,13 @@ class V8_EXPORT Int16Array : public TypedArray {
156
198
  */
157
199
  class V8_EXPORT Uint32Array : public TypedArray {
158
200
  public:
201
+ /*
202
+ * The largest Uint32Array size that can be constructed using New.
203
+ */
204
+ static constexpr size_t kMaxLength =
205
+ TypedArray::kMaxByteLength / sizeof(uint32_t);
206
+ static_assert(sizeof(uint32_t) == 4);
207
+
159
208
  static Local<Uint32Array> New(Local<ArrayBuffer> array_buffer,
160
209
  size_t byte_offset, size_t length);
161
210
  static Local<Uint32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -177,6 +226,13 @@ class V8_EXPORT Uint32Array : public TypedArray {
177
226
  */
178
227
  class V8_EXPORT Int32Array : public TypedArray {
179
228
  public:
229
+ /*
230
+ * The largest Int32Array size that can be constructed using New.
231
+ */
232
+ static constexpr size_t kMaxLength =
233
+ TypedArray::kMaxByteLength / sizeof(int32_t);
234
+ static_assert(sizeof(int32_t) == 4);
235
+
180
236
  static Local<Int32Array> New(Local<ArrayBuffer> array_buffer,
181
237
  size_t byte_offset, size_t length);
182
238
  static Local<Int32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -193,11 +249,42 @@ class V8_EXPORT Int32Array : public TypedArray {
193
249
  static void CheckCast(Value* obj);
194
250
  };
195
251
 
252
+ /**
253
+ * An instance of Float16Array constructor.
254
+ */
255
+ class V8_EXPORT Float16Array : public TypedArray {
256
+ static constexpr size_t kMaxLength =
257
+ TypedArray::kMaxByteLength / sizeof(uint16_t);
258
+
259
+ public:
260
+ static Local<Float16Array> New(Local<ArrayBuffer> array_buffer,
261
+ size_t byte_offset, size_t length);
262
+ static Local<Float16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
263
+ size_t byte_offset, size_t length);
264
+ V8_INLINE static Float16Array* Cast(Value* value) {
265
+ #ifdef V8_ENABLE_CHECKS
266
+ CheckCast(value);
267
+ #endif
268
+ return static_cast<Float16Array*>(value);
269
+ }
270
+
271
+ private:
272
+ Float16Array();
273
+ static void CheckCast(Value* obj);
274
+ };
275
+
196
276
  /**
197
277
  * An instance of Float32Array constructor (ES6 draft 15.13.6).
198
278
  */
199
279
  class V8_EXPORT Float32Array : public TypedArray {
200
280
  public:
281
+ /*
282
+ * The largest Float32Array size that can be constructed using New.
283
+ */
284
+ static constexpr size_t kMaxLength =
285
+ TypedArray::kMaxByteLength / sizeof(float);
286
+ static_assert(sizeof(float) == 4);
287
+
201
288
  static Local<Float32Array> New(Local<ArrayBuffer> array_buffer,
202
289
  size_t byte_offset, size_t length);
203
290
  static Local<Float32Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -219,6 +306,13 @@ class V8_EXPORT Float32Array : public TypedArray {
219
306
  */
220
307
  class V8_EXPORT Float64Array : public TypedArray {
221
308
  public:
309
+ /*
310
+ * The largest Float64Array size that can be constructed using New.
311
+ */
312
+ static constexpr size_t kMaxLength =
313
+ TypedArray::kMaxByteLength / sizeof(double);
314
+ static_assert(sizeof(double) == 8);
315
+
222
316
  static Local<Float64Array> New(Local<ArrayBuffer> array_buffer,
223
317
  size_t byte_offset, size_t length);
224
318
  static Local<Float64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -240,6 +334,13 @@ class V8_EXPORT Float64Array : public TypedArray {
240
334
  */
241
335
  class V8_EXPORT BigInt64Array : public TypedArray {
242
336
  public:
337
+ /*
338
+ * The largest BigInt64Array size that can be constructed using New.
339
+ */
340
+ static constexpr size_t kMaxLength =
341
+ TypedArray::kMaxByteLength / sizeof(int64_t);
342
+ static_assert(sizeof(int64_t) == 8);
343
+
243
344
  static Local<BigInt64Array> New(Local<ArrayBuffer> array_buffer,
244
345
  size_t byte_offset, size_t length);
245
346
  static Local<BigInt64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -261,6 +362,13 @@ class V8_EXPORT BigInt64Array : public TypedArray {
261
362
  */
262
363
  class V8_EXPORT BigUint64Array : public TypedArray {
263
364
  public:
365
+ /*
366
+ * The largest BigUint64Array size that can be constructed using New.
367
+ */
368
+ static constexpr size_t kMaxLength =
369
+ TypedArray::kMaxByteLength / sizeof(uint64_t);
370
+ static_assert(sizeof(uint64_t) == 8);
371
+
264
372
  static Local<BigUint64Array> New(Local<ArrayBuffer> array_buffer,
265
373
  size_t byte_offset, size_t length);
266
374
  static Local<BigUint64Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -240,8 +240,9 @@ class PersistentValueMapBase {
240
240
  : value_(other.value_) { }
241
241
 
242
242
  Local<V> NewLocal(Isolate* isolate) const {
243
- return Local<V>::New(
244
- isolate, internal::ValueHelper::SlotAsValue<V>(FromVal(value_)));
243
+ return Local<V>::New(isolate,
244
+ internal::ValueHelper::SlotAsValue<V>(
245
+ reinterpret_cast<internal::Address*>(value_)));
245
246
  }
246
247
  bool IsEmpty() const {
247
248
  return value_ == kPersistentContainerNotFound;
@@ -298,7 +299,8 @@ class PersistentValueMapBase {
298
299
  typename Traits::Impl* impl() { return &impl_; }
299
300
 
300
301
  static V* FromVal(PersistentContainerValue v) {
301
- return reinterpret_cast<V*>(v);
302
+ return internal::ValueHelper::SlotAsValue<V>(
303
+ reinterpret_cast<internal::Address*>(v));
302
304
  }
303
305
 
304
306
  static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
@@ -318,7 +320,7 @@ class PersistentValueMapBase {
318
320
  */
319
321
  static Global<V> Release(PersistentContainerValue v) {
320
322
  Global<V> p;
321
- p.slot() = reinterpret_cast<internal::Address*>(FromVal(v));
323
+ p.slot() = reinterpret_cast<internal::Address*>(v);
322
324
  if (Traits::kCallbackType != kNotWeak && p.IsWeak()) {
323
325
  Traits::DisposeCallbackData(
324
326
  p.template ClearWeak<typename Traits::WeakCallbackDataType>());
@@ -328,8 +330,8 @@ class PersistentValueMapBase {
328
330
 
329
331
  void RemoveWeak(const K& key) {
330
332
  Global<V> p;
331
- p.slot() = reinterpret_cast<internal::Address*>(
332
- FromVal(Traits::Remove(&impl_, key)));
333
+ p.slot() =
334
+ reinterpret_cast<internal::Address*>(Traits::Remove(&impl_, key));
333
335
  p.Reset();
334
336
  }
335
337
 
@@ -345,8 +347,7 @@ class PersistentValueMapBase {
345
347
  PersistentContainerValue value) {
346
348
  bool hasValue = value != kPersistentContainerNotFound;
347
349
  if (hasValue) {
348
- returnValue->SetInternal(
349
- *reinterpret_cast<internal::Address*>(FromVal(value)));
350
+ returnValue->SetInternal(*reinterpret_cast<internal::Address*>(value));
350
351
  }
351
352
  return hasValue;
352
353
  }
@@ -620,7 +621,7 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
620
621
  */
621
622
  Local<V> Get(size_t index) const {
622
623
  return Local<V>::New(isolate_, internal::ValueHelper::SlotAsValue<V>(
623
- FromVal(Traits::Get(&impl_, index))));
624
+ Traits::Get(&impl_, index)));
624
625
  }
625
626
 
626
627
  /**
@@ -630,8 +631,7 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
630
631
  size_t length = Traits::Size(&impl_);
631
632
  for (size_t i = 0; i < length; i++) {
632
633
  Global<V> p;
633
- p.slot() =
634
- reinterpret_cast<internal::Address>(FromVal(Traits::Get(&impl_, i)));
634
+ p.slot() = reinterpret_cast<internal::Address>(Traits::Get(&impl_, i));
635
635
  }
636
636
  Traits::Clear(&impl_);
637
637
  }
@@ -652,7 +652,8 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
652
652
  }
653
653
 
654
654
  static V* FromVal(PersistentContainerValue v) {
655
- return reinterpret_cast<V*>(v);
655
+ return internal::ValueHelper::SlotAsValue<V>(
656
+ reinterpret_cast<internal::Address*>(v));
656
657
  }
657
658
 
658
659
  Isolate* isolate_;
@@ -16,7 +16,7 @@
16
16
  */
17
17
  namespace v8 {
18
18
 
19
- class Primiitive;
19
+ class Primitive;
20
20
  class Numeric;
21
21
  class BigInt;
22
22
  class Int32;
@@ -63,7 +63,7 @@ class V8_EXPORT Value : public Data {
63
63
  * conversion to boolean, i.e. the result of `Boolean(value)` in JS, whereas
64
64
  * this checks `value === true`.
65
65
  */
66
- bool IsTrue() const;
66
+ V8_INLINE bool IsTrue() const;
67
67
 
68
68
  /**
69
69
  * Returns true if this value is false.
@@ -72,7 +72,7 @@ class V8_EXPORT Value : public Data {
72
72
  * conversion to boolean, i.e. the result of `!Boolean(value)` in JS, whereas
73
73
  * this checks `value === false`.
74
74
  */
75
- bool IsFalse() const;
75
+ V8_INLINE bool IsFalse() const;
76
76
 
77
77
  /**
78
78
  * Returns true if this value is a symbol or a string.
@@ -301,6 +301,11 @@ class V8_EXPORT Value : public Data {
301
301
  */
302
302
  bool IsInt32Array() const;
303
303
 
304
+ /**
305
+ * Returns true if this value is a Float16Array.
306
+ */
307
+ bool IsFloat16Array() const;
308
+
304
309
  /**
305
310
  * Returns true if this value is a Float32Array.
306
311
  */
@@ -391,7 +396,7 @@ class V8_EXPORT Value : public Data {
391
396
  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString(
392
397
  Local<Context> context) const;
393
398
  /**
394
- * Perform the equivalent of `Object(value)` in JS.
399
+ * Perform the equivalent of `Tagged<Object>(value)` in JS.
395
400
  */
396
401
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
397
402
  Local<Context> context) const;
@@ -461,14 +466,55 @@ class V8_EXPORT Value : public Data {
461
466
  V8_INLINE bool QuickIsUndefined() const;
462
467
  V8_INLINE bool QuickIsNull() const;
463
468
  V8_INLINE bool QuickIsNullOrUndefined() const;
469
+ #if V8_STATIC_ROOTS_BOOL
470
+ V8_INLINE bool QuickIsTrue() const;
471
+ V8_INLINE bool QuickIsFalse() const;
472
+ #endif // V8_STATIC_ROOTS_BOOL
464
473
  V8_INLINE bool QuickIsString() const;
465
474
  bool FullIsUndefined() const;
466
475
  bool FullIsNull() const;
476
+ bool FullIsTrue() const;
477
+ bool FullIsFalse() const;
467
478
  bool FullIsString() const;
468
479
 
469
480
  static void CheckCast(Data* that);
470
481
  };
471
482
 
483
+ /**
484
+ * Can be used to avoid repeated expensive type checks for groups of objects
485
+ * that are expected to be similar (e.g. when Blink converts a bunch of
486
+ * JavaScript objects to "ScriptWrappable" after a "HasInstance" check) by
487
+ * making use of V8-internal "hidden classes". An object that has passed the
488
+ * full check can be remembered via {Update}; further objects can be queried
489
+ * using {Matches}.
490
+ * Note that the answer will be conservative/"best-effort": when {Matches}
491
+ * returns true, then the {candidate} can be relied upon to have the same
492
+ * shape/constructor/prototype/etc. as the {baseline}. Otherwise, no reliable
493
+ * statement can be made (the objects might still have indistinguishable shapes
494
+ * for all intents and purposes, but this mechanism, being optimized for speed,
495
+ * couldn't determine that quickly).
496
+ */
497
+ class V8_EXPORT TypecheckWitness {
498
+ public:
499
+ explicit TypecheckWitness(Isolate* isolate);
500
+
501
+ /**
502
+ * Checks whether {candidate} can cheaply be identified as being "similar"
503
+ * to the {baseline} that was passed to {Update} earlier.
504
+ * It's safe to call this on an uninitialized {TypecheckWitness} instance:
505
+ * it will then return {false} for any input.
506
+ */
507
+ V8_INLINE bool Matches(Local<Value> candidate) const;
508
+
509
+ /**
510
+ * Remembers a new baseline for future {Matches} queries.
511
+ */
512
+ void Update(Local<Value> baseline);
513
+
514
+ private:
515
+ Local<Data> cached_map_;
516
+ };
517
+
472
518
  template <>
473
519
  V8_INLINE Value* Value::Cast(Data* value) {
474
520
  #ifdef V8_ENABLE_CHECKS
@@ -541,6 +587,40 @@ bool Value::QuickIsNullOrUndefined() const {
541
587
  #endif // V8_STATIC_ROOTS_BOOL
542
588
  }
543
589
 
590
+ bool Value::IsTrue() const {
591
+ #if V8_STATIC_ROOTS_BOOL && !defined(V8_ENABLE_CHECKS)
592
+ return QuickIsTrue();
593
+ #else
594
+ return FullIsTrue();
595
+ #endif
596
+ }
597
+
598
+ #if V8_STATIC_ROOTS_BOOL
599
+ bool Value::QuickIsTrue() const {
600
+ using A = internal::Address;
601
+ using I = internal::Internals;
602
+ A obj = internal::ValueHelper::ValueAsAddress(this);
603
+ return I::is_identical(obj, I::StaticReadOnlyRoot::kTrueValue);
604
+ }
605
+ #endif // V8_STATIC_ROOTS_BOOL
606
+
607
+ bool Value::IsFalse() const {
608
+ #if V8_STATIC_ROOTS_BOOL && !defined(V8_ENABLE_CHECKS)
609
+ return QuickIsFalse();
610
+ #else
611
+ return FullIsFalse();
612
+ #endif
613
+ }
614
+
615
+ #if V8_STATIC_ROOTS_BOOL
616
+ bool Value::QuickIsFalse() const {
617
+ using A = internal::Address;
618
+ using I = internal::Internals;
619
+ A obj = internal::ValueHelper::ValueAsAddress(this);
620
+ return I::is_identical(obj, I::StaticReadOnlyRoot::kFalseValue);
621
+ }
622
+ #endif // V8_STATIC_ROOTS_BOOL
623
+
544
624
  bool Value::IsString() const {
545
625
  #ifdef V8_ENABLE_CHECKS
546
626
  return FullIsString();
@@ -562,6 +642,14 @@ bool Value::QuickIsString() const {
562
642
  #endif // V8_STATIC_ROOTS_BOOL
563
643
  }
564
644
 
645
+ bool TypecheckWitness::Matches(Local<Value> candidate) const {
646
+ internal::Address obj = internal::ValueHelper::ValueAsAddress(*candidate);
647
+ internal::Address obj_map = internal::Internals::LoadMap(obj);
648
+ internal::Address cached =
649
+ internal::ValueHelper::ValueAsAddress(*cached_map_);
650
+ return obj_map == cached;
651
+ }
652
+
565
653
  } // namespace v8
566
654
 
567
655
  #endif // INCLUDE_V8_VALUE_H_
@@ -8,10 +8,10 @@
8
8
  // These macros define the version number for the current version.
9
9
  // NOTE these macros are used by some of the tool scripts and the build
10
10
  // system so their names cannot be changed without changing the scripts.
11
- #define V8_MAJOR_VERSION 11
12
- #define V8_MINOR_VERSION 8
13
- #define V8_BUILD_NUMBER 172
14
- #define V8_PATCH_LEVEL 17
11
+ #define V8_MAJOR_VERSION 12
12
+ #define V8_MINOR_VERSION 4
13
+ #define V8_BUILD_NUMBER 254
14
+ #define V8_PATCH_LEVEL 21
15
15
 
16
16
  // Use 1 for candidates and 0 otherwise.
17
17
  // (Boolean macro values are not supported by all preprocessors.)