libv8-node 15.14.0.1-x86_64-linux → 17.9.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/include/cppgc/allocation.h +110 -44
  6. data/vendor/v8/include/cppgc/common.h +9 -6
  7. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  8. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  9. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  10. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  11. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  12. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  13. data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
  14. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  15. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  16. data/vendor/v8/include/cppgc/heap.h +68 -6
  17. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  18. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +4 -3
  19. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  20. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  21. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  22. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  23. data/vendor/v8/include/cppgc/internal/persistent-node.h +94 -6
  24. data/vendor/v8/include/cppgc/internal/pointer-policies.h +81 -29
  25. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  26. data/vendor/v8/include/cppgc/internal/write-barrier.h +398 -35
  27. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  28. data/vendor/v8/include/cppgc/macros.h +2 -0
  29. data/vendor/v8/include/cppgc/member.h +87 -25
  30. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  31. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  32. data/vendor/v8/include/cppgc/persistent.h +41 -11
  33. data/vendor/v8/include/cppgc/platform.h +49 -25
  34. data/vendor/v8/include/cppgc/prefinalizer.h +2 -2
  35. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  36. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  37. data/vendor/v8/include/cppgc/source-location.h +2 -1
  38. data/vendor/v8/include/cppgc/testing.h +99 -0
  39. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  40. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  41. data/vendor/v8/include/cppgc/visitor.h +194 -28
  42. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  43. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  44. data/vendor/v8/include/v8-array-buffer.h +433 -0
  45. data/vendor/v8/include/v8-callbacks.h +377 -0
  46. data/vendor/v8/include/v8-container.h +129 -0
  47. data/vendor/v8/include/v8-context.h +418 -0
  48. data/vendor/v8/include/v8-cppgc.h +261 -159
  49. data/vendor/v8/include/v8-data.h +65 -0
  50. data/vendor/v8/include/v8-date.h +43 -0
  51. data/vendor/v8/include/v8-debug.h +151 -0
  52. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  53. data/vendor/v8/include/v8-exception.h +224 -0
  54. data/vendor/v8/include/v8-extension.h +62 -0
  55. data/vendor/v8/include/v8-external.h +37 -0
  56. data/vendor/v8/include/v8-fast-api-calls.h +652 -152
  57. data/vendor/v8/include/v8-forward.h +81 -0
  58. data/vendor/v8/include/v8-function-callback.h +475 -0
  59. data/vendor/v8/include/v8-function.h +122 -0
  60. data/vendor/v8/include/v8-initialization.h +282 -0
  61. data/vendor/v8/include/v8-inspector.h +33 -25
  62. data/vendor/v8/include/v8-internal.h +178 -31
  63. data/vendor/v8/include/v8-isolate.h +1662 -0
  64. data/vendor/v8/include/v8-json.h +47 -0
  65. data/vendor/v8/include/v8-local-handle.h +459 -0
  66. data/vendor/v8/include/v8-locker.h +148 -0
  67. data/vendor/v8/include/v8-maybe.h +137 -0
  68. data/vendor/v8/include/v8-memory-span.h +43 -0
  69. data/vendor/v8/include/v8-message.h +241 -0
  70. data/vendor/v8/include/v8-metrics.h +114 -9
  71. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  72. data/vendor/v8/include/v8-microtask.h +28 -0
  73. data/vendor/v8/include/v8-object.h +770 -0
  74. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  75. data/vendor/v8/include/v8-platform.h +74 -25
  76. data/vendor/v8/include/v8-primitive-object.h +118 -0
  77. data/vendor/v8/include/v8-primitive.h +858 -0
  78. data/vendor/v8/include/v8-profiler.h +72 -9
  79. data/vendor/v8/include/v8-promise.h +174 -0
  80. data/vendor/v8/include/v8-proxy.h +50 -0
  81. data/vendor/v8/include/v8-regexp.h +105 -0
  82. data/vendor/v8/include/v8-script.h +771 -0
  83. data/vendor/v8/include/v8-snapshot.h +198 -0
  84. data/vendor/v8/include/v8-statistics.h +215 -0
  85. data/vendor/v8/include/v8-template.h +1052 -0
  86. data/vendor/v8/include/v8-traced-handle.h +605 -0
  87. data/vendor/v8/include/v8-typed-array.h +282 -0
  88. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  89. data/vendor/v8/include/v8-unwinder.h +129 -0
  90. data/vendor/v8/include/v8-util.h +8 -2
  91. data/vendor/v8/include/v8-value-serializer.h +249 -0
  92. data/vendor/v8/include/v8-value.h +526 -0
  93. data/vendor/v8/include/v8-version.h +3 -3
  94. data/vendor/v8/include/v8-wasm.h +245 -0
  95. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  96. data/vendor/v8/include/v8.h +41 -12050
  97. data/vendor/v8/include/v8config.h +87 -11
  98. data/vendor/v8/{out.gn → x86_64-linux}/libv8/obj/libv8_monolith.a +0 -0
  99. metadata +60 -6
  100. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -15,9 +15,12 @@
