libv8-node 19.9.0.0-x86_64-linux → 20.12.1.0-x86_64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/include/cppgc/cross-thread-persistent.h +4 -2
  4. data/vendor/v8/include/cppgc/heap-consistency.h +2 -2
  5. data/vendor/v8/include/cppgc/heap-handle.h +5 -0
  6. data/vendor/v8/include/cppgc/internal/api-constants.h +4 -1
  7. data/vendor/v8/include/cppgc/internal/gc-info.h +35 -33
  8. data/vendor/v8/include/cppgc/internal/member-storage.h +19 -7
  9. data/vendor/v8/include/cppgc/internal/pointer-policies.h +38 -2
  10. data/vendor/v8/include/cppgc/internal/write-barrier.h +15 -5
  11. data/vendor/v8/include/cppgc/macros.h +10 -1
  12. data/vendor/v8/include/cppgc/member.h +167 -129
  13. data/vendor/v8/include/cppgc/persistent.h +22 -15
  14. data/vendor/v8/include/cppgc/platform.h +6 -4
  15. data/vendor/v8/include/cppgc/type-traits.h +4 -3
  16. data/vendor/v8/include/cppgc/visitor.h +16 -1
  17. data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
  18. data/vendor/v8/include/v8-array-buffer.h +59 -0
  19. data/vendor/v8/include/v8-callbacks.h +14 -1
  20. data/vendor/v8/include/v8-context.h +50 -3
  21. data/vendor/v8/include/v8-cppgc.h +15 -0
  22. data/vendor/v8/include/v8-data.h +1 -1
  23. data/vendor/v8/include/v8-embedder-heap.h +0 -169
  24. data/vendor/v8/include/v8-fast-api-calls.h +7 -3
  25. data/vendor/v8/include/v8-function-callback.h +69 -42
  26. data/vendor/v8/include/v8-function.h +1 -0
  27. data/vendor/v8/include/v8-inspector.h +20 -5
  28. data/vendor/v8/include/v8-internal.h +242 -150
  29. data/vendor/v8/include/v8-isolate.h +30 -40
  30. data/vendor/v8/include/v8-local-handle.h +81 -48
  31. data/vendor/v8/include/v8-metrics.h +28 -2
  32. data/vendor/v8/include/v8-microtask-queue.h +5 -0
  33. data/vendor/v8/include/v8-object.h +38 -3
  34. data/vendor/v8/include/v8-persistent-handle.h +25 -16
  35. data/vendor/v8/include/v8-platform.h +79 -10
  36. data/vendor/v8/include/v8-primitive.h +19 -12
  37. data/vendor/v8/include/v8-profiler.h +59 -31
  38. data/vendor/v8/include/v8-script.h +32 -5
  39. data/vendor/v8/include/v8-snapshot.h +4 -8
  40. data/vendor/v8/include/v8-template.h +3 -1
  41. data/vendor/v8/include/v8-traced-handle.h +22 -28
  42. data/vendor/v8/include/v8-util.h +9 -3
  43. data/vendor/v8/include/v8-value.h +31 -4
  44. data/vendor/v8/include/v8-version.h +4 -4
  45. data/vendor/v8/include/v8-wasm.h +2 -1
  46. data/vendor/v8/include/v8config.h +73 -2
  47. data/vendor/v8/x86_64-linux/libv8/obj/libv8_monolith.a +0 -0
  48. metadata +2 -2
