node-linux-s390x 24.11.1 → 25.1.0

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 (48) hide show
  1. package/CHANGELOG.md +270 -1945
  2. package/bin/node +0 -0
  3. package/include/node/common.gypi +1 -13
  4. package/include/node/config.gypi +10 -9
  5. package/include/node/cppgc/allocation.h +3 -3
  6. package/include/node/cppgc/cross-thread-persistent.h +25 -29
  7. package/include/node/cppgc/internal/finalizer-trait.h +1 -1
  8. package/include/node/cppgc/internal/gc-info.h +3 -3
  9. package/include/node/cppgc/internal/logging.h +2 -2
  10. package/include/node/cppgc/internal/name-trait.h +1 -1
  11. package/include/node/cppgc/internal/pointer-policies.h +3 -3
  12. package/include/node/cppgc/member.h +10 -4
  13. package/include/node/cppgc/persistent.h +14 -15
  14. package/include/node/cppgc/platform.h +1 -1
  15. package/include/node/cppgc/trace-trait.h +1 -2
  16. package/include/node/cppgc/visitor.h +14 -9
  17. package/include/node/js_native_api.h +12 -0
  18. package/include/node/node.h +34 -78
  19. package/include/node/node_version.h +6 -6
  20. package/include/node/v8-array-buffer.h +1 -1
  21. package/include/node/v8-callbacks.h +3 -4
  22. package/include/node/v8-context.h +15 -5
  23. package/include/node/v8-data.h +5 -0
  24. package/include/node/v8-debug.h +11 -0
  25. package/include/node/v8-function-callback.h +26 -26
  26. package/include/node/v8-internal.h +136 -36
  27. package/include/node/v8-isolate.h +75 -16
  28. package/include/node/v8-json.h +8 -1
  29. package/include/node/v8-local-handle.h +112 -13
  30. package/include/node/v8-maybe.h +34 -10
  31. package/include/node/v8-memory-span.h +9 -4
  32. package/include/node/v8-message.h +3 -0
  33. package/include/node/v8-object.h +87 -24
  34. package/include/node/v8-persistent-handle.h +4 -4
  35. package/include/node/v8-platform.h +92 -28
  36. package/include/node/v8-primitive.h +22 -9
  37. package/include/node/v8-profiler.h +4 -0
  38. package/include/node/v8-sandbox.h +16 -0
  39. package/include/node/v8-script.h +17 -0
  40. package/include/node/v8-source-location.h +19 -26
  41. package/include/node/v8-template.h +37 -15
  42. package/include/node/v8-traced-handle.h +6 -6
  43. package/include/node/v8-unwinder.h +13 -0
  44. package/include/node/v8-version.h +4 -4
  45. package/include/node/v8config.h +65 -5
  46. package/package.json +1 -1
  47. package/share/doc/node/gdbinit +221 -4
  48. package/share/man/man1/node.1 +16 -3
@@ -11,6 +11,7 @@
11
11
  #include <stdlib.h> // For abort.
12
12
 
13
13
  #include <memory>
14
+ #include <optional>
14
15
  #include <string>
15
16
 
16
17
  #include "v8-source-location.h" // NOLINT(build/include_directory)
