libv8-node 16.19.0.1-aarch64-linux-musl → 17.9.1.1-aarch64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/aarch64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/allocation.h +11 -5
  5. data/vendor/v8/include/cppgc/cross-thread-persistent.h +78 -26
  6. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +2 -2
  7. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  8. data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
  9. data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
  10. data/vendor/v8/include/cppgc/internal/persistent-node.h +44 -12
  11. data/vendor/v8/include/cppgc/internal/pointer-policies.h +22 -11
  12. data/vendor/v8/include/cppgc/internal/write-barrier.h +9 -1
  13. data/vendor/v8/include/cppgc/persistent.h +1 -1
  14. data/vendor/v8/include/cppgc/prefinalizer.h +1 -1
  15. data/vendor/v8/include/v8-array-buffer.h +433 -0
  16. data/vendor/v8/include/v8-callbacks.h +377 -0
  17. data/vendor/v8/include/v8-container.h +129 -0
  18. data/vendor/v8/include/v8-context.h +418 -0
  19. data/vendor/v8/include/v8-cppgc.h +5 -2
  20. data/vendor/v8/include/v8-data.h +65 -0
  21. data/vendor/v8/include/v8-date.h +43 -0
  22. data/vendor/v8/include/v8-debug.h +151 -0
  23. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  24. data/vendor/v8/include/v8-exception.h +224 -0
  25. data/vendor/v8/include/v8-extension.h +62 -0
  26. data/vendor/v8/include/v8-external.h +37 -0
  27. data/vendor/v8/include/v8-fast-api-calls.h +63 -11
  28. data/vendor/v8/include/v8-forward.h +81 -0
  29. data/vendor/v8/include/v8-function-callback.h +475 -0
  30. data/vendor/v8/include/v8-function.h +122 -0
  31. data/vendor/v8/include/v8-initialization.h +282 -0
  32. data/vendor/v8/include/v8-inspector.h +11 -21
  33. data/vendor/v8/include/v8-internal.h +85 -22
  34. data/vendor/v8/include/v8-isolate.h +1662 -0
  35. data/vendor/v8/include/v8-json.h +47 -0
  36. data/vendor/v8/include/v8-local-handle.h +459 -0
  37. data/vendor/v8/include/v8-locker.h +148 -0
  38. data/vendor/v8/include/v8-maybe.h +137 -0
  39. data/vendor/v8/include/v8-memory-span.h +43 -0
  40. data/vendor/v8/include/v8-message.h +241 -0
  41. data/vendor/v8/include/v8-metrics.h +37 -1
  42. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  43. data/vendor/v8/include/v8-microtask.h +28 -0
  44. data/vendor/v8/include/v8-object.h +770 -0
  45. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  46. data/vendor/v8/include/v8-platform.h +41 -17
  47. data/vendor/v8/include/v8-primitive-object.h +118 -0
  48. data/vendor/v8/include/v8-primitive.h +858 -0
  49. data/vendor/v8/include/v8-profiler.h +10 -11
  50. data/vendor/v8/include/v8-promise.h +174 -0
  51. data/vendor/v8/include/v8-proxy.h +50 -0
  52. data/vendor/v8/include/v8-regexp.h +105 -0
  53. data/vendor/v8/include/v8-script.h +771 -0
  54. data/vendor/v8/include/v8-snapshot.h +198 -0
  55. data/vendor/v8/include/v8-statistics.h +215 -0
  56. data/vendor/v8/include/v8-template.h +1052 -0
  57. data/vendor/v8/include/v8-traced-handle.h +605 -0
  58. data/vendor/v8/include/v8-typed-array.h +282 -0
  59. data/vendor/v8/include/v8-unwinder-state.h +4 -3
  60. data/vendor/v8/include/v8-unwinder.h +129 -0
  61. data/vendor/v8/include/v8-util.h +7 -1
  62. data/vendor/v8/include/v8-value-serializer.h +249 -0
  63. data/vendor/v8/include/v8-value.h +526 -0
  64. data/vendor/v8/include/v8-version.h +3 -3
  65. data/vendor/v8/include/v8-wasm.h +245 -0
  66. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  67. data/vendor/v8/include/v8.h +41 -12604
  68. metadata +43 -1
