libv8-node 22.7.0.4-x86_64-linux → 24.1.0.0-x86_64-linux

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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/allocation.h +11 -13
  4. data/vendor/v8/include/cppgc/default-platform.h +3 -2
  5. data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
  6. data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
  7. data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
  8. data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
  9. data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
  10. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
  11. data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
  12. data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
  13. data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
  14. data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
  15. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  16. data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
  17. data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
  18. data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
  19. data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
  20. data/vendor/v8/include/cppgc/macros.h +21 -0
  21. data/vendor/v8/include/cppgc/member.h +70 -36
  22. data/vendor/v8/include/cppgc/name-provider.h +10 -0
  23. data/vendor/v8/include/cppgc/platform.h +11 -0
  24. data/vendor/v8/include/cppgc/type-traits.h +1 -0
  25. data/vendor/v8/include/cppgc/visitor.h +25 -1
  26. data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
  27. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  28. data/vendor/v8/include/v8-array-buffer.h +143 -46
  29. data/vendor/v8/include/v8-callbacks.h +94 -31
  30. data/vendor/v8/include/v8-context.h +48 -15
  31. data/vendor/v8/include/v8-cppgc.h +5 -56
  32. data/vendor/v8/include/v8-data.h +5 -0
  33. data/vendor/v8/include/v8-date.h +9 -0
  34. data/vendor/v8/include/v8-debug.h +11 -0
  35. data/vendor/v8/include/v8-embedder-heap.h +1 -29
  36. data/vendor/v8/include/v8-exception.h +72 -0
  37. data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
  38. data/vendor/v8/include/v8-fast-api-calls.h +41 -206
  39. data/vendor/v8/include/v8-function-callback.h +190 -78
  40. data/vendor/v8/include/v8-function.h +11 -3
  41. data/vendor/v8/include/v8-handle-base.h +20 -2
  42. data/vendor/v8/include/v8-initialization.h +26 -1
  43. data/vendor/v8/include/v8-inspector.h +10 -3
  44. data/vendor/v8/include/v8-internal.h +638 -315
  45. data/vendor/v8/include/v8-isolate.h +275 -189
  46. data/vendor/v8/include/v8-local-handle.h +69 -42
  47. data/vendor/v8/include/v8-maybe.h +2 -1
  48. data/vendor/v8/include/v8-memory-span.h +149 -24
  49. data/vendor/v8/include/v8-message.h +9 -22
  50. data/vendor/v8/include/v8-metrics.h +14 -0
  51. data/vendor/v8/include/v8-microtask-queue.h +0 -5
  52. data/vendor/v8/include/v8-object.h +291 -37
  53. data/vendor/v8/include/v8-persistent-handle.h +17 -36
  54. data/vendor/v8/include/v8-platform.h +66 -45
  55. data/vendor/v8/include/v8-primitive.h +221 -5
  56. data/vendor/v8/include/v8-profiler.h +51 -2
  57. data/vendor/v8/include/v8-promise.h +2 -2
  58. data/vendor/v8/include/v8-proxy.h +0 -1
  59. data/vendor/v8/include/v8-regexp.h +0 -1
  60. data/vendor/v8/include/v8-sandbox.h +173 -0
  61. data/vendor/v8/include/v8-script.h +65 -17
  62. data/vendor/v8/include/v8-snapshot.h +38 -2
  63. data/vendor/v8/include/v8-source-location.h +6 -1
  64. data/vendor/v8/include/v8-template.h +111 -263
  65. data/vendor/v8/include/v8-trace-categories.h +23 -0
  66. data/vendor/v8/include/v8-traced-handle.h +20 -32
  67. data/vendor/v8/include/v8-typed-array.h +6 -10
  68. data/vendor/v8/include/v8-unwinder-state.h +2 -3
  69. data/vendor/v8/include/v8-unwinder.h +2 -1
  70. data/vendor/v8/include/v8-util.h +1 -117
  71. data/vendor/v8/include/v8-value-serializer-version.h +3 -3
  72. data/vendor/v8/include/v8-value.h +21 -2
  73. data/vendor/v8/include/v8-version.h +4 -4
  74. data/vendor/v8/include/v8-wasm.h +27 -0
  75. data/vendor/v8/include/v8-weak-callback-info.h +20 -12
  76. data/vendor/v8/include/v8.h +3 -3
  77. data/vendor/v8/include/v8config.h +83 -45
  78. data/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a +0 -0
  79. metadata +6 -3
  80. data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -9,6 +9,7 @@
9
9
  #include <stdint.h>
10
10
 
11
11
  #include <memory>
12
+ #include <string>
12
13
  #include <utility>
13
14
 
14
15
  #include "cppgc/common.h"
@@ -17,6 +18,7 @@
17
18
  #include "v8-data.h" // NOLINT(build/include_directory)
