node-darwin-x64 25.8.2 → 26.0.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 (50) hide show
  1. package/CHANGELOG.md +200 -1293
  2. package/bin/node +0 -0
  3. package/include/node/common.gypi +13 -1
  4. package/include/node/config.gypi +20 -10
  5. package/include/node/cppgc/allocation.h +6 -7
  6. package/include/node/cppgc/heap-statistics.h +6 -2
  7. package/include/node/cppgc/internal/api-constants.h +1 -1
  8. package/include/node/cppgc/visitor.h +1 -0
  9. package/include/node/libplatform/v8-tracing.h +13 -2
  10. package/include/node/node.h +17 -1
  11. package/include/node/node_object_wrap.h +4 -2
  12. package/include/node/node_version.h +4 -4
  13. package/include/node/uv/unix.h +1 -4
  14. package/include/node/uv/version.h +2 -2
  15. package/include/node/uv/win.h +1 -1
  16. package/include/node/uv.h +7 -8
  17. package/include/node/v8-array-buffer.h +10 -0
  18. package/include/node/v8-callbacks.h +15 -6
  19. package/include/node/v8-context.h +79 -27
  20. package/include/node/v8-data.h +7 -1
  21. package/include/node/v8-debug.h +23 -3
  22. package/include/node/v8-exception.h +7 -4
  23. package/include/node/v8-extension.h +0 -2
  24. package/include/node/v8-external.h +40 -4
  25. package/include/node/v8-function-callback.h +172 -183
  26. package/include/node/v8-function.h +2 -2
  27. package/include/node/v8-initialization.h +29 -0
  28. package/include/node/v8-internal.h +149 -142
  29. package/include/node/v8-isolate.h +35 -22
  30. package/include/node/v8-local-handle.h +1 -1
  31. package/include/node/v8-memory-span.h +4 -59
  32. package/include/node/v8-message.h +0 -8
  33. package/include/node/v8-object.h +85 -92
  34. package/include/node/v8-persistent-handle.h +2 -9
  35. package/include/node/v8-platform.h +167 -58
  36. package/include/node/v8-primitive.h +5 -57
  37. package/include/node/v8-profiler.h +69 -3
  38. package/include/node/v8-promise.h +16 -5
  39. package/include/node/v8-sandbox.h +34 -53
  40. package/include/node/v8-script.h +27 -0
  41. package/include/node/v8-source-location.h +9 -8
  42. package/include/node/v8-statistics.h +8 -0
  43. package/include/node/v8-template.h +44 -122
  44. package/include/node/v8-version.h +3 -3
  45. package/include/node/v8-wasm.h +118 -21
  46. package/include/node/v8config.h +10 -8
  47. package/package.json +1 -1
  48. package/share/doc/node/gdbinit +79 -0
  49. package/share/doc/node/lldb_commands.py +6 -0
  50. package/share/man/man1/node.1 +6 -7
@@ -316,6 +316,29 @@ class JobTask {
316
316
  virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
317
317
  };
318
318
 
319
+ // Allows a thread to temporarily boost another thread's priority to match its
320
+ // own priority. The priority is reset when the object is destroyed, which must
321
+ // happens on the boosted thread.
322
+ class ScopedBoostablePriority {
323
+ public:
324
+ ScopedBoostablePriority() = default;
325
+ virtual ~ScopedBoostablePriority() = default;
326
+ ScopedBoostablePriority(const ScopedBoostablePriority&) = delete;
327
+ ScopedBoostablePriority& operator=(const ScopedBoostablePriority& other) =
328
+ delete;
329
+
330
+ // Boosts the priority of the thread where this ScopedBoostablePriority was
331
+ // created. Can be called from any thread, but requires proper external
332
+ // synchronization with the constructor, destructor and any other call to
333
+ // BoostPriority/Reset(). If called multiple times, only the first call takes
334
+ // effect.
335
+ virtual bool BoostPriority() = 0;
336
+
337
+ // Resets the priority of the thread where this ScopedBoostablePriority was
338
+ // created to its original priority.
339
+ virtual void Reset() = 0;
340
+ };
341
+
319
342
  /**
320
343
  * A "blocking call" refers to any call that causes the calling thread to wait
321
344
  * off-CPU. It includes but is not limited to calls that wait on synchronous
@@ -369,7 +392,7 @@ class ConvertableToTraceFormat {
369
392
  *
370
393
  * Can be implemented by an embedder to record trace events from V8.
371
394
  *
372
- * Will become obsolete in Perfetto SDK build (v8_use_perfetto = true).
395
+ * Will become obsolete in Perfetto build (v8_use_perfetto = true).
373
396
  */