@@ -0,0 +1,282 @@
1
+ // Copyright 2021 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_V8_INITIALIZATION_H_
6
+ #define INCLUDE_V8_INITIALIZATION_H_
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ #include "v8-internal.h" // NOLINT(build/include_directory)
12
+ #include "v8-isolate.h" // NOLINT(build/include_directory)
13
+ #include "v8-platform.h" // NOLINT(build/include_directory)
14
+ #include "v8config.h" // NOLINT(build/include_directory)
15
+
16
+ // We reserve the V8_* prefix for macros defined in V8 public API and
17
+ // assume there are no name conflicts with the embedder's code.
18
+
19
+ /**
20
+ * The v8 JavaScript engine.
21
+ */
22
+ namespace v8 {
23
+
24
+ class PageAllocator;
25
+ class Platform;
26
+ template <class K, class V, class T>
27
+ class PersistentValueMapBase;
28
+
29
+ /**
30
+ * EntropySource is used as a callback function when v8 needs a source
31
+ * of entropy.
32
+ */
33
+ using EntropySource = bool (*)(unsigned char* buffer, size_t length);
34
+
35
+ /**
36
+ * ReturnAddressLocationResolver is used as a callback function when v8 is
37
+ * resolving the location of a return address on the stack. Profilers that
38
+ * change the return address on the stack can use this to resolve the stack
39
+ * location to wherever the profiler stashed the original return address.
40
+ *
41
+ * \param return_addr_location A location on stack where a machine
42
+ * return address resides.
43
+ * \returns Either return_addr_location, or else a pointer to the profiler's
44
+ * copy of the original return address.
45
+ *
46
+ * \note The resolver function must not cause garbage collection.
47
+ */
48
+ using ReturnAddressLocationResolver =
49
+ uintptr_t (*)(uintptr_t return_addr_location);
50
+
51
+ using DcheckErrorCallback = void (*)(const char* file, int line,
52
+ const char* message);
53
+
54
+ /**
55
+ * Container class for static utility functions.
56
+ */
57
+ class V8_EXPORT V8 {
58
+ public:
59
+ /**
60
+ * Hand startup data to V8, in case the embedder has chosen to build
61
+ * V8 with external startup data.
62
+ *
63
+ * Note:
64
+ * - By default the startup data is linked into the V8 library, in which
65
+ * case this function is not meaningful.
66
+ * - If this needs to be called, it needs to be called before V8
67
+ * tries to make use of its built-ins.
68
+ * - To avoid unnecessary copies of data, V8 will point directly into the
69
+ * given data blob, so pretty please keep it around until V8 exit.
70
+ * - Compression of the startup blob might be useful, but needs to
71
+ * handled entirely on the embedders' side.
72
+ * - The call will abort if the data is invalid.
73
+ */
74
+ static void SetSnapshotDataBlob(StartupData* startup_blob);
75
+
76
+ /** Set the callback to invoke in case of Dcheck failures. */
77
+ static void SetDcheckErrorHandler(DcheckErrorCallback that);
78
+
79
+ /**
80
+ * Sets V8 flags from a string.
81
+ */
82
+ static void SetFlagsFromString(const char* str);
83
+ static void SetFlagsFromString(const char* str, size_t length);
84
+
85
+ /**
86
+ * Sets V8 flags from the command line.
87
+ */
88
+ static void SetFlagsFromCommandLine(int* argc, char** argv,
89
+ bool remove_flags);
90
+
91
+ /** Get the version string. */
92
+ static const char* GetVersion();
93
+
94
+ /**
95
+ * Initializes V8. This function needs to be called before the first Isolate
96
+ * is created. It always returns true.
97
+ */
98
+ V8_INLINE static bool Initialize() {
99
+ const int kBuildConfiguration =
100
+ (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
101
+ (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) |
102
+ (internal::HeapSandboxIsEnabled() ? kHeapSandbox : 0) |
103
+ (internal::VirtualMemoryCageIsEnabled() ? kVirtualMemoryCage : 0);
104
+ return Initialize(kBuildConfiguration);
105
+ }
106
+
107
+ /**
108
+ * Allows the host application to provide a callback which can be used
109
+ * as a source of entropy for random number generators.
110
+ */
111
+ static void SetEntropySource(EntropySource source);
112
+
113
+ /**
114
+ * Allows the host application to provide a callback that allows v8 to
115
+ * cooperate with a profiler that rewrites return addresses on stack.
116
+ */
117
+ static void SetReturnAddressLocationResolver(
118
+ ReturnAddressLocationResolver return_address_resolver);
119
+
120
+ /**
121
+ * Releases any resources used by v8 and stops any utility threads
122
+ * that may be running. Note that disposing v8 is permanent, it
123
+ * cannot be reinitialized.
124
+ *
125
+ * It should generally not be necessary to dispose v8 before exiting
126
+ * a process, this should happen automatically. It is only necessary
127
+ * to use if the process needs the resources taken up by v8.
128
+ */
129
+ static bool Dispose();
130
+
131
+ /**
132
+ * Initialize the ICU library bundled with V8. The embedder should only
133
+ * invoke this method when using the bundled ICU. Returns true on success.
134
+ *
135
+ * If V8 was compiled with the ICU data in an external file, the location
136
+ * of the data file has to be provided.
137
+ */
138
+ static bool InitializeICU(const char* icu_data_file = nullptr);
139
+
140
+ /**
141
+ * Initialize the ICU library bundled with V8. The embedder should only
142
+ * invoke this method when using the bundled ICU. If V8 was compiled with
143
+ * the ICU data in an external file and when the default location of that
144
+ * file should be used, a path to the executable must be provided.
145
+ * Returns true on success.
146
+ *
147
+ * The default is a file called icudtl.dat side-by-side with the executable.
148
+ *
149
+ * Optionally, the location of the data file can be provided to override the
150
+ * default.
151
+ */
152
+ static bool InitializeICUDefaultLocation(const char* exec_path,
153
+ const char* icu_data_file = nullptr);
154
+
155
+ /**
156
+ * Initialize the external startup data. The embedder only needs to
157
+ * invoke this method when external startup data was enabled in a build.
158
+ *
159
+ * If V8 was compiled with the startup data in an external file, then
160
+ * V8 needs to be given those external files during startup. There are
161
+ * three ways to do this:
162
+ * - InitializeExternalStartupData(const char*)
163
+ * This will look in the given directory for the file "snapshot_blob.bin".
164
+ * - InitializeExternalStartupDataFromFile(const char*)
165
+ * As above, but will directly use the given file name.
166
+ * - Call SetSnapshotDataBlob.
167
+ * This will read the blobs from the given data structure and will
168
+ * not perform any file IO.
169
+ */
170
+ static void InitializeExternalStartupData(const char* directory_path);
171
+ static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
172
+
173
+ /**
174
+ * Sets the v8::Platform to use. This should be invoked before V8 is
175
+ * initialized.
176
+ */
177
+ static void InitializePlatform(Platform* platform);
178
+
179
+ /**
180
+ * Clears all references to the v8::Platform. This should be invoked after
181
+ * V8 was disposed.
182
+ */
183
+ static void ShutdownPlatform();
184
+
185
+ #ifdef V8_VIRTUAL_MEMORY_CAGE
186
+ //
187
+ // Virtual Memory Cage related API.
188
+ //
189
+ // This API is not yet stable and subject to changes in the future.
190
+ //
191
+
192
+ /**
193
+ * Initializes the virtual memory cage for V8.
194
+ *
195
+ * This must be invoked after the platform was initialized but before V8 is
196
+ * initialized. The virtual memory cage is torn down during platform shutdown.
197
+ * Returns true on success, false otherwise.
198
+ *
199
+ * TODO(saelo) Once it is no longer optional to create the virtual memory
200
+ * cage when compiling with V8_VIRTUAL_MEMORY_CAGE, the cage initialization
201
+ * will likely happen as part of V8::Initialize, at which point this function
202
+ * should be removed.
203
+ */
204
+ static bool InitializeVirtualMemoryCage();
205
+
206
+ /**
207
+ * Provides access to the virtual memory cage page allocator.
208
+ *
209
+ * This allocator allocates pages inside the virtual memory cage. It can for
210
+ * example be used to obtain virtual memory for ArrayBuffer backing stores,
211
+ * which must be located inside the cage.
212
+ *
213
+ * It should be assumed that an attacker can corrupt data inside the cage,
214
+ * and so in particular the contents of pages returned by this allocator,
215
+ * arbitrarily and concurrently. Due to this, it is recommended to to only
216
+ * place pure data buffers in pages obtained through this allocator.
217
+ *
218
+ * This function must only be called after initializing the virtual memory
219
+ * cage and V8.
220
+ */
221
+ static PageAllocator* GetVirtualMemoryCagePageAllocator();
222
+
223
+ /**
224
+ * Returns the size of the virtual memory cage in bytes.
225
+ *
226
+ * If the cage has not been initialized, or if the initialization failed,
227
+ * this returns zero.
228
+ */
229
+ static size_t GetVirtualMemoryCageSizeInBytes();
230
+ #endif
231
+
232
+ /**
233
+ * Activate trap-based bounds checking for WebAssembly.
234
+ *
235
+ * \param use_v8_signal_handler Whether V8 should install its own signal
236
+ * handler or rely on the embedder's.
237
+ */
238
+ static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
239
+
240
+ #if defined(V8_OS_WIN)
241
+ /**
242
+ * On Win64, by default V8 does not emit unwinding data for jitted code,
243
+ * which means the OS cannot walk the stack frames and the system Structured
244
+ * Exception Handling (SEH) cannot unwind through V8-generated code:
245
+ * https://code.google.com/p/v8/issues/detail?id=3598.
246
+ *
247
+ * This function allows embedders to register a custom exception handler for
248
+ * exceptions in V8-generated code.
249
+ */
250
+ static void SetUnhandledExceptionCallback(
251
+ UnhandledExceptionCallback unhandled_exception_callback);
252
+ #endif
253
+
254
+ /**
255
+ * Get statistics about the shared memory usage.
256
+ */
257
+ static void GetSharedMemoryStatistics(SharedMemoryStatistics* statistics);
258
+
259
+ private:
260
+ V8();
261
+
262
+ enum BuildConfigurationFeatures {
263
+ kPointerCompression = 1 << 0,
264
+ k31BitSmis = 1 << 1,
265
+ kHeapSandbox = 1 << 2,
266
+ kVirtualMemoryCage = 1 << 3,
267
+ };
268
+
269
+ /**
270
+ * Checks that the embedder build configuration is compatible with
271
+ * the V8 binary and if so initializes V8.
272
+ */
273
+ static bool Initialize(int build_config);
274
+
275
+ friend class Context;
276
+ template <class K, class V, class T>
277
+ friend class PersistentValueMapBase;
278
+ };
279
+
280
+ } // namespace v8
281
+
282
+ #endif // INCLUDE_V8_INITIALIZATION_H_
@@ -6,12 +6,20 @@
6
6
  #define V8_V8_INSPECTOR_H_
7
7
 
8
8
  #include <stdint.h>
9
- #include <cctype>
10
9
 
10
+ #include <cctype>
11
11
  #include <memory>
12
- #include <unordered_map>
13
12
 
14
- #include "v8.h" // NOLINT(build/include_directory)
13
+ #include "v8-isolate.h" // NOLINT(build/include_directory)
14
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
15
+
16
+ namespace v8 {
17
+ class Context;
18
+ class Name;
19
+ class Object;
20
+ class StackTrace;
21
+ class Value;
22
+ } // namespace v8
15
23
 
16
24
  namespace v8_inspector {
17
25
 
@@ -320,24 +328,6 @@ class V8_EXPORT V8Inspector {
320
328
  virtual std::unique_ptr<V8StackTrace> createStackTrace(
321
329
  v8::Local<v8::StackTrace>) = 0;
322
330
  virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0;
323
-
324
- // Performance counters.
325
- class V8_EXPORT Counters : public std::enable_shared_from_this<Counters> {
326
- public:
327
- explicit Counters(v8::Isolate* isolate);
328
- ~Counters();
329
- const std::unordered_map<std::string, int>& getCountersMap() const {
330
- return m_countersMap;
331
- }
332
-
333
- private:
334
- static int* getCounterPtr(const char* name);
335
-
336
- v8::Isolate* m_isolate;
337
- std::unordered_map<std::string, int> m_countersMap;
338
- };
339
-
340
- virtual std::shared_ptr<Counters> enableCounters() = 0;
341
331
  };
342
332
 
343
333
  } // namespace v8_inspector
@@ -36,6 +36,7 @@ const int kApiSystemPointerSize = sizeof(void*);
36
36
  const int kApiDoubleSize = sizeof(double);
37
37
  const int kApiInt32Size = sizeof(int32_t);
38
38
  const int kApiInt64Size = sizeof(int64_t);
39
+ const int kApiSizetSize = sizeof(size_t);
39
40
 
40
41
  // Tag information for HeapObject.
41
42
  const int kHeapObjectTag = 1;
@@ -140,15 +141,12 @@ using ExternalPointer_t = Address;
140
141
  // the same time.
141
142
  enum ExternalPointerTag : uint64_t {
142
143
  kExternalPointerNullTag = 0x0000000000000000,
143
- kArrayBufferBackingStoreTag = 0x00ff000000000000, // 0b000000011111111
144
- kTypedArrayExternalPointerTag = 0x017f000000000000, // 0b000000101111111
145
- kDataViewDataPointerTag = 0x01bf000000000000, // 0b000000110111111
146
- kExternalStringResourceTag = 0x01df000000000000, // 0b000000111011111
147
- kExternalStringResourceDataTag = 0x01ef000000000000, // 0b000000111101111
148
- kForeignForeignAddressTag = 0x01f7000000000000, // 0b000000111110111
149
- kNativeContextMicrotaskQueueTag = 0x01fb000000000000, // 0b000000111111011
150
- kEmbedderDataSlotPayloadTag = 0x01fd000000000000, // 0b000000111111101
151
- kCodeEntryPointTag = 0x01fe000000000000, // 0b000000111111110
144
+ kExternalStringResourceTag = 0x00ff000000000000, // 0b000000011111111
145
+ kExternalStringResourceDataTag = 0x017f000000000000, // 0b000000101111111
146
+ kForeignForeignAddressTag = 0x01bf000000000000, // 0b000000110111111
147
+ kNativeContextMicrotaskQueueTag = 0x01df000000000000, // 0b000000111011111
148
+ kEmbedderDataSlotPayloadTag = 0x01ef000000000000, // 0b000000111101111
149
+ kCodeEntryPointTag = 0x01f7000000000000, // 0b000000111110111
152
150
  };
153
151
 
154
152
  constexpr uint64_t kExternalPointerTagMask = 0xffff000000000000;
@@ -187,6 +185,8 @@ V8_EXPORT internal::Isolate* IsolateFromNeverReadOnlySpaceObject(Address obj);
187
185
  // language mode is strict.
188
186
  V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate);
