libv8-node 23.6.1.0-arm64-darwin → 24.1.0.0-arm64-darwin

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/allocation.h +1 -2
  5. data/vendor/v8/include/cppgc/default-platform.h +3 -2
  6. data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
  7. data/vendor/v8/include/cppgc/internal/api-constants.h +0 -17
  8. data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
  9. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
  10. data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
  11. data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
  12. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  13. data/vendor/v8/include/cppgc/internal/member-storage.h +63 -20
  14. data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
  15. data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
  16. data/vendor/v8/include/cppgc/macros.h +21 -0
  17. data/vendor/v8/include/cppgc/member.h +70 -36
  18. data/vendor/v8/include/cppgc/name-provider.h +3 -0
  19. data/vendor/v8/include/cppgc/platform.h +11 -0
  20. data/vendor/v8/include/cppgc/type-traits.h +1 -0
  21. data/vendor/v8/include/cppgc/visitor.h +25 -1
  22. data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
  23. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  24. data/vendor/v8/include/v8-array-buffer.h +111 -34
  25. data/vendor/v8/include/v8-callbacks.h +84 -26
  26. data/vendor/v8/include/v8-context.h +7 -6
  27. data/vendor/v8/include/v8-cppgc.h +2 -1
  28. data/vendor/v8/include/v8-data.h +5 -0
  29. data/vendor/v8/include/v8-debug.h +11 -0
  30. data/vendor/v8/include/v8-embedder-heap.h +1 -32
  31. data/vendor/v8/include/v8-exception.h +2 -0
  32. data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
  33. data/vendor/v8/include/v8-fast-api-calls.h +17 -175
  34. data/vendor/v8/include/v8-function-callback.h +4 -33
  35. data/vendor/v8/include/v8-function.h +7 -0
  36. data/vendor/v8/include/v8-handle-base.h +18 -0
  37. data/vendor/v8/include/v8-initialization.h +9 -1
  38. data/vendor/v8/include/v8-inspector.h +8 -4
  39. data/vendor/v8/include/v8-internal.h +477 -399
  40. data/vendor/v8/include/v8-isolate.h +218 -151
  41. data/vendor/v8/include/v8-local-handle.h +56 -28
  42. data/vendor/v8/include/v8-maybe.h +2 -1
  43. data/vendor/v8/include/v8-memory-span.h +149 -24
  44. data/vendor/v8/include/v8-message.h +9 -1
  45. data/vendor/v8/include/v8-metrics.h +10 -0
  46. data/vendor/v8/include/v8-object.h +7 -2
  47. data/vendor/v8/include/v8-persistent-handle.h +17 -17
  48. data/vendor/v8/include/v8-platform.h +48 -13
  49. data/vendor/v8/include/v8-primitive.h +131 -6
  50. data/vendor/v8/include/v8-profiler.h +13 -1
  51. data/vendor/v8/include/v8-proxy.h +0 -1
  52. data/vendor/v8/include/v8-regexp.h +0 -1
  53. data/vendor/v8/include/v8-sandbox.h +3 -3
  54. data/vendor/v8/include/v8-script.h +21 -3
  55. data/vendor/v8/include/v8-source-location.h +6 -1
  56. data/vendor/v8/include/v8-template.h +8 -2
  57. data/vendor/v8/include/v8-trace-categories.h +23 -0
  58. data/vendor/v8/include/v8-traced-handle.h +16 -17
  59. data/vendor/v8/include/v8-typed-array.h +6 -10
  60. data/vendor/v8/include/v8-unwinder-state.h +2 -3
  61. data/vendor/v8/include/v8-value-serializer-version.h +3 -3
  62. data/vendor/v8/include/v8-value.h +18 -0
  63. data/vendor/v8/include/v8-version.h +4 -4
  64. data/vendor/v8/include/v8-wasm.h +24 -0
  65. data/vendor/v8/include/v8-weak-callback-info.h +20 -12
  66. data/vendor/v8/include/v8.h +3 -3
  67. data/vendor/v8/include/v8config.h +34 -40
  68. metadata +6 -7
  69. data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -14,7 +14,7 @@
14
14
  #include <string>
15
15
 
16
16
  #include "v8-source-location.h" // NOLINT(build/include_directory)
17
- #include "v8config.h" // NOLINT(build/include_directory)
17
+ #include "v8config.h" // NOLINT(build/include_directory)
18
18
 