15
15
 
16
16
  namespace v8 {
17
17
 
18
+ class Array;
18
19
  class Context;
19
20
  class Data;
20
21
  class Isolate;
22
+ template <typename T>
23
+ class Local;
21
24
 
22
25
  namespace internal {
23
26
 
@@ -33,6 +36,7 @@ const int kApiSystemPointerSize = sizeof(void*);
33
36
  const int kApiDoubleSize = sizeof(double);
34
37
  const int kApiInt32Size = sizeof(int32_t);
35
38
  const int kApiInt64Size = sizeof(int64_t);
39
+ const int kApiSizetSize = sizeof(size_t);
36
40
 
37
41
  // Tag information for HeapObject.
38
42
  const int kHeapObjectTag = 1;
@@ -40,6 +44,13 @@ const int kWeakHeapObjectTag = 3;
40
44
  const int kHeapObjectTagSize = 2;
41
45
  const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
42
46
 
47
+ // Tag information for fowarding pointers stored in object headers.
48
+ // 0b00 at the lowest 2 bits in the header indicates that the map word is a
49
+ // forwarding pointer.
50
+ const int kForwardingTag = 0;
51
+ const int kForwardingTagSize = 2;
52
+ const intptr_t kForwardingTagMask = (1 << kForwardingTagSize) - 1;
53
+
43
54
  // Tag information for Smi.
44
55
  const int kSmiTag = 0;
45
56
  const int kSmiTagSize = 1;
@@ -120,6 +131,26 @@ constexpr bool HeapSandboxIsEnabled() {
120
131
 
121
132
  using ExternalPointer_t = Address;
122
133
 
134
+ // If the heap sandbox is enabled, these tag values will be ORed with the
135
+ // external pointers in the external pointer table to prevent use of pointers of
136
+ // the wrong type. When a pointer is loaded, it is ANDed with the inverse of the
137
+ // expected type's tag. The tags are constructed in a way that guarantees that a
138
+ // failed type check will result in one or more of the top bits of the pointer
139
+ // to be set, rendering the pointer inacessible. This construction allows
140
+ // performing the type check and removing GC marking bits from the pointer at
141
+ // the same time.
142
+ enum ExternalPointerTag : uint64_t {
143
+ kExternalPointerNullTag = 0x0000000000000000,
144
+ kExternalStringResourceTag = 0x00ff000000000000, // 0b000000011111111
145
+ kExternalStringResourceDataTag = 0x017f000000000000, // 0b000000101111111
146
+ kForeignForeignAddressTag = 0x01bf000000000000, // 0b000000110111111
147
+ kNativeContextMicrotaskQueueTag = 0x01df000000000000, // 0b000000111011111
148
+ kEmbedderDataSlotPayloadTag = 0x01ef000000000000, // 0b000000111101111
149
+ kCodeEntryPointTag = 0x01f7000000000000, // 0b000000111110111
150
+ };
151
+
152
+ constexpr uint64_t kExternalPointerTagMask = 0xffff000000000000;
153
+
123
154
  #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
124
155
  using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
125
156
  #else
@@ -140,6 +171,11 @@ V8_INLINE static constexpr internal::Address IntToSmi(int value) {
140
171
  kSmiTag;
141
172
  }
142
173
 
174
+ // Converts encoded external pointer to address.
175
+ V8_EXPORT Address DecodeExternalPointerImpl(const Isolate* isolate,
176
+ ExternalPointer_t pointer,
177
+ ExternalPointerTag tag);
178
+
143
179
  // {obj} must be the raw tagged pointer representation of a HeapObject
144
180
  // that's guaranteed to never be in ReadOnlySpace.
145
181
  V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj);
@@ -149,12 +185,22 @@ V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj);
149
185
  // language mode is strict.
150
186
  V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate);