18
19
  #include "v8-debug.h" // NOLINT(build/include_directory)
19
20
  #include "v8-embedder-heap.h" // NOLINT(build/include_directory)
21
+ #include "v8-exception.h" // NOLINT(build/include_directory)
20
22
  #include "v8-function-callback.h" // NOLINT(build/include_directory)
21
23
  #include "v8-internal.h" // NOLINT(build/include_directory)
22
24
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
@@ -162,28 +164,6 @@ class V8_EXPORT ResourceConstraints {
162
164
  uint32_t* stack_limit_ = nullptr;
163
165
  };
164
166
 
165
- /**
166
- * Option flags passed to the SetRAILMode function.
167
- * See documentation https://developers.google.com/web/tools/chrome-devtools/
168
- * profile/evaluate-performance/rail
169
- */
170
- enum RAILMode : unsigned {
171
- // Response performance mode: In this mode very low virtual machine latency
172
- // is provided. V8 will try to avoid JavaScript execution interruptions.
173
- // Throughput may be throttled.
174
- PERFORMANCE_RESPONSE,
175
- // Animation performance mode: In this mode low virtual machine latency is
176
- // provided. V8 will try to avoid as many JavaScript execution interruptions
177
- // as possible. Throughput may be throttled. This is the default mode.
178
- PERFORMANCE_ANIMATION,
179
- // Idle performance mode: The embedder is idle. V8 can complete deferred work
180
- // in this mode.
181
- PERFORMANCE_IDLE,
182
- // Load performance mode: In this mode high throughput is provided. V8 may
183
- // turn off latency optimizations.
184
- PERFORMANCE_LOAD
185
- };
186
-
187
167
  /**
188
168
  * Memory pressure level for the MemoryPressureNotification.
189
169
  * kNone hints V8 that there is no memory pressure.
@@ -194,11 +174,95 @@ enum RAILMode : unsigned {
194
174
  */
195
175
  enum class MemoryPressureLevel { kNone, kModerate, kCritical };
196
176
 
177
+ /**
178
+ * Signal for dependants of contexts. Useful for
179
+ * `ContextDisposedNotification()` to implement different strategies.
180
+ */
181
+ enum class ContextDependants {
182
+ /** Context has no dependants. These are usually top-level contexts. */
183
+ kNoDependants,
184
+ /** Context has some dependants, i.e., it may depend on other contexts. This
185
+ is usually the case for inner contexts. */
186
+ kSomeDependants
187
+ };
188
+
197
189
  /**
198
190
  * Indicator for the stack state.
199
191
  */
200
192
  using StackState = cppgc::EmbedderStackState;
201
193
 
194
+ /**
195
+ * The set of V8 isolates in a process is partitioned into groups. Each group
196
+ * has its own sandbox (if V8 was configured with support for the sandbox) and
197
+ * pointer-compression cage (if configured with pointer compression).
198
+ *
199
+ * By default, all isolates are placed in the same group. This is the most
200
+ * efficient configuration in terms of speed and memory use. However, with
201
+ * pointer compression enabled, total heap usage of isolates in a group
202
+ * cannot exceed 4 GB, not counting array buffers and other off-heap storage.
203
+ * Using multiple isolate groups can allow embedders to allocate more than 4GB
204
+ * of objects with pointer compression enabled, if the embedder's use case can
205
+ * span multiple isolates.
206
+ *
207
+ * Creating an isolate group reserves a range of virtual memory addresses. A
208
+ * group's memory mapping will be released when the last isolate in the group is
209
+ * disposed, and there are no more live IsolateGroup objects that refer to it.
210
+ *
211
+ * Note that Isolate groups are reference counted, and
212
+ * the IsolateGroup type is a reference to one.
213
+ *
214
+ * Note that it's not going to be possible to pass shared JS objects
215
+ * across IsolateGroup boundary.
216
+ *
217
+ */
218
+ class V8_EXPORT IsolateGroup {
219
+ public:
220
+ /**
221
+ * Get the default isolate group. If this V8's build configuration only
222
+ * supports a single group, this is a reference to that single group.
223
+ * Otherwise this is a group like any other, distinguished only
224
+ * in that it is the first group.
225
+ */
226
+ static IsolateGroup GetDefault();
227
+
228
+ /**
229
+ * Return true if new isolate groups can be created at run-time, or false if
230
+ * all isolates must be in the same group.
231
+ */
232
+ static bool CanCreateNewGroups();
233
+
234
+ /**
235
+ * Create a new isolate group. If this V8's build configuration only supports
236
+ * a single group, abort.
237
+ */
238
+ static IsolateGroup Create();
239
+
240
+ IsolateGroup(IsolateGroup&& other);
241
+ IsolateGroup& operator=(IsolateGroup&& other);
242
+
243
+ IsolateGroup(const IsolateGroup&);
244
+ IsolateGroup& operator=(const IsolateGroup&);
245
+
246
+ ~IsolateGroup();
247
+
248
+ bool operator==(const IsolateGroup& other) const {
249
+ return isolate_group_ == other.isolate_group_;
250
+ }
251
+
252
+ bool operator!=(const IsolateGroup& other) const {
253
+ return !operator==(other);
254
+ }
255
+
256
+ private:
257
+ friend class Isolate;
258
+ friend class ArrayBuffer::Allocator;
259
+
260
+ // The isolate_group pointer should be already acquired.
261
+ explicit IsolateGroup(internal::IsolateGroup*&& isolate_group);
262
+
263
+ internal::IsolateGroup* isolate_group_;
264
+ };
265
+
202
266
  /**
203
267
  * Isolate represents an isolated instance of the V8 engine. V8 isolates have
204
268
  * completely separate states. Objects from one isolate must not be used in
@@ -276,11 +340,6 @@ class V8_EXPORT Isolate {
276
340
  */