@@ -233,7 +233,7 @@ class V8_EXPORT Isolate {
233
233
  * Explicitly specify a startup snapshot blob. The embedder owns the blob.
234
234
  * The embedder *must* ensure that the snapshot is from a trusted source.
235
235
  */
236
- StartupData* snapshot_blob = nullptr;
236
+ const StartupData* snapshot_blob = nullptr;
237
237
 
238
238
  /**
239
239
  * Enables the host application to provide a mechanism for recording
@@ -333,12 +333,9 @@ class V8_EXPORT Isolate {
333
333
  const DisallowJavascriptExecutionScope&) = delete;
334
334
 
335
335
  private:
336
- OnFailure on_failure_;
337
- v8::Isolate* v8_isolate_;
338
-
339
- bool was_execution_allowed_assert_;
340
- bool was_execution_allowed_throws_;
341
- bool was_execution_allowed_dump_;
336
+ v8::Isolate* const v8_isolate_;
337
+ const OnFailure on_failure_;
338
+ bool was_execution_allowed_;
342
339
  };
343
340
 
344
341
  /**
@@ -356,7 +353,7 @@ class V8_EXPORT Isolate {
356
353
  const AllowJavascriptExecutionScope&) = delete;
357
354
 
358
355
  private:
359
- Isolate* v8_isolate_;
356
+ Isolate* const v8_isolate_;
360
357
  bool was_execution_allowed_assert_;
361
358
  bool was_execution_allowed_throws_;
362
359
  bool was_execution_allowed_dump_;
@@ -537,6 +534,8 @@ class V8_EXPORT Isolate {
537
534
  kTurboFanOsrCompileStarted = 115,
538
535
  kAsyncStackTaggingCreateTaskCall = 116,
539
536
  kDurationFormat = 117,
537
+ kInvalidatedNumberStringPrototypeNoReplaceProtector = 118,
538
+ kRegExpUnicodeSetIncompatibilitiesWithUnicodeMode = 119, // Unused.
540
539
 
541
540
  // If you add new values here, you'll also need to update Chromium's:
542
541
  // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
@@ -924,27 +923,10 @@ class V8_EXPORT Isolate {
924
923
  void RemoveGCPrologueCallback(GCCallbackWithData, void* data = nullptr);
925
924
  void RemoveGCPrologueCallback(GCCallback callback);
926
925
 
927
- START_ALLOW_USE_DEPRECATED()
928
- /**
929
- * Sets the embedder heap tracer for the isolate.
930
- * SetEmbedderHeapTracer cannot be used simultaneously with AttachCppHeap.
931
- */
932
- void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer);
933
-
934
- /*
935
- * Gets the currently active heap tracer for the isolate that was set with
936
- * SetEmbedderHeapTracer.
937
- */
938
- EmbedderHeapTracer* GetEmbedderHeapTracer();
939
- END_ALLOW_USE_DEPRECATED()
940
-
941
926
  /**
942
927
  * Sets an embedder roots handle that V8 should consider when performing
943
- * non-unified heap garbage collections.
944
- *
945
- * Using only EmbedderHeapTracer automatically sets up a default handler.
946
- * The intended use case is for setting a custom handler after invoking
947
- * `AttachCppHeap()`.
928
+ * non-unified heap garbage collections. The intended use case is for setting
929
+ * a custom handler after invoking `AttachCppHeap()`.
948
930
  *
949
931
  * V8 does not take ownership of the handler.
950
932
  */
