libv8-node 21.7.2.0-x86_64-linux → 22.5.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/internal/api-constants.h +1 -1
  4. data/vendor/v8/include/cppgc/type-traits.h +25 -4
  5. data/vendor/v8/include/v8-array-buffer.h +6 -0
  6. data/vendor/v8/include/v8-callbacks.h +6 -12
  7. data/vendor/v8/include/v8-container.h +54 -0
  8. data/vendor/v8/include/v8-context.h +51 -22
  9. data/vendor/v8/include/v8-embedder-heap.h +19 -3
  10. data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
  11. data/vendor/v8/include/v8-exception.h +15 -9
  12. data/vendor/v8/include/v8-fast-api-calls.h +35 -26
  13. data/vendor/v8/include/v8-forward.h +1 -0
  14. data/vendor/v8/include/v8-function-callback.h +129 -20
  15. data/vendor/v8/include/v8-handle-base.h +32 -80
  16. data/vendor/v8/include/v8-inspector.h +16 -24
  17. data/vendor/v8/include/v8-internal.h +472 -65
  18. data/vendor/v8/include/v8-isolate.h +86 -51
  19. data/vendor/v8/include/v8-local-handle.h +257 -31
  20. data/vendor/v8/include/v8-memory-span.h +157 -2
  21. data/vendor/v8/include/v8-message.h +22 -3
  22. data/vendor/v8/include/v8-metrics.h +1 -0
  23. data/vendor/v8/include/v8-object.h +29 -10
  24. data/vendor/v8/include/v8-persistent-handle.h +5 -3
  25. data/vendor/v8/include/v8-platform.h +81 -44
  26. data/vendor/v8/include/v8-script.h +61 -11
  27. data/vendor/v8/include/v8-snapshot.h +94 -23
  28. data/vendor/v8/include/v8-statistics.h +10 -24
  29. data/vendor/v8/include/v8-template.h +410 -131
  30. data/vendor/v8/include/v8-traced-handle.h +81 -46
  31. data/vendor/v8/include/v8-typed-array.h +115 -7
  32. data/vendor/v8/include/v8-util.h +13 -12
  33. data/vendor/v8/include/v8-value.h +92 -4
  34. data/vendor/v8/include/v8-version.h +4 -4
  35. data/vendor/v8/include/v8config.h +35 -10
  36. data/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a +0 -0
  37. metadata +2 -2
@@ -172,9 +172,6 @@ using AccessorNameSetterCallback =
172
172
  */
173
173
  enum AccessControl {
174
174
  DEFAULT = 0,
175
- ALL_CAN_READ = 1,
176
- ALL_CAN_WRITE = 1 << 1,
177
- PROHIBITS_OVERWRITING V8_ENUM_DEPRECATE_SOON("unused") = 1 << 2
178
175
  };
179
176
 
180
177
  /**
@@ -342,22 +339,20 @@ class V8_EXPORT Object : public Value {
342
339
  V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context,
343
340
  uint32_t index);
344
341
 
345
- /**
346
- * Note: SideEffectType affects the getter only, not the setter.
347
- */
342
+ V8_DEPRECATE_SOON("Use SetNativeDataProperty instead")
348
343
  V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(
349
344
  Local<Context> context, Local<Name> name,
350
345
  AccessorNameGetterCallback getter,
351
346
  AccessorNameSetterCallback setter = nullptr,
352
347
  MaybeLocal<Value> data = MaybeLocal<Value>(),
353
- AccessControl settings = DEFAULT, PropertyAttribute attribute = None,
348
+ AccessControl deprecated_settings = DEFAULT,
349
+ PropertyAttribute attribute = None,
354
350
  SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
355
351
  SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
356
352
 
357
353
  void SetAccessorProperty(Local<Name> name, Local<Function> getter,
358
354
  Local<Function> setter = Local<Function>(),
359
- PropertyAttribute attributes = None,
360
- AccessControl settings = DEFAULT);
355
+ PropertyAttribute attributes = None);
361
356
 
362
357
  /**
363
358
  * Sets a native data property like Template::SetNativeDataProperty, but
@@ -504,6 +499,8 @@ class V8_EXPORT Object : public Value {
504
499
  * leads to undefined behavior.
505
500
  */