@@ -80,7 +81,7 @@ class TaskRunner {
80
81
  * Embedders should override PostTaskImpl instead of this.
81
82
  */
82
83
  void PostTask(std::unique_ptr<Task> task,
83
- const SourceLocation& location = SourceLocation::Current()) {
84
+ SourceLocation location = SourceLocation::Current()) {
84
85
  PostTaskImpl(std::move(task), location);
85
86
  }
86
87
 
@@ -103,7 +104,7 @@ class TaskRunner {
103
104
  */
104
105
  void PostNonNestableTask(
105
106
  std::unique_ptr<Task> task,
106
- const SourceLocation& location = SourceLocation::Current()) {
107
+ SourceLocation location = SourceLocation::Current()) {
107
108
  PostNonNestableTaskImpl(std::move(task), location);
108
109
  }
109
110
 
@@ -114,9 +115,8 @@ class TaskRunner {
114
115
  *
115
116
  * Embedders should override PostDelayedTaskImpl instead of this.
116
117
  */
117
- void PostDelayedTask(
118
- std::unique_ptr<Task> task, double delay_in_seconds,
119
- const SourceLocation& location = SourceLocation::Current()) {
118
+ void PostDelayedTask(std::unique_ptr<Task> task, double delay_in_seconds,
119
+ SourceLocation location = SourceLocation::Current()) {
120
120
  PostDelayedTaskImpl(std::move(task), delay_in_seconds, location);
121
121
  }
122
122
 
@@ -140,7 +140,7 @@ class TaskRunner {
140
140
  */
141
141
  void PostNonNestableDelayedTask(
142
142
  std::unique_ptr<Task> task, double delay_in_seconds,
143
- const SourceLocation& location = SourceLocation::Current()) {
143
+ SourceLocation location = SourceLocation::Current()) {
144
144
  PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds, location);
145
145
  }
146
146
 
@@ -154,9 +154,8 @@ class TaskRunner {
154
154
  *
155
155
  * Embedders should override PostIdleTaskImpl instead of this.
156
156
  */
157
- void PostIdleTask(
158
- std::unique_ptr<IdleTask> task,
159
- const SourceLocation& location = SourceLocation::Current()) {
157
+ void PostIdleTask(std::unique_ptr<IdleTask> task,
158
+ SourceLocation location = SourceLocation::Current()) {
160
159
  PostIdleTaskImpl(std::move(task), location);
161
160
  }
162
161
 
@@ -499,12 +498,59 @@ class PageAllocator {
499
498
  kNoAccessWillJitLater
500
499
  };
501
500
 
501
+ /**
502
+ * Optional hints for AllocatePages().
503
+ */
504
+ class AllocationHint final {
505
+ public:
506
+ AllocationHint() = default;
507
+
508
+ V8_WARN_UNUSED_RESULT constexpr AllocationHint WithAddress(
509
+ void* address) const {
510
+ return AllocationHint(address, may_grow_);
511
+ }
512
+
513
+ V8_WARN_UNUSED_RESULT constexpr AllocationHint WithMayGrow() const {
514
+ return AllocationHint(address_, true);
515
+ }
516
+
517
+ bool MayGrow() const { return may_grow_; }
518
+ void* Address() const { return address_; }
519
+
520
+ private:
521
+ constexpr AllocationHint(void* address, bool may_grow)
522
+ : address_(address), may_grow_(may_grow) {}
523
+
524
+ void* address_ = nullptr;
525
+ bool may_grow_ = false;
526
+ };
527
+
502
528
  /**
503
529
  * Allocates memory in range with the given alignment and permission.
504
530
  */
505
531
  virtual void* AllocatePages(void* address, size_t length, size_t alignment,
506
532
  Permission permissions) = 0;
507
533
 
534
+ /**
535
+ * Allocates memory in range with the given alignment and permission. In
536
+ * addition to AllocatePages it allows to pass in allocation hints. The
537
+ * underlying implementation may not make use of hints.
538
+ */
539
+ virtual void* AllocatePages(size_t length, size_t alignment,
540
+ Permission permissions, AllocationHint hint) {
541
+ return AllocatePages(hint.Address(), length, alignment, permissions);
542
+ }
543
+
544
+ /**
545
+ * Resizes the previously allocated memory at the given address. Returns true
546
+ * if the allocation could be resized. Returns false if this operation is
547
+ * either not supported or the object could not be resized in-place.
548
+ */
549
+ virtual bool ResizeAllocationAt(void* address, size_t old_length,
550
+ size_t new_length, Permission permissions) {
551
+ return false;
552
+ }
553
+
508
554
  /**
509
555
  * Frees memory in a range that was allocated by a call to AllocatePages.
510
556
  */
@@ -655,14 +701,6 @@ class ThreadIsolatedAllocator {
655
701
  * Return the pkey used to implement the thread isolation if Type == kPkey.
656
702
  */
657
703
  virtual int Pkey() const { return -1; }
658
-
659
- /**
660
- * Per-thread permissions can be reset on signal handler entry. Even reading
661
- * ThreadIsolated memory will segfault in that case.
662
- * Call this function on signal handler entry to ensure that read permissions
663
- * are restored.
664
- */
665
- static void SetDefaultPermissionsForSignalHandler();
666
704
  };
667
705
 
668
706
  // Opaque type representing a handle to a shared memory region.
@@ -948,6 +986,29 @@ class VirtualAddressSpace {
948
986
  */
949
987
  virtual void FreeSharedPages(Address address, size_t size) = 0;
950
988
 
989
+ /**
990
+ * Memory protection key support.
991
+ *
992
+ * If supported by the hardware and operating system, virtual address spaces
993
+ * can use memory protection keys in addition to the regular page
994
+ * permissions. The MemoryProtectionKeyId type identifies a memory protection
995
+ * key and is used by the related APIs in this class.
996
+ *
997
+ * TODO(saelo): consider renaming to just MemoryProtectionKey, but currently
998
+ * there's a naming conflict with base::MemoryProtectionKey.
999
+ */
1000
+ using MemoryProtectionKeyId = int;
1001
+
1002
+ /**
1003
+ * The memory protection key used by this space, if any.
1004
+ *
1005
+ * If this space uses a memory protection key, then all memory pages in it
1006
+ * will have this key set. In that case, this API will return that key.
1007
+ *
1008
+ * \returns the memory protection key used by this space or std::nullopt.
1009
+ */
1010
+ virtual std::optional<MemoryProtectionKeyId> ActiveMemoryProtectionKey() = 0;
1011
+
951
1012
  /**
952
1013
  * Whether this instance can allocate subspaces or not.
953
1014
  *
@@ -974,11 +1035,15 @@ class VirtualAddressSpace {
974
1035
  * \param max_page_permissions The maximum permissions that pages allocated in
975
1036
  * the subspace can obtain.
976
1037
  *
1038
+ * \param key Optional memory protection key for the subspace. If used, the
1039
+ * returned subspace will use this key for all its memory pages.
1040
+ *
977
1041
  * \returns a new subspace or nullptr on failure.
978
1042
  */
979
1043
  virtual std::unique_ptr<VirtualAddressSpace> AllocateSubspace(
980
1044
  Address hint, size_t size, size_t alignment,
981
- PagePermissions max_page_permissions) = 0;
1045
+ PagePermissions max_page_permissions,
1046
+ std::optional<MemoryProtectionKeyId> key = std::nullopt) = 0;
982
1047
 
983
1048
  //
984
1049
  // TODO(v8) maybe refactor the methods below before stabilizing the API. For
@@ -1117,9 +1182,8 @@ class Platform {
1117
1182
  * CallOnWorkerThread().
1118
1183
  */
1119
1184
  V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1120
- void CallOnWorkerThread(
1121
- std::unique_ptr<Task> task,
1122
- const SourceLocation& location = SourceLocation::Current()) {
1185
+ void CallOnWorkerThread(std::unique_ptr<Task> task,
1186
+ SourceLocation location = SourceLocation::Current()) {
1123
1187
  PostTaskOnWorkerThreadImpl(TaskPriority::kUserVisible, std::move(task),
1124
1188
  location);
1125
1189
  }
@@ -1133,7 +1197,7 @@ class Platform {
1133
1197
  V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1134
1198
  void CallBlockingTaskOnWorkerThread(
1135
1199
  std::unique_ptr<Task> task,
1136
- const SourceLocation& location = SourceLocation::Current()) {
1200
+ SourceLocation location = SourceLocation::Current()) {
1137
1201
  // Embedders may optionally override this to process these tasks in a high
1138
1202
  // priority pool.
1139
1203
  PostTaskOnWorkerThreadImpl(TaskPriority::kUserBlocking, std::move(task),
@@ -1148,7 +1212,7 @@ class Platform {
1148
1212
  V8_DEPRECATE_SOON("Use PostTaskOnWorkerThread instead.")
1149
1213
  void CallLowPriorityTaskOnWorkerThread(
1150
1214
  std::unique_ptr<Task> task,
1151
- const SourceLocation& location = SourceLocation::Current()) {
1215
+ SourceLocation location = SourceLocation::Current()) {
1152
1216
  // Embedders may optionally override this to process these tasks in a low
1153
1217
  // priority pool.
1154
1218
  PostTaskOnWorkerThreadImpl(TaskPriority::kBestEffort, std::move(task),
@@ -1164,7 +1228,7 @@ class Platform {
1164
1228
  V8_DEPRECATE_SOON("Use PostDelayedTaskOnWorkerThread instead.")
1165
1229
  void CallDelayedOnWorkerThread(
1166
1230
  std::unique_ptr<Task> task, double delay_in_seconds,
1167
- const SourceLocation& location = SourceLocation::Current()) {
1231
+ SourceLocation location = SourceLocation::Current()) {
1168
1232
  PostDelayedTaskOnWorkerThreadImpl(TaskPriority::kUserVisible,
1169
1233
  std::move(task), delay_in_seconds,
1170
1234
  location);
@@ -1177,7 +1241,7 @@ class Platform {
1177
1241
  */
1178
1242
  void PostTaskOnWorkerThread(
1179
1243
  TaskPriority priority, std::unique_ptr<Task> task,
1180
- const SourceLocation& location = SourceLocation::Current()) {
1244
+ SourceLocation location = SourceLocation::Current()) {
1181
1245
  PostTaskOnWorkerThreadImpl(priority, std::move(task), location);
1182
1246
  }
1183
1247
 
@@ -1190,7 +1254,7 @@ class Platform {
1190
1254
  void PostDelayedTaskOnWorkerThread(
1191
1255
  TaskPriority priority, std::unique_ptr<Task> task,
1192
1256
  double delay_in_seconds,
1193
- const SourceLocation& location = SourceLocation::Current()) {
1257
+ SourceLocation location = SourceLocation::Current()) {
1194
1258
  PostDelayedTaskOnWorkerThreadImpl(priority, std::move(task),
1195
1259
  delay_in_seconds, location);
1196
1260
  }
@@ -1247,7 +1311,7 @@ class Platform {
1247
1311
  */
1248
1312
  std::unique_ptr<JobHandle> PostJob(
1249
1313
  TaskPriority priority, std::unique_ptr<JobTask> job_task,
1250
- const SourceLocation& location = SourceLocation::Current()) {
1314
+ SourceLocation location = SourceLocation::Current()) {
1251
1315
  auto handle = CreateJob(priority, std::move(job_task), location);
1252
1316
  handle->NotifyConcurrencyIncrease();
1253
1317
  return handle;
@@ -1270,7 +1334,7 @@ class Platform {
1270
1334
  */
1271
1335
  std::unique_ptr<JobHandle> CreateJob(
1272
1336
  TaskPriority priority, std::unique_ptr<JobTask> job_task,
1273
- const SourceLocation& location = SourceLocation::Current()) {
1337
+ SourceLocation location = SourceLocation::Current()) {
1274
1338
  return CreateJobImpl(priority, std::move(job_task), location);
1275
1339
  }
1276
1340
 
@@ -635,11 +635,10 @@ class V8_EXPORT String : public Name {
635
635
  bool StringEquals(Local<String> str) const;
636
636
 
637
637
  /**
638
- * Converts an object to a UTF-8-encoded character array. Useful if
639
- * you want to print the object. If conversion to a string fails
640
- * (e.g. due to an exception in the toString() method of the object)
641
- * then the length() method returns 0 and the * operator returns
642
- * NULL.
638
+ * Converts an object to a null-terminated UTF-8-encoded character array.
639
+ * Useful if you want to print the object. If conversion to a string fails
640
+ * (e.g. due to an exception in the toString() method of the object) then the
641
+ * length() method returns 0 and the * operator returns NULL.
643
642
  *
644
643
  * WARNING: This will unconditionally copy the contents of the JavaScript
645
644
  * string, and should be avoided in situations where performance is a concern.
@@ -647,8 +646,7 @@ class V8_EXPORT String : public Name {
647
646
  */
648
647
  class V8_EXPORT Utf8Value {
649
648
  public:
650
- Utf8Value(Isolate* isolate, Local<v8::Value> obj,
651
- WriteOptions options = REPLACE_INVALID_UTF8);
649
+ Utf8Value(Isolate* isolate, Local<v8::Value> obj);
652
650
  ~Utf8Value();
653
651
  char* operator*() { return str_; }
654
652
  const char* operator*() const { return str_; }
@@ -851,6 +849,19 @@ class V8_EXPORT Number : public Numeric {
851
849
  public:
852
850
  double Value() const;
853
851
  static Local<Number> New(Isolate* isolate, double value);
852
+ template <typename Int>
853
+ requires(std::is_integral<Int>::value && !std::is_same<Int, bool>::value &&
854
+ std::is_signed_v<Int> && sizeof(Int) <= sizeof(int32_t))
855
+ V8_INLINE static Local<Number> New(Isolate* isolate, Int value) {
856
+ return NewFromInt32(isolate, value);
857
+ }
858
+ template <typename UInt>
859
+ requires(std::is_integral<UInt>::value &&
860
+ !std::is_same<UInt, bool>::value && std::is_unsigned_v<UInt> &&
861
+ sizeof(UInt) <= sizeof(uint32_t))
862
+ V8_INLINE static Local<Number> New(Isolate* isolate, UInt value) {
863
+ return NewFromUint32(isolate, value);
864
+ }
854
865
  V8_INLINE static Number* Cast(v8::Data* data) {
855
866
  #ifdef V8_ENABLE_CHECKS
856
867
  CheckCast(data);
@@ -860,6 +871,8 @@ class V8_EXPORT Number : public Numeric {
860
871
 
861
872
  private:
862
873
  Number();
874
+ static Local<Number> NewFromInt32(Isolate* isolate, int32_t value);
875
+ static Local<Number> NewFromUint32(Isolate* isolate, uint32_t value);
863
876
  static void CheckCast(v8::Data* that);
864
877
  };
865
878
 
@@ -994,7 +1007,7 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
994
1007
 
995
1008
  ExternalStringResource* result;
996
1009
  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
997
- Isolate* isolate = I::GetIsolateForSandbox(obj);
1010
+ Isolate* isolate = I::GetCurrentIsolateForSandbox();
998
1011
  A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
999
1012
  isolate, obj, I::kStringResourceOffset);
1000
1013
  result = reinterpret_cast<String::ExternalStringResource*>(value);
@@ -1039,7 +1052,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
1039
1052
  ExternalStringResourceBase* resource;
1040
1053
  if (type == I::kExternalOneByteRepresentationTag ||
1041
1054
  type == I::kExternalTwoByteRepresentationTag) {
1042
- Isolate* isolate = I::GetIsolateForSandbox(obj);
1055
+ Isolate* isolate = I::GetCurrentIsolateForSandbox();
1043
1056
  A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1044
1057
  isolate, obj, I::kStringResourceOffset);
1045
1058
  resource = reinterpret_cast<ExternalStringResourceBase*>(value);
@@ -71,6 +71,10 @@ class V8_EXPORT CpuProfileNode {
71
71
  /** The 1-based number of the source line where the function originates. */
72
72
  int line;
73
73
 
74
+ /** The 1-based number of the source column where the function originates.
75
+ */
76
+ int column;
77
+
74
78
  /** The count of samples associated with the source line. */
75
79
  unsigned int hit_count;
76
80
  };
@@ -101,6 +101,12 @@ struct CppHeapPointerTagRange {
101
101
  constexpr CppHeapPointerTagRange kAnyCppHeapPointer(
102
102
  CppHeapPointerTag::kFirstTag, CppHeapPointerTag::kLastTag);
103
103
 
104
+ /**
105
+ * Hardware support for the V8 Sandbox.
106
+ *
107
+ * This is an experimental feature that may change or be removed without
108
+ * further notice. Use at your own risk.
109
+ */
104
110
  class SandboxHardwareSupport {
105
111
  public:
106
112
  /**
@@ -109,6 +115,16 @@ class SandboxHardwareSupport {
109
115
  * hardware permissions to the memory that will be inherited on clone.
110
116
  */
111
117
  V8_EXPORT static void InitializeBeforeThreadCreation();
118
+
119
+ /**
120
+ * Prepares the current thread for executing sandboxed code.
121
+ *
122
+ * This must be called on newly created threads before they execute any
123
+ * sandboxed code (in particular any JavaScript or WebAssembly code). It
124
+ * should not be invoked on threads that never execute sandboxed code,
125
+ * although it is fine to do so from a security point of view.
126
+ */
127
+ V8_EXPORT static void PrepareCurrentThreadForHardwareSandboxing();
112
128
  };
113
129
 
114
130
  namespace internal {
@@ -220,6 +220,13 @@ class V8_EXPORT Module : public Data {
220
220
  Local<Context> context, Local<String> specifier,
221
221
  Local<FixedArray> import_attributes, Local<Module> referrer);
222
222
 
223
+ using ResolveModuleByIndexCallback = MaybeLocal<Module> (*)(
224
+ Local<Context> context, size_t module_request_index,
225
+ Local<Module> referrer);
226
+ using ResolveSourceByIndexCallback = MaybeLocal<Object> (*)(
227
+ Local<Context> context, size_t module_request_index,
228
+ Local<Module> referrer);
229
+
223
230
  /**
224
231
  * Instantiates the module and its dependencies.
225
232
  *
@@ -231,6 +238,16 @@ class V8_EXPORT Module : public Data {
231
238
  Local<Context> context, ResolveModuleCallback module_callback,
232
239
  ResolveSourceCallback source_callback = nullptr);
233
240
 
241
+ /**
242
+ * Similar to the variant that takes ResolveModuleCallback and
243
+ * ResolveSourceCallback, but uses the index into the array that is returned
244
+ * by GetModuleRequests() instead of the specifier and import attributes to
245
+ * identify the requests.
246
+ */
247
+ V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(
248
+ Local<Context> context, ResolveModuleByIndexCallback module_callback,
249
+ ResolveSourceByIndexCallback source_callback = nullptr);
250
+
234
251
  /**
235
252
  * Evaluates the module and its dependencies.
236
253
  *
@@ -6,21 +6,12 @@
6
6
  #define INCLUDE_SOURCE_LOCATION_H_
7
7
 
8
8
  #include <cstddef>
9
+ #include <source_location>
9
10
  #include <string>
10
11
 
11
12
  #include "v8config.h" // NOLINT(build/include_directory)
12
13
 
13
- #if defined(__has_builtin)
14
- #define V8_SUPPORTS_SOURCE_LOCATION \
15
- (__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
16
- __has_builtin(__builtin_LINE)) // NOLINT
17
- #elif defined(V8_CC_GNU) && __GNUC__ >= 7
18
14
  #define V8_SUPPORTS_SOURCE_LOCATION 1
19
- #elif defined(V8_CC_INTEL) && __ICC >= 1800
20
- #define V8_SUPPORTS_SOURCE_LOCATION 1
21
- #else
22
- #define V8_SUPPORTS_SOURCE_LOCATION 0
23
- #endif
24
15
 
25
16
  namespace v8 {
26
17
 
@@ -34,15 +25,18 @@ class V8_EXPORT SourceLocation final {
34
25
  * Construct source location information corresponding to the location of the
35
26
  * call site.
36
27
  */
37
- #if V8_SUPPORTS_SOURCE_LOCATION
38
28
  static constexpr SourceLocation Current(
39
- const char* function = __builtin_FUNCTION(),
40
- const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) {
41
- return SourceLocation(function, file, line);
29
+ const std::source_location& loc = std::source_location::current()) {
30
+ return SourceLocation(loc);
31
+ }
32
+ #ifdef DEBUG
33
+ static constexpr SourceLocation CurrentIfDebug(
34
+ const std::source_location& loc = std::source_location::current()) {
35
+ return SourceLocation(loc);
42
36
  }
43
37
  #else
44
- static constexpr SourceLocation Current() { return SourceLocation(); }
45
- #endif // V8_SUPPORTS_SOURCE_LOCATION
38
+ static constexpr SourceLocation CurrentIfDebug() { return {}; }
39
+ #endif
46
40
 
47
41
  /**
48
42
  * Constructs unspecified source location information.
@@ -55,21 +49,21 @@ class V8_EXPORT SourceLocation final {
55
49
  *
56
50
  * \returns the function name as cstring.
57
51
  */
58
- constexpr const char* Function() const { return function_; }
52
+ constexpr const char* Function() const { return loc_.function_name(); }
59
53
 
60
54
  /**
61
55
  * Returns the name of the current source file represented by this object.
62
56
  *
63
57
  * \returns the file name as cstring.
64
58
  */
65
- constexpr const char* FileName() const { return file_; }
59
+ constexpr const char* FileName() const { return loc_.file_name(); }
66
60
 
67
61
  /**
68
62
  * Returns the line number represented by this object.
69
63
  *
70
64
  * \returns the line number.
71
65
  */
72
- constexpr size_t Line() const { return line_; }
66
+ constexpr size_t Line() const { return loc_.line(); }
73
67
 
74
68
  /**
75
69
  * Returns a human-readable string representing this object.
@@ -77,19 +71,18 @@ class V8_EXPORT SourceLocation final {
77
71
  * \returns a human-readable string representing source location information.
78
72
  */
79
73
  std::string ToString() const {
80
- if (!file_) {
74
+ if (loc_.line() == 0) {
81
75
  return {};
82
76
  }
83
- return std::string(function_) + "@" + file_ + ":" + std::to_string(line_);
77
+ return std::string(loc_.function_name()) + "@" + loc_.file_name() + ":" +
78
+ std::to_string(loc_.line());
84
79
  }
85
80
 
86
81
  private:
87
- constexpr SourceLocation(const char* function, const char* file, size_t line)
88
- : function_(function), file_(file), line_(line) {}
82
+ constexpr explicit SourceLocation(const std::source_location& loc)
83
+ : loc_(loc) {}
89
84
 
90
- const char* function_ = nullptr;
91
- const char* file_ = nullptr;
92
- size_t line_ = 0u;
85
+ std::source_location loc_;
93
86
  };
94
87
 
95
88
  } // namespace v8
@@ -188,7 +188,8 @@ using NamedPropertyGetterCallback = Intercepted (*)(
188
188
  // Use `info.GetReturnValue().Set()` to set the return value of the
189
189
  // intercepted get request. If the property does not exist the callback should
190
190
  // not set the result and must not produce side effects.
191
- using GenericNamedPropertyGetterCallback =
191
+ using GenericNamedPropertyGetterCallback V8_DEPRECATE_SOON(
192
+ "Use NamedPropertyGetterCallback instead") =
192
193
  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
193
194
 
194
195
  /**
@@ -221,7 +222,8 @@ using NamedPropertySetterCallback =
221
222
  // `info.GetReturnValue().Set(value)`. If the setter did not intercept the
222
223
  // request, i.e., if the request should be handled as if no interceptor is
223
224
  // present, do not not call `Set()` and do not produce side effects.
224
- using GenericNamedPropertySetterCallback =
225
+ using GenericNamedPropertySetterCallback V8_DEPRECATE_SOON(
226
+ "Use NamedPropertySetterCallback instead") =
225
227
  void (*)(Local<Name> property, Local<Value> value,
226
228
  const PropertyCallbackInfo<Value>& info);
227
229
 
@@ -259,7 +261,8 @@ using NamedPropertyQueryCallback = Intercepted (*)(
259
261
  // value is an integer encoding a `v8::PropertyAttribute`. If the property does
260
262
  // not exist the callback should not set the result and must not produce side
261
263
  // effects.
262
- using GenericNamedPropertyQueryCallback =
264
+ using GenericNamedPropertyQueryCallback V8_DEPRECATE_SOON(
265
+ "Use NamedPropertyQueryCallback instead") =
263
266
  void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
264
267
 
265
268
  /**
@@ -296,7 +299,8 @@ using NamedPropertyDeleterCallback = Intercepted (*)(
296
299
  // `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
297
300
  // used as the return value of `delete`. If the deleter does not intercept the
298
301
  // request then it should not set the result and must not produce side effects.
299
- using GenericNamedPropertyDeleterCallback =
302
+ using GenericNamedPropertyDeleterCallback V8_DEPRECATE_SOON(
303
+ "Use NamedPropertyDeleterCallback instead") =
300
304
  void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
301
305
 
302
306
  /**
@@ -309,7 +313,9 @@ using NamedPropertyEnumeratorCallback =
309
313
  void (*)(const PropertyCallbackInfo<Array>& info);
310
314
  // This variant will be deprecated soon.
311
315
  // This is just a renaming of the typedef.
312
- using GenericNamedPropertyEnumeratorCallback = NamedPropertyEnumeratorCallback;
316
+ using GenericNamedPropertyEnumeratorCallback V8_DEPRECATE_SOON(
317
+ "Use NamedPropertyEnumeratorCallback instead") =
318
+ NamedPropertyEnumeratorCallback;
313
319
 
314
320
  /**
315
321
  * Interceptor for defineProperty requests on an object.
@@ -341,7 +347,8 @@ using NamedPropertyDefinerCallback =
341
347
  // `info.GetReturnValue().Set(value)`. If the definer did not intercept the
342
348
  // request, i.e., if the request should be handled as if no interceptor is
343
349
  // present, do not not call `Set()` and do not produce side effects.
344
- using GenericNamedPropertyDefinerCallback =
350
+ using GenericNamedPropertyDefinerCallback V8_DEPRECATE_SOON(
351
+ "Use NamedPropertyDefinerCallback instead") =
345
352
  void (*)(Local<Name> property, const PropertyDescriptor& desc,
346
353
  const PropertyCallbackInfo<Value>& info);
347
354
 
@@ -377,7 +384,8 @@ using NamedPropertyDescriptorCallback = Intercepted (*)(
377
384
  // intercepted request. The return value must be an object that
378
385
  // can be converted to a PropertyDescriptor, e.g., a `v8::Value` returned from
379
386
  // `v8::Object::getOwnPropertyDescriptor`.
380
- using GenericNamedPropertyDescriptorCallback =
387
+ using GenericNamedPropertyDescriptorCallback V8_DEPRECATE_SOON(
388
+ "Use NamedPropertyDescriptorCallback instead") =
381
389
  void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
382
390
 
383
391
  // TODO(ishell): Rename IndexedPropertyXxxCallbackV2 back to
@@ -390,7 +398,8 @@ using GenericNamedPropertyDescriptorCallback =
390
398
  using IndexedPropertyGetterCallbackV2 =
391
399
  Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
392
400
  // This variant will be deprecated soon.
393
- using IndexedPropertyGetterCallback =
401
+ using IndexedPropertyGetterCallback V8_DEPRECATE_SOON(
402
+ "Use IndexedPropertyGetterCallbackV2 instead") =
394
403
  void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
395
404
 
396
405
  /**
@@ -399,7 +408,8 @@ using IndexedPropertyGetterCallback =
399
408
  using IndexedPropertySetterCallbackV2 = Intercepted (*)(
400
409
  uint32_t index, Local<Value> value, const PropertyCallbackInfo<void>& info);
401
410
  // This variant will be deprecated soon.
402
- using IndexedPropertySetterCallback =
411
+ using IndexedPropertySetterCallback V8_DEPRECATE_SOON(
412
+ "Use IndexedPropertySetterCallbackV2 instead") =
403
413
  void (*)(uint32_t index, Local<Value> value,
404
414
  const PropertyCallbackInfo<Value>& info);
405
415
 
@@ -409,7 +419,8 @@ using IndexedPropertySetterCallback =
409
419
  using IndexedPropertyQueryCallbackV2 =
410
420
  Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
411
421
  // This variant will be deprecated soon.
412
- using IndexedPropertyQueryCallback =
422
+ using IndexedPropertyQueryCallback V8_DEPRECATE_SOON(
423
+ "Use IndexedPropertyQueryCallbackV2 instead") =
413
424
  void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
414
425
 
415
426
  /**
@@ -418,7 +429,8 @@ using IndexedPropertyQueryCallback =
418
429
  using IndexedPropertyDeleterCallbackV2 =
419
430
  Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
420
431
  // This variant will be deprecated soon.
421
- using IndexedPropertyDeleterCallback =
432
+ using IndexedPropertyDeleterCallback V8_DEPRECATE_SOON(
433
+ "Use IndexedPropertyDeleterCallbackV2 instead") =
422
434
  void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
423
435
 
424
436
  /**
@@ -437,7 +449,8 @@ using IndexedPropertyDefinerCallbackV2 =
437
449
  Intercepted (*)(uint32_t index, const PropertyDescriptor& desc,
438
450
  const PropertyCallbackInfo<void>& info);
439
451
  // This variant will be deprecated soon.
440
- using IndexedPropertyDefinerCallback =
452
+ using IndexedPropertyDefinerCallback V8_DEPRECATE_SOON(
453
+ "Use IndexedPropertyDefinerCallbackV2 instead") =
441
454
  void (*)(uint32_t index, const PropertyDescriptor& desc,
442
455
  const PropertyCallbackInfo<Value>& info);
443
456
 
@@ -447,7 +460,8 @@ using IndexedPropertyDefinerCallback =
447
460
  using IndexedPropertyDescriptorCallbackV2 =
448
461
  Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
449
462
  // This variant will be deprecated soon.
450
- using IndexedPropertyDescriptorCallback =
463
+ using IndexedPropertyDescriptorCallback V8_DEPRECATE_SOON(
464
+ "Use IndexedPropertyDescriptorCallbackV2 instead") =
451
465
  void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
452
466
 
453
467
  /**
@@ -702,8 +716,8 @@ class V8_EXPORT FunctionTemplate : public Template {
702
716
  bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
703
717
 
704
718
  /**
705
- * Checks if the object can be promoted to read only space, seals it and
706
- * prepares for promotion.
719
+ * Seal the object and mark it for promotion to read only space during
720
+ * context snapshot creation.
707
721
  *
708
722
  * This is an experimental feature and may still change significantly.
709
723
  */
@@ -1037,6 +1051,14 @@ class V8_EXPORT ObjectTemplate : public Template {
1037
1051
  void SetCodeLike();
1038
1052
  bool IsCodeLike() const;
1039
1053
 
1054
+ /**
1055
+ * Seal the object and mark it for promotion to read only space during
1056
+ * context snapshot creation.
1057
+ *
1058
+ * This is an experimental feature and may still change significantly.
1059
+ */
1060
+ void SealAndPrepareForPromotionToReadOnly();
1061
+
1040
1062
  V8_INLINE static ObjectTemplate* Cast(Data* data);
1041
1063
 
1042
1064
  private: