libv8-node 20.12.1.0-aarch64-linux-musl → 22.5.1.0-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/aarch64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +24 -5
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +16 -6
- data/vendor/v8/include/cppgc/internal/caged-heap.h +12 -5
- data/vendor/v8/include/cppgc/internal/gc-info.h +82 -91
- data/vendor/v8/include/cppgc/internal/member-storage.h +16 -8
- data/vendor/v8/include/cppgc/member.h +25 -0
- data/vendor/v8/include/cppgc/persistent.h +4 -0
- data/vendor/v8/include/cppgc/platform.h +6 -1
- data/vendor/v8/include/cppgc/sentinel-pointer.h +7 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -78
- data/vendor/v8/include/cppgc/trace-trait.h +8 -0
- data/vendor/v8/include/cppgc/type-traits.h +25 -4
- data/vendor/v8/include/cppgc/visitor.h +82 -4
- data/vendor/v8/include/libplatform/libplatform.h +7 -1
- data/vendor/v8/include/v8-array-buffer.h +6 -0
- data/vendor/v8/include/v8-callbacks.h +57 -19
- data/vendor/v8/include/v8-container.h +54 -0
- data/vendor/v8/include/v8-context.h +58 -32
- data/vendor/v8/include/v8-embedder-heap.h +31 -3
- data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
- data/vendor/v8/include/v8-exception.h +15 -9
- data/vendor/v8/include/v8-fast-api-calls.h +58 -31
- data/vendor/v8/include/v8-forward.h +1 -0
- data/vendor/v8/include/v8-function-callback.h +135 -30
- data/vendor/v8/include/v8-function.h +6 -0
- data/vendor/v8/include/v8-handle-base.h +137 -0
- data/vendor/v8/include/v8-inspector.h +35 -13
- data/vendor/v8/include/v8-internal.h +510 -71
- data/vendor/v8/include/v8-isolate.h +176 -100
- data/vendor/v8/include/v8-local-handle.h +383 -112
- data/vendor/v8/include/v8-memory-span.h +157 -2
- data/vendor/v8/include/v8-message.h +22 -3
- data/vendor/v8/include/v8-metrics.h +1 -0
- data/vendor/v8/include/v8-object.h +98 -77
- data/vendor/v8/include/v8-persistent-handle.h +68 -90
- data/vendor/v8/include/v8-platform.h +191 -23
- data/vendor/v8/include/v8-primitive.h +12 -8
- data/vendor/v8/include/v8-profiler.h +16 -2
- data/vendor/v8/include/v8-script.h +88 -14
- data/vendor/v8/include/v8-snapshot.h +96 -22
- data/vendor/v8/include/v8-source-location.h +92 -0
- data/vendor/v8/include/v8-statistics.h +31 -10
- data/vendor/v8/include/v8-template.h +410 -131
- data/vendor/v8/include/v8-traced-handle.h +108 -90
- data/vendor/v8/include/v8-typed-array.h +115 -7
- data/vendor/v8/include/v8-unwinder.h +1 -1
- data/vendor/v8/include/v8-util.h +23 -20
- data/vendor/v8/include/v8-value-serializer.h +14 -0
- data/vendor/v8/include/v8-value.h +105 -3
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8config.h +54 -20
- metadata +4 -2
@@ -13,6 +13,7 @@
|
|
13
13
|
#include <memory>
|
14
14
|
#include <string>
|
15
15
|
|
16
|
+
#include "v8-source-location.h" // NOLINT(build/include_directory)
|
16
17
|
#include "v8config.h" // NOLINT(build/include_directory)
|
17
18
|
|
18
19
|
namespace v8 {
|
@@ -39,6 +40,7 @@ enum class TaskPriority : uint8_t {
|
|
39
40
|
* possible.
|
40
41
|
*/
|
41
42
|
kUserBlocking,
|
43
|
+
kMaxPriority = kUserBlocking
|
42
44
|
};
|
43
45
|
|
44
46
|
/**
|
@@ -74,8 +76,12 @@ class TaskRunner {
|
|
74
76
|
/**
|
75
77
|
* Schedules a task to be invoked by this TaskRunner. The TaskRunner
|
76
78
|
* implementation takes ownership of |task|.
|
79
|
+
*
|
80
|
+
* Embedders should override PostTaskImpl instead of this.
|
77
81
|
*/
|
78
|
-
virtual void PostTask(std::unique_ptr<Task> task)
|
82
|
+
virtual void PostTask(std::unique_ptr<Task> task) {
|
83
|
+
PostTaskImpl(std::move(task), SourceLocation::Current());
|
84
|
+
}
|
79
85
|
|
80
86
|
/**
|
81
87
|
* Schedules a task to be invoked by this TaskRunner. The TaskRunner
|
@@ -91,16 +97,25 @@ class TaskRunner {
|
|
91
97
|
* execution is not allowed to nest.
|
92
98
|
*
|
93
99
|
* Requires that |TaskRunner::NonNestableTasksEnabled()| is true.
|
100
|
+
*
|
101
|
+
* Embedders should override PostNonNestableTaskImpl instead of this.
|
94
102
|
*/
|
95
|
-
virtual void PostNonNestableTask(std::unique_ptr<Task> task) {
|
103
|
+
virtual void PostNonNestableTask(std::unique_ptr<Task> task) {
|
104
|
+
PostNonNestableTaskImpl(std::move(task), SourceLocation::Current());
|
105
|
+
}
|
96
106
|
|
97
107
|
/**
|
98
108
|
* Schedules a task to be invoked by this TaskRunner. The task is scheduled
|
99
109
|
* after the given number of seconds |delay_in_seconds|. The TaskRunner
|
100
110
|
* implementation takes ownership of |task|.
|
111
|
+
*
|
112
|
+
* Embedders should override PostDelayedTaskImpl instead of this.
|
101
113
|
*/
|
102
114
|
virtual void PostDelayedTask(std::unique_ptr<Task> task,
|
103
|
-
double delay_in_seconds)
|
115
|
+
double delay_in_seconds) {
|
116
|
+
PostDelayedTaskImpl(std::move(task), delay_in_seconds,
|
117
|
+
SourceLocation::Current());
|
118
|
+
}
|
104
119
|
|
105
120
|
/**
|
106
121
|
* Schedules a task to be invoked by this TaskRunner. The task is scheduled
|
@@ -117,9 +132,14 @@ class TaskRunner {
|
|
117
132
|
* execution is not allowed to nest.
|
118
133
|
*
|
119
134
|
* Requires that |TaskRunner::NonNestableDelayedTasksEnabled()| is true.
|
135
|
+
*
|
136
|
+
* Embedders should override PostNonNestableDelayedTaskImpl instead of this.
|
120
137
|
*/
|
121
138
|
virtual void PostNonNestableDelayedTask(std::unique_ptr<Task> task,
|
122
|
-
double delay_in_seconds) {
|
139
|
+
double delay_in_seconds) {
|
140
|
+
PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds,
|
141
|
+
SourceLocation::Current());
|
142
|
+
}
|
123
143
|
|
124
144
|
/**
|
125
145
|
* Schedules an idle task to be invoked by this TaskRunner. The task is
|
@@ -128,8 +148,12 @@ class TaskRunner {
|
|
128
148
|
* relative to other task types and may be starved for an arbitrarily long
|
129
149
|
* time if no idle time is available. The TaskRunner implementation takes
|
130
150
|
* ownership of |task|.
|
151
|
+
*
|
152
|
+
* Embedders should override PostIdleTaskImpl instead of this.
|
131
153
|
*/
|
132
|
-
virtual void PostIdleTask(std::unique_ptr<IdleTask> task)
|
154
|
+
virtual void PostIdleTask(std::unique_ptr<IdleTask> task) {
|
155
|
+
PostIdleTaskImpl(std::move(task), SourceLocation::Current());
|
156
|
+
}
|
133
157
|
|
134
158
|
/**
|
135
159
|
* Returns true if idle tasks are enabled for this TaskRunner.
|
@@ -151,6 +175,23 @@ class TaskRunner {
|
|
151
175
|
|
152
176
|
TaskRunner(const TaskRunner&) = delete;
|
153
177
|
TaskRunner& operator=(const TaskRunner&) = delete;
|
178
|
+
|
179
|
+
protected:
|
180
|
+
/**
|
181
|
+
* Implementation of above methods with an additional `location` argument.
|
182
|
+
*/
|
183
|
+
virtual void PostTaskImpl(std::unique_ptr<Task> task,
|
184
|
+
const SourceLocation& location) {}
|
185
|
+
virtual void PostNonNestableTaskImpl(std::unique_ptr<Task> task,
|
186
|
+
const SourceLocation& location) {}
|
187
|
+
virtual void PostDelayedTaskImpl(std::unique_ptr<Task> task,
|
188
|
+
double delay_in_seconds,
|
189
|
+
const SourceLocation& location) {}
|
190
|
+
virtual void PostNonNestableDelayedTaskImpl(std::unique_ptr<Task> task,
|
191
|
+
double delay_in_seconds,
|
192
|
+
const SourceLocation& location) {}
|
193
|
+
virtual void PostIdleTaskImpl(std::unique_ptr<IdleTask> task,
|
194
|
+
const SourceLocation& location) {}
|
154
195
|
};
|
155
196
|
|
156
197
|
/**
|
@@ -261,8 +302,12 @@ class JobTask {
|
|
261
302
|
* Controls the maximum number of threads calling Run() concurrently, given
|
262
303
|
* the number of threads currently assigned to this job and executing Run().
|
263
304
|
* Run() is only invoked if the number of threads previously running Run() was
|
264
|
-
* less than the value returned.
|
265
|
-
*
|
305
|
+
* less than the value returned. In general, this should return the latest
|
306
|
+
* number of incomplete work items (smallest unit of work) left to process,
|
307
|
+
* including items that are currently in progress. |worker_count| is the
|
308
|
+
* number of threads currently assigned to this job which some callers may
|
309
|
+
* need to determine their return value. Since GetMaxConcurrency() is a leaf
|
310
|
+
* function, it must not call back any JobHandle methods.
|
266
311
|
*/
|
267
312
|
virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
|
268
313
|
};
|
@@ -566,6 +611,42 @@ class PageAllocator {
|
|
566
611
|
virtual bool CanAllocateSharedPages() { return false; }
|
567
612
|
};
|
568
613
|
|
614
|
+
/**
|
615
|
+
* An allocator that uses per-thread permissions to protect the memory.
|
616
|
+
*
|
617
|
+
* The implementation is platform/hardware specific, e.g. using pkeys on x64.
|
618
|
+
*
|
619
|
+
* INTERNAL ONLY: This interface has not been stabilised and may change
|
620
|
+
* without notice from one release to another without being deprecated first.
|
621
|
+
*/
|
622
|
+
class ThreadIsolatedAllocator {
|
623
|
+
public:
|
624
|
+
virtual ~ThreadIsolatedAllocator() = default;
|
625
|
+
|
626
|
+
virtual void* Allocate(size_t size) = 0;
|
627
|
+
|
628
|
+
virtual void Free(void* object) = 0;
|
629
|
+
|
630
|
+
enum class Type {
|
631
|
+
kPkey,
|
632
|
+
};
|
633
|
+
|
634
|
+
virtual Type Type() const = 0;
|
635
|
+
|
636
|
+
/**
|
637
|
+
* Return the pkey used to implement the thread isolation if Type == kPkey.
|
638
|
+
*/
|
639
|
+
virtual int Pkey() const { return -1; }
|
640
|
+
|
641
|
+
/**
|
642
|
+
* Per-thread permissions can be reset on signal handler entry. Even reading
|
643
|
+
* ThreadIsolated memory will segfault in that case.
|
644
|
+
* Call this function on signal handler entry to ensure that read permissions
|
645
|
+
* are restored.
|
646
|
+
*/
|
647
|
+
static void SetDefaultPermissionsForSignalHandler();
|
648
|
+
};
|
649
|
+
|
569
650
|
// Opaque type representing a handle to a shared memory region.
|
570
651
|
using PlatformSharedMemoryHandle = intptr_t;
|
571
652
|
static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1;
|
@@ -694,6 +775,15 @@ class VirtualAddressSpace {
|
|
694
775
|
*/
|
695
776
|
PagePermissions max_page_permissions() const { return max_page_permissions_; }
|
696
777
|
|
778
|
+
/**
|
779
|
+
* Whether the |address| is inside the address space managed by this instance.
|
780
|
+
*
|
781
|
+
* \returns true if it is inside the address space, false if not.
|
782
|
+
*/
|
783
|
+
bool Contains(Address address) const {
|
784
|
+
return (address >= base()) && (address < base() + size());
|
785
|
+
}
|
786
|
+
|
697
787
|
/**
|
698
788
|
* Sets the random seed so that GetRandomPageAddress() will generate
|
699
789
|
* repeatable sequences of random addresses.
|
@@ -969,6 +1059,16 @@ class Platform {
|
|
969
1059
|
*/
|
970
1060
|
virtual PageAllocator* GetPageAllocator() = 0;
|
971
1061
|
|
1062
|
+
/**
|
1063
|
+
* Allows the embedder to provide an allocator that uses per-thread memory
|
1064
|
+
* permissions to protect allocations.
|
1065
|
+
* Returning nullptr will cause V8 to disable protections that rely on this
|
1066
|
+
* feature.
|
1067
|
+
*/
|
1068
|
+
virtual ThreadIsolatedAllocator* GetThreadIsolatedAllocator() {
|
1069
|
+
return nullptr;
|
1070
|
+
}
|
1071
|
+
|
972
1072
|
/**
|
973
1073
|
* Allows the embedder to specify a custom allocator used for zones.
|
974
1074
|
*/
|
@@ -1000,40 +1100,79 @@ class Platform {
|
|
1000
1100
|
* Returns a TaskRunner which can be used to post a task on the foreground.
|
1001
1101
|
* The TaskRunner's NonNestableTasksEnabled() must be true. This function
|
1002
1102
|
* should only be called from a foreground thread.
|
1103
|
+
* TODO(chromium:1448758): Deprecate once |GetForegroundTaskRunner(Isolate*,
|
1104
|
+
* TaskPriority)| is ready.
|
1003
1105
|
*/
|
1004
1106
|
virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
|
1005
|
-
Isolate* isolate)
|
1107
|
+
Isolate* isolate) {
|
1108
|
+
return GetForegroundTaskRunner(isolate, TaskPriority::kUserBlocking);
|
1109
|
+
}
|
1006
1110
|
|
1007
1111
|
/**
|
1008
|
-
*
|
1112
|
+
* Returns a TaskRunner with a specific |priority| which can be used to post a
|
1113
|
+
* task on the foreground thread. The TaskRunner's NonNestableTasksEnabled()
|
1114
|
+
* must be true. This function should only be called from a foreground thread.
|
1115
|
+
* TODO(chromium:1448758): Make pure virtual once embedders implement it.
|
1009
1116
|
*/
|
1010
|
-
virtual
|
1117
|
+
virtual std::shared_ptr<v8::TaskRunner> GetForegroundTaskRunner(
|
1118
|
+
Isolate* isolate, TaskPriority priority) {
|
1119
|
+
return nullptr;
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
/**
|
1123
|
+
* Schedules a task to be invoked on a worker thread.
|
1124
|
+
* Embedders should override PostTaskOnWorkerThreadImpl() instead of
|
1125
|
+
* CallOnWorkerThread().
|
1126
|
+
*/
|
1127
|
+
void CallOnWorkerThread(
|
1128
|
+
std::unique_ptr<Task> task,
|
1129
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1130
|
+
PostTaskOnWorkerThreadImpl(TaskPriority::kUserVisible, std::move(task),
|
1131
|
+
location);
|
1132
|
+
}
|
1011
1133
|
|
1012
1134
|
/**
|
1013
1135
|
* Schedules a task that blocks the main thread to be invoked with
|
1014
1136
|
* high-priority on a worker thread.
|
1137
|
+
* Embedders should override PostTaskOnWorkerThreadImpl() instead of
|
1138
|
+
* CallBlockingTaskOnWorkerThread().
|
1015
1139
|
*/
|
1016
|
-
|
1140
|
+
void CallBlockingTaskOnWorkerThread(
|
1141
|
+
std::unique_ptr<Task> task,
|
1142
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1017
1143
|
// Embedders may optionally override this to process these tasks in a high
|
1018
1144
|
// priority pool.
|
1019
|
-
|
1145
|
+
PostTaskOnWorkerThreadImpl(TaskPriority::kUserBlocking, std::move(task),
|
1146
|
+
location);
|
1020
1147
|
}
|
1021
1148
|
|
1022
1149
|
/**
|
1023
1150
|
* Schedules a task to be invoked with low-priority on a worker thread.
|
1151
|
+
* Embedders should override PostTaskOnWorkerThreadImpl() instead of
|
1152
|
+
* CallLowPriorityTaskOnWorkerThread().
|
1024
1153
|
*/
|
1025
|
-
|
1154
|
+
void CallLowPriorityTaskOnWorkerThread(
|
1155
|
+
std::unique_ptr<Task> task,
|
1156
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1026
1157
|
// Embedders may optionally override this to process these tasks in a low
|
1027
1158
|
// priority pool.
|
1028
|
-
|
1159
|
+
PostTaskOnWorkerThreadImpl(TaskPriority::kBestEffort, std::move(task),
|
1160
|
+
location);
|
1029
1161
|
}
|
1030
1162
|
|
1031
1163
|
/**
|
1032
1164
|
* Schedules a task to be invoked on a worker thread after |delay_in_seconds|
|
1033
1165
|
* expires.
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1166
|
+
* Embedders should override PostDelayedTaskOnWorkerThreadImpl() instead of
|
1167
|
+
* CallDelayedOnWorkerThread().
|
1168
|
+
*/
|
1169
|
+
void CallDelayedOnWorkerThread(
|
1170
|
+
std::unique_ptr<Task> task, double delay_in_seconds,
|
1171
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1172
|
+
PostDelayedTaskOnWorkerThreadImpl(TaskPriority::kUserVisible,
|
1173
|
+
std::move(task), delay_in_seconds,
|
1174
|
+
location);
|
1175
|
+
}
|
1037
1176
|
|
1038
1177
|
/**
|
1039
1178
|
* Returns true if idle tasks are enabled for the given |isolate|.
|
@@ -1083,10 +1222,12 @@ class Platform {
|
|
1083
1222
|
* thread (A=>B/B=>A deadlock) and [2] JobTask::Run or
|
1084
1223
|
* JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle
|
1085
1224
|
* (B=>JobHandle::foo=>B deadlock).
|
1225
|
+
* Embedders should override CreateJobImpl() instead of PostJob().
|
1086
1226
|
*/
|
1087
|
-
|
1088
|
-
TaskPriority priority, std::unique_ptr<JobTask> job_task
|
1089
|
-
|
1227
|
+
std::unique_ptr<JobHandle> PostJob(
|
1228
|
+
TaskPriority priority, std::unique_ptr<JobTask> job_task,
|
1229
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1230
|
+
auto handle = CreateJob(priority, std::move(job_task), location);
|
1090
1231
|
handle->NotifyConcurrencyIncrease();
|
1091
1232
|
return handle;
|
1092
1233
|
}
|
@@ -1103,9 +1244,14 @@ class Platform {
|
|
1103
1244
|
* return v8::platform::NewDefaultJobHandle(
|
1104
1245
|
* this, priority, std::move(job_task), NumberOfWorkerThreads());
|
1105
1246
|
* }
|
1247
|
+
*
|
1248
|
+
* Embedders should override CreateJobImpl() instead of CreateJob().
|
1106
1249
|
*/
|
1107
|
-
|
1108
|
-
TaskPriority priority, std::unique_ptr<JobTask> job_task
|
1250
|
+
std::unique_ptr<JobHandle> CreateJob(
|
1251
|
+
TaskPriority priority, std::unique_ptr<JobTask> job_task,
|
1252
|
+
const SourceLocation& location = SourceLocation::Current()) {
|
1253
|
+
return CreateJobImpl(priority, std::move(job_task), location);
|
1254
|
+
}
|
1109
1255
|
|
1110
1256
|
/**
|
1111
1257
|
* Instantiates a ScopedBlockingCall to annotate a scope that may/will block.
|
@@ -1130,7 +1276,7 @@ class Platform {
|
|
1130
1276
|
* required.
|
1131
1277
|
*/
|
1132
1278
|
virtual int64_t CurrentClockTimeMilliseconds() {
|
1133
|
-
return floor(CurrentClockTimeMillis());
|
1279
|
+
return static_cast<int64_t>(floor(CurrentClockTimeMillis()));
|
1134
1280
|
}
|
1135
1281
|
|
1136
1282
|
/**
|
@@ -1183,6 +1329,28 @@ class Platform {
|
|
1183
1329
|
* nothing special needed.
|
1184
1330
|
*/
|
1185
1331
|
V8_EXPORT static double SystemClockTimeMillis();
|
1332
|
+
|
1333
|
+
/**
|
1334
|
+
* Creates and returns a JobHandle associated with a Job.
|
1335
|
+
*/
|
1336
|
+
virtual std::unique_ptr<JobHandle> CreateJobImpl(
|
1337
|
+
TaskPriority priority, std::unique_ptr<JobTask> job_task,
|
1338
|
+
const SourceLocation& location) = 0;
|
1339
|
+
|
1340
|
+
/**
|
1341
|
+
* Schedules a task with |priority| to be invoked on a worker thread.
|
1342
|
+
*/
|
1343
|
+
virtual void PostTaskOnWorkerThreadImpl(TaskPriority priority,
|
1344
|
+
std::unique_ptr<Task> task,
|
1345
|
+
const SourceLocation& location) = 0;
|
1346
|
+
|
1347
|
+
/**
|
1348
|
+
* Schedules a task with |priority| to be invoked on a worker thread after
|
1349
|
+
* |delay_in_seconds| expires.
|
1350
|
+
*/
|
1351
|
+
virtual void PostDelayedTaskOnWorkerThreadImpl(
|
1352
|
+
TaskPriority priority, std::unique_ptr<Task> task,
|
1353
|
+
double delay_in_seconds, const SourceLocation& location) = 0;
|
1186
1354
|
};
|
1187
1355
|
|
1188
1356
|
} // namespace v8
|
@@ -490,12 +490,6 @@ class V8_EXPORT String : public Name {
|
|
490
490
|
*/
|
491
491
|
bool MakeExternal(ExternalOneByteStringResource* resource);
|
492
492
|
|
493
|
-
/**
|
494
|
-
* Returns true if this string can be made external.
|
495
|
-
*/
|
496
|
-
V8_DEPRECATE_SOON("Use the version that takes an encoding as argument.")
|
497
|
-
bool CanMakeExternal() const;
|
498
|
-
|
499
493
|
/**
|
500
494
|
* Returns true if this string can be made external, given the encoding for
|
501
495
|
* the external string resource.
|
@@ -644,10 +638,20 @@ class V8_EXPORT Symbol : public Name {
|
|
644
638
|
static void CheckCast(Data* that);
|
645
639
|
};
|
646
640
|
|
641
|
+
/**
|
642
|
+
* A JavaScript numeric value (either Number or BigInt).
|
643
|
+
* https://tc39.es/ecma262/#sec-numeric-types
|
644
|
+
*/
|
645
|
+
class V8_EXPORT Numeric : public Primitive {
|
646
|
+
private:
|
647
|
+
Numeric();
|
648
|
+
static void CheckCast(v8::Data* that);
|
649
|
+
};
|
650
|
+
|
647
651
|
/**
|
648
652
|
* A JavaScript number value (ECMA-262, 4.3.20)
|
649
653
|
*/
|
650
|
-
class V8_EXPORT Number : public
|
654
|
+
class V8_EXPORT Number : public Numeric {
|
651
655
|
public:
|
652
656
|
double Value() const;
|
653
657
|
static Local<Number> New(Isolate* isolate, double value);
|
@@ -722,7 +726,7 @@ class V8_EXPORT Uint32 : public Integer {
|
|
722
726
|
/**
|
723
727
|
* A JavaScript BigInt value (https://tc39.github.io/proposal-bigint)
|
724
728
|
*/
|
725
|
-
class V8_EXPORT BigInt : public
|
729
|
+
class V8_EXPORT BigInt : public Numeric {
|
726
730
|
public:
|
727
731
|
static Local<BigInt> New(Isolate* isolate, int64_t value);
|
728
732
|
static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include <unordered_set>
|
12
12
|
#include <vector>
|
13
13
|
|
14
|
+
#include "cppgc/common.h" // NOLINT(build/include_directory)
|
14
15
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
15
16
|
#include "v8-message.h" // NOLINT(build/include_directory)
|
16
17
|
#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
|
@@ -24,7 +25,7 @@ enum class EmbedderStateTag : uint8_t;
|
|
24
25
|
class HeapGraphNode;
|
25
26
|
struct HeapStatsUpdate;
|
26
27
|
class Object;
|
27
|
-
enum StateTag :
|
28
|
+
enum StateTag : uint16_t;
|
28
29
|
|
29
30
|
using NativeObject = void*;
|
30
31
|
using SnapshotObjectId = uint32_t;
|
@@ -596,7 +597,6 @@ class V8_EXPORT HeapGraphNode {
|
|
596
597
|
kBigInt = 13, // BigInt.
|
597
598
|
kObjectShape = 14, // Internal data used for tracking the shapes (or
|
598
599
|
// "hidden classes") of JS objects.
|
599
|
-
kWasmObject = 15, // A WasmGC struct or array.
|
600
600
|
};
|
601
601
|
|
602
602
|
/** Returns node type (see HeapGraphNode::Type). */
|
@@ -883,6 +883,15 @@ class V8_EXPORT EmbedderGraph {
|
|
883
883
|
*/
|
884
884
|
virtual Detachedness GetDetachedness() { return Detachedness::kUnknown; }
|
885
885
|
|
886
|
+
/**
|
887
|
+
* Returns the address of the object in the embedder heap, or nullptr to not
|
888
|
+
* specify the address. If this address is provided, then V8 can generate
|
889
|
+
* consistent IDs for objects across subsequent heap snapshots, which allows
|
890
|
+
* devtools to determine which objects were retained from one snapshot to
|
891
|
+
* the next. This value is used only if GetNativeObject returns nullptr.
|
892
|
+
*/
|
893
|
+
virtual const void* GetAddress() { return nullptr; }
|
894
|
+
|
886
895
|
Node(const Node&) = delete;
|
887
896
|
Node& operator=(const Node&) = delete;
|
888
897
|
};
|
@@ -1055,6 +1064,11 @@ class V8_EXPORT HeapProfiler {
|
|
1055
1064
|
* Mode for dealing with numeric values, see `NumericsMode`.
|
1056
1065
|
*/
|
1057
1066
|
NumericsMode numerics_mode = NumericsMode::kHideNumericValues;
|
1067
|
+
/**
|
1068
|
+
* Whether stack is considered as a root set.
|
1069
|
+
*/
|
1070
|
+
cppgc::EmbedderStackState stack_state =
|
1071
|
+
cppgc::EmbedderStackState::kMayContainHeapPointers;
|
1058
1072
|
};
|
1059
1073
|
|
1060
1074
|
/**
|
@@ -9,12 +9,14 @@
|
|
9
9
|
#include <stdint.h>
|
10
10
|
|
11
11
|
#include <memory>
|
12
|
+
#include <tuple>
|
12
13
|
#include <vector>
|
13
14
|
|
14
15
|
#include "v8-callbacks.h" // NOLINT(build/include_directory)
|
15
16
|
#include "v8-data.h" // NOLINT(build/include_directory)
|
16
17
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
17
18
|
#include "v8-maybe.h" // NOLINT(build/include_directory)
|
19
|
+
#include "v8-memory-span.h" // NOLINT(build/include_directory)
|
18
20
|
#include "v8-message.h" // NOLINT(build/include_directory)
|
19
21
|
#include "v8config.h" // NOLINT(build/include_directory)
|
20
22
|
|
@@ -55,7 +57,7 @@ class V8_EXPORT ScriptOrModule {
|
|
55
57
|
/**
|
56
58
|
* A compiled JavaScript script, not yet tied to a Context.
|
57
59
|
*/
|
58
|
-
class V8_EXPORT UnboundScript {
|
60
|
+
class V8_EXPORT UnboundScript : public Data {
|
59
61
|
public:
|
60
62
|
/**
|
61
63
|
* Binds the script to the currently entered context.
|
@@ -134,19 +136,24 @@ class V8_EXPORT ModuleRequest : public Data {
|
|
134
136
|
int GetSourceOffset() const;
|
135
137
|
|
136
138
|
/**
|
137
|
-
* Contains the import
|
139
|
+
* Contains the import attributes for this request in the form:
|
138
140
|
* [key1, value1, source_offset1, key2, value2, source_offset2, ...].
|
139
141
|
* The keys and values are of type v8::String, and the source offsets are of
|
140
142
|
* type Int32. Use Module::SourceOffsetToLocation to convert the source
|
141
143
|
* offsets to Locations with line/column numbers.
|
142
144
|
*
|
143
|
-
* All
|
145
|
+
* All attributes present in the module request will be supplied in this
|
144
146
|
* list, regardless of whether they are supported by the host. Per
|
145
147
|
* https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes,
|
146
|
-
* hosts are expected to throw for
|
148
|
+
* hosts are expected to throw for attributes that they do not support (as
|
147
149
|
* opposed to, for example, ignoring them).
|
148
150
|
*/
|
149
|
-
Local<FixedArray>
|
151
|
+
Local<FixedArray> GetImportAttributes() const;
|
152
|
+
|
153
|
+
V8_DEPRECATE_SOON("Use GetImportAttributes instead")
|
154
|
+
Local<FixedArray> GetImportAssertions() const {
|
155
|
+
return GetImportAttributes();
|
156
|
+
}
|
150
157
|
|
151
158
|
V8_INLINE static ModuleRequest* Cast(Data* data);
|
152
159
|
|
@@ -286,7 +293,7 @@ class V8_EXPORT Module : public Data {
|
|
286
293
|
*/
|
287
294
|
static Local<Module> CreateSyntheticModule(
|
288
295
|
Isolate* isolate, Local<String> module_name,
|
289
|
-
const
|
296
|
+
const MemorySpan<const Local<String>>& export_names,
|
290
297
|
SyntheticModuleEvaluationSteps evaluation_steps);
|
291
298
|
|
292
299
|
/**
|
@@ -302,12 +309,12 @@ class V8_EXPORT Module : public Data {
|
|
302
309
|
/**
|
303
310
|
* Search the modules requested directly or indirectly by the module for
|
304
311
|
* any top-level await that has not yet resolved. If there is any, the
|
305
|
-
* returned
|
306
|
-
* with the pending top-level await.
|
312
|
+
* returned pair of vectors (of equal size) contain the unresolved module
|
313
|
+
* and corresponding message with the pending top-level await.
|
307
314
|
* An embedder may call this before exiting to improve error messages.
|
308
315
|
*/
|
309
|
-
std::
|
310
|
-
|
316
|
+
std::pair<LocalVector<Module>, LocalVector<Message>>
|
317
|
+
GetStalledTopLevelAwaitMessages(Isolate* isolate);
|
311
318
|
|
312
319
|
V8_INLINE static Module* Cast(Data* data);
|
313
320
|
|
@@ -319,7 +326,7 @@ class V8_EXPORT Module : public Data {
|
|
319
326
|
* A compiled JavaScript script, tied to a Context which was active when the
|
320
327
|
* script was compiled.
|
321
328
|
*/
|
322
|
-
class V8_EXPORT Script {
|
329
|
+
class V8_EXPORT Script : public Data {
|
323
330
|
public:
|
324
331
|
/**
|
325
332
|
* A shorthand for ScriptCompiler::Compile().
|
@@ -387,6 +394,27 @@ class V8_EXPORT ScriptCompiler {
|
|
387
394
|
CachedData(const uint8_t* data, int length,
|
388
395
|
BufferPolicy buffer_policy = BufferNotOwned);
|
389
396
|
~CachedData();
|
397
|
+
|
398
|
+
enum CompatibilityCheckResult {
|
399
|
+
// Don't change order/existing values of this enum since it keys into the
|
400
|
+
// `code_cache_reject_reason` histogram. Append-only!
|
401
|
+
kSuccess = 0,
|
402
|
+
kMagicNumberMismatch = 1,
|
403
|
+
kVersionMismatch = 2,
|
404
|
+
kSourceMismatch = 3,
|
405
|
+
kFlagsMismatch = 5,
|
406
|
+
kChecksumMismatch = 6,
|
407
|
+
kInvalidHeader = 7,
|
408
|
+
kLengthMismatch = 8,
|
409
|
+
kReadOnlySnapshotChecksumMismatch = 9,
|
410
|
+
|
411
|
+
// This should always point at the last real enum value.
|
412
|
+
kLast = kReadOnlySnapshotChecksumMismatch
|
413
|
+
};
|
414
|
+
|
415
|
+
// Check if the CachedData can be loaded in the given isolate.
|
416
|
+
CompatibilityCheckResult CompatibilityCheck(Isolate* isolate);
|
417
|
+
|
390
418
|
// TODO(marja): Async compilation; add constructors which take a callback
|
391
419
|
// which will be called when V8 no longer needs the data.
|
392
420
|
const uint8_t* data;
|
@@ -399,6 +427,33 @@ class V8_EXPORT ScriptCompiler {
|
|
399
427
|
CachedData& operator=(const CachedData&) = delete;
|
400
428
|
};
|
401
429
|
|
430
|
+
enum class InMemoryCacheResult {
|
431
|
+
// V8 did not attempt to find this script in its in-memory cache.
|
432
|
+
kNotAttempted,
|
433
|
+
|
434
|
+
// V8 found a previously compiled copy of this script in its in-memory
|
435
|
+
// cache. Any data generated by a streaming compilation or background
|
436
|
+
// deserialization was abandoned.
|
437
|
+
kHit,
|
438
|
+
|
439
|
+
// V8 didn't have any previously compiled data for this script.
|
440
|
+
kMiss,
|
441
|
+
|
442
|
+
// V8 had some previously compiled data for an identical script, but the
|
443
|
+
// data was incomplete.
|
444
|
+
kPartial,
|
445
|
+
};
|
446
|
+
|
447
|
+
// Details about what happened during a compilation.
|
448
|
+
struct CompilationDetails {
|
449
|
+
InMemoryCacheResult in_memory_cache_result =
|
450
|
+
InMemoryCacheResult::kNotAttempted;
|
451
|
+
|
452
|
+
static constexpr int64_t kTimeNotMeasured = -1;
|
453
|
+
int64_t foreground_time_in_microseconds = kTimeNotMeasured;
|
454
|
+
int64_t background_time_in_microseconds = kTimeNotMeasured;
|
455
|
+
};
|
456
|
+
|
402
457
|
/**
|
403
458
|
* Source code which can be then compiled to a UnboundScript or Script.
|
404
459
|
*/
|
@@ -424,6 +479,8 @@ class V8_EXPORT ScriptCompiler {
|
|
424
479
|
|
425
480
|
V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
|
426
481
|
|
482
|
+
V8_INLINE const CompilationDetails& GetCompilationDetails() const;
|
483
|
+
|
427
484
|
private:
|
428
485
|
friend class ScriptCompiler;
|
429
486
|
|
@@ -431,8 +488,8 @@ class V8_EXPORT ScriptCompiler {
|
|
431
488
|
|
432
489
|
// Origin information
|
433
490
|
Local<Value> resource_name;
|
434
|
-
int resource_line_offset;
|
435
|
-
int resource_column_offset;
|
491
|
+
int resource_line_offset = -1;
|
492
|
+
int resource_column_offset = -1;
|
436
493
|
ScriptOriginOptions resource_options;
|
437
494
|
Local<Value> source_map_url;
|
438
495
|
Local<Data> host_defined_options;
|
@@ -446,6 +503,10 @@ class V8_EXPORT ScriptCompiler {
|
|
446
503
|
// For requesting compile hints from the embedder.
|
447
504
|
CompileHintCallback compile_hint_callback = nullptr;
|
448
505
|
void* compile_hint_callback_data = nullptr;
|
506
|
+
|
507
|
+
// V8 writes this data and never reads it. It exists only to be informative
|
508
|
+
// to the embedder.
|
509
|
+
CompilationDetails compilation_details;
|
449
510
|
};
|
450
511
|
|
451
512
|
/**
|
@@ -500,8 +561,14 @@ class V8_EXPORT ScriptCompiler {
|
|
500
561
|
StreamedSource(const StreamedSource&) = delete;
|
501
562
|
StreamedSource& operator=(const StreamedSource&) = delete;
|
502
563
|
|
564
|
+
CompilationDetails& compilation_details() { return compilation_details_; }
|
565
|
+
|
503
566
|
private:
|
504
567
|
std::unique_ptr<internal::ScriptStreamingData> impl_;
|
568
|
+
|
569
|
+
// V8 writes this data and never reads it. It exists only to be informative
|
570
|
+
// to the embedder.
|
571
|
+
CompilationDetails compilation_details_;
|
505
572
|
};
|
506
573
|
|
507
574
|
/**
|
@@ -649,7 +716,9 @@ class V8_EXPORT ScriptCompiler {
|
|
649
716
|
static ScriptStreamingTask* StartStreaming(
|
650
717
|
Isolate* isolate, StreamedSource* source,
|
651
718
|
ScriptType type = ScriptType::kClassic,
|
652
|
-
CompileOptions options = kNoCompileOptions
|
719
|
+
CompileOptions options = kNoCompileOptions,
|
720
|
+
CompileHintCallback compile_hint_callback = nullptr,
|
721
|
+
void* compile_hint_callback_data = nullptr);
|
653
722
|
|
654
723
|
static ConsumeCodeCacheTask* StartConsumingCodeCache(
|
655
724
|
Isolate* isolate, std::unique_ptr<CachedData> source);
|
@@ -811,6 +880,11 @@ const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const {
|
|
811
880
|
return resource_options;
|
812
881
|
}
|
813
882
|
|
883
|
+
const ScriptCompiler::CompilationDetails&
|
884
|
+
ScriptCompiler::Source::GetCompilationDetails() const {
|
885
|
+
return compilation_details;
|
886
|
+
}
|
887
|
+
|
814
888
|
ModuleRequest* ModuleRequest::Cast(Data* data) {
|
815
889
|
#ifdef V8_ENABLE_CHECKS
|
816
890
|
CheckCast(data);
|