506
501
  V8_INLINE void* GetAlignedPointerFromInternalField(int index);
502
+ V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
503
+ int index);
507
504
 
508
505
  /** Same as above, but works for PersistentBase. */
509
506
  V8_INLINE static void* GetAlignedPointerFromInternalField(
@@ -736,6 +733,7 @@ class V8_EXPORT Object : public Value {
736
733
  static void CheckCast(Value* obj);
737
734
  Local<Data> SlowGetInternalField(int index);
738
735
  void* SlowGetAlignedPointerFromInternalField(int index);
736
+ void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index);
739
737
  };
740
738
 
741
739
  // --- Implementation ---
@@ -765,6 +763,27 @@ Local<Data> Object::GetInternalField(int index) {
765
763
  return SlowGetInternalField(index);
766
764
  }
767
765
 
766
+ void* Object::GetAlignedPointerFromInternalField(v8::Isolate* isolate,
767
+ int index) {
768
+ #if !defined(V8_ENABLE_CHECKS)
769
+ using A = internal::Address;
770
+ using I = internal::Internals;
771
+ A obj = internal::ValueHelper::ValueAsAddress(this);
772
+ // Fast path: If the object is a plain JSObject, which is the common case, we
773
+ // know where to find the internal fields and can return the value directly.
774
+ auto instance_type = I::GetInstanceType(obj);
775
+ if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
776
+ int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) +
777
+ I::kEmbedderDataSlotExternalPointerOffset;
778
+ A value =
779
+ I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
780
+ isolate, obj, offset);
781
+ return reinterpret_cast<void*>(value);
782
+ }
783
+ #endif
784
+ return SlowGetAlignedPointerFromInternalField(isolate, index);
785
+ }
786
+
768
787
  void* Object::GetAlignedPointerFromInternalField(int index) {
769
788
  #if !defined(V8_ENABLE_CHECKS)
770
789
  using A = internal::Address;
@@ -773,7 +792,7 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
773
792
  // Fast path: If the object is a plain JSObject, which is the common case, we
774
793
  // know where to find the internal fields and can return the value directly.
775
794
  auto instance_type = I::GetInstanceType(obj);
776
- if (I::CanHaveInternalField(instance_type)) {
795
+ if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
777
796
  int offset = I::kJSObjectHeaderSize + (I::kEmbedderDataSlotSize * index) +
778
797
  I::kEmbedderDataSlotExternalPointerOffset;
779
798
  Isolate* isolate = I::GetIsolateForSandbox(obj);
@@ -44,7 +44,7 @@ V8_EXPORT void MoveGlobalReference(internal::Address** from,
44
44
  * isolate.
45
45
  */
46
46
  template <class T>
47
- class Eternal : public IndirectHandleBase {
47
+ class Eternal : public api_internal::IndirectHandleBase {
48
48
  public:
49
49
  V8_INLINE Eternal() = default;
50
50
 
@@ -88,7 +88,7 @@ V8_EXPORT void MakeWeak(internal::Address* location, void* data,
88
88
  *
89
89
  */
90
90
  template <class T>
91
- class PersistentBase : public IndirectHandleBase {
91
+ class PersistentBase : public api_internal::IndirectHandleBase {
92
92
  public:
93
93
  /**
94
94
  * If non-empty, destroy the underlying storage cell
@@ -257,7 +257,9 @@ struct CopyablePersistentTraits {
257
257
  * Copy, assignment and destructor behavior is controlled by the traits
258
258
  * class M.
259
259
  *
260
- * Note: Persistent class hierarchy is subject to future changes.
260
+ * CAVEAT: Persistent objects do not have proper destruction behavior by default
261
+ * and as such will leak the object without explicit clear. Consider using
262
+ * `v8::Global` instead which has proper destruction and move semantics.
261
263
  */
262
264
  template <class T, class M>
263
265
  class Persistent : public PersistentBase<T> {
@@ -76,8 +76,12 @@ class TaskRunner {
76
76
  /**
77
77
  * Schedules a task to be invoked by this TaskRunner. The TaskRunner
78
78
  * implementation takes ownership of |task|.
79
+ *
80
+ * Embedders should override PostTaskImpl instead of this.
79
81
  */
80
- virtual void PostTask(std::unique_ptr<Task> task) = 0;
82
+ virtual void PostTask(std::unique_ptr<Task> task) {
83
+ PostTaskImpl(std::move(task), SourceLocation::Current());
84
+ }
81
85
 
82
86
  /**
83
87
  * Schedules a task to be invoked by this TaskRunner. The TaskRunner
@@ -93,16 +97,25 @@ class TaskRunner {
93
97
  * execution is not allowed to nest.
94
98
  *
95
99
  * Requires that |TaskRunner::NonNestableTasksEnabled()| is true.
100
+ *
101
+ * Embedders should override PostNonNestableTaskImpl instead of this.
96
102
  */
97
- 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
+ }
98
106
 
99
107
  /**
100
108
  * Schedules a task to be invoked by this TaskRunner. The task is scheduled
101
109
  * after the given number of seconds |delay_in_seconds|. The TaskRunner
102
110
  * implementation takes ownership of |task|.
111
+ *
112
+ * Embedders should override PostDelayedTaskImpl instead of this.
103
113
  */
104
114
  virtual void PostDelayedTask(std::unique_ptr<Task> task,
105
- double delay_in_seconds) = 0;
115
+ double delay_in_seconds) {
116
+ PostDelayedTaskImpl(std::move(task), delay_in_seconds,
117
+ SourceLocation::Current());
118
+ }
106
119
 
107
120
  /**
108
121
  * Schedules a task to be invoked by this TaskRunner. The task is scheduled
@@ -119,9 +132,14 @@ class TaskRunner {
119
132
  * execution is not allowed to nest.
120
133
  *
121
134
  * Requires that |TaskRunner::NonNestableDelayedTasksEnabled()| is true.
135
+ *
136
+ * Embedders should override PostNonNestableDelayedTaskImpl instead of this.
122
137
  */
123
138
  virtual void PostNonNestableDelayedTask(std::unique_ptr<Task> task,
124
- double delay_in_seconds) {}
139
+ double delay_in_seconds) {
140
+ PostNonNestableDelayedTaskImpl(std::move(task), delay_in_seconds,
141
+ SourceLocation::Current());
142
+ }
125
143
 
126
144
  /**
127
145
  * Schedules an idle task to be invoked by this TaskRunner. The task is
@@ -130,8 +148,12 @@ class TaskRunner {
130
148
  * relative to other task types and may be starved for an arbitrarily long
131
149
  * time if no idle time is available. The TaskRunner implementation takes
132
150
  * ownership of |task|.
151
+ *
152
+ * Embedders should override PostIdleTaskImpl instead of this.
133
153
  */
134
- virtual void PostIdleTask(std::unique_ptr<IdleTask> task) = 0;
154
+ virtual void PostIdleTask(std::unique_ptr<IdleTask> task) {
155
+ PostIdleTaskImpl(std::move(task), SourceLocation::Current());
156
+ }
135
157
 
136
158
  /**
137
159
  * Returns true if idle tasks are enabled for this TaskRunner.
@@ -153,6 +175,23 @@ class TaskRunner {
153
175
 
154
176
  TaskRunner(const TaskRunner&) = delete;
155
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) {}
156
195
  };
157
196
 
158
197
  /**
@@ -736,6 +775,15 @@ class VirtualAddressSpace {
736
775
  */
737
776
  PagePermissions max_page_permissions() const { return max_page_permissions_; }
738
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
+
739
787
  /**
740
788
  * Sets the random seed so that GetRandomPageAddress() will generate
741
789
  * repeatable sequences of random addresses.
@@ -1075,12 +1123,12 @@ class Platform {
1075
1123
  * Schedules a task to be invoked on a worker thread.
1076
1124
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1077
1125
  * CallOnWorkerThread().
1078
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1079
- * PostTaskOnWorkerThreadImpl().
1080
1126
  */
1081
- virtual void CallOnWorkerThread(std::unique_ptr<Task> task) {
1127
+ void CallOnWorkerThread(
1128
+ std::unique_ptr<Task> task,
1129
+ const SourceLocation& location = SourceLocation::Current()) {
1082
1130
  PostTaskOnWorkerThreadImpl(TaskPriority::kUserVisible, std::move(task),
1083
- SourceLocation::Current());
1131
+ location);
1084
1132
  }
1085
1133
 
1086
1134
  /**
@@ -1088,28 +1136,28 @@ class Platform {
1088
1136
  * high-priority on a worker thread.
1089
1137
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1090
1138
  * CallBlockingTaskOnWorkerThread().
1091
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1092
- * PostTaskOnWorkerThreadImpl().
1093
1139
  */
1094
- virtual void CallBlockingTaskOnWorkerThread(std::unique_ptr<Task> task) {
1140
+ void CallBlockingTaskOnWorkerThread(
1141
+ std::unique_ptr<Task> task,
1142
+ const SourceLocation& location = SourceLocation::Current()) {
1095
1143
  // Embedders may optionally override this to process these tasks in a high
1096
1144
  // priority pool.
1097
1145
  PostTaskOnWorkerThreadImpl(TaskPriority::kUserBlocking, std::move(task),
1098
- SourceLocation::Current());
1146
+ location);
1099
1147
  }
1100
1148
 
1101
1149
  /**
1102
1150
  * Schedules a task to be invoked with low-priority on a worker thread.
1103
1151
  * Embedders should override PostTaskOnWorkerThreadImpl() instead of
1104
1152
  * CallLowPriorityTaskOnWorkerThread().
1105
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1106
- * PostTaskOnWorkerThreadImpl().
1107
1153
  */
1108
- virtual void CallLowPriorityTaskOnWorkerThread(std::unique_ptr<Task> task) {
1154
+ void CallLowPriorityTaskOnWorkerThread(
1155
+ std::unique_ptr<Task> task,
1156
+ const SourceLocation& location = SourceLocation::Current()) {
1109
1157
  // Embedders may optionally override this to process these tasks in a low
1110
1158
  // priority pool.
1111
1159
  PostTaskOnWorkerThreadImpl(TaskPriority::kBestEffort, std::move(task),
1112
- SourceLocation::Current());
1160
+ location);
1113
1161
  }
1114
1162
 
1115
1163
  /**
@@ -1117,14 +1165,13 @@ class Platform {
1117
1165
  * expires.
1118
1166
  * Embedders should override PostDelayedTaskOnWorkerThreadImpl() instead of
1119
1167
  * CallDelayedOnWorkerThread().
1120
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1121
- * PostDelayedTaskOnWorkerThreadImpl().
1122
1168
  */
1123
- virtual void CallDelayedOnWorkerThread(std::unique_ptr<Task> task,
1124
- double delay_in_seconds) {
1169
+ void CallDelayedOnWorkerThread(
1170
+ std::unique_ptr<Task> task, double delay_in_seconds,
1171
+ const SourceLocation& location = SourceLocation::Current()) {
1125
1172
  PostDelayedTaskOnWorkerThreadImpl(TaskPriority::kUserVisible,
1126
1173
  std::move(task), delay_in_seconds,
1127
- SourceLocation::Current());
1174
+ location);
1128
1175
  }
1129
1176
 
1130
1177
  /**
@@ -1176,12 +1223,11 @@ class Platform {
1176
1223
  * JobTask::GetMaxConcurrency may be invoked synchronously from JobHandle
1177
1224
  * (B=>JobHandle::foo=>B deadlock).
1178
1225
  * Embedders should override CreateJobImpl() instead of PostJob().
1179
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1180
- * CreateJobImpl().
1181
1226
  */
1182
- virtual std::unique_ptr<JobHandle> PostJob(
1183
- TaskPriority priority, std::unique_ptr<JobTask> job_task) {
1184
- auto handle = CreateJob(priority, std::move(job_task));
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);
1185
1231
  handle->NotifyConcurrencyIncrease();
1186
1232
  return handle;
1187
1233
  }
@@ -1200,13 +1246,11 @@ class Platform {
1200
1246
  * }
1201
1247
  *
1202
1248
  * Embedders should override CreateJobImpl() instead of CreateJob().
1203
- * TODO(chromium:1424158): Make non-virtual once embedders are migrated to
1204
- * CreateJobImpl().
1205
1249
  */
1206
- virtual std::unique_ptr<JobHandle> CreateJob(
1207
- TaskPriority priority, std::unique_ptr<JobTask> job_task) {
1208
- return CreateJobImpl(priority, std::move(job_task),
1209
- SourceLocation::Current());
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);
1210
1254
  }
1211
1255
 
1212
1256
  /**
@@ -1232,7 +1276,7 @@ class Platform {
1232
1276
  * required.
1233
1277
  */
1234
1278
  virtual int64_t CurrentClockTimeMilliseconds() {
1235
- return floor(CurrentClockTimeMillis());
1279
+ return static_cast<int64_t>(floor(CurrentClockTimeMillis()));
1236
1280
  }
1237
1281
 
1238
1282
  /**
@@ -1288,32 +1332,25 @@ class Platform {
1288
1332
 
1289
1333
  /**
1290
1334
  * Creates and returns a JobHandle associated with a Job.
1291
- * TODO(chromium:1424158): Make pure virtual once embedders implement it.
1292
1335
  */
1293
1336
  virtual std::unique_ptr<JobHandle> CreateJobImpl(
1294
1337
  TaskPriority priority, std::unique_ptr<JobTask> job_task,
1295
- const SourceLocation& location) {
1296
- return nullptr;
1297
- }
1338
+ const SourceLocation& location) = 0;
1298
1339
 
1299
1340
  /**
1300
1341
  * Schedules a task with |priority| to be invoked on a worker thread.
1301
- * TODO(chromium:1424158): Make pure virtual once embedders implement it.
1302
1342
  */
1303
1343
  virtual void PostTaskOnWorkerThreadImpl(TaskPriority priority,
1304
1344
  std::unique_ptr<Task> task,
1305
- const SourceLocation& location) {
1306
- CallOnWorkerThread(std::move(task));
1307
- }
1345
+ const SourceLocation& location) = 0;
1308
1346
 
1309
1347
  /**
1310
1348
  * Schedules a task with |priority| to be invoked on a worker thread after
1311
1349
  * |delay_in_seconds| expires.
1312
- * TODO(chromium:1424158): Make pure virtual once embedders implement it.
1313
1350
  */
1314
1351
  virtual void PostDelayedTaskOnWorkerThreadImpl(
1315
1352
  TaskPriority priority, std::unique_ptr<Task> task,
1316
- double delay_in_seconds, const SourceLocation& location) {}
1353
+ double delay_in_seconds, const SourceLocation& location) = 0;
1317
1354
  };
1318
1355
 
1319
1356
  } // namespace v8