19
19
  namespace v8 {
20
20
 
@@ -79,9 +79,8 @@ class TaskRunner {
79
79
  *
80
80
  * Embedders should override PostTaskImpl instead of this.
81
81
  */
82
- void PostTask(
83
- std::unique_ptr<Task> task,
84
- const SourceLocation& location = SourceLocation::Current()) {
82
+ void PostTask(std::unique_ptr<Task> task,
83
+ const SourceLocation& location = SourceLocation::Current()) {
85
84
  PostTaskImpl(std::move(task), location);
86
85
  }
87
86
 
@@ -553,6 +552,19 @@ class PageAllocator {
553
552
  */
554
553
  virtual bool DecommitPages(void* address, size_t size) = 0;
555
554
 
555
+ /**
556
+ * Block any modifications to the given mapping such as changing permissions
557
+ * or unmapping the pages on supported platforms.
558
+ * The address space reservation will exist until the process ends, but it's
559
+ * possible to release the memory using DiscardSystemPages. Note that this
560
+ * might require write permissions to the page as e.g. on Linux, mseal will
561
+ * block discarding sealed anonymous memory.
562
+ */
563
+ virtual bool SealPages(void* address, size_t length) {
564
+ // TODO(360048056): make it pure once it's implemented on Chromium side.
565
+ return false;
566
+ }
567
+
556
568
  /**
557
569
  * INTERNAL ONLY: This interface has not been stabilised and may change
558
570
  * without notice from one release to another without being deprecated first.
@@ -1051,7 +1063,7 @@ class Platform {
1051
1063
  * Allows the embedder to manage memory page allocations.
1052
1064
  * Returning nullptr will cause V8 to use the default page allocator.
1053
1065
  */
1054
- virtual PageAllocator* GetPageAllocator() = 0;
1066
+ virtual PageAllocator* GetPageAllocator() { return nullptr; }
1055
1067
 
1056
1068
  /**
1057
1069
  * Allows the embedder to provide an allocator that uses per-thread memory
@@ -1086,11 +1098,8 @@ class Platform {
1086
1098
  * Returns a TaskRunner which can be used to post a task on the foreground.
1087
1099
  * The TaskRunner's NonNestableTasksEnabled() must be true. This function
1088
1100
  * should only be called from a foreground thread.
1089
- * TODO(chromium:1448758): Deprecate once |GetForegroundTaskRunner(Isolate*,
1090
- * TaskPriority)| is ready.
1091
1101
  */
1092
- virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
1093
- Isolate* isolate) {
1102
+ std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(Isolate* isolate) {
1094
1103
  return GetForegroundTaskRunner(isolate, TaskPriority::kUserBlocking);
1095
1104
  }
1096
1105
 
@@ -1098,18 +1107,16 @@ class Platform {
1098
1107
  * Returns a TaskRunner with a specific |priority| which can be used to post a
1099
1108
  * task on the foreground thread. The TaskRunner's NonNestableTasksEnabled()
1100
1109
  * must be true. This function should only be called from a foreground thread.
1101
- * TODO(chromium:1448758): Make pure virtual once embedders implement it.
1102
1110
  */
1103
1111
  virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
1104
- Isolate* isolate, TaskPriority priority) {
1105
- return nullptr;
1106
- }
1112
+ Isolate* isolate, TaskPriority priority) = 0;
1107
1113
 
1108
1114
  /**
1109
1115
  * Schedules a task to be invoked on a worker thread.
1110
1116
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1111
1117
  * CallOnWorkerThread().
1112
1118
  */
1119
+ V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1113
1120
  void CallOnWorkerThread(
1114
1121
  std::unique_ptr<Task> task,
1115
1122
  const SourceLocation& location = SourceLocation::Current()) {
@@ -1123,6 +1130,7 @@ class Platform {
1123
1130
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1124
1131
  * CallBlockingTaskOnWorkerThread().
1125
1132
  */
1133
+ V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1126
1134
  void CallBlockingTaskOnWorkerThread(
1127
1135
  std::unique_ptr<Task> task,
1128
1136
  const SourceLocation& location = SourceLocation::Current()) {
@@ -1137,6 +1145,7 @@ class Platform {
1137
1145
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1138
1146
  * CallLowPriorityTaskOnWorkerThread().
1139
1147
  */
1148
+ V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1140
1149
  void CallLowPriorityTaskOnWorkerThread(
1141
1150
  std::unique_ptr<Task> task,
1142
1151
  const SourceLocation& location = SourceLocation::Current()) {
@@ -1152,6 +1161,7 @@ class Platform {
1152
1161
  * Embedders should override PostDelayedTaskOnWorkerThreadImpl() instead of
1153
1162
  * CallDelayedOnWorkerThread().
1154
1163
  */
1164
+ V8_DEPRECATE_SOON("Use PostDelayedTaskOnWorkerThread instead.")
1155
1165
  void CallDelayedOnWorkerThread(
1156
1166
  std::unique_ptr<Task> task, double delay_in_seconds,
1157
1167
  const SourceLocation& location = SourceLocation::Current()) {
@@ -1160,6 +1170,31 @@ class Platform {
1160
1170
  location);
1161
1171
  }
1162
1172
 
1173
+ /**
1174
+ * Schedules a task to be invoked on a worker thread.
1175
+ * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1176
+ * PostTaskOnWorkerThread().
1177
+ */
1178
+ void PostTaskOnWorkerThread(
1179
+ TaskPriority priority, std::unique_ptr<Task> task,
1180
+ const SourceLocation& location = SourceLocation::Current()) {
1181
+ PostTaskOnWorkerThreadImpl(priority, std::move(task), location);
1182
+ }
1183
+
1184
+ /**
1185
+ * Schedules a task to be invoked on a worker thread after |delay_in_seconds|
1186
+ * expires.
1187
+ * Embedders should override PostDelayedTaskOnWorkerThreadImpl() instead of
1188
+ * PostDelayedTaskOnWorkerThread().
1189
+ */
1190
+ void PostDelayedTaskOnWorkerThread(
1191
+ TaskPriority priority, std::unique_ptr<Task> task,
1192
+ double delay_in_seconds,
1193
+ const SourceLocation& location = SourceLocation::Current()) {
1194
+ PostDelayedTaskOnWorkerThreadImpl(priority, std::move(task),
1195
+ delay_in_seconds, location);
1196
+ }
1197
+
1163
1198
  /**
1164
1199
  * Returns true if idle tasks are enabled for the given |isolate|.
1165
1200
  */
@@ -140,8 +140,14 @@ class V8_EXPORT String : public Name {
140
140
  * Returns the number of bytes in the UTF-8 encoded
141
141
  * representation of this string.
142
142
  */
143
+ V8_DEPRECATED("Use Utf8LengthV2 instead.")
143
144
  int Utf8Length(Isolate* isolate) const;
144
145
 
146
+ /**
147
+ * Returns the number of bytes needed for the Utf8 encoding of this string.
148
+ */
149
+ size_t Utf8LengthV2(Isolate* isolate) const;
150
+
145
151
  /**
146
152
  * Returns whether this string is known to contain only one byte data,
147
153
  * i.e. ISO-8859-1 code points.
@@ -194,15 +200,72 @@ class V8_EXPORT String : public Name {
194
200
  };
195
201
 
196
202
  // 16-bit character codes.
203
+ V8_DEPRECATED("Use WriteV2 instead.")
197
204
  int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
198
205
  int options = NO_OPTIONS) const;
199
206
  // One byte characters.
207
+ V8_DEPRECATED("Use WriteOneByteV2 instead.")
200
208
  int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
201
209
  int length = -1, int options = NO_OPTIONS) const;
202
210
  // UTF-8 encoded characters.
211
+ V8_DEPRECATED("Use WriteUtf8V2 instead.")
203
212
  int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
204
213
  int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
205
214
 
215
+ struct WriteFlags {
216
+ enum {
217
+ kNone = 0,
218
+ // Indicates that the output string should be null-terminated. In that
219
+ // case, the output buffer must include sufficient space for the
220
+ // additional null character.
221
+ kNullTerminate = 1,
222
+ // Used by WriteUtf8 to replace orphan surrogate code units with the
223
+ // unicode replacement character. Needs to be set to guarantee valid UTF-8
224
+ // output.
225
+ kReplaceInvalidUtf8 = 2
226
+ };
227
+ };
228
+
229
+ /**
230
+ * Write the contents of the string to an external buffer.
231
+ *
232
+ * Copies length characters into the output buffer starting at offset. The
233
+ * output buffer must have sufficient space for all characters and the null
234
+ * terminator if null termination is requested through the flags.
235
+ *
236
+ * \param offset The position within the string at which copying begins.
237
+ * \param length The number of characters to copy from the string.
238
+ * \param buffer The buffer into which the string will be copied.
239
+ * \param flags Various flags that influence the behavior of this operation.
240
+ */
241
+ void WriteV2(Isolate* isolate, uint32_t offset, uint32_t length,
242
+ uint16_t* buffer, int flags = WriteFlags::kNone) const;
243
+ void WriteOneByteV2(Isolate* isolate, uint32_t offset, uint32_t length,
244
+ uint8_t* buffer, int flags = WriteFlags::kNone) const;
245
+
246
+ /**
247
+ * Encode the contents of the string as Utf8 into an external buffer.
248
+ *
249
+ * Encodes the characters of this string as Utf8 and writes them into the
250
+ * output buffer until either all characters were encoded or the buffer is
251
+ * full. Will not write partial UTF-8 sequences, preferring to stop before
252
+ * the end of the buffer. If null termination is requested, the output buffer
253
+ * will always be null terminated even if not all characters fit. In that
254
+ * case, the capacity must be at least one. The required size of the output
255
+ * buffer can be determined using Utf8Length().
256
+ *
257
+ * \param buffer The buffer into which the string will be written.
258
+ * \param capacity The number of bytes available in the output buffer.
259
+ * \param flags Various flags that influence the behavior of this operation.
260
+ * \param processed_characters_return The number of processed characters from
261
+ * the buffer.
262
+ * \return The number of bytes copied to the buffer including the null
263
+ * terminator (if written).
264
+ */
265
+ size_t WriteUtf8V2(Isolate* isolate, char* buffer, size_t capacity,
266
+ int flags = WriteFlags::kNone,
267
+ size_t* processed_characters_return = nullptr) const;
268
+
206
269
  /**
207
270
  * A zero length string.
208
271
  */
@@ -240,6 +303,44 @@ class V8_EXPORT String : public Name {
240
303
  */
241
304
  virtual bool IsCacheable() const { return true; }
242
305
 
306
+ /**
307
+ * Internally V8 will call this Unaccount method when the external string
308
+ * resource should be unaccounted for. This method can be overridden in
309
+ * subclasses to control how allocated external bytes are accounted.
310
+ */
311
+ virtual void Unaccount(Isolate* isolate) {}
312
+
313
+ /**
314
+ * Returns an estimate of the memory occupied by this external string, to be
315
+ * used by V8 when producing a heap snapshot. If this function returns
316
+ * kDefaultMemoryEstimate, then V8 will estimate the external size based on
317
+ * the string length. This function should return only memory that is
318
+ * uniquely owned by this resource. If the resource has shared ownership of
319
+ * a secondary allocation, it can report that memory by implementing
320
+ * EstimateSharedMemoryUsage.
321
+ */
322
+ virtual size_t EstimateMemoryUsage() const {
323
+ return kDefaultMemoryEstimate;
324
+ }
325
+ static constexpr size_t kDefaultMemoryEstimate = static_cast<size_t>(-1);
326
+
327
+ class V8_EXPORT SharedMemoryUsageRecorder {
328
+ public:
329
+ /**
330
+ * Record that a shared allocation at the given location has the given
331
+ * size.
332
+ */
333
+ virtual void RecordSharedMemoryUsage(const void* location,
334
+ size_t size) = 0;
335
+ };
336
+
337
+ /**
338
+ * Estimates memory that this string resource may share with other string
339
+ * resources, to be used by V8 when producing a heap snapshot.
340
+ */
341
+ virtual void EstimateSharedMemoryUsage(
342
+ SharedMemoryUsageRecorder* recorder) const {}
343
+
243
344
  // Disallow copying and assigning.
244
345
  ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
245
346
  void operator=(const ExternalStringResourceBase&) = delete;
@@ -474,8 +575,20 @@ class V8_EXPORT String : public Name {
474
575
  * The string is not modified if the operation fails. See NewExternal for
475
576
  * information on the lifetime of the resource.
476
577
  */
578
+ V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
477
579
  bool MakeExternal(ExternalStringResource* resource);
478
580
 
581
+ /**
582
+ * Associate an external string resource with this string by transforming it
583
+ * in place so that existing references to this string in the JavaScript heap
584
+ * will use the external string resource. The external string resource's
585
+ * character contents need to be equivalent to this string.
586
+ * Returns true if the string has been changed to be an external string.
587
+ * The string is not modified if the operation fails. See NewExternal for
588
+ * information on the lifetime of the resource.
589
+ */
590
+ bool MakeExternal(Isolate* isolate, ExternalStringResource* resource);
591
+
479
592
  /**
480
593
  * Creates a new external string using the one-byte data defined in the given
481
594
  * resource. When the external string is no longer live on V8's heap the
@@ -496,8 +609,20 @@ class V8_EXPORT String : public Name {
496
609
  * The string is not modified if the operation fails. See NewExternal for
497
610
  * information on the lifetime of the resource.
498
611
  */
612
+ V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
499
613
  bool MakeExternal(ExternalOneByteStringResource* resource);
500
614
 
615
+ /**
616
+ * Associate an external string resource with this string by transforming it
617
+ * in place so that existing references to this string in the JavaScript heap
618
+ * will use the external string resource. The external string resource's
619
+ * character contents need to be equivalent to this string.
620
+ * Returns true if the string has been changed to be an external string.
621
+ * The string is not modified if the operation fails. See NewExternal for
622
+ * information on the lifetime of the resource.
623
+ */
624
+ bool MakeExternal(Isolate* isolate, ExternalOneByteStringResource* resource);
625
+
501
626
  /**
502
627
  * Returns true if this string can be made external, given the encoding for
503
628
  * the external string resource.
@@ -527,7 +652,7 @@ class V8_EXPORT String : public Name {
527
652
  ~Utf8Value();
528
653
  char* operator*() { return str_; }
529
654
  const char* operator*() const { return str_; }
530
- int length() const { return length_; }
655
+ size_t length() const { return length_; }
531
656
 
532
657
  // Disallow copying and assigning.
533
658
  Utf8Value(const Utf8Value&) = delete;
@@ -535,7 +660,7 @@ class V8_EXPORT String : public Name {
535
660
 
536
661
  private:
537
662
  char* str_;
538
- int length_;
663
+ size_t length_;
539
664
  };
540
665
 
541
666
  /**
@@ -557,7 +682,7 @@ class V8_EXPORT String : public Name {
557
682
  ~Value();
558
683
  uint16_t* operator*() { return str_; }
559
684
  const uint16_t* operator*() const { return str_; }
560
- int length() const { return length_; }
685
+ uint32_t length() const { return length_; }
561
686
 
562
687
  // Disallow copying and assigning.
563
688
  Value(const Value&) = delete;
@@ -565,7 +690,7 @@ class V8_EXPORT String : public Name {
565
690
 
566
691
  private:
567
692
  uint16_t* str_;
568
- int length_;
693
+ uint32_t length_;
569
694
  };
570
695
 
571
696
  /**
@@ -594,7 +719,7 @@ class V8_EXPORT String : public Name {
594
719
  #endif
595
720
  return data16_;
596
721
  }
597
- int length() const { return length_; }
722
+ uint32_t length() const { return length_; }
598
723
  bool is_one_byte() const { return is_one_byte_; }
599
724
 
600
725
  // Disallow copying and assigning.
@@ -609,7 +734,7 @@ class V8_EXPORT String : public Name {
609
734
  const uint8_t* data8_;
610
735
  const uint16_t* data16_;
611
736
  };
612
- int length_;
737
+ uint32_t length_;
613
738
  bool is_one_byte_;
614
739
  // Avoid exposing the internal DisallowGarbageCollection scope.
615
740
  alignas(internal::Internals::
@@ -418,8 +418,11 @@ class V8_EXPORT CpuProfiler {
418
418
  * Synchronously collect current stack sample in all profilers attached to
419
419
  * the |isolate|. The call does not affect number of ticks recorded for
420
420
  * the current top node.
421
+ * |trace_id| is an optional identifier set to the collected sample.
422
+ * this is useful to associate the sample with a trace event.
421
423
  */
422
- static void CollectSample(Isolate* isolate);
424
+ static void CollectSample(
425
+ Isolate* isolate, const std::optional<uint64_t> trace_id = std::nullopt);
423
426
 
424
427
  /**
425
428
  * Disposes the CPU profiler object.
@@ -937,6 +940,15 @@ class V8_EXPORT EmbedderGraph {
937
940
  */
938
941
  virtual void AddEdge(Node* from, Node* to, const char* name = nullptr) = 0;
939
942
 
943
+ /**
944
+ * Adds a count of bytes that are not associated with any particular Node.
945
+ * An embedder may use this to represent the size of nodes which were omitted
946
+ * from this EmbedderGraph despite being retained by the graph, or other
947
+ * overhead costs. This number will contribute to the total size in a heap
948
+ * snapshot, without being represented in the object graph.
949
+ */
950
+ virtual void AddNativeSize(size_t size) {}
951
+
940
952
  virtual ~EmbedderGraph() = default;
941
953
  };
942
954
 
@@ -1,4 +1,3 @@
1
-
2
1
  // Copyright 2021 the V8 project authors. All rights reserved.
3
2
  // Use of this source code is governed by a BSD-style license that can be
4
3
  // found in the LICENSE file.
@@ -1,4 +1,3 @@
1
-
2
1
  // Copyright 2021 the V8 project authors. All rights reserved.
3
2
  // Use of this source code is governed by a BSD-style license that can be
4
3
  // found in the LICENSE file.
@@ -23,15 +23,14 @@ namespace v8 {
23
23
  * type check for a supertype must succeed for any subtype.
24
24
  *
25
25
  * The tag is currently in practice limited to 15 bits since it needs to fit
26
- * together with a marking bit into the unused parts of a pointer (the top 16
27
- * bits).
26
+ * together with a marking bit into the unused parts of a pointer.
28
27
  */
29
28
  enum class CppHeapPointerTag : uint16_t {
30
29
  kFirstTag = 0,
31
30
  kNullTag = 0,
32
31
 
33
32
  /**
34
- * The lower type ids are reserved for the embedder to assign. For that, the
33
+ * The lower type ids are reserved for the embedder to assign. For that, the
35
34
  * main requirement is that all (transitive) child classes of a given parent
36
35
  * class have type ids in the same range, and that there are no unrelated
37
36
  * types in that range. For example, given the following type hierarchy:
@@ -67,6 +66,7 @@ enum class CppHeapPointerTag : uint16_t {
67
66
  // against supertypes, which cover a range of types (their subtypes).
68
67
  // Both the lower- and the upper bound are inclusive. In other words, this
69
68
  // struct represents the range [lower_bound, upper_bound].
69
+ // TODO(saelo): reuse internal::TagRange here.
70
70
  struct CppHeapPointerTagRange {
71
71
  constexpr CppHeapPointerTagRange(CppHeapPointerTag lower,
72
72
  CppHeapPointerTag upper)
@@ -129,6 +129,11 @@ class V8_EXPORT ModuleRequest : public Data {
129
129
  */
130
130
  Local<String> GetSpecifier() const;
131
131
 
132
+ /**
133
+ * Returns the module import phase for this ModuleRequest.
134
+ */
135
+ ModuleImportPhase GetPhase() const;
136
+
132
137
  /**
133
138
  * Returns the source code offset of this module request.
134
139
  * Use Module::SourceOffsetToLocation to convert this to line/column numbers.
@@ -150,7 +155,7 @@ class V8_EXPORT ModuleRequest : public Data {
150
155
  */
151
156
  Local<FixedArray> GetImportAttributes() const;
152
157
 
153
- V8_DEPRECATE_SOON("Use GetImportAttributes instead")
158
+ V8_DEPRECATED("Use GetImportAttributes instead")
154
159
  Local<FixedArray> GetImportAssertions() const {
155
160
  return GetImportAttributes();
156
161
  }
@@ -211,6 +216,9 @@ class V8_EXPORT Module : public Data {
211
216
  using ResolveModuleCallback = MaybeLocal<Module> (*)(
212
217
  Local<Context> context, Local<String> specifier,
213
218
  Local<FixedArray> import_attributes, Local<Module> referrer);
219
+ using ResolveSourceCallback = MaybeLocal<Object> (*)(
220
+ Local<Context> context, Local<String> specifier,
221
+ Local<FixedArray> import_attributes, Local<Module> referrer);
214
222
 
215
223
  /**
216
224
  * Instantiates the module and its dependencies.
@@ -220,7 +228,8 @@ class V8_EXPORT Module : public Data {
220
228
  * exception is propagated.)
221
229
  */
222
230
  V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(
223
- Local<Context> context, ResolveModuleCallback callback);
231
+ Local<Context> context, ResolveModuleCallback module_callback,
232
+ ResolveSourceCallback source_callback = nullptr);
224
233
 
225
234
  /**
226
235
  * Evaluates the module and its dependencies.
@@ -264,6 +273,13 @@ class V8_EXPORT Module : public Data {
264
273
  */
265
274
  bool IsGraphAsync() const;
266
275
 
276
+ /**
277
+ * Returns whether this module is individually asynchronous (for example,
278
+ * if it's a Source Text Module Record containing a top-level await).
279
+ * See [[HasTLA]] in https://tc39.es/ecma262/#sec-cyclic-module-records
280
+ */
281
+ bool HasTopLevelAwait() const;
282
+
267
283
  /**
268
284
  * Returns whether the module is a SourceTextModule.
269
285
  */
@@ -661,6 +677,7 @@ class V8_EXPORT ScriptCompiler {
661
677
  kProduceCompileHints = 1 << 2,
662
678
  kConsumeCompileHints = 1 << 3,
663
679
  kFollowCompileHintsMagicComment = 1 << 4,
680
+ kFollowCompileHintsPerFunctionMagicComment = 1 << 5,
664
681
  };
665
682
 
666
683
  static inline bool CompileOptionsIsValid(CompileOptions compile_options) {
@@ -701,7 +718,8 @@ class V8_EXPORT ScriptCompiler {
701
718
  kNoCacheBecausePacScript,
702
719
  kNoCacheBecauseInDocumentWrite,
703
720
  kNoCacheBecauseResourceWithNoCacheHandler,
704
- kNoCacheBecauseDeferredProduceCodeCache
721
+ kNoCacheBecauseDeferredProduceCodeCache,
722
+ kNoCacheBecauseStaticCodeCache,
705
723
  };
706
724
 
707
725
  /**
@@ -76,7 +76,12 @@ class V8_EXPORT SourceLocation final {
76
76
  *
77
77
  * \returns a human-readable string representing source location information.
78
78
  */
79
- std::string ToString() const;
79
+ std::string ToString() const {
80
+ if (!file_) {
81
+ return {};
82
+ }
83
+ return std::string(function_) + "@" + file_ + ":" + std::to_string(line_);
84
+ }
80
85
 
81
86
  private:
82
87
  constexpr SourceLocation(const char* function, const char* file, size_t line)
@@ -72,8 +72,6 @@ class V8_EXPORT Template : public Data {
72
72
  * \param name The name of the property for which an accessor is added.
73
73
  * \param getter The callback to invoke when getting the property.
74
74
  * \param setter The callback to invoke when setting the property.
75
- * \param data A piece of data that will be passed to the getter and setter
76
- * callbacks whenever they are invoked.
77
75
  * \param attribute The attributes of the property for which an accessor
78
76
  * is added.
79
77
  */
@@ -703,6 +701,14 @@ class V8_EXPORT FunctionTemplate : public Template {
703
701
  */
704
702
  bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
705
703
 
704
+ /**
705
+ * Checks if the object can be promoted to read only space, seals it and
706
+ * prepares for promotion.
707
+ *
708
+ * This is an experimental feature and may still change significantly.
709
+ */
710
+ void SealAndPrepareForPromotionToReadOnly();
711
+
706
712
  V8_INLINE static FunctionTemplate* Cast(Data* data);
707
713
 
708
714
  private:
@@ -0,0 +1,23 @@
1
+ // Copyright 2025 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_TRACE_CATEGORIES_H_
6
+ #define INCLUDE_V8_TRACE_CATEGORIES_H_
7
+
8
+ #if defined(V8_USE_PERFETTO)
9
+
10
+ #include "perfetto/tracing/track_event.h"
11
+ #include "v8config.h"
12
+
13
+ namespace v8 {
14
+
15
+ // Returns the perfeto TrackEventCategoryRegistry for v8 tracing categories.
16
+ V8_EXPORT const perfetto::internal::TrackEventCategoryRegistry&
17
+ GetTrackEventCategoryRegistry();
18
+
19
+ } // namespace v8
20
+
21
+ #endif // defined(V8_USE_PERFETTO)
22
+
23
+ #endif // INCLUDE_V8_TRACE_CATEGORIES_H_
@@ -37,15 +37,13 @@ enum class TracedReferenceHandling {
37
37
  kDroppable
38
38
  };
39
39
 
40
- V8_EXPORT internal::Address* GlobalizeTracedReference(
41
- internal::Isolate* isolate, internal::Address value,
42
- internal::Address* slot, TracedReferenceStoreMode store_mode,
43
- internal::TracedReferenceHandling reference_handling);
44
- V8_EXPORT void MoveTracedReference(internal::Address** from,
45
- internal::Address** to);
46
- V8_EXPORT void CopyTracedReference(const internal::Address* const* from,
47
- internal::Address** to);
48
- V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
40
+ V8_EXPORT Address* GlobalizeTracedReference(
41
+ Isolate* isolate, Address value, Address* slot,
42
+ TracedReferenceStoreMode store_mode,
43
+ TracedReferenceHandling reference_handling);
44
+ V8_EXPORT void MoveTracedReference(Address** from, Address** to);
45
+ V8_EXPORT void CopyTracedReference(const Address* const* from, Address** to);
46
+ V8_EXPORT void DisposeTracedReference(Address* global_handle);
49
47
 
50
48
  } // namespace internal
51
49
 
@@ -55,6 +53,9 @@ V8_EXPORT void DisposeTracedReference(internal::Address* global_handle);
55
53
  */
56
54
  class TracedReferenceBase : public api_internal::IndirectHandleBase {
57
55
  public:
56
+ static_assert(sizeof(std::atomic<internal::Address*>) ==
57
+ sizeof(internal::Address*));
58
+
58
59
  /**
59
60
  * If non-empty, destroy the underlying storage cell. |IsEmpty| will return
60
61
  * true after this call.
@@ -73,9 +74,7 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase {
73
74
  * Returns true if this TracedReference is empty, i.e., has not been
74
75
  * assigned an object. This version of IsEmpty is thread-safe.
75
76
  */
76
- bool IsEmptyThreadSafe() const {
77
- return this->GetSlotThreadSafe() == nullptr;
78
- }
77
+ bool IsEmptyThreadSafe() const { return GetSlotThreadSafe() == nullptr; }
79
78
 
80
79
  protected:
81
80
  V8_INLINE TracedReferenceBase() = default;
@@ -83,17 +82,17 @@ class TracedReferenceBase : public api_internal::IndirectHandleBase {
83
82
  /**
84
83
  * Update this reference in a thread-safe way.
85
84
  */
86
- void SetSlotThreadSafe(void* new_val) {
87
- reinterpret_cast<std::atomic<void*>*>(&slot())->store(
85
+ void SetSlotThreadSafe(internal::Address* new_val) {
86
+ reinterpret_cast<std::atomic<internal::Address*>*>(&slot())->store(
88
87
  new_val, std::memory_order_relaxed);
89
88
  }
90
89
 
91
90
  /**
92
91
  * Get this reference in a thread-safe way
93
92
  */
94
- const void* GetSlotThreadSafe() const {
95
- return reinterpret_cast<std::atomic<const void*> const*>(&slot())->load(
96
- std::memory_order_relaxed);
93
+ const internal::Address* GetSlotThreadSafe() const {
94
+ return reinterpret_cast<const std::atomic<internal::Address*>*>(&slot())
95
+ ->load(std::memory_order_relaxed);
97
96
  }
98
97
 
99
98
  V8_EXPORT void CheckValue() const;
@@ -23,15 +23,11 @@ class V8_EXPORT TypedArray : public ArrayBufferView {
23
23
  * The largest supported typed array byte size. Each subclass defines a
24
24
  * type-specific kMaxLength for the maximum length that can be passed to New.
25
25
  */
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);
26
+ static constexpr size_t kMaxByteLength = ArrayBuffer::kMaxByteLength;
27
+
28
+ #ifdef V8_ENABLE_SANDBOX
29
+ static_assert(v8::TypedArray::kMaxByteLength <=
30
+ v8::internal::kMaxSafeBufferSizeForSandbox);
35
31
  #endif
36
32
 
37
33
  /**
@@ -253,10 +249,10 @@ class V8_EXPORT Int32Array : public TypedArray {
253
249
  * An instance of Float16Array constructor.
254
250
  */
255
251
  class V8_EXPORT Float16Array : public TypedArray {
252
+ public:
256
253
  static constexpr size_t kMaxLength =
257
254
  TypedArray::kMaxByteLength / sizeof(uint16_t);
258
255
 
259
- public:
260
256
  static Local<Float16Array> New(Local<ArrayBuffer> array_buffer,
261
257
  size_t byte_offset, size_t length);
262
258
  static Local<Float16Array> New(Local<SharedArrayBuffer> shared_array_buffer,
@@ -18,9 +18,8 @@ struct CalleeSavedRegisters {
18
18
  void* arm_r10;
19
19
  };
20
20
  #elif V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM64 || \
21
- V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || \
22
- V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_LOONG64 || \
23
- V8_TARGET_ARCH_RISCV32
21
+ V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_RISCV64 || \
22
+ V8_TARGET_ARCH_S390X || V8_TARGET_ARCH_LOONG64 || V8_TARGET_ARCH_RISCV32
24
23
  struct CalleeSavedRegisters {};
25
24
  #else
26
25
  #error Target architecture was not detected as supported by v8