374
397
  class TracingController {
375
398
  public:
@@ -446,6 +469,77 @@ class TracingController {
446
469
  virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
447
470
  };
448
471
 
472
+ // Opaque type representing a handle to a shared memory region.
473
+ class SharedMemoryHandle {
474
+ public:
475
+ // For the handle itself, we use the underlying type (e.g. unsigned int)
476
+ // instead of e.g. mach_port_t to avoid pulling in large OS header files into
477
+ // this header file. Instead, the users of these routines are expected to
478
+ // include the respective OS headers in addition to this one.
479
+
480
+ #if V8_OS_DARWIN
481
+ // A mach_port_t referencing a memory entry object.
482
+ using PlatformHandle = unsigned int;
483
+ #elif V8_OS_FUCHSIA
484
+ // A zx_handle_t to a VMO.
485
+ using PlatformHandle = uint32_t;
486
+ #elif V8_OS_WIN
487
+ // A Windows HANDLE to a file mapping object.
488
+ using PlatformHandle = void*;
489
+ #else
490
+ // A file descriptor.
491
+ using PlatformHandle = int;
492
+ #endif
493
+
494
+ static constexpr SharedMemoryHandle FromPlatformHandle(
495
+ PlatformHandle handle) {
496
+ return SharedMemoryHandle(handle);
497
+ }
498
+
499
+ PlatformHandle GetPlatformHandle() const { return handle_; }
500
+
501
+ private:
502
+ SharedMemoryHandle() = delete;
503
+ explicit constexpr SharedMemoryHandle(PlatformHandle handle)
504
+ : handle_(handle) {}
505
+
506
+ PlatformHandle handle_;
507
+ };
508
+
509
+ #define DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS(Wrap, Unwrap) \
510
+ V8_DEPRECATE_SOON("Use SharedMemoryHandle::FromPlatformHandle instead") \
511
+ inline SharedMemoryHandle Wrap(SharedMemoryHandle::PlatformHandle handle) { \
512
+ return SharedMemoryHandle::FromPlatformHandle(handle); \
513
+ } \
514
+ V8_DEPRECATE_SOON("Use SharedMemoryHandle::GetPlatformHandle instead") \
515
+ inline SharedMemoryHandle::PlatformHandle Unwrap( \
516
+ SharedMemoryHandle handle) { \
517
+ return handle.GetPlatformHandle(); \
518
+ }
519
+
520
+ #if V8_OS_DARWIN
521
+ DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS(SharedMemoryHandleFromMachMemoryEntry,
522
+ MachMemoryEntryFromSharedMemoryHandle)
523
+ #elif V8_OS_FUCHSIA
524
+ DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS(SharedMemoryHandleFromVMO,
525
+ VMOFromSharedMemoryHandle)
526
+ #elif V8_OS_WIN
527
+ DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS(SharedMemoryHandleFromFileMapping,
528
+ FileMappingFromSharedMemoryHandle)
529
+ #else
530
+ DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS(SharedMemoryHandleFromFileDescriptor,
531
+ FileDescriptorFromSharedMemoryHandle)
532
+ #endif
533
+
534
+ #undef DEFINE_SHARED_MEMORY_HANDLE_WRAPPERS
535
+
536
+ // TODO(https://crbug.com/463925491): Remove this type alias once Chromium's
537
+ // "gin" V8 binding migrates off it.
538
+ using PlatformSharedMemoryHandle = std::optional<SharedMemoryHandle>;
539
+ V8_DEPRECATE_SOON("Use std::nullopt instead")
540
+ static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle =
541
+ std::nullopt;
542
+
449
543
  /**
450
544
  * A V8 memory page allocator.
451
545
  *
@@ -703,67 +797,44 @@ class ThreadIsolatedAllocator {
703
797
  virtual int Pkey() const { return -1; }
704
798
  };
705
799
 
706
- // Opaque type representing a handle to a shared memory region.
707
- using PlatformSharedMemoryHandle = intptr_t;
708
- static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1;
709
-
710
- // Conversion routines from the platform-dependent shared memory identifiers
711
- // into the opaque PlatformSharedMemoryHandle type. These use the underlying
712
- // types (e.g. unsigned int) instead of the typedef'd ones (e.g. mach_port_t)
713
- // to avoid pulling in large OS header files into this header file. Instead,
714
- // the users of these routines are expected to include the respecitve OS
715
- // headers in addition to this one.
716
- #if V8_OS_DARWIN
717
- // Convert between a shared memory handle and a mach_port_t referencing a memory
718
- // entry object.
719
- inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry(
720
- unsigned int port) {
721
- return static_cast<PlatformSharedMemoryHandle>(port);
722
- }
723
- inline unsigned int MachMemoryEntryFromSharedMemoryHandle(
724
- PlatformSharedMemoryHandle handle) {
725
- return static_cast<unsigned int>(handle);
726
- }
727
- #elif V8_OS_FUCHSIA
728
- // Convert between a shared memory handle and a zx_handle_t to a VMO.
729
- inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
730
- return static_cast<PlatformSharedMemoryHandle>(handle);
731
- }
732
- inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) {
733
- return static_cast<uint32_t>(handle);
734
- }
735
- #elif V8_OS_WIN
736
- // Convert between a shared memory handle and a Windows HANDLE to a file mapping
737
- // object.
738
- inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileMapping(
739
- void* handle) {
740
- return reinterpret_cast<PlatformSharedMemoryHandle>(handle);
741
- }
742
- inline void* FileMappingFromSharedMemoryHandle(
743
- PlatformSharedMemoryHandle handle) {
744
- return reinterpret_cast<void*>(handle);
800
+ /**
801
+ * Possible permissions for memory pages.
802
+ */
803
+ enum class PagePermissions {
804
+ kNoAccess = 0,
805
+ kRead = 1,
806
+ kWrite = 2,
807
+ kExecute = 4,
808
+ kReadWrite = kRead | kWrite,
809
+ kReadExecute = kRead | kExecute,
810
+ kWriteExecute = kWrite | kExecute,
811
+ kReadWriteExecute = kRead | kWrite | kExecute,
812
+ };
813
+
814
+ inline constexpr PagePermissions operator|(PagePermissions lhs,
815
+ PagePermissions rhs) {
816
+ return static_cast<PagePermissions>(static_cast<int>(lhs) |
817
+ static_cast<int>(rhs));
745
818
  }
746
- #else
747
- // Convert between a shared memory handle and a file descriptor.
748
- inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileDescriptor(int fd) {
749
- return static_cast<PlatformSharedMemoryHandle>(fd);
819
+
820
+ inline constexpr PagePermissions operator&(PagePermissions lhs,
821
+ PagePermissions rhs) {
822
+ return static_cast<PagePermissions>(static_cast<int>(lhs) &
823
+ static_cast<int>(rhs));
750
824
  }
751
- inline int FileDescriptorFromSharedMemoryHandle(
752
- PlatformSharedMemoryHandle handle) {
753
- return static_cast<int>(handle);
825
+
826
+ inline PagePermissions& operator|=(PagePermissions& lhs, PagePermissions rhs) {
827
+ lhs = lhs | rhs;
828
+ return lhs;
754
829
  }
755
- #endif
756
830
 
757
831
  /**
758
- * Possible permissions for memory pages.
832
+ * Helper routine to determine whether one set of page permissions (the lhs) is
833
+ * a subset of another one (the rhs).
759
834
  */
760
- enum class PagePermissions {
761
- kNoAccess,
762
- kRead,
763
- kReadWrite,
764
- kReadWriteExecute,
765
- kReadExecute,
766
- };
835
+ inline constexpr bool IsSubset(PagePermissions lhs, PagePermissions rhs) {
836
+ return (lhs & rhs) == lhs;
837
+ }
767
838
 
768
839
  /**
769
840
  * Class to manage a virtual memory address space.
@@ -970,7 +1041,16 @@ class VirtualAddressSpace {
970
1041
  */
971
1042
  virtual V8_WARN_UNUSED_RESULT Address
972
1043
  AllocateSharedPages(Address hint, size_t size, PagePermissions permissions,
973
- PlatformSharedMemoryHandle handle, uint64_t offset) = 0;
1044
+ SharedMemoryHandle handle, uint64_t offset) = 0;
1045
+
1046
+ // TODO(https://crbug.com/463925491): Remove me once API users change from
1047
+ // PlatformSharedMemoryHandle to SharedMemoryHandle.
1048
+ V8_DEPRECATE_SOON("Use AllocateSharedPages() with SharedMemoryHandle")
1049
+ V8_WARN_UNUSED_RESULT Address AllocateSharedPages(
1050
+ Address hint, size_t size, PagePermissions permissions,
1051
+ std::optional<SharedMemoryHandle> handle, uint64_t offset) {
1052
+ return AllocateSharedPages(hint, size, permissions, *handle, offset);
1053
+ }
974
1054
 
975
1055
  /**
976
1056
  * Frees previously allocated shared pages.
@@ -1038,12 +1118,17 @@ class VirtualAddressSpace {
1038
1118
  * \param key Optional memory protection key for the subspace. If used, the
1039
1119
  * returned subspace will use this key for all its memory pages.
1040
1120
  *
1121
+ * \param handle Optional file descriptor for the subspace. If used, the
1122
+ * returned subspace will use this file descriptor with 0 offset as the
1123
+ * space's underlying file.
1124
+ *
1041
1125
  * \returns a new subspace or nullptr on failure.
1042
1126
  */
1043
1127
  virtual std::unique_ptr<VirtualAddressSpace> AllocateSubspace(
1044
1128
  Address hint, size_t size, size_t alignment,
1045
1129
  PagePermissions max_page_permissions,
1046
- std::optional<MemoryProtectionKeyId> key = std::nullopt) = 0;
1130
+ std::optional<MemoryProtectionKeyId> key = std::nullopt,
1131
+ std::optional<SharedMemoryHandle> handle = std::nullopt) = 0;
1047
1132
 
1048
1133
  //
1049
1134
  // TODO(v8) maybe refactor the methods below before stabilizing the API. For
@@ -1096,6 +1181,22 @@ class VirtualAddressSpace {
1096
1181
  virtual V8_WARN_UNUSED_RESULT bool DecommitPages(Address address,
1097
1182
  size_t size) = 0;
1098
1183
 
1184
+ /**
1185
+ * Sets a name for the address space.
1186
+ *
1187
+ * This is mostly useful for debugging tools. If supported by the system, the
1188
+ * name will for example show up in /proc/$pid/maps next to the virtual
1189
+ * address reservation:
1190
+ *
1191
+ * 2ae700000000-2ae700010000 r--p 00000000 00:00 0 [anon:foo-bar]
1192
+ *
1193
+ * \param name The name of the address space. The name must only contain
1194
+ * alphanumeric characters or dashes.
1195
+ *
1196
+ * \returns true on success, false otherwise.
1197
+ */
1198
+ virtual bool SetName(const std::string& name) { return false; }
1199
+
1099
1200
  private:
1100
1201
  const size_t page_size_;
1101
1202
  const size_t allocation_granularity_;
@@ -1338,6 +1439,14 @@ class Platform {
1338
1439
  return CreateJobImpl(priority, std::move(job_task), location);
1339
1440
  }
1340
1441
 
1442
+ /**
1443
+ * Instantiates a ScopedBoostablePriority to boost a thread's priority.
1444
+ */
1445
+ virtual std::unique_ptr<ScopedBoostablePriority>
1446
+ CreateBoostablePriorityScope() {
1447
+ return nullptr;
1448
+ }
1449
+
1341
1450
  /**
1342
1451
  * Instantiates a ScopedBlockingCall to annotate a scope that may/will block.
1343
1452
  */
@@ -136,15 +136,9 @@ class V8_EXPORT String : public Name {
136
136
  */
137
137
  int Length() const;
138
138
 
139
- /**
140
- * Returns the number of bytes in the UTF-8 encoded
141
- * representation of this string.
142
- */
143
- V8_DEPRECATED("Use Utf8LengthV2 instead.")
144
- int Utf8Length(Isolate* isolate) const;
145
-
146
139
  /**
147
140
  * Returns the number of bytes needed for the Utf8 encoding of this string.
141
+ * TODO(http://crbug.com/373485796): rename back to Utf8Length().
148
142
  */
149
143
  size_t Utf8LengthV2(Isolate* isolate) const;
150
144
 
@@ -163,55 +157,6 @@ class V8_EXPORT String : public Name {
163
157
  */
164
158
  bool ContainsOnlyOneByte() const;
165
159
 
166
- /**
167
- * Write the contents of the string to an external buffer.
168
- * If no arguments are given, expects the buffer to be large
169
- * enough to hold the entire string and NULL terminator. Copies
170
- * the contents of the string and the NULL terminator into the
171
- * buffer.
172
- *
173
- * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
174
- * before the end of the buffer.
175
- *
176
- * Copies up to length characters into the output buffer.
177
- * Only null-terminates if there is enough space in the buffer.
178
- *
179
- * \param buffer The buffer into which the string will be copied.
180
- * \param start The starting position within the string at which
181
- * copying begins.
182
- * \param length The number of characters to copy from the string. For
183
- * WriteUtf8 the number of bytes in the buffer.
184
- * \param nchars_ref The number of characters written, can be NULL.
185
- * \param options Various options that might affect performance of this or
186
- * subsequent operations.
187
- * \return The number of characters copied to the buffer excluding the null
188
- * terminator. For WriteUtf8: The number of bytes copied to the buffer
189
- * including the null terminator (if written).
190
- */
191
- enum WriteOptions {
192
- NO_OPTIONS = 0,
193
- HINT_MANY_WRITES_EXPECTED = 1,
194
- NO_NULL_TERMINATION = 2,
195
- PRESERVE_ONE_BYTE_NULL = 4,
196
- // Used by WriteUtf8 to replace orphan surrogate code units with the
197
- // unicode replacement character. Needs to be set to guarantee valid UTF-8
198
- // output.
199
- REPLACE_INVALID_UTF8 = 8
200
- };
201
-
202
- // 16-bit character codes.
203
- V8_DEPRECATED("Use WriteV2 instead.")
204
- int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
205
- int options = NO_OPTIONS) const;
206
- // One byte characters.
207
- V8_DEPRECATED("Use WriteOneByteV2 instead.")
208
- int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
209
- int length = -1, int options = NO_OPTIONS) const;
210
- // UTF-8 encoded characters.
211
- V8_DEPRECATED("Use WriteUtf8V2 instead.")
212
- int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
213
- int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
214
-
215
160
  struct WriteFlags {
216
161
  enum {
217
162
  kNone = 0,
@@ -237,6 +182,8 @@ class V8_EXPORT String : public Name {
237
182
  * \param length The number of characters to copy from the string.
238
183
  * \param buffer The buffer into which the string will be copied.
239
184
  * \param flags Various flags that influence the behavior of this operation.
185
+ * TODO(http://crbug.com/373485796): rename back to Write() and
186
+ * WriteOneByte().
240
187
  */
241
188
  void WriteV2(Isolate* isolate, uint32_t offset, uint32_t length,
242
189
  uint16_t* buffer, int flags = WriteFlags::kNone) const;
@@ -252,7 +199,7 @@ class V8_EXPORT String : public Name {
252
199
  * the end of the buffer. If null termination is requested, the output buffer
253
200
  * will always be null terminated even if not all characters fit. In that
254
201
  * case, the capacity must be at least one. The required size of the output
255
- * buffer can be determined using Utf8Length().
202
+ * buffer can be determined using Utf8LengthV2().
256
203
  *
257
204
  * \param buffer The buffer into which the string will be written.
258
205
  * \param capacity The number of bytes available in the output buffer.
@@ -261,6 +208,7 @@ class V8_EXPORT String : public Name {
261
208
  * the buffer.
262
209
  * \return The number of bytes copied to the buffer including the null
263
210
  * terminator (if written).
211
+ * TODO(http://crbug.com/373485796): rename back to WriteUtf8().
264
212
  */
265
213
  size_t WriteUtf8V2(Isolate* isolate, char* buffer, size_t capacity,
266
214
  int flags = WriteFlags::kNone,
@@ -48,6 +48,21 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>;
48
48
 
49
49
  namespace v8 {
50
50
 
51
+ /**
52
+ * Identifies which component initiated CPU profiling for proper attribution.
53
+ */
54
+ enum class CpuProfileSource : uint8_t {
55
+ /** Default value when no explicit source is specified. */
56
+ kUnspecified = 0,
57
+ /** Profiling initiated via the DevTools Inspector protocol. */
58
+ kInspector = 1,
59
+ /** Profiling initiated by the embedder (e.g., Blink) via self-profiling API.
60
+ */
61
+ kSelfProfiling = 2,
62
+ /** Profiling initiated internally by V8 (e.g., tracing CPU profiler). */
63
+ kInternal = 3,
64
+ };
65
+
51
66
  struct V8_EXPORT CpuProfileDeoptInfo {
52
67
  /** A pointer to a static string owned by v8. */
53
68
  const char* deopt_reason;
@@ -378,11 +393,13 @@ class V8_EXPORT CpuProfilingOptions {
378
393
  * the profiler's sampling interval.
379
394
  * \param filter_context If specified, profiles will only contain frames
380
395
  * using this context. Other frames will be elided.
396
+ * \param profile_source Identifies the source of this CPU profile.
381
397
  */
382
398
  CpuProfilingOptions(
383
399
  CpuProfilingMode mode = kLeafNodeLineNumbers,
384
400
  unsigned max_samples = kNoSampleLimit, int sampling_interval_us = 0,
385
- MaybeLocal<Context> filter_context = MaybeLocal<Context>());
401
+ MaybeLocal<Context> filter_context = MaybeLocal<Context>(),
402
+ CpuProfileSource profile_source = CpuProfileSource::kUnspecified);
386
403
 
387
404
  CpuProfilingOptions(CpuProfilingOptions&&) = default;
388
405
  CpuProfilingOptions& operator=(CpuProfilingOptions&&) = default;
@@ -390,6 +407,7 @@ class V8_EXPORT CpuProfilingOptions {
390
407
  CpuProfilingMode mode() const { return mode_; }
391
408
  unsigned max_samples() const { return max_samples_; }
392
409
  int sampling_interval_us() const { return sampling_interval_us_; }
410
+ CpuProfileSource profile_source() const { return profile_source_; }
393
411
 
394
412
  private:
395
413
  friend class internal::CpuProfile;
@@ -401,6 +419,7 @@ class V8_EXPORT CpuProfilingOptions {
401
419
  unsigned max_samples_;
402
420
  int sampling_interval_us_;
403
421
  Global<Context> filter_context_;
422
+ CpuProfileSource profile_source_;
404
423
  };
405
424
 
406
425
  /**
@@ -811,6 +830,12 @@ class V8_EXPORT AllocationProfile {
811
830
  * what samples were added or removed between two snapshots.
812
831
  */
813
832
  uint64_t sample_id;
833
+
834
+ /**
835
+ * Indicates whether the sampled allocation is still live or has already
836
+ * been collected by GC.
837
+ */
838
+ bool is_live;
814
839
  };
815
840
 
816
841
  /**
@@ -1041,6 +1066,8 @@ class V8_EXPORT HeapProfiler {
1041
1066
 
1042
1067
  /**
1043
1068
  * Callback interface for retrieving user friendly names of global objects.
1069
+ *
1070
+ * This interface will soon be deprecated in favour of ContextNameResolver.
1044
1071
  */
1045
1072
  class ObjectNameResolver {
1046
1073
  public:
@@ -1054,6 +1081,23 @@ class V8_EXPORT HeapProfiler {
1054
1081
  virtual ~ObjectNameResolver() = default;
1055
1082
  };
1056
1083
 
1084
+ /**
1085
+ * Callback interface for retrieving user friendly names of a V8::Context
1086
+ * objects.
1087
+ */
1088
+ class ContextNameResolver {
1089
+ public:
1090
+ /**
1091
+ * Returns name to be used in the heap snapshot for given node. Returned
1092
+ * string must stay alive until snapshot collection is completed.
1093
+ * If no user friendly name is available return nullptr.
1094
+ */
1095
+ virtual const char* GetName(Local<Context> context) = 0;
1096
+
1097
+ protected:
1098
+ virtual ~ContextNameResolver() = default;
1099
+ };
1100
+
1057
1101
  enum class HeapSnapshotMode {
1058
1102
  /**
1059
1103
  * Heap snapshot for regular developers.
@@ -1083,6 +1127,10 @@ class V8_EXPORT HeapProfiler {
1083
1127
  // NOLINTNEXTLINE
1084
1128
  HeapSnapshotOptions() {}
1085
1129
 
1130
+ // TODO(https://crbug.com/333672197): remove once ObjectNameResolver is
1131
+ // removed.
1132
+ ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(HeapSnapshotOptions)
1133
+
1086
1134
  /**
1087
1135
  * The control used to report intermediate progress to.
1088
1136
  */
@@ -1090,7 +1138,15 @@ class V8_EXPORT HeapProfiler {
1090
1138
  /**
1091
1139
  * The resolver used by the snapshot generator to get names for V8 objects.
1092
1140
  */
1141
+ V8_DEPRECATED("Use context_name_resolver callback instead.")
1093
1142
  ObjectNameResolver* global_object_name_resolver = nullptr;
1143
+ /**
1144
+ * The resolver used by the snapshot generator to get names for v8::Context
1145
+ * objects.
1146
+ * In case both this and |global_object_name_resolver| callbacks are
1147
+ * provided, this one will be used.
1148
+ */
1149
+ ContextNameResolver* context_name_resolver = nullptr;
1094
1150
  /**
1095
1151
  * Mode for taking the snapshot, see `HeapSnapshotMode`.
1096
1152
  */
@@ -1120,10 +1176,20 @@ class V8_EXPORT HeapProfiler {
1120
1176
  *
1121
1177
  * \returns the snapshot.
1122
1178
  */
1179
+ V8_DEPRECATED("Use overload with ContextNameResolver* resolver instead.")
1123
1180
  const HeapSnapshot* TakeHeapSnapshot(
1124
- ActivityControl* control,
1125
- ObjectNameResolver* global_object_name_resolver = nullptr,
1181
+ ActivityControl* control, ObjectNameResolver* global_object_name_resolver,
1126
1182
  bool hide_internals = true, bool capture_numeric_value = false);
1183
+ const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control,
1184
+ ContextNameResolver* resolver,
1185
+ bool hide_internals = true,
1186
+ bool capture_numeric_value = false);
1187
+ // TODO(333672197): remove this version once ObjectNameResolver* overload
1188
+ // is removed.
1189
+ const HeapSnapshot* TakeHeapSnapshot(ActivityControl* control,
1190
+ std::nullptr_t resolver = nullptr,
1191
+ bool hide_internals = true,
1192
+ bool capture_numeric_value = false);
1127
1193
 
1128
1194
  /**
1129
1195
  * Obtains list of Detached JS Wrapper Objects. This functon calls garbage
@@ -19,7 +19,7 @@ class Context;
19
19
  #endif
20
20
 
21
21
  /**
22
- * An instance of the built-in Promise constructor (ES6 draft).
22
+ * An instance of the built-in Promise constructor.
23
23
  */
24
24
  class V8_EXPORT Promise : public Object {
25
25
  public:
@@ -65,10 +65,21 @@ class V8_EXPORT Promise : public Object {
65
65
  };
66
66
 
67
67
  /**
68
- * Register a resolution/rejection handler with a promise.
69
- * The handler is given the respective resolution/rejection value as
70
- * an argument. If the promise is already resolved/rejected, the handler is
71
- * invoked at the end of turn.
68
+ * Register a resolution/rejection handler with a promise. The handler is
69
+ * given the respective resolution/rejection value as an argument. If the
70
+ * promise is already resolved/rejected, the handler is invoked at the end of
71
+ * turn.
72
+ *
73
+ * This performs the PerformPromiseThen abstract operation with a fresh native
74
+ * promise as result, rather than the similar Promise.prototype.then
75
+ * operation. In particular, it does not do species lookup on the Promise
76
+ * constructor, and is therefore guaranteed to return a Promise.
77
+ *
78
+ * https://tc39.es/ecma262/#sec-performpromisethen
79
+ *
80
+ * This is consistent with Promise reactions in WebIDL:
81
+ *
82
+ * https://webidl.spec.whatwg.org/#dfn-perform-steps-once-promise-is-settled
72
83
  */
73
84
  V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context,
74
85
  Local<Function> handler);