@@ -16,6 +16,7 @@
16
16
  #include "v8-data.h" // NOLINT(build/include_directory)
17
17
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
18
18
  #include "v8-maybe.h" // NOLINT(build/include_directory)
19
+ #include "v8-memory-span.h" // NOLINT(build/include_directory)
19
20
  #include "v8-message.h" // NOLINT(build/include_directory)
20
21
  #include "v8config.h" // NOLINT(build/include_directory)
21
22
 
@@ -135,19 +136,24 @@ class V8_EXPORT ModuleRequest : public Data {
135
136
  int GetSourceOffset() const;
136
137
 
137
138
  /**
138
- * Contains the import assertions for this request in the form:
139
+ * Contains the import attributes for this request in the form:
139
140
  * [key1, value1, source_offset1, key2, value2, source_offset2, ...].
140
141
  * The keys and values are of type v8::String, and the source offsets are of
141
142
  * type Int32. Use Module::SourceOffsetToLocation to convert the source
142
143
  * offsets to Locations with line/column numbers.
143
144
  *
144
- * All assertions present in the module request will be supplied in this
145
+ * All attributes present in the module request will be supplied in this
145
146
  * list, regardless of whether they are supported by the host. Per
146
147
  * https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes,
147
- * hosts are expected to throw for assertions that they do not support (as
148
+ * hosts are expected to throw for attributes that they do not support (as
148
149
  * opposed to, for example, ignoring them).
149
150
  */
150
- Local<FixedArray> GetImportAssertions() const;
151
+ Local<FixedArray> GetImportAttributes() const;
152
+
153
+ V8_DEPRECATE_SOON("Use GetImportAttributes instead")
154
+ Local<FixedArray> GetImportAssertions() const {
155
+ return GetImportAttributes();
156
+ }
151
157
 
152
158
  V8_INLINE static ModuleRequest* Cast(Data* data);
153
159
 
@@ -287,7 +293,7 @@ class V8_EXPORT Module : public Data {
287
293
  */
288
294
  static Local<Module> CreateSyntheticModule(
289
295
  Isolate* isolate, Local<String> module_name,
290
- const std::vector<Local<String>>& export_names,
296
+ const MemorySpan<const Local<String>>& export_names,
291
297
  SyntheticModuleEvaluationSteps evaluation_steps);
292
298
 
293
299
  /**
@@ -303,12 +309,12 @@ class V8_EXPORT Module : public Data {
303
309
  /**
304
310
  * Search the modules requested directly or indirectly by the module for
305
311
  * any top-level await that has not yet resolved. If there is any, the
306
- * returned vector contains a tuple of the unresolved module and a message
307
- * 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.
308
314
  * An embedder may call this before exiting to improve error messages.
309
315
  */
310
- std::vector<std::tuple<Local<Module>, Local<Message>>>
311
- GetStalledTopLevelAwaitMessage(Isolate* isolate);
316
+ std::pair<LocalVector<Module>, LocalVector<Message>>
317
+ GetStalledTopLevelAwaitMessages(Isolate* isolate);
312
318
 
313
319
  V8_INLINE static Module* Cast(Data* data);
314
320
 
@@ -421,6 +427,33 @@ class V8_EXPORT ScriptCompiler {
421
427
  CachedData& operator=(const CachedData&) = delete;
422
428
  };
423
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
+
424
457
  /**
425
458
  * Source code which can be then compiled to a UnboundScript or Script.
426
459
  */
@@ -446,6 +479,8 @@ class V8_EXPORT ScriptCompiler {
446
479
 
447
480
  V8_INLINE const ScriptOriginOptions& GetResourceOptions() const;
448
481
 
482
+ V8_INLINE const CompilationDetails& GetCompilationDetails() const;
483
+
449
484
  private:
450
485
  friend class ScriptCompiler;
451
486
 
@@ -453,8 +488,8 @@ class V8_EXPORT ScriptCompiler {
453
488
 
454
489
  // Origin information
455
490
  Local<Value> resource_name;
456
- int resource_line_offset;
457
- int resource_column_offset;
491
+ int resource_line_offset = -1;
492
+ int resource_column_offset = -1;
458
493
  ScriptOriginOptions resource_options;
459
494
  Local<Value> source_map_url;
460
495
  Local<Data> host_defined_options;
@@ -468,6 +503,10 @@ class V8_EXPORT ScriptCompiler {
468
503
  // For requesting compile hints from the embedder.
469
504
  CompileHintCallback compile_hint_callback = nullptr;
470
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;
471
510
  };
472
511
 
473
512
  /**
@@ -522,8 +561,14 @@ class V8_EXPORT ScriptCompiler {
522
561
  StreamedSource(const StreamedSource&) = delete;
523
562
  StreamedSource& operator=(const StreamedSource&) = delete;
524
563
 
564
+ CompilationDetails& compilation_details() { return compilation_details_; }
565
+
525
566
  private:
526
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_;
527
572
  };
528
573
 
529
574
  /**
@@ -835,6 +880,11 @@ const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const {
835
880
  return resource_options;
836
881
  }
837
882
 
883
+ const ScriptCompiler::CompilationDetails&
884
+ ScriptCompiler::Source::GetCompilationDetails() const {
885
+ return compilation_details;
886
+ }
887
+
838
888
  ModuleRequest* ModuleRequest::Cast(Data* data) {
839
889
  #ifdef V8_ENABLE_CHECKS
840
890
  CheckCast(data);