node-darwin-x64 25.9.0 → 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 -1436
  2. package/bin/node +0 -0
  3. package/include/node/common.gypi +13 -1
  4. package/include/node/config.gypi +5 -9
  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 +1 -1
  11. package/include/node/node_object_wrap.h +4 -2
  12. package/include/node/node_version.h +3 -3
  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 +0 -6
@@ -10,6 +10,8 @@
10
10
  #include <string.h>
11
11
 
12
12
  #include <atomic>
13
+ #include <compare>
14
+ #include <concepts>
13
15
  #include <iterator>
14
16
  #include <limits>
15
17
  #include <memory>
@@ -18,22 +20,6 @@
18
20
 
19
21
  #include "v8config.h" // NOLINT(build/include_directory)
20
22
 
21
- // TODO(pkasting): Use <compare>/spaceship unconditionally after dropping
22
- // support for old libstdc++ versions.
23
- #if __has_include(<version>)
24
- #include <version>
25
- #endif
26
- #if defined(__cpp_lib_three_way_comparison) && \
27
- __cpp_lib_three_way_comparison >= 201711L && \
28
- defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L
29
- #include <compare>
30
- #include <concepts>
31
-
32
- #define V8_HAVE_SPACESHIP_OPERATOR 1
33
- #else
34
- #define V8_HAVE_SPACESHIP_OPERATOR 0
35
- #endif
36
-
37
23
  namespace v8 {
38
24
 
39
25
  class Array;
@@ -322,6 +308,13 @@ constexpr size_t kExternalPointerTableReservationSize = 256 * MB;
322
308
  // smaller than the maximum table size even after the C++ compiler multiplies
323
309
  // them by 8 to be used as indexes into a table of 64 bit pointers.
324
310
  constexpr uint32_t kExternalPointerIndexShift = 7;
311
+ #elif defined(V8_TARGET_OS_IOS)
312
+ // iOS restricts large memory allocations, with 128 MB being the maximum size we
313
+ // can configure. If we exceed this, SegmentedTable::Initialize will throw a V8
314
+ // out-of-memory error when running the JetStream benchmark
315
+ // (https://browserbench.org/JetStream/).
316
+ constexpr size_t kExternalPointerTableReservationSize = 128 * MB;
317
+ constexpr uint32_t kExternalPointerIndexShift = 8;
325
318
  #else
326
319
  constexpr size_t kExternalPointerTableReservationSize = 512 * MB;
327
320
  constexpr uint32_t kExternalPointerIndexShift = 6;
@@ -421,10 +414,15 @@ constexpr size_t kMaxCppHeapPointers = 0;
421
414
 
422
415
  #endif // V8_COMPRESS_POINTERS
423
416
 
424
- // The number of tags reserved for embedder data. The value is picked
425
- // arbitrarily. In Chrome there are 4 embedders, so at least 4 tags are needed.
426
- // A generic tag was used for embedder data before, so one tag is used for that.
427
- #define V8_EMBEDDER_DATA_TAG_COUNT 5
417
+ // The number of tags reserved for embedder data stored in internal fields. The
418
+ // value is picked arbitrarily, and is slightly larger than the number of tags
419
+ // currently used in Chrome.
420
+ #define V8_EMBEDDER_DATA_TAG_COUNT 15
421
+
422
+ // The number of tags reserved for pointers stored in v8::External. The value is
423
+ // picked arbitrarily, and is slightly larger than the number of tags currently
424
+ // used in Chrome.
425
+ #define V8_EXTERNAL_POINTER_TAG_COUNT 40
428
426
 
429
427
  // Generic tag range struct to represent ranges of type tags.
430
428
  //
@@ -440,6 +438,35 @@ constexpr size_t kMaxCppHeapPointers = 0;
440
438
  // the type check to use even fewer instructions (essentially replace a AND +
441
439
  // SUB with a single AND).
442
440
  //
441
+ // Tag ranges can also to a limited degree be used for union types. For
442
+ // example, with the type graph as above, it would be possible to specify a
443
+ // Union(D, E, F) as the tag range [D, F]. However, this only works as long as
444
+ // the (otherwise independent) types that form the union have adjacent tags.
445
+ //
446
+ //
447
+ // There are broadly speaking two options for performing the type check when
448
+ // given the expected type range and the actual tag of the entry.
449
+ //
450
+ // The first option is to simply have the equivalent of
451
+ //
452
+ // CHECK(expected_tag_range.Contains(actual_tag))
453
+ //
454
+ // This is nice and simple, and friendly to both the branch-predictor and the
455
+ // user/developer as it produces clear error messages. However, this approach
456
+ // may result in quite a bit of code being generated, for example for calling
457
+ // RuntimeAbort from generated code or similar.
458
+ //
459
+ // The second option is to generate code such as
460
+ //
461
+ // if (!expected_tag_range.Contains(actual_tag)) return nullptr;
462
+ //
463
+ // With this, we are also guaranteed to crash safely when the returned pointer
464
+ // is used, but this may result in significantly less code being generated, for
465
+ // example because the compiler can implement this with a single conditional
466
+ // select in combination with the zero register (e.g. on Arm).
467
+ //
468
+ // The choice of which approach to use therefore depends on the use case, the
469
+ // performance and code size constraints, and the importance of debuggability.
443
470
  template <typename Tag>
444
471
  struct TagRange {
445
472
  static_assert(std::is_enum_v<Tag> &&
@@ -447,7 +474,16 @@ struct TagRange {
447
474
  "Tag parameter must be an enum with base type uint16_t");
448
475
 
449
476
  // Construct the inclusive tag range [first, last].
450
- constexpr TagRange(Tag first, Tag last) : first(first), last(last) {}
477
+ constexpr TagRange(Tag first, Tag last) : first(first), last(last) {
478
+ #ifdef V8_ENABLE_CHECKS
479
+ // This would typically be a DCHECK, but that's not available here.
480
+ #if V8_HAS_BUILTIN_UNREACHABLE
481
+ if (first > last) __builtin_unreachable(); // Invalid tag range.
482
+ #elif defined(_MSC_VER)
483
+ if (first > last) __assume(0); // Invalid tag range.
484
+ #endif
485
+ #endif
486
+ }
451
487
 
452
488
  // Construct a tag range consisting of a single tag.
453
489
  //
@@ -475,8 +511,8 @@ struct TagRange {
475
511
  // Need to perform the math with uint32_t. Otherwise, the uint16_ts would
476
512
  // be promoted to (signed) int, allowing the compiler to (wrongly) assume
477
513
  // that an underflow cannot happen as that would be undefined behavior.
478
- return static_cast<uint32_t>(tag) - first <=
479
- static_cast<uint32_t>(last) - first;
514
+ return static_cast<uint32_t>(tag) - static_cast<uint32_t>(first) <=
515
+ static_cast<uint32_t>(last) - static_cast<uint32_t>(first);
480
516
  }
481
517
 
482
518
  constexpr bool Contains(TagRange tag_range) const {
@@ -492,9 +528,9 @@ struct TagRange {
492
528
  return (static_cast<size_t>(first) << 16) | last;
493
529
  }
494
530
 
495
- // Internally we represent tag ranges as half-open ranges [first, last).
496
- const Tag first;
497
- const Tag last;
531
+ // Internally we represent tag ranges as closed ranges [first, last].
532
+ Tag first;
533
+ Tag last;
498
534
  };
499
535
 
500
536
  //
@@ -566,11 +602,15 @@ enum ExternalPointerTag : uint16_t {
566
602
  // Placeholders for embedder data.
567
603
  kFirstEmbedderDataTag,
568
604
  kLastEmbedderDataTag = kFirstEmbedderDataTag + V8_EMBEDDER_DATA_TAG_COUNT - 1,
569
- kEmbedderDataSlotPayloadTag = kLastEmbedderDataTag,
570
- // This tag essentially stands for a `void*` pointer in the V8 API, and it is
571
- // the Embedder's responsibility to ensure type safety (against substitution)
572
- // and lifetime validity of these objects.
573
- kExternalObjectValueTag,
605
+
606
+ // Placeholders for pointers store in v8::External.
607
+ kFirstExternalTypeTag,
608
+ kLastExternalTypeTag =
609
+ kFirstExternalTypeTag + V8_EXTERNAL_POINTER_TAG_COUNT - 1,
610
+ // This tag is used when a fast-api callback as a parameter of type
611
+ // `kPointer`. The V8 fast API is only able to use this generic tag, and is
612
+ // therefore not supposed to be used in Chrome.
613
+ kFastApiExternalTypeTag = kLastExternalTypeTag,
574
614
  kFirstMaybeReadOnlyExternalPointerTag,
575
615
  kFunctionTemplateInfoCallbackTag = kFirstMaybeReadOnlyExternalPointerTag,
576
616
  kAccessorInfoGetterTag,
@@ -621,6 +661,7 @@ enum ExternalPointerTag : uint16_t {
621
661
  kWasmFuncDataTag,
622
662
  kWasmManagedDataTag,
623
663
  kWasmNativeModuleTag,
664
+ kBackingStoreTag,
624
665
  kIcuBreakIteratorTag,
625
666
  kIcuUnicodeStringTag,
626
667
  kIcuListFormatterTag,
@@ -906,6 +947,9 @@ class Internals {
906
947
  static const int kExternalTwoByteRepresentationTag = 0x02;
907
948
  static const int kExternalOneByteRepresentationTag = 0x0a;
908
949
 
950
+ // AccessorInfo::data and InterceptorInfo::data field.
951
+ static const int kCallbackInfoDataOffset = 1 * kApiTaggedSize;
952
+
909
953
  static const uint32_t kNumIsolateDataSlots = 4;
910
954
  static const int kStackGuardSize = 8 * kApiSystemPointerSize;
911
955
  static const int kNumberOfBooleanFlags = 6;
@@ -920,15 +964,11 @@ class Internals {
920
964
  2 * kApiSystemPointerSize + 2 * kApiInt32Size;
921
965
 
922
966
  // ExternalPointerTable and TrustedPointerTable layout guarantees.
923
- static const int kExternalPointerTableBasePointerOffset = 0;
967
+ static const int kExternalEntityTableBasePointerOffset = 0;
924
968
  static const int kSegmentedTableSegmentPoolSize = 4;
925
- static const int kExternalPointerTableSize =
926
- 4 * kApiSystemPointerSize +
927
- kSegmentedTableSegmentPoolSize * sizeof(uint32_t);
928
- static const int kTrustedPointerTableSize =
969
+ static const int kExternalEntityTableSize =
929
970
  4 * kApiSystemPointerSize +
930
971
  kSegmentedTableSegmentPoolSize * sizeof(uint32_t);
931
- static const int kTrustedPointerTableBasePointerOffset = 0;
932
972
 
933
973
  // IsolateData layout guarantees.
934
974
  static const int kIsolateCageBaseOffset = 0;
@@ -972,39 +1012,57 @@ class Internals {
972
1012
  static const int kIsolateExternalPointerTableOffset =
973
1013
  kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize;
974
1014
  static const int kIsolateSharedExternalPointerTableAddressOffset =
975
- kIsolateExternalPointerTableOffset + kExternalPointerTableSize;
1015
+ kIsolateExternalPointerTableOffset + kExternalEntityTableSize;
976
1016
  static const int kIsolateCppHeapPointerTableOffset =
977
1017
  kIsolateSharedExternalPointerTableAddressOffset + kApiSystemPointerSize;
978
1018
  #ifdef V8_ENABLE_SANDBOX
979
1019
  static const int kIsolateTrustedCageBaseOffset =
980
- kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize;
1020
+ kIsolateCppHeapPointerTableOffset + kExternalEntityTableSize;
981
1021
  static const int kIsolateTrustedPointerTableOffset =
982
1022
  kIsolateTrustedCageBaseOffset + kApiSystemPointerSize;
983
1023
  static const int kIsolateSharedTrustedPointerTableAddressOffset =
984
- kIsolateTrustedPointerTableOffset + kTrustedPointerTableSize;
1024
+ kIsolateTrustedPointerTableOffset + kExternalEntityTableSize;
985
1025
  static const int kIsolateTrustedPointerPublishingScopeOffset =
986
1026
  kIsolateSharedTrustedPointerTableAddressOffset + kApiSystemPointerSize;
987
1027
  static const int kIsolateCodePointerTableBaseAddressOffset =
988
1028
  kIsolateTrustedPointerPublishingScopeOffset + kApiSystemPointerSize;
989
- static const int kIsolateApiCallbackThunkArgumentOffset =
1029
+ static const int kIsolateJSDispatchTableOffset =
990
1030
  kIsolateCodePointerTableBaseAddressOffset + kApiSystemPointerSize;
991
1031
  #else
992
- static const int kIsolateApiCallbackThunkArgumentOffset =
993
- kIsolateCppHeapPointerTableOffset + kExternalPointerTableSize;
1032
+ static const int kIsolateJSDispatchTableOffset =
1033
+ kIsolateCppHeapPointerTableOffset + kExternalEntityTableSize;
994
1034
  #endif // V8_ENABLE_SANDBOX
995
1035
  #else
996
- static const int kIsolateApiCallbackThunkArgumentOffset =
1036
+ static const int kIsolateJSDispatchTableOffset =
997
1037
  kIsolateEmbedderDataOffset + kNumIsolateDataSlots * kApiSystemPointerSize;
998
1038
  #endif // V8_COMPRESS_POINTERS
999
- static const int kJSDispatchTableOffset =
1000
- kIsolateApiCallbackThunkArgumentOffset + kApiSystemPointerSize;
1039
+ static const int kIsolateApiCallbackThunkArgumentOffset =
1040
+ kIsolateJSDispatchTableOffset + kExternalEntityTableSize;
1001
1041
  static const int kIsolateRegexpExecVectorArgumentOffset =
1002
- kJSDispatchTableOffset + kApiSystemPointerSize;
1042
+ kIsolateApiCallbackThunkArgumentOffset + kApiSystemPointerSize;
1003
1043
  static const int kContinuationPreservedEmbedderDataOffset =
1004
1044
  kIsolateRegexpExecVectorArgumentOffset + kApiSystemPointerSize;
1005
1045
  static const int kIsolateRootsOffset =
1006
1046
  kContinuationPreservedEmbedderDataOffset + kApiSystemPointerSize;
1007
1047
 
1048
+ #if V8_TARGET_ARCH_PPC64
1049
+ static constexpr int kFrameCPSlotCount = 1;
1050
+ #else
1051
+ static constexpr int kFrameCPSlotCount = 0;
1052
+ #endif
1053
+
1054
+ #if V8_TARGET_ARCH_ARM64
1055
+ // The padding required to keep SP 16-byte aligned.
1056
+ static constexpr int kSPAlignmentSlotCount = 1;
1057
+ #else
1058
+ static constexpr int kSPAlignmentSlotCount = 0;
1059
+ #endif
1060
+
1061
+ static const int kFrameTypeApiCallExit = 18;
1062
+ static const int kFrameTypeApiConstructExit = 19;
1063
+ static const int kFrameTypeApiNamedAccessorExit = 20;
1064
+ static const int kFrameTypeApiIndexedAccessorExit = 21;
1065
+
1008
1066
  // Assert scopes
1009
1067
  static const int kDisallowGarbageCollectionAlign = alignof(uint32_t);
1010
1068
  static const int kDisallowGarbageCollectionSize = sizeof(uint32_t);
@@ -1025,17 +1083,9 @@ class Internals {
1025
1083
  using Tagged_t = uint32_t;
1026
1084
  struct StaticReadOnlyRoot {
1027
1085
  #ifdef V8_ENABLE_WEBASSEMBLY
1028
- #ifdef V8_INTL_SUPPORT
1029
- static constexpr Tagged_t kBuildDependentTheHoleValue = 0x67b9;
1086
+ static constexpr Tagged_t kBuildDependentTheHoleValue = 0x2fffd;
1030
1087
  #else
1031
- static constexpr Tagged_t kBuildDependentTheHoleValue = 0x5b1d;
1032
- #endif
1033
- #else
1034
- #ifdef V8_INTL_SUPPORT
1035
- static constexpr Tagged_t kBuildDependentTheHoleValue = 0x6511;
1036
- #else
1037
- static constexpr Tagged_t kBuildDependentTheHoleValue = 0x5875;
1038
- #endif
1088
+ static constexpr Tagged_t kBuildDependentTheHoleValue = 0xfffd;
1039
1089
  #endif
1040
1090
 
1041
1091
  #define DEF_ROOT(name, value) static constexpr Tagged_t k##name = value;
@@ -1276,7 +1326,7 @@ class Internals {
1276
1326
  V8_INLINE static Address* GetExternalPointerTableBase(v8::Isolate* isolate) {
1277
1327
  Address addr = reinterpret_cast<Address>(isolate) +
1278
1328
  kIsolateExternalPointerTableOffset +
1279
- kExternalPointerTableBasePointerOffset;
1329
+ kExternalEntityTableBasePointerOffset;
1280
1330
  return *reinterpret_cast<Address**>(addr);
1281
1331
  }
1282
1332
 
@@ -1285,7 +1335,7 @@ class Internals {
1285
1335
  Address addr = reinterpret_cast<Address>(isolate) +
1286
1336
  kIsolateSharedExternalPointerTableAddressOffset;
1287
1337
  addr = *reinterpret_cast<Address*>(addr);
1288
- addr += kExternalPointerTableBasePointerOffset;
1338
+ addr += kExternalEntityTableBasePointerOffset;
1289
1339
  return *reinterpret_cast<Address**>(addr);
1290
1340
  }
1291
1341
  #endif
@@ -1328,18 +1378,6 @@ class Internals {
1328
1378
  #endif
1329
1379
  }
1330
1380
 
1331
- V8_DEPRECATED(
1332
- "Use GetCurrentIsolateForSandbox() instead, which is guaranteed to "
1333
- "return the same isolate since https://crrev.com/c/6458560.")
1334
- V8_INLINE static v8::Isolate* GetIsolateForSandbox(Address obj) {
1335
- #ifdef V8_ENABLE_SANDBOX
1336
- return GetCurrentIsolate();
1337
- #else
1338
- // Not used in non-sandbox mode.
1339
- return nullptr;
1340
- #endif
1341
- }
1342
-
1343
1381
  // Returns v8::Isolate::Current(), but without needing to include the
1344
1382
  // v8-isolate.h header.
1345
1383
  V8_EXPORT static v8::Isolate* GetCurrentIsolate();
@@ -1383,6 +1421,34 @@ class Internals {
1383
1421
  #endif // V8_ENABLE_SANDBOX
1384
1422
  }
1385
1423
 
1424
+ V8_INLINE static Address ReadExternalPointerField(
1425
+ v8::Isolate* isolate, Address heap_object_ptr, int offset,
1426
+ ExternalPointerTagRange tag_range) {
1427
+ #ifdef V8_ENABLE_SANDBOX
1428
+ // See src/sandbox/external-pointer-table.h. Logic duplicated here so
1429
+ // it can be inlined and doesn't require an additional call.
1430
+ Address* table = IsSharedExternalPointerType(tag_range)
1431
+ ? GetSharedExternalPointerTableBase(isolate)
1432
+ : GetExternalPointerTableBase(isolate);
1433
+ internal::ExternalPointerHandle handle =
1434
+ ReadRawField<ExternalPointerHandle>(heap_object_ptr, offset);
1435
+ uint32_t index = handle >> kExternalPointerIndexShift;
1436
+ std::atomic<Address>* ptr =
1437
+ reinterpret_cast<std::atomic<Address>*>(&table[index]);
1438
+ Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
1439
+ ExternalPointerTag actual_tag = static_cast<ExternalPointerTag>(
1440
+ (entry & kExternalPointerTagMask) >> kExternalPointerTagShift);
1441
+ if (V8_LIKELY(tag_range.Contains(actual_tag))) {
1442
+ return entry & kExternalPointerPayloadMask;
1443
+ } else {
1444
+ return 0;
1445
+ }
1446
+ return entry;
1447
+ #else
1448
+ return ReadRawField<Address>(heap_object_ptr, offset);
1449
+ #endif // V8_ENABLE_SANDBOX
1450
+ }
1451
+
1386
1452
  #ifdef V8_COMPRESS_POINTERS
1387
1453
  V8_INLINE static Address GetPtrComprCageBaseFromOnHeapAddress(Address addr) {
1388
1454
  return addr & -static_cast<intptr_t>(kPtrComprCageBaseAlignment);
@@ -1439,12 +1505,7 @@ class V8_EXPORT StrongRootAllocatorBase {
1439
1505
  public:
1440
1506
  Heap* heap() const { return heap_; }
1441
1507
 
1442
- friend bool operator==(const StrongRootAllocatorBase& a,
1443
- const StrongRootAllocatorBase& b) {
1444
- // TODO(pkasting): Replace this body with `= default` after dropping support
1445
- // for old gcc versions.
1446
- return a.heap_ == b.heap_;
1447
- }
1508
+ constexpr bool operator==(const StrongRootAllocatorBase&) const = default;
1448
1509
 
1449
1510
  protected:
1450
1511
  explicit StrongRootAllocatorBase(Heap* heap) : heap_(heap) {}
@@ -1480,45 +1541,29 @@ class StrongRootAllocator : private std::allocator<T> {
1480
1541
  using std::allocator<T>::deallocate;
1481
1542
  };
1482
1543
 
1483
- // TODO(pkasting): Replace with `requires` clauses after dropping support for
1484
- // old gcc versions.
1485
- template <typename Iterator, typename = void>
1486
- inline constexpr bool kHaveIteratorConcept = false;
1487
1544
  template <typename Iterator>
1488
- inline constexpr bool kHaveIteratorConcept<
1489
- Iterator, std::void_t<typename Iterator::iterator_concept>> = true;
1545
+ concept HasIteratorConcept = requires { typename Iterator::iterator_concept; };
1490
1546
 
1491
- template <typename Iterator, typename = void>
1492
- inline constexpr bool kHaveIteratorCategory = false;
1493
1547
  template <typename Iterator>
1494
- inline constexpr bool kHaveIteratorCategory<
1495
- Iterator, std::void_t<typename Iterator::iterator_category>> = true;
1548
+ concept HasIteratorCategory =
1549
+ requires { typename Iterator::iterator_category; };
1496
1550
 
1497
1551
  // Helper struct that contains an `iterator_concept` type alias only when either
1498
1552
  // `Iterator` or `std::iterator_traits<Iterator>` do.
1499
1553
  // Default: no alias.
1500
- template <typename Iterator, typename = void>
1554
+ template <typename Iterator>
1501
1555
  struct MaybeDefineIteratorConcept {};
1502
1556
  // Use `Iterator::iterator_concept` if available.
1503
- template <typename Iterator>
1504
- struct MaybeDefineIteratorConcept<
1505
- Iterator, std::enable_if_t<kHaveIteratorConcept<Iterator>>> {
1557
+ template <HasIteratorConcept Iterator>
1558
+ struct MaybeDefineIteratorConcept<Iterator> {
1506
1559
  using iterator_concept = typename Iterator::iterator_concept;
1507
1560
  };
1508
1561
  // Otherwise fall back to `std::iterator_traits<Iterator>` if possible.
1509
1562
  template <typename Iterator>
1510
- struct MaybeDefineIteratorConcept<
1511
- Iterator, std::enable_if_t<kHaveIteratorCategory<Iterator> &&
1512
- !kHaveIteratorConcept<Iterator>>> {
1513
- // There seems to be no feature-test macro covering this, so use the
1514
- // presence of `<ranges>` as a crude proxy, since it was added to the
1515
- // standard as part of the Ranges papers.
1516
- // TODO(pkasting): Add this unconditionally after dropping support for old
1517
- // libstdc++ versions.
1518
- #if __has_include(<ranges>)
1563
+ requires(HasIteratorCategory<Iterator> && !HasIteratorConcept<Iterator>)
1564
+ struct MaybeDefineIteratorConcept<Iterator> {
1519
1565
  using iterator_concept =
1520
1566
  typename std::iterator_traits<Iterator>::iterator_concept;
1521
- #endif
1522
1567
  };
1523
1568
 
1524
1569
  // A class of iterators that wrap some different iterator type.
@@ -1555,11 +1600,8 @@ class WrappedIterator : public MaybeDefineIteratorConcept<Iterator> {
1555
1600
  constexpr WrappedIterator() noexcept = default;
1556
1601
  constexpr explicit WrappedIterator(Iterator it) noexcept : it_(it) {}
1557
1602
 
1558
- // TODO(pkasting): Switch to `requires` and concepts after dropping support
1559
- // for old gcc and libstdc++ versions.
1560
- template <typename OtherIterator, typename OtherElementType,
1561
- typename = std::enable_if_t<
1562
- std::is_convertible_v<OtherIterator, Iterator>>>
1603
+ template <typename OtherIterator, typename OtherElementType>
1604
+ requires std::is_convertible_v<OtherIterator, Iterator>
1563
1605
  constexpr WrappedIterator(
1564
1606
  const WrappedIterator<OtherIterator, OtherElementType>& other) noexcept
1565
1607
  : it_(other.base()) {}
@@ -1579,7 +1621,7 @@ class WrappedIterator : public MaybeDefineIteratorConcept<Iterator> {
1579
1621
  const noexcept {
1580
1622
  return it_ == other.base();
1581
1623
  }
1582
- #if V8_HAVE_SPACESHIP_OPERATOR
1624
+
1583
1625
  template <typename OtherIterator, typename OtherElementType>
1584
1626
  [[nodiscard]] constexpr auto operator<=>(
1585
1627
  const WrappedIterator<OtherIterator, OtherElementType>& other)
@@ -1603,41 +1645,6 @@ class WrappedIterator : public MaybeDefineIteratorConcept<Iterator> {
1603
1645
  : std::partial_ordering::unordered;
1604
1646
  }
1605
1647
  }
1606
- #else
1607
- // Assume that if spaceship isn't present, operator rewriting might not be
1608
- // either.
1609
- template <typename OtherIterator, typename OtherElementType>
1610
- [[nodiscard]] constexpr bool operator!=(
1611
- const WrappedIterator<OtherIterator, OtherElementType>& other)
1612
- const noexcept {
1613
- return it_ != other.base();
1614
- }
1615
-
1616
- template <typename OtherIterator, typename OtherElementType>
1617
- [[nodiscard]] constexpr bool operator<(
1618
- const WrappedIterator<OtherIterator, OtherElementType>& other)
1619
- const noexcept {
1620
- return it_ < other.base();
1621
- }
1622
- template <typename OtherIterator, typename OtherElementType>
1623
- [[nodiscard]] constexpr bool operator<=(
1624
- const WrappedIterator<OtherIterator, OtherElementType>& other)
1625
- const noexcept {
1626
- return it_ <= other.base();
1627
- }
1628
- template <typename OtherIterator, typename OtherElementType>
1629
- [[nodiscard]] constexpr bool operator>(
1630
- const WrappedIterator<OtherIterator, OtherElementType>& other)
1631
- const noexcept {
1632
- return it_ > other.base();
1633
- }
1634
- template <typename OtherIterator, typename OtherElementType>
1635
- [[nodiscard]] constexpr bool operator>=(
1636
- const WrappedIterator<OtherIterator, OtherElementType>& other)
1637
- const noexcept {
1638
- return it_ >= other.base();
1639
- }
1640
- #endif
1641
1648
 
1642
1649
  constexpr WrappedIterator& operator++() noexcept {
1643
1650
  ++it_;
@@ -8,6 +8,7 @@
8
8
  #include <stddef.h>
9
9
  #include <stdint.h>
10
10
 
11
+ #include <functional>
11
12
  #include <memory>
12
13
  #include <string>
13
14
  #include <utility>
@@ -356,16 +357,6 @@ class V8_EXPORT Isolate {
356
357
  */
357
358
  bool allow_atomics_wait = true;
358
359
 
359
- /**
360
- * The following parameters describe the offsets for addressing type info
361
- * for wrapped API objects and are used by the fast C API
362
- * (for details see v8-fast-api-calls.h).
363
- */
364
- V8_DEPRECATE_SOON("This field is unused.")
365
- int embedder_wrapper_type_index = -1;
366
- V8_DEPRECATE_SOON("This field is unused.")
367
- int embedder_wrapper_object_index = -1;
368
-
369
360
  /**
370
361
  * Callbacks to invoke in case of fatal or OOM errors.
371
362
  */
@@ -668,6 +659,7 @@ class V8_EXPORT Isolate {
668
659
  kWithStatement = 180,
669
660
  kHtmlWrapperMethods = 181,
670
661
  kWasmCustomDescriptors = 182,
662
+ kWasmResizableBuffers = 183,
671
663
 
672
664
  // If you add new values here, you'll also need to update Chromium's:
673
665
  // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -861,6 +853,12 @@ class V8_EXPORT Isolate {
861
853
  */
862
854
  void MemoryPressureNotification(MemoryPressureLevel level);
863
855
 
856
+ /**
857
+ * This triggers garbage collections until either `allocate` succeeds, or
858
+ * until v8 gives up and triggers an OOM error.
859
+ */
860
+ bool RetryCustomAllocate(std::function<bool()> allocate);
861
+
864
862
  /**
865
863
  * Optional request from the embedder to tune v8 towards energy efficiency
866
864
  * rather than speed if `battery_saver_mode_enabled` is true, because the
@@ -1001,13 +999,6 @@ class V8_EXPORT Isolate {
1001
999
  */
1002
1000
  void GetHeapStatistics(HeapStatistics* heap_statistics);
1003
1001
 
1004
- /**
1005
- * Get total allocated bytes since isolate creation.
1006
- * This should be used only by Node.JS, since it's a temporary method
1007
- * to avoid breaking ABI on HeapStatistics.
1008
- */
1009
- uint64_t GetTotalAllocatedBytes();
1010
-
1011
1002
  /**
1012
1003
  * Returns the number of spaces in the heap.
1013
1004
  */
@@ -1489,6 +1480,13 @@ class V8_EXPORT Isolate {
1489
1480
  */
1490
1481
  void SetAddCrashKeyCallback(AddCrashKeyCallback);
1491
1482
 
1483
+ /**
1484
+ * Enables the host application to provide a mechanism for allocating a new
1485
+ * crash key and setting/updating values for them.
1486
+ */
1487
+ void SetCrashKeyStringCallbacks(AllocateCrashKeyStringCallback,
1488
+ SetCrashKeyStringCallback);
1489
+
1492
1490
  /**
1493
1491
  * Optional notification that the system is running low on memory.
1494
1492
  * V8 uses these notifications to attempt to free memory.
@@ -1550,6 +1548,19 @@ class V8_EXPORT Isolate {
1550
1548
  */
1551
1549
  void SetIsLoading(bool is_loading);
1552
1550
 
1551
+ /**
1552
+ * Optional notification to tell V8 whether the embedder is currently
1553
+ * handling user input. If the embedder uses this notification, it should
1554
+ * call SetIsInputHandling(true) when input handling starts, and
1555
+ * SetIsInputHandling(false) when it ends.
1556
+ * Calling SetIsInputHandling(true) while handling input, or calling
1557
+ * SetIsInputHandling(false) while not handling input, both have no effect.
1558
+ * V8 uses these notifications to guide heuristics.
1559
+ * This is an unfinished experimental feature. Semantics and implementation
1560
+ * may change frequently.
1561
+ */
1562
+ void SetIsInputHandling(bool is_input_handling);
1563
+
1553
1564
  /**
1554
1565
  * Optional notification to tell V8 whether the embedder is currently frozen.
1555
1566
  * V8 uses these notifications to guide heuristics.
@@ -1662,6 +1673,13 @@ class V8_EXPORT Isolate {
1662
1673
  /** Set the callback to invoke in case of OOM errors. */
1663
1674
  void SetOOMErrorHandler(OOMErrorCallback that);
1664
1675
 
1676
+ /**
1677
+ * \copydoc SetOOMErrorHandler(OOMErrorCallback)
1678
+ *
1679
+ * \param data Additional data that should be passed to the callback.
1680
+ */
1681
+ void SetOOMErrorHandler(OOMErrorCallbackWithData that, void* data);
1682
+
1665
1683
  /**
1666
1684
  * Add a callback to invoke in case the heap size is close to the heap limit.
1667
1685
  * If multiple callbacks are added, only the most recently added callback is
@@ -1715,17 +1733,12 @@ class V8_EXPORT Isolate {
1715
1733
 
1716
1734
  void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1717
1735
 
1718
- void SetWasmImportedStringsEnabledCallback(
1719
- WasmImportedStringsEnabledCallback callback);
1720
-
1721
1736
  void SetWasmCustomDescriptorsEnabledCallback(
1722
1737
  WasmCustomDescriptorsEnabledCallback callback);
1723
1738
 
1724
1739
  void SetSharedArrayBufferConstructorEnabledCallback(
1725
1740
  SharedArrayBufferConstructorEnabledCallback callback);
1726
1741
 
1727
- void SetWasmJSPIEnabledCallback(WasmJSPIEnabledCallback callback);
1728
-
1729
1742
  /**
1730
1743
  * This function can be called by the embedder to signal V8 that the dynamic
1731
1744
  * enabling of features has finished. V8 can now set up dynamically added
@@ -389,7 +389,7 @@ class V8_TRIVIAL_ABI Local : public LocalBase<T>,
389
389
  * objects to which they refer are physically equal.
390
390
  *
391
391
  * If both handles refer to JS objects, this is the same as strict
392
- * non-equality. For primitives, such as numbers or strings, a `true` return
392
+ * non-equality. For primitives, such as numbers or strings, a `false` return
393
393
  * value does not indicate that the values aren't equal in the JavaScript
394
394
  * sense. Use `Value::StrictEquals()` to check primitives for equality.
395
395
  */