151
187
 
188
+ V8_EXPORT bool CanHaveInternalField(int instance_type);
189
+
152
190
  /**
153
191
  * This class exports constants and functionality from within v8 that
154
192
  * is necessary to implement inline functions in the v8 api. Don't
155
193
  * depend on functions and constants defined here.
156
194
  */
157
195
  class Internals {
196
+ #ifdef V8_MAP_PACKING
197
+ V8_INLINE static constexpr internal::Address UnpackMapWord(
198
+ internal::Address mapword) {
199
+ // TODO(wenyuzhao): Clear header metadata.
200
+ return mapword ^ kMapWordXorMask;
201
+ }
202
+ #endif
203
+
158
204
  public:
159
205
  // These values match non-compiler-dependent values defined within
160
206
  // the implementation of v8.
@@ -168,6 +214,9 @@ class Internals {
168
214
  static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize;
169
215
  static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize;
170
216
  static const int kEmbedderDataSlotSize = kApiSystemPointerSize;
217
+ #ifdef V8_HEAP_SANDBOX
218
+ static const int kEmbedderDataSlotRawPayloadOffset = kApiTaggedSize;
219
+ #endif
171
220
  static const int kNativeContextEmbedderDataOffset = 6 * kApiTaggedSize;
172
221
  static const int kFullStringRepresentationMask = 0x0f;
173
222
  static const int kStringEncodingMask = 0x8;
@@ -175,17 +224,36 @@ class Internals {
175
224
  static const int kExternalOneByteRepresentationTag = 0x0a;
176
225
 
177
226
  static const uint32_t kNumIsolateDataSlots = 4;
227
+ static const int kStackGuardSize = 7 * kApiSystemPointerSize;
228
+ static const int kBuiltinTier0EntryTableSize = 13 * kApiSystemPointerSize;
229
+ static const int kBuiltinTier0TableSize = 13 * kApiSystemPointerSize;
178
230
 
179
231
  // IsolateData layout guarantees.
180
- static const int kIsolateEmbedderDataOffset = 0;
232
+ static const int kIsolateCageBaseOffset = 0;
233
+ static const int kIsolateStackGuardOffset =
234
+ kIsolateCageBaseOffset + kApiSystemPointerSize;
235
+ static const int kBuiltinTier0EntryTableOffset =
236
+ kIsolateStackGuardOffset + kStackGuardSize;
237
+ static const int kBuiltinTier0TableOffset =
238
+ kBuiltinTier0EntryTableOffset + kBuiltinTier0EntryTableSize;
239
+ static const int kIsolateEmbedderDataOffset =
240
+ kBuiltinTier0TableOffset + kBuiltinTier0TableSize;
181
241
  static const int kIsolateFastCCallCallerFpOffset =
182
- kNumIsolateDataSlots * kApiSystemPointerSize;
242
+ kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize;
183
243
  static const int kIsolateFastCCallCallerPcOffset =
184
244
  kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize;
185
- static const int kIsolateStackGuardOffset =
245
+ static const int kIsolateFastApiCallTargetOffset =
186
246
  kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize;
247
+ static const int kIsolateLongTaskStatsCounterOffset =
248
+ kIsolateFastApiCallTargetOffset + kApiSystemPointerSize;
187
249
  static const int kIsolateRootsOffset =
188
- kIsolateStackGuardOffset + 7 * kApiSystemPointerSize;
250
+ kIsolateLongTaskStatsCounterOffset + kApiSizetSize;
251
+
252
+ static const int kExternalPointerTableBufferOffset = 0;
253
+ static const int kExternalPointerTableLengthOffset =
254
+ kExternalPointerTableBufferOffset + kApiSystemPointerSize;
255
+ static const int kExternalPointerTableCapacityOffset =
256
+ kExternalPointerTableLengthOffset + kApiInt32Size;
189
257
 
190
258
  static const int kUndefinedValueRootIndex = 4;
191
259
  static const int kTheHoleValueRootIndex = 5;
@@ -204,8 +272,9 @@ class Internals {
204
272
  static const int kOddballType = 0x43;
205
273
  static const int kForeignType = 0x46;
206
274
  static const int kJSSpecialApiObjectType = 0x410;
207
- static const int kJSApiObjectType = 0x420;
208
275
  static const int kJSObjectType = 0x421;
276
+ static const int kFirstJSApiObjectType = 0x422;
277
+ static const int kLastJSApiObjectType = 0x80A;
209
278
 
210
279
  static const int kUndefinedOddballKind = 5;
211
280
  static const int kNullOddballKind = 3;
@@ -220,6 +289,17 @@ class Internals {
220
289
  // incremental GC once the external memory reaches this limit.
221
290
  static constexpr int kExternalAllocationSoftLimit = 64 * 1024 * 1024;
222
291
 
292
+ #ifdef V8_MAP_PACKING
293
+ static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
294
+ // The lowest two bits of mapwords are always `0b10`
295
+ static const uintptr_t kMapWordSignature = 0b10;
296
+ // XORing a (non-compressed) map with this mask ensures that the two
297
+ // low-order bits are 0b10. The 0 at the end makes this look like a Smi,
298
+ // although real Smis have all lower 32 bits unset. We only rely on these
299
+ // values passing as Smis in very few places.
300
+ static const int kMapWordXorMask = 0b11;
301
+ #endif
302
+
223
303
  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
224
304
  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
225
305
  #ifdef V8_ENABLE_CHECKS
@@ -246,6 +326,9 @@ class Internals {
246
326
  V8_INLINE static int GetInstanceType(const internal::Address obj) {
247
327
  typedef internal::Address A;
248
328
  A map = ReadTaggedPointerField(obj, kHeapObjectMapOffset);
329
+ #ifdef V8_MAP_PACKING
330
+ map = UnpackMapWord(map);
331
+ #endif
249
332
  return ReadRawField<uint16_t>(map, kMapInstanceTypeOffset);
250
333
  }
251
334
 
@@ -296,6 +379,12 @@ class Internals {
296
379
  return *reinterpret_cast<void* const*>(addr);
297
380
  }
298
381
 
382
+ V8_INLINE static void IncrementLongTasksStatsCounter(v8::Isolate* isolate) {
383
+ internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
384
+ kIsolateLongTaskStatsCounterOffset;
385
+ ++(*reinterpret_cast<size_t*>(addr));
386
+ }
387
+
299
388
  V8_INLINE static internal::Address* GetRoot(v8::Isolate* isolate, int index) {
300
389
  internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
301
390
  kIsolateRootsOffset +
@@ -325,8 +414,9 @@ class Internals {
325
414
  internal::Address heap_object_ptr, int offset) {
326
415
  #ifdef V8_COMPRESS_POINTERS
327
416
  uint32_t value = ReadRawField<uint32_t>(heap_object_ptr, offset);
328
- internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
329
- return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
417
+ internal::Address base =
418
+ GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
419
+ return base + static_cast<internal::Address>(static_cast<uintptr_t>(value));
330
420
  #else
331
421
  return ReadRawField<internal::Address>(heap_object_ptr, offset);
332
422
  #endif
@@ -352,48 +442,103 @@ class Internals {
352
442
  #endif
353
443
  }
354
444
 
445
+ V8_INLINE static Address DecodeExternalPointer(
446
+ const Isolate* isolate, ExternalPointer_t encoded_pointer,
447
+ ExternalPointerTag tag) {
448
+ #ifdef V8_HEAP_SANDBOX
449
+ return internal::DecodeExternalPointerImpl(isolate, encoded_pointer, tag);
450
+ #else
451
+ return encoded_pointer;
452
+ #endif
453
+ }
454
+
355
455
  V8_INLINE static internal::Address ReadExternalPointerField(
356
- internal::Isolate* isolate, internal::Address heap_object_ptr,
357
- int offset) {
358
- internal::Address value = ReadRawField<Address>(heap_object_ptr, offset);
456
+ internal::Isolate* isolate, internal::Address heap_object_ptr, int offset,
457
+ ExternalPointerTag tag) {
359
458
  #ifdef V8_HEAP_SANDBOX
459
+ internal::ExternalPointer_t encoded_value =
460
+ ReadRawField<uint32_t>(heap_object_ptr, offset);
360
461
  // We currently have to treat zero as nullptr in embedder slots.
361
- if (value) value = DecodeExternalPointer(isolate, value);
462
+ return encoded_value ? DecodeExternalPointer(isolate, encoded_value, tag)
463
+ : 0;
464
+ #else
465
+ return ReadRawField<Address>(heap_object_ptr, offset);
362
466
  #endif
363
- return value;
364
467
  }
365
468
 
366
469
  #ifdef V8_COMPRESS_POINTERS
367
470
  // See v8:7703 or src/ptr-compr.* for details about pointer compression.
368
- static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32;
369
- static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32;
370
-
371
- // See v8:10391 for details about V8 heap sandbox.
372
- static constexpr uint32_t kExternalPointerSalt =
373
- 0x7fffffff & ~static_cast<uint32_t>(kHeapObjectTagMask);
471
+ static constexpr size_t kPtrComprCageReservationSize = size_t{1} << 32;
472
+ static constexpr size_t kPtrComprCageBaseAlignment = size_t{1} << 32;
374
473
 
375
- V8_INLINE static internal::Address GetRootFromOnHeapAddress(
474
+ V8_INLINE static internal::Address GetPtrComprCageBaseFromOnHeapAddress(
376
475
  internal::Address addr) {
377
- return addr & -static_cast<intptr_t>(kPtrComprIsolateRootAlignment);
476
+ return addr & -static_cast<intptr_t>(kPtrComprCageBaseAlignment);
378
477
  }
379
478
 
380
479
  V8_INLINE static internal::Address DecompressTaggedAnyField(
381
480
  internal::Address heap_object_ptr, uint32_t value) {
382
- internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
383
- return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
481
+ internal::Address base =
482
+ GetPtrComprCageBaseFromOnHeapAddress(heap_object_ptr);
483
+ return base + static_cast<internal::Address>(static_cast<uintptr_t>(value));
384
484
  }
385
485
 
386
- V8_INLINE static Address DecodeExternalPointer(
387
- const Isolate* isolate, ExternalPointer_t encoded_pointer) {
388
- #ifndef V8_HEAP_SANDBOX
389
- return encoded_pointer;
390
- #else
391
- return encoded_pointer ^ kExternalPointerSalt;
392
- #endif
393
- }
394
486
  #endif // V8_COMPRESS_POINTERS
395
487
  };
396
488
 
489
+ constexpr bool VirtualMemoryCageIsEnabled() {
490
+ #ifdef V8_VIRTUAL_MEMORY_CAGE
491
+ return true;
492
+ #else
493
+ return false;
494
+ #endif
495
+ }
496
+
497
+ #ifdef V8_VIRTUAL_MEMORY_CAGE
498
+ // Size of the virtual memory cage, excluding the guard regions surrounding it.
499
+ constexpr size_t kVirtualMemoryCageSize = size_t{1} << 40; // 1 TB
500
+
501
+ static_assert(kVirtualMemoryCageSize > Internals::kPtrComprCageReservationSize,
502
+ "The virtual memory cage must be larger than the pointer "
503
+ "compression cage contained within it.");
504
+
505
+ // Required alignment of the virtual memory cage. For simplicity, we require the
506
+ // size of the guard regions to be a multiple of this, so that this specifies
507
+ // the alignment of the cage including and excluding surrounding guard regions.
508
+ // The alignment requirement is due to the pointer compression cage being
509
+ // located at the start of the virtual memory cage.
510
+ constexpr size_t kVirtualMemoryCageAlignment =
511
+ Internals::kPtrComprCageBaseAlignment;
512
+
513
+ // Size of the guard regions surrounding the virtual memory cage. This assumes a
514
+ // worst-case scenario of a 32-bit unsigned index being used to access an array
515
+ // of 64-bit values.
516
+ constexpr size_t kVirtualMemoryCageGuardRegionSize = size_t{32} << 30; // 32 GB
517
+
518
+ static_assert((kVirtualMemoryCageGuardRegionSize %
519
+ kVirtualMemoryCageAlignment) == 0,
520
+ "The size of the virtual memory cage guard region must be a "
521
+ "multiple of its required alignment.");
522
+
523
+ // Minimum size of the virtual memory cage, excluding the guard regions
524
+ // surrounding it. If the cage reservation fails, its size is currently halved
525
+ // until either the reservation succeeds or the minimum size is reached. A
526
+ // minimum of 32GB allows the 4GB pointer compression region as well as the
527
+ // ArrayBuffer partition and two 10GB WASM memory cages to fit into the cage.
528
+ constexpr size_t kVirtualMemoryCageMinimumSize = size_t{32} << 30; // 32 GB
529
+
530
+ // For now, even if the virtual memory cage is enabled, we still allow backing
531
+ // stores to be allocated outside of it as fallback. This will simplify the
532
+ // initial rollout. However, if the heap sandbox is also enabled, we already use
533
+ // the "enforcing mode" of the virtual memory cage. This is useful for testing.
534
+ #ifdef V8_HEAP_SANDBOX
535
+ constexpr bool kAllowBackingStoresOutsideCage = false;
536
+ #else
537
+ constexpr bool kAllowBackingStoresOutsideCage = true;
538
+ #endif // V8_HEAP_SANDBOX
539
+
540
+ #endif // V8_VIRTUAL_MEMORY_CAGE
541
+
397
542
  // Only perform cast check for types derived from v8::Data since
398
543
  // other types do not implement the Cast method.
399
544
  template <bool PerformCheck>
@@ -414,7 +559,8 @@ void CastCheck<false>::Perform(T* data) {}
414
559
 
415
560
  template <class T>
416
561
  V8_INLINE void PerformCastCheck(T* data) {
417
- CastCheck<std::is_base_of<Data, T>::value>::Perform(data);
562
+ CastCheck<std::is_base_of<Data, T>::value &&
563
+ !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
418
564
  }
419
565
 
420
566
  // A base class for backing stores, which is needed due to vagaries of
@@ -422,6 +568,7 @@ V8_INLINE void PerformCastCheck(T* data) {
422
568
  class BackingStoreBase {};
423
569
 
424
570
  } // namespace internal
571
+
425
572
  } // namespace v8
426
573
 
427
574
  #endif // INCLUDE_V8_INTERNAL_H_