277
341
  bool allow_atomics_wait = true;
278
342
 
279
- /**
280
- * Termination is postponed when there is no active SafeForTerminationScope.
281
- */
282
- bool only_terminate_in_safe_scope = false;
283
-
284
343
  /**
285
344
  * The following parameters describe the offsets for addressing type info
286
345
  * for wrapped API objects and are used by the fast C API
@@ -389,21 +448,6 @@ class V8_EXPORT Isolate {
389
448
  friend class internal::ThreadLocalTop;
390
449
  };
391
450
 
392
- /**
393
- * This scope allows terminations inside direct V8 API calls and forbid them
394
- * inside any recursive API calls without explicit SafeForTerminationScope.
395
- */
396
- class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
397
- public:
398
- V8_DEPRECATE_SOON("All code should be safe for termination")
399
- explicit SafeForTerminationScope(v8::Isolate* v8_isolate) {}
400
- ~SafeForTerminationScope() {}
401
-
402
- // Prevent copying of Scope objects.
403
- SafeForTerminationScope(const SafeForTerminationScope&) = delete;
404
- SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete;
405
- };
406
-
407
451
  /**
408
452
  * Types of garbage collections that can be requested via
409
453
  * RequestGarbageCollectionForTesting.
@@ -542,7 +586,7 @@ class V8_EXPORT Isolate {
542
586
  kDurationFormat = 117,
543
587
  kInvalidatedNumberStringNotRegexpLikeProtector = 118,
544
588
  kOBSOLETE_RegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119,
545
- kImportAssertionDeprecatedSyntax = 120,
589
+ kOBSOLETE_ImportAssertionDeprecatedSyntax = 120,
546
590
  kLocaleInfoObsoletedGetters = 121,
547
591
  kLocaleInfoFunctions = 122,
548
592
  kCompileHintsMagicAll = 123,
@@ -563,6 +607,33 @@ class V8_EXPORT Isolate {
563
607
  kWasmExnRef = 138,
564
608
  kWasmTypedFuncRef = 139,
565
609
  kInvalidatedStringWrapperToPrimitiveProtector = 140,
610
+ kDocumentAllLegacyCall = 141,
611
+ kDocumentAllLegacyConstruct = 142,
612
+ kConsoleContext = 143,
613
+ kWasmImportedStringsUtf8 = 144,
614
+ kResizableArrayBuffer = 145,
615
+ kGrowableSharedArrayBuffer = 146,
616
+ kArrayByCopy = 147,
617
+ kArrayFromAsync = 148,
618
+ kIteratorMethods = 149,
619
+ kPromiseAny = 150,
620
+ kSetMethods = 151,
621
+ kArrayFindLast = 152,
622
+ kArrayGroup = 153,
623
+ kArrayBufferTransfer = 154,
624
+ kPromiseWithResolvers = 155,
625
+ kAtomicsWaitAsync = 156,
626
+ kExtendingNonExtensibleWithPrivate = 157,
627
+ kPromiseTry = 158,
628
+ kStringReplaceAll = 159,
629
+ kStringWellFormed = 160,
630
+ kWeakReferences = 161,
631
+ kErrorIsError = 162,
632
+ kInvalidatedTypedArrayLengthLookupChainProtector = 163,
633
+ kRegExpEscape = 164,
634
+ kFloat16Array = 165,
635
+ kExplicitResourceManagement = 166,
636
+ kWasmBranchHinting = 167,
566
637
 
567
638
  // If you add new values here, you'll also need to update Chromium's:
568
639
  // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -580,6 +651,21 @@ class V8_EXPORT Isolate {
580
651
  kMessageWarning,
581
652
  };
582
653
 
654
+ // The different priorities that an isolate can have.
655
+ enum class Priority {
656
+ // The isolate does not relate to content that is currently important
657
+ // to the user. Lowest priority.
658
+ kBestEffort,
659
+
660
+ // The isolate contributes to content that is visible to the user, like a
661
+ // visible iframe that's not interacted directly with. High priority.
662
+ kUserVisible,
663
+
664
+ // The isolate contributes to content that is of the utmost importance to
665
+ // the user, like visible content in the focused window. Highest priority.
666
+ kUserBlocking,
667
+ };
668
+
583
669
  using UseCounterCallback = void (*)(Isolate* isolate,
584
670
  UseCounterFeature feature);
585
671
 
@@ -588,9 +674,9 @@ class V8_EXPORT Isolate {
588
674
  * currently entered isolate.
589
675
  *
590
676
  * Only Isolate::GetData() and Isolate::SetData(), which access the
591
- * embedder-controlled parts of the isolate, are allowed to be called on the
592
- * uninitialized isolate. To initialize the isolate, call
593
- * `Isolate::Initialize()` or initialize a `SnapshotCreator`.
677
+ * embedder-controlled parts of the isolate, as well as Isolate::GetGroup(),
678
+ * are allowed to be called on the uninitialized isolate. To initialize the
679
+ * isolate, call `Isolate::Initialize()` or initialize a `SnapshotCreator`.
594
680
  *
595
681
  * When an isolate is no longer used its resources should be freed
596
682
  * by calling Dispose(). Using the delete operator is not allowed.
@@ -598,6 +684,12 @@ class V8_EXPORT Isolate {
598
684
  * V8::Initialize() must have run prior to this.
599
685
  */
