libv8-node 18.19.1.0-arm64-darwin → 19.9.0.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/common.h +0 -1
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +7 -8
- data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
- data/vendor/v8/include/cppgc/heap-handle.h +43 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
- data/vendor/v8/include/cppgc/heap.h +3 -7
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -1
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
- data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +0 -1
- data/vendor/v8/include/cppgc/internal/member-storage.h +236 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
- data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +28 -7
- data/vendor/v8/include/cppgc/internal/write-barrier.h +143 -101
- data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
- data/vendor/v8/include/cppgc/member.h +364 -89
- data/vendor/v8/include/cppgc/name-provider.h +4 -4
- data/vendor/v8/include/cppgc/persistent.h +5 -9
- data/vendor/v8/include/cppgc/platform.h +2 -2
- data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
- data/vendor/v8/include/cppgc/trace-trait.h +4 -0
- data/vendor/v8/include/cppgc/type-traits.h +9 -0
- data/vendor/v8/include/cppgc/visitor.h +89 -57
- data/vendor/v8/include/v8-callbacks.h +19 -5
- data/vendor/v8/include/v8-context.h +13 -8
- data/vendor/v8/include/v8-cppgc.h +12 -0
- data/vendor/v8/include/v8-date.h +5 -0
- data/vendor/v8/include/v8-embedder-heap.h +8 -3
- data/vendor/v8/include/v8-exception.h +1 -1
- data/vendor/v8/include/v8-fast-api-calls.h +46 -32
- data/vendor/v8/include/v8-function.h +8 -0
- data/vendor/v8/include/v8-initialization.h +23 -49
- data/vendor/v8/include/v8-inspector.h +13 -7
- data/vendor/v8/include/v8-internal.h +328 -123
- data/vendor/v8/include/v8-isolate.h +27 -42
- data/vendor/v8/include/v8-local-handle.h +5 -5
- data/vendor/v8/include/v8-locker.h +0 -11
- data/vendor/v8/include/v8-maybe.h +24 -1
- data/vendor/v8/include/v8-message.h +2 -4
- data/vendor/v8/include/v8-metrics.h +20 -38
- data/vendor/v8/include/v8-microtask-queue.h +1 -1
- data/vendor/v8/include/v8-object.h +8 -15
- data/vendor/v8/include/v8-persistent-handle.h +0 -2
- data/vendor/v8/include/v8-platform.h +54 -25
- data/vendor/v8/include/v8-primitive.h +8 -8
- data/vendor/v8/include/v8-profiler.h +84 -22
- data/vendor/v8/include/v8-regexp.h +2 -1
- data/vendor/v8/include/v8-script.h +62 -6
- data/vendor/v8/include/v8-template.h +13 -76
- data/vendor/v8/include/v8-unwinder-state.h +4 -4
- data/vendor/v8/include/v8-util.h +2 -4
- data/vendor/v8/include/v8-value-serializer.h +46 -23
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +5 -62
- data/vendor/v8/include/v8-weak-callback-info.h +0 -7
- data/vendor/v8/include/v8config.h +280 -13
- metadata +7 -3
@@ -194,6 +194,11 @@ enum RAILMode : unsigned {
|
|
194
194
|
*/
|
195
195
|
enum class MemoryPressureLevel { kNone, kModerate, kCritical };
|
196
196
|
|
197
|
+
/**
|
198
|
+
* Indicator for the stack state.
|
199
|
+
*/
|
200
|
+
using StackState = cppgc::EmbedderStackState;
|
201
|
+
|
197
202
|
/**
|
198
203
|
* Isolate represents an isolated instance of the V8 engine. V8 isolates have
|
199
204
|
* completely separate states. Objects from one isolate must not be used in
|
@@ -211,6 +216,8 @@ class V8_EXPORT Isolate {
|
|
211
216
|
CreateParams();
|
212
217
|
~CreateParams();
|
213
218
|
|
219
|
+
ALLOW_COPY_AND_MOVE_WITH_DEPRECATED_FIELDS(CreateParams)
|
220
|
+
|
214
221
|
/**
|
215
222
|
* Allows the host application to provide the address of a function that is
|
216
223
|
* notified each time code is added, moved or removed.
|
@@ -287,12 +294,6 @@ class V8_EXPORT Isolate {
|
|
287
294
|
*/
|
288
295
|
FatalErrorCallback fatal_error_callback = nullptr;
|
289
296
|
OOMErrorCallback oom_error_callback = nullptr;
|
290
|
-
|
291
|
-
/**
|
292
|
-
* The following parameter is experimental and may change significantly.
|
293
|
-
* This is currently for internal testing.
|
294
|
-
*/
|
295
|
-
Isolate* experimental_attach_to_shared_isolate = nullptr;
|
296
297
|
};
|
297
298
|
|
298
299
|
/**
|
@@ -301,16 +302,18 @@ class V8_EXPORT Isolate {
|
|
301
302
|
*/
|
302
303
|
class V8_EXPORT V8_NODISCARD Scope {
|
303
304
|
public:
|
304
|
-
explicit Scope(Isolate* isolate) :
|
305
|
+
explicit Scope(Isolate* isolate) : v8_isolate_(isolate) {
|
306
|
+
v8_isolate_->Enter();
|
307
|
+
}
|
305
308
|
|
306
|
-
~Scope() {
|
309
|
+
~Scope() { v8_isolate_->Exit(); }
|
307
310
|
|
308
311
|
// Prevent copying of Scope objects.
|
309
312
|
Scope(const Scope&) = delete;
|
310
313
|
Scope& operator=(const Scope&) = delete;
|
311
314
|
|
312
315
|
private:
|
313
|
-
Isolate* const
|
316
|
+
Isolate* const v8_isolate_;
|
314
317
|
};
|
315
318
|
|
316
319
|
/**
|
@@ -331,7 +334,7 @@ class V8_EXPORT Isolate {
|
|
331
334
|
|
332
335
|
private:
|
333
336
|
OnFailure on_failure_;
|
334
|
-
Isolate*
|
337
|
+
v8::Isolate* v8_isolate_;
|
335
338
|
|
336
339
|
bool was_execution_allowed_assert_;
|
337
340
|
bool was_execution_allowed_throws_;
|
@@ -353,7 +356,7 @@ class V8_EXPORT Isolate {
|
|
353
356
|
const AllowJavascriptExecutionScope&) = delete;
|
354
357
|
|
355
358
|
private:
|
356
|
-
Isolate*
|
359
|
+
Isolate* v8_isolate_;
|
357
360
|
bool was_execution_allowed_assert_;
|
358
361
|
bool was_execution_allowed_throws_;
|
359
362
|
bool was_execution_allowed_dump_;
|
@@ -376,7 +379,7 @@ class V8_EXPORT Isolate {
|
|
376
379
|
const SuppressMicrotaskExecutionScope&) = delete;
|
377
380
|
|
378
381
|
private:
|
379
|
-
internal::Isolate* const
|
382
|
+
internal::Isolate* const i_isolate_;
|
380
383
|
internal::MicrotaskQueue* const microtask_queue_;
|
381
384
|
internal::Address previous_stack_height_;
|
382
385
|
|
@@ -389,7 +392,7 @@ class V8_EXPORT Isolate {
|
|
389
392
|
*/
|
390
393
|
class V8_EXPORT V8_NODISCARD SafeForTerminationScope {
|
391
394
|
public:
|
392
|
-
explicit SafeForTerminationScope(v8::Isolate*
|
395
|
+
explicit SafeForTerminationScope(v8::Isolate* v8_isolate);
|
393
396
|
~SafeForTerminationScope();
|
394
397
|
|
395
398
|
// Prevent copying of Scope objects.
|
@@ -397,7 +400,7 @@ class V8_EXPORT Isolate {
|
|
397
400
|
SafeForTerminationScope& operator=(const SafeForTerminationScope&) = delete;
|
398
401
|
|
399
402
|
private:
|
400
|
-
internal::Isolate*
|
403
|
+
internal::Isolate* i_isolate_;
|
401
404
|
bool prev_value_;
|
402
405
|
};
|
403
406
|
|
@@ -531,6 +534,9 @@ class V8_EXPORT Isolate {
|
|
531
534
|
kInvalidatedMegaDOMProtector = 112,
|
532
535
|
kFunctionPrototypeArguments = 113,
|
533
536
|
kFunctionPrototypeCaller = 114,
|
537
|
+
kTurboFanOsrCompileStarted = 115,
|
538
|
+
kAsyncStackTaggingCreateTaskCall = 116,
|
539
|
+
kDurationFormat = 117,
|
534
540
|
|
535
541
|
// If you add new values here, you'll also need to update Chromium's:
|
536
542
|
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
|
@@ -636,9 +642,6 @@ class V8_EXPORT Isolate {
|
|
636
642
|
* This specifies the callback called by the upcoming dynamic
|
637
643
|
* import() language feature to load modules.
|
638
644
|
*/
|
639
|
-
V8_DEPRECATED("Use HostImportModuleDynamicallyCallback")
|
640
|
-
void SetHostImportModuleDynamicallyCallback(
|
641
|
-
HostImportModuleDynamicallyWithImportAssertionsCallback callback);
|
642
645
|
void SetHostImportModuleDynamicallyCallback(
|
643
646
|
HostImportModuleDynamicallyCallback callback);
|
644
647
|
|
@@ -839,12 +842,6 @@ class V8_EXPORT Isolate {
|
|
839
842
|
*/
|
840
843
|
int64_t AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes);
|
841
844
|
|
842
|
-
/**
|
843
|
-
* Returns the number of phantom handles without callbacks that were reset
|
844
|
-
* by the garbage collector since the last call to this function.
|
845
|
-
*/
|
846
|
-
size_t NumberOfPhantomHandleResetsSinceLastCall();
|
847
|
-
|
848
845
|
/**
|
849
846
|
* Returns heap profiler for this isolate. Will return NULL until the isolate
|
850
847
|
* is initialized.
|
@@ -927,6 +924,7 @@ class V8_EXPORT Isolate {
|
|
927
924
|
void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
|
928
925
|
void RemoveGCPrologueCallback(GCCallback callback);
|
929
926
|
|
927
|
+
START_ALLOW_USE_DEPRECATED()
|
930
928
|
/**
|
931
929
|
* Sets the embedder heap tracer for the isolate.
|
932
930
|
* SetEmbedderHeapTracer cannot be used simultaneously with AttachCppHeap.
|
@@ -938,6 +936,7 @@ class V8_EXPORT Isolate {
|
|
938
936
|
* SetEmbedderHeapTracer.
|
939
937
|
*/
|
940
938
|
EmbedderHeapTracer* GetEmbedderHeapTracer();
|
939
|
+
END_ALLOW_USE_DEPRECATED()
|
941
940
|
|
942
941
|
/**
|
943
942
|
* Sets an embedder roots handle that V8 should consider when performing
|
@@ -1163,9 +1162,8 @@ class V8_EXPORT Isolate {
|
|
1163
1162
|
* LowMemoryNotification() instead to influence the garbage collection
|
1164
1163
|
* schedule.
|
1165
1164
|
*/
|
1166
|
-
void RequestGarbageCollectionForTesting(
|
1167
|
-
|
1168
|
-
EmbedderHeapTracer::EmbedderStackState stack_state);
|
1165
|
+
void RequestGarbageCollectionForTesting(GarbageCollectionType type,
|
1166
|
+
StackState stack_state);
|
1169
1167
|
|
1170
1168
|
/**
|
1171
1169
|
* Set the callback to invoke for logging event.
|
@@ -1523,15 +1521,15 @@ class V8_EXPORT Isolate {
|
|
1523
1521
|
|
1524
1522
|
void SetWasmStreamingCallback(WasmStreamingCallback callback);
|
1525
1523
|
|
1524
|
+
void SetWasmAsyncResolvePromiseCallback(
|
1525
|
+
WasmAsyncResolvePromiseCallback callback);
|
1526
|
+
|
1526
1527
|
void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
|
1527
1528
|
|
1528
1529
|
void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
|
1529
1530
|
|
1530
1531
|
void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
|
1531
1532
|
|
1532
|
-
void SetWasmDynamicTieringEnabledCallback(
|
1533
|
-
WasmDynamicTieringEnabledCallback callback);
|
1534
|
-
|
1535
1533
|
void SetSharedArrayBufferConstructorEnabledCallback(
|
1536
1534
|
SharedArrayBufferConstructorEnabledCallback callback);
|
1537
1535
|
|
@@ -1598,19 +1596,6 @@ class V8_EXPORT Isolate {
|
|
1598
1596
|
*/
|
1599
1597
|
void VisitExternalResources(ExternalResourceVisitor* visitor);
|
1600
1598
|
|
1601
|
-
/**
|
1602
|
-
* Iterates through all the persistent handles in the current isolate's heap
|
1603
|
-
* that have class_ids.
|
1604
|
-
*/
|
1605
|
-
void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor);
|
1606
|
-
|
1607
|
-
/**
|
1608
|
-
* Iterates through all the persistent handles in the current isolate's heap
|
1609
|
-
* that have class_ids and are weak to be marked as inactive if there is no
|
1610
|
-
* pending activity for the handle.
|
1611
|
-
*/
|
1612
|
-
void VisitWeakHandles(PersistentHandleVisitor* visitor);
|
1613
|
-
|
1614
1599
|
/**
|
1615
1600
|
* Check if this isolate is in use.
|
1616
1601
|
* True if at least one thread Enter'ed this isolate.
|
@@ -86,7 +86,7 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
86
86
|
static int NumberOfHandles(Isolate* isolate);
|
87
87
|
|
88
88
|
V8_INLINE Isolate* GetIsolate() const {
|
89
|
-
return reinterpret_cast<Isolate*>(
|
89
|
+
return reinterpret_cast<Isolate*>(i_isolate_);
|
90
90
|
}
|
91
91
|
|
92
92
|
HandleScope(const HandleScope&) = delete;
|
@@ -97,7 +97,7 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
97
97
|
|
98
98
|
void Initialize(Isolate* isolate);
|
99
99
|
|
100
|
-
static internal::Address* CreateHandle(internal::Isolate*
|
100
|
+
static internal::Address* CreateHandle(internal::Isolate* i_isolate,
|
101
101
|
internal::Address value);
|
102
102
|
|
103
103
|
private:
|
@@ -108,7 +108,7 @@ class V8_EXPORT V8_NODISCARD HandleScope {
|
|
108
108
|
void operator delete(void*, size_t);
|
109
109
|
void operator delete[](void*, size_t);
|
110
110
|
|
111
|
-
internal::Isolate*
|
111
|
+
internal::Isolate* i_isolate_;
|
112
112
|
internal::Address* prev_next_;
|
113
113
|
internal::Address* prev_limit_;
|
114
114
|
|
@@ -354,7 +354,7 @@ class MaybeLocal {
|
|
354
354
|
|
355
355
|
/**
|
356
356
|
* Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
|
357
|
-
* |false| is returned and |out| is
|
357
|
+
* |false| is returned and |out| is assigned with nullptr.
|
358
358
|
*/
|
359
359
|
template <class S>
|
360
360
|
V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
|
@@ -445,7 +445,7 @@ class V8_EXPORT V8_NODISCARD SealHandleScope {
|
|
445
445
|
void operator delete(void*, size_t);
|
446
446
|
void operator delete[](void*, size_t);
|
447
447
|
|
448
|
-
internal::Isolate* const
|
448
|
+
internal::Isolate* const i_isolate_;
|
449
449
|
internal::Address* prev_limit_;
|
450
450
|
int prev_sealed_level_;
|
451
451
|
};
|
@@ -121,17 +121,6 @@ class V8_EXPORT Locker {
|
|
121
121
|
*/
|
122
122
|
static bool IsLocked(Isolate* isolate);
|
123
123
|
|
124
|
-
/**
|
125
|
-
* Returns whether any v8::Locker has ever been used in this process.
|
126
|
-
* TODO(cbruni, chromium:1240851): Fix locking checks on a per-thread basis.
|
127
|
-
* The current implementation is quite confusing and leads to unexpected
|
128
|
-
* results if anybody uses v8::Locker in the current process.
|
129
|
-
*/
|
130
|
-
V8_DEPRECATE_SOON("This method will be removed.")
|
131
|
-
static bool WasEverUsed();
|
132
|
-
V8_DEPRECATED("Use WasEverUsed instead")
|
133
|
-
static bool IsActive();
|
134
|
-
|
135
124
|
// Disallow copying and assigning.
|
136
125
|
Locker(const Locker&) = delete;
|
137
126
|
void operator=(const Locker&) = delete;
|
@@ -5,6 +5,9 @@
|
|
5
5
|
#ifndef INCLUDE_V8_MAYBE_H_
|
6
6
|
#define INCLUDE_V8_MAYBE_H_
|
7
7
|
|
8
|
+
#include <type_traits>
|
9
|
+
#include <utility>
|
10
|
+
|
8
11
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
9
12
|
#include "v8config.h" // NOLINT(build/include_directory)
|
10
13
|
|
@@ -57,11 +60,20 @@ class Maybe {
|
|
57
60
|
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
58
61
|
* nothing (empty), V8 will crash the process.
|
59
62
|
*/
|
60
|
-
V8_INLINE T FromJust() const {
|
63
|
+
V8_INLINE T FromJust() const& {
|
61
64
|
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
62
65
|
return value_;
|
63
66
|
}
|
64
67
|
|
68
|
+
/**
|
69
|
+
* Converts this Maybe<> to a value of type T. If this Maybe<> is
|
70
|
+
* nothing (empty), V8 will crash the process.
|
71
|
+
*/
|
72
|
+
V8_INLINE T FromJust() && {
|
73
|
+
if (V8_UNLIKELY(!IsJust())) api_internal::FromJustIsNothing();
|
74
|
+
return std::move(value_);
|
75
|
+
}
|
76
|
+
|
65
77
|
/**
|
66
78
|
* Converts this Maybe<> to a value of type T, using a default value if this
|
67
79
|
* Maybe<> is nothing (empty).
|
@@ -82,6 +94,7 @@ class Maybe {
|
|
82
94
|
private:
|
83
95
|
Maybe() : has_value_(false) {}
|
84
96
|
explicit Maybe(const T& t) : has_value_(true), value_(t) {}
|
97
|
+
explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
|
85
98
|
|
86
99
|
bool has_value_;
|
87
100
|
T value_;
|
@@ -90,6 +103,8 @@ class Maybe {
|
|
90
103
|
friend Maybe<U> Nothing();
|
91
104
|
template <class U>
|
92
105
|
friend Maybe<U> Just(const U& u);
|
106
|
+
template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
|
107
|
+
friend Maybe<U> Just(U&& u);
|
93
108
|
};
|
94
109
|
|
95
110
|
template <class T>
|
@@ -102,6 +117,14 @@ inline Maybe<T> Just(const T& t) {
|
|
102
117
|
return Maybe<T>(t);
|
103
118
|
}
|
104
119
|
|
120
|
+
// Don't use forwarding references here but instead use two overloads.
|
121
|
+
// Forwarding references only work when type deduction takes place, which is not
|
122
|
+
// the case for callsites such as Just<Type>(t).
|
123
|
+
template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
|
124
|
+
inline Maybe<T> Just(T&& t) {
|
125
|
+
return Maybe<T>(std::move(t));
|
126
|
+
}
|
127
|
+
|
105
128
|
// A template specialization of Maybe<T> for the case of T = void.
|
106
129
|
template <>
|
107
130
|
class Maybe<void> {
|
@@ -70,7 +70,7 @@ class V8_EXPORT ScriptOrigin {
|
|
70
70
|
bool resource_is_opaque = false, bool is_wasm = false,
|
71
71
|
bool is_module = false,
|
72
72
|
Local<Data> host_defined_options = Local<Data>())
|
73
|
-
:
|
73
|
+
: v8_isolate_(isolate),
|
74
74
|
resource_name_(resource_name),
|
75
75
|
resource_line_offset_(resource_line_offset),
|
76
76
|
resource_column_offset_(resource_column_offset),
|
@@ -87,14 +87,12 @@ class V8_EXPORT ScriptOrigin {
|
|
87
87
|
V8_INLINE int ColumnOffset() const;
|
88
88
|
V8_INLINE int ScriptId() const;
|
89
89
|
V8_INLINE Local<Value> SourceMapUrl() const;
|
90
|
-
V8_DEPRECATE_SOON("Use GetHostDefinedOptions")
|
91
|
-
Local<PrimitiveArray> HostDefinedOptions() const;
|
92
90
|
V8_INLINE Local<Data> GetHostDefinedOptions() const;
|
93
91
|
V8_INLINE ScriptOriginOptions Options() const { return options_; }
|
94
92
|
|
95
93
|
private:
|
96
94
|
void VerifyHostDefinedOptions() const;
|
97
|
-
Isolate*
|
95
|
+
Isolate* v8_isolate_;
|
98
96
|
Local<Value> resource_name_;
|
99
97
|
int resource_line_offset_;
|
100
98
|
int resource_column_offset_;
|
@@ -125,31 +125,10 @@ struct WasmModuleInstantiated {
|
|
125
125
|
int64_t wall_clock_duration_in_us = -1;
|
126
126
|
};
|
127
127
|
|
128
|
-
struct WasmModuleTieredUp {
|
129
|
-
bool lazy = false;
|
130
|
-
size_t code_size_in_bytes = 0;
|
131
|
-
int64_t wall_clock_duration_in_us = -1;
|
132
|
-
int64_t cpu_duration_in_us = -1;
|
133
|
-
};
|
134
|
-
|
135
128
|
struct WasmModulesPerIsolate {
|
136
129
|
size_t count = 0;
|
137
130
|
};
|
138
131
|
|
139
|
-
#define V8_MAIN_THREAD_METRICS_EVENTS(V) \
|
140
|
-
V(GarbageCollectionFullCycle) \
|
141
|
-
V(GarbageCollectionFullMainThreadIncrementalMark) \
|
142
|
-
V(GarbageCollectionFullMainThreadBatchedIncrementalMark) \
|
143
|
-
V(GarbageCollectionFullMainThreadIncrementalSweep) \
|
144
|
-
V(GarbageCollectionFullMainThreadBatchedIncrementalSweep) \
|
145
|
-
V(GarbageCollectionYoungCycle) \
|
146
|
-
V(WasmModuleDecoded) \
|
147
|
-
V(WasmModuleCompiled) \
|
148
|
-
V(WasmModuleInstantiated) \
|
149
|
-
V(WasmModuleTieredUp)
|
150
|
-
|
151
|
-
#define V8_THREAD_SAFE_METRICS_EVENTS(V) V(WasmModulesPerIsolate)
|
152
|
-
|
153
132
|
/**
|
154
133
|
* This class serves as a base class for recording event-based metrics in V8.
|
155
134
|
* There a two kinds of metrics, those which are expected to be thread-safe and
|
@@ -159,19 +138,6 @@ struct WasmModulesPerIsolate {
|
|
159
138
|
* background thread, it will be delayed and executed by the foreground task
|
160
139
|
* runner.
|
161
140
|
*
|
162
|
-
* The thread-safe events are listed in the V8_THREAD_SAFE_METRICS_EVENTS
|
163
|
-
* macro above while the main thread event are listed in
|
164
|
-
* V8_MAIN_THREAD_METRICS_EVENTS above. For the former, a virtual method
|
165
|
-
* AddMainThreadEvent(const E& event, v8::Context::Token token) will be
|
166
|
-
* generated and for the latter AddThreadSafeEvent(const E& event).
|
167
|
-
*
|
168
|
-
* Thread-safe events are not allowed to access the context and therefore do
|
169
|
-
* not carry a context ID with them. These IDs can be generated using
|
170
|
-
* Recorder::GetContextId() and the ID will be valid throughout the lifetime
|
171
|
-
* of the isolate. It is not guaranteed that the ID will still resolve to
|
172
|
-
* a valid context using Recorder::GetContext() at the time the metric is
|
173
|
-
* recorded. In this case, an empty handle will be returned.
|
174
|
-
*
|
175
141
|
* The embedder is expected to call v8::Isolate::SetMetricsRecorder()
|
176
142
|
* providing its implementation and have the virtual methods overwritten
|
177
143
|
* for the events it cares about.
|
@@ -202,14 +168,30 @@ class V8_EXPORT Recorder {
|
|
202
168
|
|
203
169
|
virtual ~Recorder() = default;
|
204
170
|
|
171
|
+
// Main thread events. Those are only triggered on the main thread, and hence
|
172
|
+
// can access the context.
|
205
173
|
#define ADD_MAIN_THREAD_EVENT(E) \
|
206
|
-
virtual void AddMainThreadEvent(const E
|
207
|
-
|
174
|
+
virtual void AddMainThreadEvent(const E&, ContextId) {}
|
175
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullCycle)
|
176
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadIncrementalMark)
|
177
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadBatchedIncrementalMark)
|
178
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadIncrementalSweep)
|
179
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionFullMainThreadBatchedIncrementalSweep)
|
180
|
+
ADD_MAIN_THREAD_EVENT(GarbageCollectionYoungCycle)
|
181
|
+
ADD_MAIN_THREAD_EVENT(WasmModuleDecoded)
|
182
|
+
ADD_MAIN_THREAD_EVENT(WasmModuleCompiled)
|
183
|
+
ADD_MAIN_THREAD_EVENT(WasmModuleInstantiated)
|
208
184
|
#undef ADD_MAIN_THREAD_EVENT
|
209
185
|
|
186
|
+
// Thread-safe events are not allowed to access the context and therefore do
|
187
|
+
// not carry a context ID with them. These IDs can be generated using
|
188
|
+
// Recorder::GetContextId() and the ID will be valid throughout the lifetime
|
189
|
+
// of the isolate. It is not guaranteed that the ID will still resolve to
|
190
|
+
// a valid context using Recorder::GetContext() at the time the metric is
|
191
|
+
// recorded. In this case, an empty handle will be returned.
|
210
192
|
#define ADD_THREAD_SAFE_EVENT(E) \
|
211
|
-
virtual void AddThreadSafeEvent(const E&
|
212
|
-
|
193
|
+
virtual void AddThreadSafeEvent(const E&) {}
|
194
|
+
ADD_THREAD_SAFE_EVENT(WasmModulesPerIsolate)
|
213
195
|
#undef ADD_THREAD_SAFE_EVENT
|
214
196
|
|
215
197
|
virtual void NotifyIsolateDisposal() {}
|
@@ -142,7 +142,7 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope {
|
|
142
142
|
MicrotasksScope& operator=(const MicrotasksScope&) = delete;
|
143
143
|
|
144
144
|
private:
|
145
|
-
internal::Isolate* const
|
145
|
+
internal::Isolate* const i_isolate_;
|
146
146
|
internal::MicrotaskQueue* const microtask_queue_;
|
147
147
|
bool run_;
|
148
148
|
};
|
@@ -594,8 +594,6 @@ class V8_EXPORT Object : public Value {
|
|
594
594
|
/**
|
595
595
|
* Returns the context in which the object was created.
|
596
596
|
*/
|
597
|
-
V8_DEPRECATED("Use MaybeLocal<Context> GetCreationContext()")
|
598
|
-
Local<Context> CreationContext();
|
599
597
|
MaybeLocal<Context> GetCreationContext();
|
600
598
|
|
601
599
|
/**
|
@@ -604,10 +602,6 @@ class V8_EXPORT Object : public Value {
|
|
604
602
|
Local<Context> GetCreationContextChecked();
|
605
603
|
|
606
604
|
/** Same as above, but works for Persistents */
|
607
|
-
V8_DEPRECATED(
|
608
|
-
"Use MaybeLocal<Context> GetCreationContext(const "
|
609
|
-
"PersistentBase<Object>& object)")
|
610
|
-
static Local<Context> CreationContext(const PersistentBase<Object>& object);
|
611
605
|
V8_INLINE static MaybeLocal<Context> GetCreationContext(
|
612
606
|
const PersistentBase<Object>& object) {
|
613
607
|
return object.val_->GetCreationContext();
|
@@ -717,7 +711,7 @@ Local<Value> Object::GetInternalField(int index) {
|
|
717
711
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
718
712
|
// know where to find the internal fields and can return the value directly.
|
719
713
|
int instance_type = I::GetInstanceType(obj);
|
720
|
-
if (
|
714
|
+
if (I::CanHaveInternalField(instance_type)) {
|
721
715
|
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index);
|
722
716
|
A value = I::ReadRawField<A>(obj, offset);
|
723
717
|
#ifdef V8_COMPRESS_POINTERS
|
@@ -742,14 +736,13 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
|
|
742
736
|
// Fast path: If the object is a plain JSObject, which is the common case, we
|
743
737
|
// know where to find the internal fields and can return the value directly.
|
744
738
|
auto instance_type = I::GetInstanceType(obj);
|
745
|
-
if (
|
746
|
-
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index)
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
isolate, obj, offset, internal::kEmbedderDataSlotPayloadTag);
|
739
|
+
if (I::CanHaveInternalField(instance_type)) {
|
740
|
+
int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) +
|
741
|
+
I::kEmbedderDataSlotExternalPointerOffset;
|
742
|
+
Isolate* isolate = I::GetIsolateForSandbox(obj);
|
743
|
+
A value =
|
744
|
+
I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
|
745
|
+
isolate, obj, offset);
|
753
746
|
return reinterpret_cast<void*>(value);
|
754
747
|
}
|
755
748
|
#endif
|
@@ -169,8 +169,6 @@ class PersistentBase {
|
|
169
169
|
* Turns this handle into a weak phantom handle without finalization callback.
|
170
170
|
* The handle will be reset automatically when the garbage collector detects
|
171
171
|
* that the object is no longer reachable.
|
172
|
-
* A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall
|
173
|
-
* returns how many phantom handles were reset by the garbage collector.
|
174
172
|
*/
|
175
173
|
V8_INLINE void SetWeak();
|
176
174
|
|
@@ -158,9 +158,10 @@ class TaskRunner {
|
|
158
158
|
class JobDelegate {
|
159
159
|
public:
|
160
160
|
/**
|
161
|
-
* Returns true if this thread
|
161
|
+
* Returns true if this thread *must* return from the worker task on the
|
162
162
|
* current thread ASAP. Workers should periodically invoke ShouldYield (or
|
163
163
|
* YieldIfNeeded()) as often as is reasonable.
|
164
|
+
* After this method returned true, ShouldYield must not be called again.
|
164
165
|
*/
|
165
166
|
virtual bool ShouldYield() = 0;
|
166
167
|
|
@@ -429,6 +430,17 @@ class PageAllocator {
|
|
429
430
|
virtual bool SetPermissions(void* address, size_t length,
|
430
431
|
Permission permissions) = 0;
|
431
432
|
|
433
|
+
/**
|
434
|
+
* Recommits discarded pages in the given range with given permissions.
|
435
|
+
* Discarded pages must be recommitted with their original permissions
|
436
|
+
* before they are used again.
|
437
|
+
*/
|
438
|
+
virtual bool RecommitPages(void* address, size_t length,
|
439
|
+
Permission permissions) {
|
440
|
+
// TODO(v8:12797): make it pure once it's implemented on Chromium side.
|
441
|
+
return false;
|
442
|
+
}
|
443
|
+
|
432
444
|
/**
|
433
445
|
* Frees memory in the given [address, address + size) range. address and size
|
434
446
|
* should be operating system page-aligned. The next write to this
|
@@ -698,6 +710,10 @@ class VirtualAddressSpace {
|
|
698
710
|
/**
|
699
711
|
* Sets permissions of all allocated pages in the given range.
|
700
712
|
*
|
713
|
+
* This operation can fail due to OOM, in which case false is returned. If
|
714
|
+
* the operation fails for a reason other than OOM, this function will
|
715
|
+
* terminate the process as this implies a bug in the client.
|
716
|
+
*
|
701
717
|
* \param address The start address of the range. Must be aligned to
|
702
718
|
* page_size().
|
703
719
|
*
|
@@ -706,7 +722,7 @@ class VirtualAddressSpace {
|
|
706
722
|
*
|
707
723
|
* \param permissions The new permissions for the range.
|
708
724
|
*
|
709
|
-
* \returns true on success, false
|
725
|
+
* \returns true on success, false on OOM.
|
710
726
|
*/
|
711
727
|
virtual V8_WARN_UNUSED_RESULT bool SetPagePermissions(
|
712
728
|
Address address, size_t size, PagePermissions permissions) = 0;
|
@@ -820,6 +836,24 @@ class VirtualAddressSpace {
|
|
820
836
|
// takes a command enum as parameter.
|
821
837
|
//
|
822
838
|
|
839
|
+
/**
|
840
|
+
* Recommits discarded pages in the given range with given permissions.
|
841
|
+
* Discarded pages must be recommitted with their original permissions
|
842
|
+
* before they are used again.
|
843
|
+
*
|
844
|
+
* \param address The start address of the range. Must be aligned to
|
845
|
+
* page_size().
|
846
|
+
*
|
847
|
+
* \param size The size in bytes of the range. Must be a multiple
|
848
|
+
* of page_size().
|
849
|
+
*
|
850
|
+
* \param permissions The permissions for the range that the pages must have.
|
851
|
+
*
|
852
|
+
* \returns true on success, false otherwise.
|
853
|
+
*/
|
854
|
+
virtual V8_WARN_UNUSED_RESULT bool RecommitPages(
|
855
|
+
Address address, size_t size, PagePermissions permissions) = 0;
|
856
|
+
|
823
857
|
/**
|
824
858
|
* Frees memory in the given [address, address + size) range. address and
|
825
859
|
* size should be aligned to the page_size(). The next write to this memory
|
@@ -890,10 +924,7 @@ class Platform {
|
|
890
924
|
/**
|
891
925
|
* Allows the embedder to manage memory page allocations.
|
892
926
|
*/
|
893
|
-
virtual PageAllocator* GetPageAllocator()
|
894
|
-
// TODO(bbudge) Make this abstract after all embedders implement this.
|
895
|
-
return nullptr;
|
896
|
-
}
|
927
|
+
virtual PageAllocator* GetPageAllocator() = 0;
|
897
928
|
|
898
929
|
/**
|
899
930
|
* Allows the embedder to specify a custom allocator used for zones.
|
@@ -910,21 +941,7 @@ class Platform {
|
|
910
941
|
* error.
|
911
942
|
* Embedder overrides of this function must NOT call back into V8.
|
912
943
|
*/
|
913
|
-
virtual void OnCriticalMemoryPressure() {
|
914
|
-
// TODO(bbudge) Remove this when embedders override the following method.
|
915
|
-
// See crbug.com/634547.
|
916
|
-
}
|
917
|
-
|
918
|
-
/**
|
919
|
-
* Enables the embedder to respond in cases where V8 can't allocate large
|
920
|
-
* memory regions. The |length| parameter is the amount of memory needed.
|
921
|
-
* Returns true if memory is now available. Returns false if no memory could
|
922
|
-
* be made available. V8 will retry allocations until this method returns
|
923
|
-
* false.
|
924
|
-
*
|
925
|
-
* Embedder overrides of this function must NOT call back into V8.
|
926
|
-
*/
|
927
|
-
virtual bool OnCriticalMemoryPressure(size_t length) { return false; }
|
944
|
+
virtual void OnCriticalMemoryPressure() {}
|
928
945
|
|
929
946
|
/**
|
930
947
|
* Gets the number of worker threads used by
|
@@ -1022,16 +1039,28 @@ class Platform {
|
|
1022
1039
|
* thread (A=>B/B=>A deadlock) and [2] JobTask::Run or
|
1023
1040
|
* JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle
|
1024
1041
|
* (B=>JobHandle::foo=>B deadlock).
|
1042
|
+
*/
|
1043
|
+
virtual std::unique_ptr<JobHandle> PostJob(
|
1044
|
+
TaskPriority priority, std::unique_ptr<JobTask> job_task) {
|
1045
|
+
auto handle = CreateJob(priority, std::move(job_task));
|
1046
|
+
handle->NotifyConcurrencyIncrease();
|
1047
|
+
return handle;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
/**
|
1051
|
+
* Creates and returns a JobHandle associated with a Job. Unlike PostJob(),
|
1052
|
+
* this doesn't immediately schedules |worker_task| to run; the Job is then
|
1053
|
+
* scheduled by calling either NotifyConcurrencyIncrease() or Join().
|
1025
1054
|
*
|
1026
|
-
* A sufficient
|
1027
|
-
* libplatform looks like:
|
1028
|
-
* std::unique_ptr<JobHandle>
|
1055
|
+
* A sufficient CreateJob() implementation that uses the default Job provided
|
1056
|
+
* in libplatform looks like:
|
1057
|
+
* std::unique_ptr<JobHandle> CreateJob(
|
1029
1058
|
* TaskPriority priority, std::unique_ptr<JobTask> job_task) override {
|
1030
1059
|
* return v8::platform::NewDefaultJobHandle(
|
1031
1060
|
* this, priority, std::move(job_task), NumberOfWorkerThreads());
|
1032
1061
|
* }
|
1033
1062
|
*/
|
1034
|
-
virtual std::unique_ptr<JobHandle>
|
1063
|
+
virtual std::unique_ptr<JobHandle> CreateJob(
|
1035
1064
|
TaskPriority priority, std::unique_ptr<JobTask> job_task) = 0;
|
1036
1065
|
|
1037
1066
|
/**
|