@@ -954,22 +936,18 @@ class V8_EXPORT Isolate {
954
936
  * Attaches a managed C++ heap as an extension to the JavaScript heap. The
955
937
  * embedder maintains ownership of the CppHeap. At most one C++ heap can be
956
938
  * attached to V8.
957
- * AttachCppHeap cannot be used simultaneously with SetEmbedderHeapTracer.
958
939
  *
959
- * This is an experimental feature and may still change significantly.
940
+ * Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see
941
+ * CppHeap.
960
942
  */
961
943
  void AttachCppHeap(CppHeap*);
962
944
 
963
945
  /**
964
946
  * Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
965
- *
966
- * This is an experimental feature and may still change significantly.
967
947
  */
968
948
  void DetachCppHeap();
969
949
 
970
950
  /**
971
- * This is an experimental feature and may still change significantly.
972
-
973
951
  * \returns the C++ heap managed by V8. Only available if such a heap has been
974
952
  * attached using `AttachCppHeap()`.
975
953
  */
@@ -1145,9 +1123,8 @@ class V8_EXPORT Isolate {
1145
1123
  *
1146
1124
  * This should only be used for testing purposes and not to enforce a garbage
1147
1125
  * collection schedule. It has strong negative impact on the garbage
1148
- * collection performance. Use IdleNotificationDeadline() or
1149
- * LowMemoryNotification() instead to influence the garbage collection
1150
- * schedule.
1126
+ * collection performance. Use MemoryPressureNotification() instead to
1127
+ * influence the garbage collection schedule.
1151
1128
  */
1152
1129
  void RequestGarbageCollectionForTesting(GarbageCollectionType type);
1153
1130
 
@@ -1158,9 +1135,8 @@ class V8_EXPORT Isolate {
1158
1135
  *
1159
1136
  * This should only be used for testing purposes and not to enforce a garbage
1160
1137
  * collection schedule. It has strong negative impact on the garbage
1161
- * collection performance. Use IdleNotificationDeadline() or
1162
- * LowMemoryNotification() instead to influence the garbage collection
1163
- * schedule.
1138
+ * collection performance. Use MemoryPressureNotification() instead to
1139
+ * influence the garbage collection schedule.
1164
1140
  */
1165
1141
  void RequestGarbageCollectionForTesting(GarbageCollectionType type,
1166
1142
  StackState stack_state);
@@ -1312,6 +1288,8 @@ class V8_EXPORT Isolate {
1312
1288
  * that function. There is no guarantee that the actual work will be done
1313
1289
  * within the time limit.
1314
1290
  */
1291
+ V8_DEPRECATE_SOON(
1292
+ "Use MemoryPressureNotification() to influence the GC schedule.")
1315
1293
  bool IdleNotificationDeadline(double deadline_in_seconds);
1316
1294
 
1317
1295
  /**
@@ -1348,11 +1326,13 @@ class V8_EXPORT Isolate {
1348
1326
  * V8 uses this notification to guide heuristics which may result in a
1349
1327
  * smaller memory footprint at the cost of reduced runtime performance.
1350
1328
  */
1329
+ V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
1351
1330
  void EnableMemorySavingsMode();
1352
1331
 
1353
1332
  /**
1354
1333
  * Optional notification which will disable the memory savings mode.
1355
1334
  */
1335
+ V8_DEPRECATED("Use IsolateInBackgroundNotification() instead")
1356
1336
  void DisableMemorySavingsMode();
1357
1337
 
1358
1338
  /**
@@ -1526,10 +1506,19 @@ class V8_EXPORT Isolate {
1526
1506
 
1527
1507
  void SetWasmLoadSourceMapCallback(WasmLoadSourceMapCallback callback);
1528
1508
 
1509
+ V8_DEPRECATED("Wasm SIMD is always enabled")
1529
1510
  void SetWasmSimdEnabledCallback(WasmSimdEnabledCallback callback);
1530
1511
 
1512
+ V8_DEPRECATED("Wasm exceptions are always enabled")
1531
1513
  void SetWasmExceptionsEnabledCallback(WasmExceptionsEnabledCallback callback);
1532
1514
 
1515
+ /**
1516
+ * Register callback to control whehter Wasm GC is enabled.
1517
+ * The callback overwrites the value of the flag.
1518
+ * If the callback returns true, it will also enable Wasm stringrefs.
1519
+ */
1520
+ void SetWasmGCEnabledCallback(WasmGCEnabledCallback callback);
1521
+
1533
1522
  void SetSharedArrayBufferConstructorEnabledCallback(
1534
1523
  SharedArrayBufferConstructorEnabledCallback callback);
1535
1524
 
@@ -1684,7 +1673,8 @@ uint32_t Isolate::GetNumberOfDataSlots() {
1684
1673
 
1685
1674
  template <class T>
1686
1675
  MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
1687
- T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
1676
+ T* data =
1677
+ internal::ValueHelper::SlotAsValue<T>(GetDataFromSnapshotOnce(index));
1688
1678
  if (data) internal::PerformCastCheck(data);
1689
1679
  return Local<T>(data);
1690
1680
  }
@@ -50,9 +50,14 @@ class TracedReference;
50
50
  class TracedReferenceBase;
51
51
  class Utils;
52
52
 
53
+ namespace debug {
54
+ class ConsoleCallArguments;
55
+ }
56
+
53
57
  namespace internal {
54
58
  template <typename T>
55
59
  class CustomArguments;
60
+ class SamplingHeapProfiler;
56
61
  } // namespace internal
57
62
 
58
63
  namespace api_internal {
@@ -92,6 +97,9 @@ class V8_EXPORT V8_NODISCARD HandleScope {
92
97
  HandleScope(const HandleScope&) = delete;
93
98
  void operator=(const HandleScope&) = delete;
94
99
 
100
+ static internal::Address* CreateHandleForCurrentIsolate(
101
+ internal::Address value);
102
+
95
103
  protected:
96
104
  V8_INLINE HandleScope() = default;
97
105
 
@@ -122,6 +130,33 @@ class V8_EXPORT V8_NODISCARD HandleScope {
122
130
  friend class Context;
123
131
  };
124
132
 
133
+ namespace internal {
134
+
135
+ /**
136
+ * Helper functions about handles.
137
+ */
138
+ class HandleHelper final {
139
+ public:
140
+ /**
141
+ * Checks whether two handles are equal.
142
+ * They are equal iff they are both empty or they are both non-empty and the
143
+ * objects to which they refer are physically equal.
144
+ *
145
+ * If both handles refer to JS objects, this is the same as strict equality.
146
+ * For primitives, such as numbers or strings, a `false` return value does not
147
+ * indicate that the values aren't equal in the JavaScript sense.
148
+ * Use `Value::StrictEquals()` to check primitives for equality.
149
+ */
150
+ template <typename T1, typename T2>
151
+ V8_INLINE static bool EqualHandles(const T1& lhs, const T2& rhs) {
152
+ if (lhs.IsEmpty()) return rhs.IsEmpty();
153
+ if (rhs.IsEmpty()) return false;
154
+ return lhs.address() == rhs.address();
155
+ }
156
+ };
157
+
158
+ } // namespace internal
159
+
125
160
  /**
126
161
  * An object reference managed by the v8 garbage collector.
127
162
  *
@@ -154,7 +189,8 @@ class V8_EXPORT V8_NODISCARD HandleScope {
154
189
  template <class T>
155
190
  class Local {
156
191
  public:
157
- V8_INLINE Local() : val_(nullptr) {}
192
+ V8_INLINE Local() : val_(internal::ValueHelper::EmptyValue<T>()) {}
193
+
158
194
  template <class S>
159
195
  V8_INLINE Local(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
160
196
  /**
@@ -168,55 +204,40 @@ class Local {
168
204
  /**
169
205
  * Returns true if the handle is empty.
170
206
  */
171
- V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
207
+ V8_INLINE bool IsEmpty() const {
208
+ return val_ == internal::ValueHelper::EmptyValue<T>();
209
+ }
172
210
 
173
211
  /**
174
212
  * Sets the handle to be empty. IsEmpty() will then return true.
175
213
  */
176
- V8_INLINE void Clear() { val_ = nullptr; }
214
+ V8_INLINE void Clear() { val_ = internal::ValueHelper::EmptyValue<T>(); }
177
215
 
178
216
  V8_INLINE T* operator->() const { return val_; }
179
217
 
180
218
  V8_INLINE T* operator*() const { return val_; }
181
219
 
182
220
  /**
183
- * Checks whether two handles are the same.
184
- * Returns true if both are empty, or if the objects to which they refer
185
- * are identical.
221
+ * Checks whether two handles are equal or different.
222
+ * They are equal iff they are both empty or they are both non-empty and the
223
+ * objects to which they refer are physically equal.
186
224
  *
187
- * If both handles refer to JS objects, this is the same as strict equality.
188
- * For primitives, such as numbers or strings, a `false` return value does not
189
- * indicate that the values aren't equal in the JavaScript sense.
190
- * Use `Value::StrictEquals()` to check primitives for equality.
225
+ * If both handles refer to JS objects, this is the same as strict
226
+ * non-equality. For primitives, such as numbers or strings, a `true` return
227
+ * value does not indicate that the values aren't equal in the JavaScript
228
+ * sense. Use `Value::StrictEquals()` to check primitives for equality.
191
229
  */
230
+
192
231
  template <class S>
193
232
  V8_INLINE bool operator==(const Local<S>& that) const {
194
- internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
195
- internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
196
- if (a == nullptr) return b == nullptr;
197
- if (b == nullptr) return false;
198
- return *a == *b;
233
+ return internal::HandleHelper::EqualHandles(*this, that);
199
234
  }
200
235
 
201
236
  template <class S>
202
237
  V8_INLINE bool operator==(const PersistentBase<S>& that) const {
203
- internal::Address* a = reinterpret_cast<internal::Address*>(this->val_);
204
- internal::Address* b = reinterpret_cast<internal::Address*>(that.val_);
205
- if (a == nullptr) return b == nullptr;
206
- if (b == nullptr) return false;
207
- return *a == *b;
238
+ return internal::HandleHelper::EqualHandles(*this, that);
208
239
  }
209
240
 
210
- /**
211
- * Checks whether two handles are different.
212
- * Returns true if only one of the handles is empty, or if
213
- * the objects to which they refer are different.
214
- *
215
- * If both handles refer to JS objects, this is the same as strict
216
- * non-equality. For primitives, such as numbers or strings, a `true` return
217
- * value does not indicate that the values aren't equal in the JavaScript
218
- * sense. Use `Value::StrictEquals()` to check primitives for equality.
219
- */
220
241
  template <class S>
221
242
  V8_INLINE bool operator!=(const Local<S>& that) const {
222
243
  return !operator==(that);
@@ -263,12 +284,12 @@ class Local {
263
284
 
264
285
  V8_INLINE static Local<T> New(Isolate* isolate,
265
286
  const PersistentBase<T>& that) {
266
- return New(isolate, that.val_);
287
+ return New(isolate, internal::ValueHelper::SlotAsValue<T>(that.val_));
267
288
  }
268
289
 
269
290
  V8_INLINE static Local<T> New(Isolate* isolate,
270
291
  const BasicTracedReference<T>& that) {
271
- return New(isolate, *that);
292
+ return New(isolate, internal::ValueHelper::SlotAsValue<T>(*that));
272
293
  }
273
294
 
274
295
  private:
@@ -277,12 +298,6 @@ class Local {
277
298
  template <class F>
278
299
  friend class Eternal;
279
300
  template <class F>
280
- friend class PersistentBase;
281
- template <class F, class M>
282
- friend class Persistent;
283
- template <class F>
284
- friend class Local;
285
- template <class F>
286
301
  friend class MaybeLocal;
287
302
  template <class F>
288
303
  friend class FunctionCallbackInfo;
@@ -309,19 +324,31 @@ class Local {
309
324
  friend class ReturnValue;
310
325
  template <class F>
311
326
  friend class Traced;
312
- template <class F>
313
- friend class BasicTracedReference;
314
- template <class F>
315
- friend class TracedReference;
327
+ friend class internal::SamplingHeapProfiler;
328
+ friend class internal::HandleHelper;
329
+ friend class debug::ConsoleCallArguments;
316
330
 
317
331
  explicit V8_INLINE Local(T* that) : val_(that) {}
332
+
333
+ V8_INLINE internal::Address address() const {
334
+ return internal::ValueHelper::ValueAsAddress(val_);
335
+ }
336
+
337
+ V8_INLINE static Local<T> FromSlot(internal::Address* slot) {
338
+ return Local<T>(internal::ValueHelper::SlotAsValue<T>(slot));
339
+ }
340
+
318
341
  V8_INLINE static Local<T> New(Isolate* isolate, T* that) {
342
+ #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
343
+ return Local<T>(that);
344
+ #else
319
345
  if (that == nullptr) return Local<T>();
320
- T* that_ptr = that;
321
- internal::Address* p = reinterpret_cast<internal::Address*>(that_ptr);
346
+ internal::Address* p = reinterpret_cast<internal::Address*>(that);
322
347
  return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
323
348
  reinterpret_cast<internal::Isolate*>(isolate), *p)));
349
+ #endif
324
350
  }
351
+
325
352
  T* val_;
326
353
  };
327
354
 
@@ -344,13 +371,15 @@ using Handle = Local<T>;
344
371
  template <class T>
345
372
  class MaybeLocal {
346
373
  public:
347
- V8_INLINE MaybeLocal() : val_(nullptr) {}
374
+ V8_INLINE MaybeLocal() : val_(internal::ValueHelper::EmptyValue<T>()) {}
348
375
  template <class S>
349
376
  V8_INLINE MaybeLocal(Local<S> that) : val_(reinterpret_cast<T*>(*that)) {
350
377
  static_assert(std::is_base_of<T, S>::value, "type check");
351
378
  }
352
379
 
353
- V8_INLINE bool IsEmpty() const { return val_ == nullptr; }
380
+ V8_INLINE bool IsEmpty() const {
381
+ return val_ == internal::ValueHelper::EmptyValue<T>();
382
+ }
354
383
 
355
384
  /**
356
385
  * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty,
@@ -358,7 +387,7 @@ class MaybeLocal {
358
387
  */
359
388
  template <class S>
360
389
  V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const {
361
- out->val_ = IsEmpty() ? nullptr : this->val_;
390
+ out->val_ = IsEmpty() ? internal::ValueHelper::EmptyValue<T>() : this->val_;
362
391
  return !IsEmpty();
363
392
  }
364
393
 
@@ -367,7 +396,7 @@ class MaybeLocal {
367
396
  * V8 will crash the process.
368
397
  */
369
398
  V8_INLINE Local<T> ToLocalChecked() {
370
- if (V8_UNLIKELY(val_ == nullptr)) api_internal::ToLocalEmpty();
399
+ if (V8_UNLIKELY(IsEmpty())) api_internal::ToLocalEmpty();
371
400
  return Local<T>(val_);
372
401
  }
373
402
 
@@ -399,9 +428,13 @@ class V8_EXPORT V8_NODISCARD EscapableHandleScope : public HandleScope {
399
428
  */
400
429
  template <class T>
401
430
  V8_INLINE Local<T> Escape(Local<T> value) {
431
+ #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
432
+ return value;
433
+ #else
402
434
  internal::Address* slot =
403
435
  Escape(reinterpret_cast<internal::Address*>(*value));
404
436
  return Local<T>(reinterpret_cast<T*>(slot));
437
+ #endif
405
438
  }
406
439
 
407
440
  template <class T>
@@ -12,6 +12,7 @@
12
12
 
13
13
  #include "v8-internal.h" // NOLINT(build/include_directory)
14
14
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
15
+ #include "v8config.h" // NOLINT(build/include_directory)
15
16
 
16
17
  namespace v8 {
17
18
 
@@ -96,16 +97,42 @@ struct GarbageCollectionYoungCycle {
96
97
  };
97
98
 
98
99
  struct WasmModuleDecoded {
100
+ WasmModuleDecoded() = default;
101
+ WasmModuleDecoded(bool async, bool streamed, bool success,
102
+ size_t module_size_in_bytes, size_t function_count,
103
+ int64_t wall_clock_duration_in_us)
104
+ : async(async),
105
+ streamed(streamed),
106
+ success(success),
107
+ module_size_in_bytes(module_size_in_bytes),
108
+ function_count(function_count),
109
+ wall_clock_duration_in_us(wall_clock_duration_in_us) {}
110
+
99
111
  bool async = false;
100
112
  bool streamed = false;
101
113
  bool success = false;
102
114
  size_t module_size_in_bytes = 0;
103
115
  size_t function_count = 0;
104
116
  int64_t wall_clock_duration_in_us = -1;
105
- int64_t cpu_duration_in_us = -1;
106
117
  };
107
118
 
108
119
  struct WasmModuleCompiled {
120
+ WasmModuleCompiled() = default;
121
+
122
+ WasmModuleCompiled(bool async, bool streamed, bool cached, bool deserialized,
123
+ bool lazy, bool success, size_t code_size_in_bytes,
124
+ size_t liftoff_bailout_count,
125
+ int64_t wall_clock_duration_in_us)
126
+ : async(async),
127
+ streamed(streamed),
128
+ cached(cached),
129
+ deserialized(deserialized),
130
+ lazy(lazy),
131
+ success(success),
132
+ code_size_in_bytes(code_size_in_bytes),
133
+ liftoff_bailout_count(liftoff_bailout_count),
134
+ wall_clock_duration_in_us(wall_clock_duration_in_us) {}
135
+
109
136
  bool async = false;
110
137
  bool streamed = false;
111
138
  bool cached = false;
@@ -115,7 +142,6 @@ struct WasmModuleCompiled {
115
142
  size_t code_size_in_bytes = 0;
116
143
  size_t liftoff_bailout_count = 0;
117
144
  int64_t wall_clock_duration_in_us = -1;
118
- int64_t cpu_duration_in_us = -1;
119
145
  };
120
146
 
121
147
  struct WasmModuleInstantiated {
@@ -118,7 +118,12 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope {
118
118
  public:
119
119
  enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
120
120
 
121
+ V8_DEPRECATE_SOON(
122
+ "May be incorrect if context was created with non-default microtask "
123
+ "queue")
121
124
  MicrotasksScope(Isolate* isolate, Type type);
125
+
126
+ MicrotasksScope(Local<Context> context, Type type);
122
127
  MicrotasksScope(Isolate* isolate, MicrotaskQueue* microtask_queue, Type type);
123
128
  ~MicrotasksScope();
124
129
 
@@ -20,6 +20,8 @@ class Function;
20
20
  class FunctionTemplate;
21
21
  template <typename T>
22
22
  class PropertyCallbackInfo;
23
+ class Module;
24
+ class UnboundScript;
23
25
 
24
26
  /**
25
27
  * A private symbol
@@ -480,6 +482,21 @@ class V8_EXPORT Object : public Value {
480
482
  /** Sets the value in an internal field. */
481
483
  void SetInternalField(int index, Local<Value> value);
482
484
 
485
+ /**
486
+ * Warning: These are Node.js-specific extentions used to avoid breaking
487
+ * changes in Node.js v20.x. They do not exist in V8 upstream and will
488
+ * not exist in Node.js v21.x. Node.js embedders and addon authors should
489
+ * not use them from v20.x.
490
+ */
491
+ #ifndef NODE_WANT_INTERNALS
492
+ V8_DEPRECATED("This extention should only be used by Node.js core")
493
+ #endif
494
+ void SetInternalFieldForNodeCore(int index, Local<Module> value);
495
+ #ifndef NODE_WANT_INTERNALS
496
+ V8_DEPRECATED("This extention should only be used by Node.js core")
497
+ #endif
498
+ void SetInternalFieldForNodeCore(int index, Local<UnboundScript> value);
499
+
483
500
  /**
484
501
  * Gets a 2-byte-aligned native pointer from an internal field. This field
485
502
  * must have been set by SetAlignedPointerInInternalField, everything else
@@ -607,6 +624,19 @@ class V8_EXPORT Object : public Value {
607
624
  return object.val_->GetCreationContext();
608
625
  }
609
626
 
627
+ /**
628
+ * Gets the context in which the object was created (see GetCreationContext())
629
+ * and if it's available reads respective embedder field value.
630
+ * If the context can't be obtained nullptr is returned.
631
+ * Basically it's a shortcut for
632
+ * obj->GetCreationContext().GetAlignedPointerFromEmbedderData(index)
633
+ * which doesn't create a handle for Context object on the way and doesn't
634
+ * try to expand the embedder data attached to the context.
635
+ * In case the Local<Context> is already available because of other reasons,
636
+ * it's fine to keep using Context::GetAlignedPointerFromEmbedderData().
637
+ */
638
+ void* GetAlignedPointerFromEmbedderDataInCreationContext(int index);
639
+
610
640
  /**
611
641
  * Checks whether a callback is set by the
612
642
  * ObjectTemplate::SetCallAsFunctionHandler method.
@@ -707,7 +737,7 @@ Local<Value> Object::GetInternalField(int index) {
707
737
  #ifndef V8_ENABLE_CHECKS
708
738
  using A = internal::Address;
709
739
  using I = internal::Internals;
710
- A obj = *reinterpret_cast<A*>(this);
740
+ A obj = internal::ValueHelper::ValueAsAddress(this);
711
741
  // Fast path: If the object is a plain JSObject, which is the common case, we
712
742
  // know where to find the internal fields and can return the value directly.
713
743
  int instance_type = I::GetInstanceType(obj);
@@ -717,12 +747,17 @@ Local<Value> Object::GetInternalField(int index) {
717
747
  #ifdef V8_COMPRESS_POINTERS
718
748
  // We read the full pointer value and then decompress it in order to avoid
719
749
  // dealing with potential endiannes issues.
720
- value = I::DecompressTaggedAnyField(obj, static_cast<uint32_t>(value));
750
+ value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
721
751
  #endif
752
+
753
+ #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
754
+ return Local<Value>(reinterpret_cast<Value*>(value));
755
+ #else
722
756
  internal::Isolate* isolate =
723
757
  internal::IsolateFromNeverReadOnlySpaceObject(obj);
724
758
  A* result = HandleScope::CreateHandle(isolate, value);
725
759
  return Local<Value>(reinterpret_cast<Value*>(result));
760
+ #endif
726
761
  }
727
762
  #endif
728
763
  return SlowGetInternalField(index);
@@ -732,7 +767,7 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
732
767
  #if !defined(V8_ENABLE_CHECKS)
733
768
  using A = internal::Address;
734
769
  using I = internal::Internals;
735
- A obj = *reinterpret_cast<A*>(this);
770
+ A obj = internal::ValueHelper::ValueAsAddress(this);
736
771
  // Fast path: If the object is a plain JSObject, which is the common case, we
737
772
  // know where to find the internal fields and can return the value directly.
738
773
  auto instance_type = I::GetInstanceType(obj);