600
686
  static Isolate* Allocate();
687
+ static Isolate* Allocate(const IsolateGroup& group);
688
+
689
+ /**
690
+ * Return the group for this isolate.
691
+ */
692
+ IsolateGroup GetGroup() const;
601
693
 
602
694
  /**
603
695
  * Initialize an Isolate previously allocated by Isolate::Allocate().
@@ -614,6 +706,7 @@ class V8_EXPORT Isolate {
614
706
  * V8::Initialize() must have run prior to this.
615
707
  */
616
708
  static Isolate* New(const CreateParams& params);
709
+ static Isolate* New(const IsolateGroup& group, const CreateParams& params);
617
710
 
618
711
  /**
619
712
  * Returns the entered isolate for the current thread or NULL in
@@ -671,6 +764,18 @@ class V8_EXPORT Isolate {
671
764
  void SetHostImportModuleDynamicallyCallback(
672
765
  HostImportModuleDynamicallyCallback callback);
673
766
 
767
+ /**
768
+ * This specifies the callback called by the upcoming dynamic
769
+ * import() and import.source() language feature to load modules.
770
+ *
771
+ * This API is experimental and is expected to be changed or removed in the
772
+ * future. The callback is currently only called when for source-phase
773
+ * imports. Evaluation-phase imports use the existing
774
+ * HostImportModuleDynamicallyCallback callback.
775
+ */
776
+ void SetHostImportModuleWithPhaseDynamicallyCallback(
777
+ HostImportModuleWithPhaseDynamicallyCallback callback);
778
+
674
779
  /**
675
780
  * This specifies the callback called by the upcoming import.meta
676
781
  * language feature to retrieve host-defined meta data for a module.
@@ -685,17 +790,33 @@ class V8_EXPORT Isolate {
685
790
  void SetHostCreateShadowRealmContextCallback(
686
791
  HostCreateShadowRealmContextCallback callback);
687
792
 
793
+ /**
794
+ * Set the callback that checks whether a Error.isError should return true for
795
+ * a JSApiWrapper object, i.e. whether it represents a native JS error. For
796
+ * example, in an HTML embedder, DOMExceptions are considered native errors.
797
+ */
798
+ void SetIsJSApiWrapperNativeErrorCallback(
799
+ IsJSApiWrapperNativeErrorCallback callback);
800
+
688
801
  /**
689
802
  * This specifies the callback called when the stack property of Error
690
803
  * is accessed.
691
804
  */
692
805
  void SetPrepareStackTraceCallback(PrepareStackTraceCallback callback);
693
806
 
807
+ /**
808
+ * Get the stackTraceLimit property of Error.
809
+ */
810
+ int GetStackTraceLimit();
811
+
694
812
  #if defined(V8_OS_WIN)
695
813
  /**
696
814
  * This specifies the callback called when an ETW tracing session starts.
697
815
  */
816
+ V8_DEPRECATE_SOON("Use SetFilterETWSessionByURL2Callback instead")
698
817
  void SetFilterETWSessionByURLCallback(FilterETWSessionByURLCallback callback);