189
187
 
188
+ V8_EXPORT bool CanHaveInternalField(int instance_type);
189
+
190
190
  /**
191
191
  * This class exports constants and functionality from within v8 that
192
192
  * is necessary to implement inline functions in the v8 api. Don't
@@ -224,19 +224,30 @@ class Internals {
224
224
  static const int kExternalOneByteRepresentationTag = 0x0a;
225
225
 
226
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;
227
230
 
228
231
  // IsolateData layout guarantees.
229
- 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;
230
241
  static const int kIsolateFastCCallCallerFpOffset =
231
- kNumIsolateDataSlots * kApiSystemPointerSize;
242
+ kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize;
232
243
  static const int kIsolateFastCCallCallerPcOffset =
233
244
  kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize;
234
245
  static const int kIsolateFastApiCallTargetOffset =
235
246
  kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize;
236
- static const int kIsolateStackGuardOffset =
247
+ static const int kIsolateLongTaskStatsCounterOffset =
237
248
  kIsolateFastApiCallTargetOffset + kApiSystemPointerSize;
238
249
  static const int kIsolateRootsOffset =
239
- kIsolateStackGuardOffset + 7 * kApiSystemPointerSize;
250
+ kIsolateLongTaskStatsCounterOffset + kApiSizetSize;
240
251
 
241
252
  static const int kExternalPointerTableBufferOffset = 0;
242
253
  static const int kExternalPointerTableLengthOffset =
@@ -261,8 +272,9 @@ class Internals {
261
272
  static const int kOddballType = 0x43;
262
273
  static const int kForeignType = 0x46;
263
274
  static const int kJSSpecialApiObjectType = 0x410;
264
- static const int kJSApiObjectType = 0x420;
265
275
  static const int kJSObjectType = 0x421;
276
+ static const int kFirstJSApiObjectType = 0x422;
277
+ static const int kLastJSApiObjectType = 0x80A;
266
278
 
267
279
  static const int kUndefinedOddballKind = 5;
268
280
  static const int kNullOddballKind = 3;
@@ -367,6 +379,12 @@ class Internals {
367
379
  return *reinterpret_cast<void* const*>(addr);
368
380
  }
369
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
+
370
388
  V8_INLINE static internal::Address* GetRoot(v8::Isolate* isolate, int index) {
371
389
  internal::Address addr = reinterpret_cast<internal::Address>(isolate) +
372
390
  kIsolateRootsOffset +
@@ -468,6 +486,59 @@ class Internals {
468
486
  #endif // V8_COMPRESS_POINTERS
469
487
  };
470
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
+
471
542
  // Only perform cast check for types derived from v8::Data since
472
543
  // other types do not implement the Cast method.
473
544
  template <bool PerformCheck>
@@ -498,14 +569,6 @@ class BackingStoreBase {};
498
569
 
499
570
  } // namespace internal
500
571
 
501
- V8_EXPORT bool CopyAndConvertArrayToCppBufferInt32(Local<Array> src,
502
- int32_t* dst,
503
- uint32_t max_length);
504
-
505
- V8_EXPORT bool CopyAndConvertArrayToCppBufferFloat64(Local<Array> src,
506
- double* dst,
507
- uint32_t max_length);
508
-
509
572
  } // namespace v8
510
573
 
511
574
  #endif // INCLUDE_V8_INTERNAL_H_