818
+ void SetFilterETWSessionByURL2Callback(
819
+ FilterETWSessionByURL2Callback callback);
699
820
  #endif // V8_OS_WIN
700
821
 
701
822
  /**
@@ -714,6 +835,14 @@ class V8_EXPORT Isolate {
714
835
  */
715
836
  void SetBatterySaverMode(bool battery_saver_mode_enabled);
716
837
 
838
+ /**
839
+ * Optional request from the embedder to tune v8 towards memory efficiency
840
+ * rather than speed if `memory_saver_mode_enabled` is true, because the
841
+ * embedder is in memory saver mode. If false, the correct tuning is left
842
+ * to v8 to decide.
843
+ */
844
+ void SetMemorySaverMode(bool memory_saver_mode_enabled);
845
+
717
846
  /**
718
847
  * Drop non-essential caches. Should only be called from testing code.
719
848
  * The method can potentially block for a long time and does not necessarily
@@ -743,11 +872,26 @@ class V8_EXPORT Isolate {
743
872
  void Exit();
744
873
 
745
874
  /**
746
- * Disposes the isolate. The isolate must not be entered by any
875
+ * Deinitializes and frees the isolate. The isolate must not be entered by any
747
876
  * thread to be disposable.
748
877
  */
749
878
  void Dispose();
750
879
 
880
+ /**
881
+ * Deinitializes the isolate, but does not free the address. The isolate must
882
+ * not be entered by any thread to be deinitializable. Embedders must call
883
+ * Isolate::Free() to free the isolate afterwards.
884
+ */
885
+ void Deinitialize();
886
+
887
+ /**
888
+ * Frees the memory allocated for the isolate. Can only be called after the
889
+ * Isolate has already been deinitialized with Isolate::Deinitialize(). After
890
+ * the isolate is freed, the next call to Isolate::New() or
891
+ * Isolate::Allocate() might return the same address that just get freed.
892
+ */
893
+ static void Free(Isolate* isolate);
894
+
751
895
  /**
752
896
  * Dumps activated low-level V8 internal stats. This can be used instead
753
897
  * of performing a full isolate disposal.
@@ -881,18 +1025,13 @@ class V8_EXPORT Isolate {
881
1025
  size_t frames_limit, SampleInfo* sample_info);
882
1026
 
883
1027
  /**
884
- * Adjusts the amount of registered external memory. Used to give V8 an
885
- * indication of the amount of externally allocated memory that is kept alive
886
- * by JavaScript objects. V8 uses this to decide when to perform global
887
- * garbage collections. Registering externally allocated memory will trigger
888
- * global garbage collections more often than it would otherwise in an attempt
889
- * to garbage collect the JavaScript objects that keep the externally
890
- * allocated memory alive.
1028
+ * Adjusts the amount of registered external memory.
891
1029
  *
892
1030
  * \param change_in_bytes the change in externally allocated memory that is
893
1031
  * kept alive by JavaScript objects.
894
1032
  * \returns the adjusted value.
895
1033
  */
1034
+ V8_DEPRECATE_SOON("Use ExternalMemoryAccounter instead.")
896
1035
  int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
897
1036
 
898
1037
  /**
@@ -932,6 +1071,12 @@ class V8_EXPORT Isolate {
932
1071
  */
933
1072
  Local<Context> GetIncumbentContext();
934
1073
 
1074
+ /**
1075
+ * Returns the host defined options set for currently running script or
1076
+ * module, if available.
1077
+ */
1078
+ MaybeLocal<Data> GetCurrentHostDefinedOptions();
1079
+
935
1080
  /**
936
1081
  * Schedules a v8::Exception::Error with the given message.
937
1082
  * See ThrowException for more details. Templatized to provide compile-time
@@ -951,6 +1096,14 @@ class V8_EXPORT Isolate {
951
1096
  */
952
1097
  Local<Value> ThrowException(Local<Value> exception);
953
1098
 
1099
+ /**
1100
+ * Returns true if an exception was thrown but not processed yet by an
1101
+ * exception handler on JavaScript side or by v8::TryCatch handler.
1102
+ *
1103
+ * This is an experimental feature and may still change significantly.
1104
+ */
1105
+ bool HasPendingException();
1106
+
954
1107
  using GCCallback = void (*)(Isolate* isolate, GCType type,
955
1108
  GCCallbackFlags flags);
956
1109
  using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
@@ -1034,28 +1187,14 @@ class V8_EXPORT Isolate {
1034
1187
  */
1035
1188
  void SetEmbedderRootsHandler(EmbedderRootsHandler* handler);
1036
1189
 
1037
- /**
1038
- * Attaches a managed C++ heap as an extension to the JavaScript heap. The
1039
- * embedder maintains ownership of the CppHeap. At most one C++ heap can be
1040
- * attached to V8.
1041
- *
1042
- * Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see
1043
- * CppHeap.
1044
- *
1045
- * If a CppHeap is set via CreateParams, then this call is a noop.
1046
- */
1047
- V8_DEPRECATE_SOON(
1048
- "Set the heap on Isolate creation using CreateParams instead.")
1049
- void AttachCppHeap(CppHeap*);
1190
+ using ReleaseCppHeapCallback = void (*)(std::unique_ptr<CppHeap>);
1050
1191
 
1051
1192
  /**
1052
- * Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
1053
- *
1054
- * If a CppHeap is set via CreateParams, then this call is a noop.
1193
+ * Sets a callback on the isolate that gets called when the CppHeap gets
1194
+ * detached. The callback can then either take ownership of the CppHeap, or
1195
+ * the CppHeap gets deallocated.
1055
1196
  */
1056
- V8_DEPRECATE_SOON(
1057
- "Set the heap on Isolate creation using CreateParams instead.")
1058
- void DetachCppHeap();
1197
+ void SetReleaseCppHeapCallbackForTesting(ReleaseCppHeapCallback callback);
1059
1198
 
1060
1199
  /**
1061
1200
  * \returns the C++ heap managed by V8. Only available if such a heap has been
@@ -1063,85 +1202,6 @@ class V8_EXPORT Isolate {
1063
1202
  */
1064
1203
  CppHeap* GetCppHeap() const;
1065
1204
 
1066
- /**
1067
- * Use for |AtomicsWaitCallback| to indicate the type of event it receives.
1068
- */
1069
- enum class AtomicsWaitEvent {
1070
- /** Indicates that this call is happening before waiting. */
1071
- kStartWait,
1072
- /** `Atomics.wait()` finished because of an `Atomics.wake()` call. */
1073
- kWokenUp,
1074
- /** `Atomics.wait()` finished because it timed out. */
1075
- kTimedOut,
1076
- /** `Atomics.wait()` was interrupted through |TerminateExecution()|. */
1077
- kTerminatedExecution,
1078
- /** `Atomics.wait()` was stopped through |AtomicsWaitWakeHandle|. */
1079
- kAPIStopped,
1080
- /** `Atomics.wait()` did not wait, as the initial condition was not met. */
1081
- kNotEqual
1082
- };
1083
-
1084
- /**
1085
- * Passed to |AtomicsWaitCallback| as a means of stopping an ongoing
1086
- * `Atomics.wait` call.
1087
- */
1088
- class V8_EXPORT AtomicsWaitWakeHandle {
1089
- public:
1090
- /**
1091
- * Stop this `Atomics.wait()` call and call the |AtomicsWaitCallback|
1092
- * with |kAPIStopped|.
1093
- *
1094
- * This function may be called from another thread. The caller has to ensure
1095
- * through proper synchronization that it is not called after
1096
- * the finishing |AtomicsWaitCallback|.
1097
- *
1098
- * Note that the ECMAScript specification does not plan for the possibility
1099
- * of wakeups that are neither coming from a timeout or an `Atomics.wake()`
1100
- * call, so this may invalidate assumptions made by existing code.
1101
- * The embedder may accordingly wish to schedule an exception in the
1102
- * finishing |AtomicsWaitCallback|.
1103
- */
1104
- void Wake();
1105
- };
1106
-
1107
- /**
1108
- * Embedder callback for `Atomics.wait()` that can be added through
1109
- * |SetAtomicsWaitCallback|.
1110
- *
1111
- * This will be called just before starting to wait with the |event| value
1112
- * |kStartWait| and after finishing waiting with one of the other
1113
- * values of |AtomicsWaitEvent| inside of an `Atomics.wait()` call.
1114
- *
1115
- * |array_buffer| will refer to the underlying SharedArrayBuffer,
1116
- * |offset_in_bytes| to the location of the waited-on memory address inside
1117
- * the SharedArrayBuffer.
1118
- *
1119
- * |value| and |timeout_in_ms| will be the values passed to
1120
- * the `Atomics.wait()` call. If no timeout was used, |timeout_in_ms|
1121
- * will be `INFINITY`.
1122
- *
1123
- * In the |kStartWait| callback, |stop_handle| will be an object that
1124
- * is only valid until the corresponding finishing callback and that
1125
- * can be used to stop the wait process while it is happening.
1126
- *
1127
- * This callback may schedule exceptions, *unless* |event| is equal to
1128
- * |kTerminatedExecution|.
1129
- */
1130
- using AtomicsWaitCallback = void (*)(AtomicsWaitEvent event,
1131
- Local<SharedArrayBuffer> array_buffer,
1132
- size_t offset_in_bytes, int64_t value,
1133
- double timeout_in_ms,
1134
- AtomicsWaitWakeHandle* stop_handle,
1135
- void* data);
1136
-
1137
- /**
1138
- * Set a new |AtomicsWaitCallback|. This overrides an earlier
1139
- * |AtomicsWaitCallback|, if there was any. If |callback| is nullptr,
1140
- * this unsets the callback. |data| will be passed to the callback
1141
- * as its last parameter.
1142
- */
1143
- void SetAtomicsWaitCallback(AtomicsWaitCallback callback, void* data);
1144
-
1145
1205
  using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
1146
1206
 
1147
1207
  /**
@@ -1273,6 +1333,15 @@ class V8_EXPORT Isolate {
1273
1333
  */
1274
1334
  void SetPromiseRejectCallback(PromiseRejectCallback callback);
1275
1335
 
1336
+ /**
1337
+ * This is a part of experimental Api and might be changed without further
1338
+ * notice.
1339
+ * Do not use it.
1340
+ *
1341
+ * Set callback to notify about a new exception being thrown.
1342
+ */
1343
+ void SetExceptionPropagationCallback(ExceptionPropagationCallback callback);
1344
+
1276
1345
  /**
1277
1346
  * Runs the default MicrotaskQueue until it gets empty and perform other
1278
1347
  * microtask checkpoint steps, such as calling ClearKeptObjects. Asserts that
@@ -1362,24 +1431,6 @@ class V8_EXPORT Isolate {
1362
1431
  */
1363
1432
  void SetAddCrashKeyCallback(AddCrashKeyCallback);
1364
1433
 
1365
- /**
1366
- * Optional notification that the embedder is idle.
1367
- * V8 uses the notification to perform garbage collection.
1368
- * This call can be used repeatedly if the embedder remains idle.
1369
- * Returns true if the embedder should stop calling IdleNotificationDeadline
1370
- * until real work has been done. This indicates that V8 has done
1371
- * as much cleanup as it will be able to do.
1372
- *
1373
- * The deadline_in_seconds argument specifies the deadline V8 has to finish
1374
- * garbage collection work. deadline_in_seconds is compared with
1375
- * MonotonicallyIncreasingTime() and should be based on the same timebase as
1376
- * that function. There is no guarantee that the actual work will be done
1377
- * within the time limit.
1378
- */
1379
- V8_DEPRECATE_SOON(
1380
- "Use MemoryPressureNotification() to influence the GC schedule.")
1381
- bool IdleNotificationDeadline(double deadline_in_seconds);
1382
-
1383
1434
  /**
1384
1435
  * Optional notification that the system is running low on memory.
1385
1436
  * V8 uses these notifications to attempt to free memory.
@@ -1395,33 +1446,59 @@ class V8_EXPORT Isolate {
1395
1446
  * The optional parameter |dependant_context| specifies whether the disposed
1396
1447
  * context was depending on state from other contexts or not.
1397
1448
  */
1449
+ V8_DEPRECATE_SOON("Use version that passes ContextDependants.")
1398
1450
  int ContextDisposedNotification(bool dependant_context = true);
1399
1451
 
1452
+ /**
1453
+ * Optional notification that a context has been disposed. V8 uses these
1454
+ * notifications to guide heuristics on e.g. GC or compilers.
1455
+ *
1456
+ * \param dependants A signal on whether this context possibly had any
1457
+ * dependants.
1458
+ */
1459
+ void ContextDisposedNotification(ContextDependants dependants);
1460
+
1400
1461
  /**
1401
1462
  * Optional notification that the isolate switched to the foreground.
1402
1463
  * V8 uses these notifications to guide heuristics.
1403
1464
  */
1465
+ V8_DEPRECATE_SOON("Use SetPriority(Priority::kUserBlocking) instead")
1404
1466
  void IsolateInForegroundNotification();
1405
1467
 
1406
1468
  /**
1407
1469
  * Optional notification that the isolate switched to the background.
1408
1470
  * V8 uses these notifications to guide heuristics.
1409
1471
  */
1472
+ V8_DEPRECATE_SOON("Use SetPriority(Priority::kBestEffort) instead")
1410
1473
  void IsolateInBackgroundNotification();
1411
1474
 
1412
1475
  /**
1413
- * Optional notification to tell V8 the current performance requirements
1414
- * of the embedder based on RAIL.
1476
+ * Optional notification that the isolate changed `priority`.
1477
+ * V8 uses the priority value to guide heuristics.
1478
+ */
1479
+ void SetPriority(Priority priority);
1480
+
1481
+ /**
1482
+ * Optional notification to tell V8 whether the embedder is currently loading
1483
+ * resources. If the embedder uses this notification, it should call
1484
+ * SetIsLoading(true) when loading starts and SetIsLoading(false) when it
1485
+ * ends.
1486
+ * It's valid to call SetIsLoading(true) again while loading, which will
1487
+ * update the timestamp when V8 considers the load started. Calling
1488
+ * SetIsLoading(false) while not loading does nothing.
1415
1489
  * V8 uses these notifications to guide heuristics.
1416
1490
  * This is an unfinished experimental feature. Semantics and implementation
1417
1491
  * may change frequently.
1418
1492
  */
1419
- void SetRAILMode(RAILMode rail_mode);
1493
+ void SetIsLoading(bool is_loading);
1420
1494
 
1421
1495
  /**
1422
- * Update load start time of the RAIL mode
1496
+ * Optional notification to tell V8 whether the embedder is currently frozen.
1497
+ * V8 uses these notifications to guide heuristics.
1498
+ * This is an unfinished experimental feature. Semantics and implementation
1499
+ * may change frequently.
1423
1500
  */
1424
- void UpdateLoadStartTime();
1501
+ void Freeze(bool is_frozen);
1425
1502
 
1426
1503
  /**
1427
1504
  * Optional notification to tell V8 the current isolate is used for debugging
@@ -1592,6 +1669,9 @@ class V8_EXPORT Isolate {
1592
1669
  * Register callback to control whether compile hints magic comments are
1593
1670
  * enabled.
1594
1671
  */
1672
+ V8_DEPRECATED(
1673
+ "Will be removed, use ScriptCompiler::CompileOptions for enabling the "
1674
+ "compile hints magic comments")
1595
1675
  void SetJavaScriptCompileHintsMagicEnabledCallback(
1596
1676
  JavaScriptCompileHintsMagicEnabledCallback callback);
1597
1677
 
@@ -1651,14 +1731,6 @@ class V8_EXPORT Isolate {
1651
1731
  bool capture, int frame_limit = 10,
1652
1732
  StackTrace::StackTraceOptions options = StackTrace::kOverview);
1653
1733
 
1654
- /**
1655
- * Iterates through all external resources referenced from current isolate
1656
- * heap. GC is not invoked prior to iterating, therefore there is no
1657
- * guarantee that visited objects are still alive.
1658
- */
1659
- V8_DEPRECATE_SOON("Will be removed without replacement. crbug.com/v8/14172")
1660
- void VisitExternalResources(ExternalResourceVisitor* visitor);
1661
-
1662
1734
  /**
1663
1735
  * Check if this isolate is in use.
1664
1736
  * True if at least one thread Enter'ed this isolate.
@@ -1711,6 +1783,17 @@ class V8_EXPORT Isolate {
1711
1783
  */
1712
1784
  void LocaleConfigurationChangeNotification();
1713
1785
 
1786
+ /**
1787
+ * Returns the default locale in a string if Intl support is enabled.
1788
+ * Otherwise returns an empty string.
1789
+ */
1790
+ std::string GetDefaultLocale();
1791
+
1792
+ /**
1793
+ * Returns the hash seed for that isolate, for testing purposes.
1794
+ */
1795
+ uint64_t GetHashSeed();
1796
+
1714
1797
  Isolate() = delete;
1715
1798
  ~Isolate() = delete;
1716
1799
  Isolate(const Isolate&) = delete;
@@ -1725,9 +1808,12 @@ class V8_EXPORT Isolate {
1725
1808
  private:
1726
1809
  template <class K, class V, class Traits>
1727
1810
  friend class PersistentValueMapBase;
1811
+ friend class ExternalMemoryAccounter;
1728
1812
 
1729
- internal::Address* GetDataFromSnapshotOnce(size_t index);
1730
- void ReportExternalAllocationLimitReached();
1813
+ internal::ValueHelper::InternalRepresentationType GetDataFromSnapshotOnce(
1814
+ size_t index);
1815
+ int64_t AdjustAmountOfExternalAllocatedMemoryImpl(int64_t change_in_bytes);
1816
+ void HandleExternalMemoryInterrupt();
1731
1817
  };
1732
1818
 
1733
1819
  void Isolate::SetData(uint32_t slot, void* data) {
@@ -1747,10 +1833,10 @@ uint32_t Isolate::GetNumberOfDataSlots() {
1747
1833
 
1748
1834
  template <class T>
1749
1835
  MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
1750
- if (auto slot = GetDataFromSnapshotOnce(index); slot) {
1751
- internal::PerformCastCheck(
1752
- internal::ValueHelper::SlotAsValue<T, false>(slot));
1753
- return Local<T>::FromSlot(slot);
1836
+ if (auto repr = GetDataFromSnapshotOnce(index);
1837
+ repr != internal::ValueHelper::kEmpty) {
1838
+ internal::PerformCastCheck(internal::ValueHelper::ReprAsValue<T>(repr));
1839
+ return Local<T>::FromRepr(repr);
1754
1840
  }
1755
1841
  return {};
1756
1842
  }