node-linux-arm64 20.8.1 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +237 -1639
  2. package/README.md +3 -3
  3. package/bin/node +0 -0
  4. package/include/node/common.gypi +3 -3
  5. package/include/node/config.gypi +5 -3
  6. package/include/node/cppgc/internal/api-constants.h +23 -4
  7. package/include/node/cppgc/internal/caged-heap-local-data.h +16 -6
  8. package/include/node/cppgc/internal/caged-heap.h +12 -5
  9. package/include/node/cppgc/internal/gc-info.h +82 -91
  10. package/include/node/cppgc/internal/member-storage.h +16 -8
  11. package/include/node/cppgc/member.h +25 -0
  12. package/include/node/cppgc/persistent.h +4 -0
  13. package/include/node/cppgc/platform.h +6 -1
  14. package/include/node/cppgc/sentinel-pointer.h +7 -0
  15. package/include/node/cppgc/source-location.h +2 -78
  16. package/include/node/cppgc/trace-trait.h +8 -0
  17. package/include/node/cppgc/visitor.h +82 -4
  18. package/include/node/js_native_api.h +11 -1
  19. package/include/node/libplatform/libplatform.h +7 -1
  20. package/include/node/node.h +2 -0
  21. package/include/node/node_api.h +8 -7
  22. package/include/node/node_version.h +8 -7
  23. package/include/node/v8-callbacks.h +52 -8
  24. package/include/node/v8-context.h +10 -13
  25. package/include/node/v8-embedder-heap.h +12 -0
  26. package/include/node/v8-function-callback.h +11 -15
  27. package/include/node/v8-function.h +6 -0
  28. package/include/node/v8-handle-base.h +185 -0
  29. package/include/node/v8-internal.h +109 -77
  30. package/include/node/v8-isolate.h +130 -89
  31. package/include/node/v8-local-handle.h +134 -89
  32. package/include/node/v8-object.h +71 -69
  33. package/include/node/v8-persistent-handle.h +65 -89
  34. package/include/node/v8-platform.h +140 -9
  35. package/include/node/v8-primitive.h +12 -8
  36. package/include/node/v8-profiler.h +16 -2
  37. package/include/node/v8-script.h +9 -7
  38. package/include/node/v8-snapshot.h +4 -1
  39. package/include/node/v8-source-location.h +92 -0
  40. package/include/node/v8-statistics.h +36 -1
  41. package/include/node/v8-traced-handle.h +37 -54
  42. package/include/node/v8-unwinder.h +1 -1
  43. package/include/node/v8-value-serializer.h +14 -0
  44. package/include/node/v8-value.h +14 -0
  45. package/include/node/v8-version.h +3 -3
  46. package/include/node/v8config.h +19 -10
  47. package/package.json +1 -1
  48. package/share/doc/node/gdbinit +60 -6
  49. package/share/doc/node/lldb_commands.py +73 -10
  50. package/share/man/man1/node.1 +12 -0
@@ -5,87 +5,11 @@
5
5
  #ifndef INCLUDE_CPPGC_SOURCE_LOCATION_H_
6
6
  #define INCLUDE_CPPGC_SOURCE_LOCATION_H_
7
7
 
8
- #include <cstddef>
9
- #include <string>
10
-
11
- #include "v8config.h" // NOLINT(build/include_directory)
12
-
13
- #if defined(__has_builtin)
14
- #define CPPGC_SUPPORTS_SOURCE_LOCATION \
15
- (__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
16
- __has_builtin(__builtin_LINE)) // NOLINT
17
- #elif defined(V8_CC_GNU) && __GNUC__ >= 7
18
- #define CPPGC_SUPPORTS_SOURCE_LOCATION 1
19
- #elif defined(V8_CC_INTEL) && __ICC >= 1800
20
- #define CPPGC_SUPPORTS_SOURCE_LOCATION 1
21
- #else
22
- #define CPPGC_SUPPORTS_SOURCE_LOCATION 0
23
- #endif
8
+ #include "v8-source-location.h"
24
9
 
25
10
  namespace cppgc {
26
11
 
27
- /**
28
- * Encapsulates source location information. Mimics C++20's
29
- * `std::source_location`.
30
- */
31
- class V8_EXPORT SourceLocation final {
32
- public:
33
- /**
34
- * Construct source location information corresponding to the location of the
35
- * call site.
36
- */
37
- #if CPPGC_SUPPORTS_SOURCE_LOCATION
38
- static constexpr SourceLocation Current(
39
- const char* function = __builtin_FUNCTION(),
40
- const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) {
41
- return SourceLocation(function, file, line);
42
- }
43
- #else
44
- static constexpr SourceLocation Current() { return SourceLocation(); }
45
- #endif // CPPGC_SUPPORTS_SOURCE_LOCATION
46
-
47
- /**
48
- * Constructs unspecified source location information.
49
- */
50
- constexpr SourceLocation() = default;
51
-
52
- /**
53
- * Returns the name of the function associated with the position represented
54
- * by this object, if any.
55
- *
56
- * \returns the function name as cstring.
57
- */
58
- constexpr const char* Function() const { return function_; }
59
-
60
- /**
61
- * Returns the name of the current source file represented by this object.
62
- *
63
- * \returns the file name as cstring.
64
- */
65
- constexpr const char* FileName() const { return file_; }
66
-
67
- /**
68
- * Returns the line number represented by this object.
69
- *
70
- * \returns the line number.
71
- */
72
- constexpr size_t Line() const { return line_; }
73
-
74
- /**
75
- * Returns a human-readable string representing this object.
76
- *
77
- * \returns a human-readable string representing source location information.
78
- */
79
- std::string ToString() const;
80
-
81
- private:
82
- constexpr SourceLocation(const char* function, const char* file, size_t line)
83
- : function_(function), file_(file), line_(line) {}
84
-
85
- const char* function_ = nullptr;
86
- const char* file_ = nullptr;
87
- size_t line_ = 0u;
88
- };
12
+ using SourceLocation = v8::SourceLocation;
89
13
 
90
14
  } // namespace cppgc
91
15
 
@@ -53,6 +53,14 @@ struct TraceDescriptor {
53
53
  TraceCallback callback;
54
54
  };
55
55
 
56
+ /**
57
+ * Callback for getting a TraceDescriptor for a given address.
58
+ *
59
+ * \param address Possibly inner address of an object.
60
+ * \returns a TraceDescriptor for the provided address.
61
+ */
62
+ using TraceDescriptorCallback = TraceDescriptor (*)(const void* address);
63
+
56
64
  namespace internal {
57
65
 
58
66
  struct V8_EXPORT TraceTraitFromInnerAddressImpl {
@@ -5,10 +5,13 @@
5
5
  #ifndef INCLUDE_CPPGC_VISITOR_H_
6
6
  #define INCLUDE_CPPGC_VISITOR_H_
7
7
 
8
+ #include <type_traits>
9
+
8
10
  #include "cppgc/custom-space.h"
9
11
  #include "cppgc/ephemeron-pair.h"
10
12
  #include "cppgc/garbage-collected.h"
11
13
  #include "cppgc/internal/logging.h"
14
+ #include "cppgc/internal/member-storage.h"
12
15
  #include "cppgc/internal/pointer-policies.h"
13
16
  #include "cppgc/liveness-broker.h"
14
17
  #include "cppgc/member.h"
@@ -113,6 +116,30 @@ class V8_EXPORT Visitor {
113
116
  }
114
117
  #endif // defined(CPPGC_POINTER_COMPRESSION)
115
118
 
119
+ template <typename T>
120
+ void TraceMultiple(const subtle::UncompressedMember<T>* start, size_t len) {
121
+ static_assert(sizeof(T), "Pointee type must be fully defined.");
122
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
123
+ "T must be GarbageCollected or GarbageCollectedMixin type");
124
+ VisitMultipleUncompressedMember(start, len,
125
+ &TraceTrait<T>::GetTraceDescriptor);
126
+ }
127
+
128
+ template <typename T,
129
+ std::enable_if_t<!std::is_same_v<
130
+ Member<T>, subtle::UncompressedMember<T>>>* = nullptr>
131
+ void TraceMultiple(const Member<T>* start, size_t len) {
132
+ static_assert(sizeof(T), "Pointee type must be fully defined.");
133
+ static_assert(internal::IsGarbageCollectedOrMixinType<T>::value,
134
+ "T must be GarbageCollected or GarbageCollectedMixin type");
135
+ #if defined(CPPGC_POINTER_COMPRESSION)
136
+ static_assert(std::is_same_v<Member<T>, subtle::CompressedMember<T>>,
137
+ "Member and CompressedMember must be the same.");
138
+ VisitMultipleCompressedMember(start, len,
139
+ &TraceTrait<T>::GetTraceDescriptor);
140
+ #endif // defined(CPPGC_POINTER_COMPRESSION)
141
+ }
142
+
116
143
  /**
117
144
  * Trace method for inlined objects that are not allocated themselves but
118
145
  * otherwise follow managed heap layout and have a Trace() method.
@@ -131,6 +158,26 @@ class V8_EXPORT Visitor {
131
158
  TraceTrait<T>::Trace(this, &object);
132
159
  }
133
160
 
161
+ template <typename T>
162
+ void TraceMultiple(const T* start, size_t len) {
163
+ #if V8_ENABLE_CHECKS
164
+ // This object is embedded in potentially multiple nested objects. The
165
+ // outermost object must not be in construction as such objects are (a) not
166
+ // processed immediately, and (b) only processed conservatively if not
167
+ // otherwise possible.
168
+ CheckObjectNotInConstruction(start);
169
+ #endif // V8_ENABLE_CHECKS
170
+ for (size_t i = 0; i < len; ++i) {
171
+ const T* object = &start[i];
172
+ if constexpr (std::is_polymorphic_v<T>) {
173
+ // The object's vtable may be uninitialized in which case the object is
174
+ // not traced.
175
+ if (*reinterpret_cast<const uintptr_t*>(object) == 0) continue;
176
+ }
177
+ TraceTrait<T>::Trace(this, object);
178
+ }
179
+ }
180
+
134
181
  /**
135
182
  * Registers a weak callback method on the object of type T. See
136
183
  * LivenessBroker for an usage example.
@@ -314,6 +361,39 @@ class V8_EXPORT Visitor {
314
361
  WeakCallback callback, const void* data) {}
315
362
  virtual void HandleMovableReference(const void**) {}
316
363
 
364
+ virtual void VisitMultipleUncompressedMember(
365
+ const void* start, size_t len,
366
+ TraceDescriptorCallback get_trace_descriptor) {
367
+ // Default implementation merely delegates to Visit().
368
+ const char* it = static_cast<const char*>(start);
369
+ const char* end = it + len * internal::kSizeOfUncompressedMember;
370
+ for (; it < end; it += internal::kSizeOfUncompressedMember) {
371
+ const auto* current = reinterpret_cast<const internal::RawPointer*>(it);
372
+ const void* object = current->LoadAtomic();
373
+ if (!object) continue;
374
+
375
+ Visit(object, get_trace_descriptor(object));
376
+ }
377
+ }
378
+
379
+ #if defined(CPPGC_POINTER_COMPRESSION)
380
+ virtual void VisitMultipleCompressedMember(
381
+ const void* start, size_t len,
382
+ TraceDescriptorCallback get_trace_descriptor) {
383
+ // Default implementation merely delegates to Visit().
384
+ const char* it = static_cast<const char*>(start);
385
+ const char* end = it + len * internal::kSizeofCompressedMember;
386
+ for (; it < end; it += internal::kSizeofCompressedMember) {
387
+ const auto* current =
388
+ reinterpret_cast<const internal::CompressedPointer*>(it);
389
+ const void* object = current->LoadAtomic();
390
+ if (!object) continue;
391
+
392
+ Visit(object, get_trace_descriptor(object));
393
+ }
394
+ }
395
+ #endif // defined(CPPGC_POINTER_COMPRESSION)
396
+
317
397
  private:
318
398
  template <typename T, void (T::*method)(const LivenessBroker&)>
319
399
  static void WeakCallbackMethodDelegate(const LivenessBroker& info,
@@ -326,8 +406,7 @@ class V8_EXPORT Visitor {
326
406
  template <typename PointerType>
327
407
  static void HandleWeak(const LivenessBroker& info, const void* object) {
328
408
  const PointerType* weak = static_cast<const PointerType*>(object);
329
- auto* raw_ptr = weak->GetFromGC();
330
- if (!info.IsHeapObjectAlive(raw_ptr)) {
409
+ if (!info.IsHeapObjectAlive(weak->GetFromGC())) {
331
410
  weak->ClearFromGC();
332
411
  }
333
412
  }
@@ -413,8 +492,7 @@ class V8_EXPORT RootVisitor {
413
492
  template <typename PointerType>
414
493
  static void HandleWeak(const LivenessBroker& info, const void* object) {
415
494
  const PointerType* weak = static_cast<const PointerType*>(object);
416
- auto* raw_ptr = weak->GetFromGC();
417
- if (!info.IsHeapObjectAlive(raw_ptr)) {
495
+ if (!info.IsHeapObjectAlive(weak->GetFromGC())) {
418
496
  weak->ClearFromGC();
419
497
  }
420
498
  }
@@ -28,7 +28,7 @@
28
28
  #ifndef NAPI_EXTERN
29
29
  #ifdef _WIN32
30
30
  #define NAPI_EXTERN __declspec(dllexport)
31
- #elif defined(__wasm32__)
31
+ #elif defined(__wasm__)
32
32
  #define NAPI_EXTERN \
33
33
  __attribute__((visibility("default"))) \
34
34
  __attribute__((__import_module__("napi")))
@@ -517,6 +517,16 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_add_finalizer(napi_env env,
517
517
 
518
518
  #endif // NAPI_VERSION >= 5
519
519
 
520
+ #ifdef NAPI_EXPERIMENTAL
521
+
522
+ NAPI_EXTERN napi_status NAPI_CDECL
523
+ node_api_post_finalizer(napi_env env,
524
+ napi_finalize finalize_cb,
525
+ void* finalize_data,
526
+ void* finalize_hint);
527
+
528
+ #endif // NAPI_EXPERIMENTAL
529
+
520
530
  #if NAPI_VERSION >= 6
521
531
 
522
532
  // BigInt
@@ -23,6 +23,8 @@ enum class MessageLoopBehavior : bool {
23
23
  kWaitForWork = true
24
24
  };
25
25
 
26
+ enum class PriorityMode : bool { kDontApply, kApply };
27
+
26
28
  /**
27
29
  * Returns a new instance of the default v8::Platform implementation.
28
30
  *
@@ -35,13 +37,17 @@ enum class MessageLoopBehavior : bool {
35
37
  * calling v8::platform::RunIdleTasks to process the idle tasks.
36
38
  * If |tracing_controller| is nullptr, the default platform will create a
37
39
  * v8::platform::TracingController instance and use it.
40
+ * If |priority_mode| is PriorityMode::kApply, the default platform will use
41
+ * multiple task queues executed by threads different system-level priorities
42
+ * (where available) to schedule tasks.
38
43
  */
39
44
  V8_PLATFORM_EXPORT std::unique_ptr<v8::Platform> NewDefaultPlatform(
40
45
  int thread_pool_size = 0,
41
46
  IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
42
47
  InProcessStackDumping in_process_stack_dumping =
43
48
  InProcessStackDumping::kDisabled,
44
- std::unique_ptr<v8::TracingController> tracing_controller = {});
49
+ std::unique_ptr<v8::TracingController> tracing_controller = {},
50
+ PriorityMode priority_mode = PriorityMode::kDontApply);
45
51
 
46
52
  /**
47
53
  * The same as NewDefaultPlatform but disables the worker thread pool.
@@ -265,6 +265,8 @@ enum Flags : uint32_t {
265
265
  // cppgc::InitializeProcess() before creating a Node.js environment
266
266
  // and call cppgc::ShutdownProcess() before process shutdown.
267
267
  kNoInitializeCppgc = 1 << 13,
268
+ // Initialize the process for predictable snapshot generation.
269
+ kGeneratePredictableSnapshot = 1 << 14,
268
270
 
269
271
  // Emulate the behavior of InitializeNodeWithArgs() when passing
270
272
  // a flags argument to the InitializeOncePerProcess() replacement
@@ -1,11 +1,11 @@
1
1
  #ifndef SRC_NODE_API_H_
2
2
  #define SRC_NODE_API_H_
3
3
 
4
- #ifdef BUILDING_NODE_EXTENSION
4
+ #if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN)
5
5
  #ifdef _WIN32
6
6
  // Building native addon against node
7
7
  #define NAPI_EXTERN __declspec(dllimport)
8
- #elif defined(__wasm32__)
8
+ #elif defined(__wasm__)
9
9
  #define NAPI_EXTERN __attribute__((__import_module__("napi")))
10
10
  #endif
11
11
  #endif
@@ -17,8 +17,13 @@ struct uv_loop_s; // Forward declaration.
17
17
  #ifdef _WIN32
18
18
  #define NAPI_MODULE_EXPORT __declspec(dllexport)
19
19
  #else
20
+ #ifdef __EMSCRIPTEN__
21
+ #define NAPI_MODULE_EXPORT \
22
+ __attribute__((visibility("default"))) __attribute__((used))
23
+ #else
20
24
  #define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
21
25
  #endif
26
+ #endif
22
27
 
23
28
  #if defined(__GNUC__)
24
29
  #define NAPI_NO_RETURN __attribute__((noreturn))
@@ -49,7 +54,7 @@ typedef struct napi_module {
49
54
  NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
50
55
  #define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
51
56
 
52
- #ifdef __wasm32__
57
+ #ifdef __wasm__
53
58
  #define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
54
59
  #else
55
60
  #define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
@@ -143,7 +148,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
143
148
  void** data,
144
149
  size_t* length);
145
150
 
146
- #ifndef __wasm32__
147
151
  // Methods to manage simple async operations
148
152
  NAPI_EXTERN napi_status NAPI_CDECL
149
153
  napi_create_async_work(napi_env env,
@@ -159,7 +163,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
159
163
  napi_async_work work);
160
164
  NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
161
165
  napi_async_work work);
162
- #endif // __wasm32__
163
166
 
164
167
  // version management
165
168
  NAPI_EXTERN napi_status NAPI_CDECL
@@ -197,7 +200,6 @@ napi_close_callback_scope(napi_env env, napi_callback_scope scope);
197
200
 
198
201
  #if NAPI_VERSION >= 4
199
202
 
200
- #ifndef __wasm32__
201
203
  // Calling into JS from other threads
202
204
  NAPI_EXTERN napi_status NAPI_CDECL
203
205
  napi_create_threadsafe_function(napi_env env,
@@ -231,7 +233,6 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
231
233
 
232
234
  NAPI_EXTERN napi_status NAPI_CDECL
233
235
  napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
234
- #endif // __wasm32__
235
236
 
236
237
  #endif // NAPI_VERSION >= 4
237
238
 
@@ -22,9 +22,9 @@
22
22
  #ifndef SRC_NODE_VERSION_H_
23
23
  #define SRC_NODE_VERSION_H_
24
24
 
25
- #define NODE_MAJOR_VERSION 20
26
- #define NODE_MINOR_VERSION 8
27
- #define NODE_PATCH_VERSION 1
25
+ #define NODE_MAJOR_VERSION 21
26
+ #define NODE_MINOR_VERSION 0
27
+ #define NODE_PATCH_VERSION 0
28
28
 
29
29
  #define NODE_VERSION_IS_LTS 0
30
30
  #define NODE_VERSION_LTS_CODENAME ""
@@ -95,12 +95,13 @@
95
95
  #if defined(NODE_EMBEDDER_MODULE_VERSION)
96
96
  #define NODE_MODULE_VERSION NODE_EMBEDDER_MODULE_VERSION
97
97
  #else
98
- #define NODE_MODULE_VERSION 115
98
+ #define NODE_MODULE_VERSION 120
99
99
  #endif
100
100
 
101
- // The NAPI_VERSION provided by this version of the runtime. This is the version
102
- // which the Node binary being built supports.
103
- #define NAPI_VERSION 9
101
+ // The NAPI_VERSION supported by the runtime. This is the inclusive range of
102
+ // versions which the Node.js binary being built supports.
103
+ #define NODE_API_SUPPORTED_VERSION_MAX 9
104
+ #define NODE_API_SUPPORTED_VERSION_MIN 1
104
105
 
105
106
  // Node API modules use NAPI_VERSION 8 by default if it is not explicitly
106
107
  // specified. It must be always 8.
@@ -147,14 +147,18 @@ using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
147
147
  * the callback functions, you therefore cannot manipulate objects (set or
148
148
  * delete properties for example) since it is possible such operations will
149
149
  * result in the allocation of objects.
150
+ * TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink.
150
151
  */
151
152
  enum GCType {
152
153
  kGCTypeScavenge = 1 << 0,
153
- kGCTypeMinorMarkCompact = 1 << 1,
154
+ kGCTypeMinorMarkSweep = 1 << 1,
155
+ kGCTypeMinorMarkCompact V8_DEPRECATE_SOON(
156
+ "Use kGCTypeMinorMarkSweep instead of kGCTypeMinorMarkCompact.") =
157
+ kGCTypeMinorMarkSweep,
154
158
  kGCTypeMarkSweepCompact = 1 << 2,
155
159
  kGCTypeIncrementalMarking = 1 << 3,
156
160
  kGCTypeProcessWeakCallbacks = 1 << 4,
157
- kGCTypeAll = kGCTypeScavenge | kGCTypeMinorMarkCompact |
161
+ kGCTypeAll = kGCTypeScavenge | kGCTypeMinorMarkSweep |
158
162
  kGCTypeMarkSweepCompact | kGCTypeIncrementalMarking |
159
163
  kGCTypeProcessWeakCallbacks
160
164
  };
@@ -323,20 +327,21 @@ using WasmAsyncResolvePromiseCallback = void (*)(
323
327
  using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
324
328
  const char* name);
325
329
 
326
- // --- Callback for checking if WebAssembly Simd is enabled ---
327
- using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
328
-
329
- // --- Callback for checking if WebAssembly exceptions are enabled ---
330
- using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
331
-
332
330
  // --- Callback for checking if WebAssembly GC is enabled ---
333
331
  // If the callback returns true, it will also enable Wasm stringrefs.
334
332
  using WasmGCEnabledCallback = bool (*)(Local<Context> context);
335
333
 
334
+ // --- Callback for checking if WebAssembly imported strings are enabled ---
335
+ using WasmImportedStringsEnabledCallback = bool (*)(Local<Context> context);
336
+
336
337
  // --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
337
338
  using SharedArrayBufferConstructorEnabledCallback =
338
339
  bool (*)(Local<Context> context);
339
340
 
341
+ // --- Callback for checking if the compile hints magic comments are enabled ---
342
+ using JavaScriptCompileHintsMagicEnabledCallback =
343
+ bool (*)(Local<Context> context);
344
+
340
345
  /**
341
346
  * HostImportModuleDynamicallyCallback is called when we
342
347
  * require the embedder to load a module. This is used as part of the dynamic
@@ -419,6 +424,45 @@ using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
419
424
  Local<Value> error,
420
425
  Local<Array> sites);
421
426
 
427
+ #if defined(V8_OS_WIN)
428
+ /**
429
+ * Callback to selectively enable ETW tracing based on the document URL.
430
+ * Implemented by the embedder, it should never call back into V8.
431
+ *
432
+ * Windows allows passing additional data to the ETW EnableCallback:
433
+ * https://learn.microsoft.com/en-us/windows/win32/api/evntprov/nc-evntprov-penablecallback
434
+ *
435
+ * This data can be configured in a WPR (Windows Performance Recorder)
436
+ * profile, adding a CustomFilter to an EventProvider like the following:
437
+ *
438
+ * <EventProvider Id=".." Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" Level="5">
439
+ * <CustomFilter Type="0x80000000" Value="AQABAAAAAAA..." />
440
+ * </EventProvider>
441
+ *
442
+ * Where:
443
+ * - Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" is the GUID of the V8
444
+ * ETW provider, (see src/libplatform/etw/etw-provider-win.h),
445
+ * - Type="0x80000000" is EVENT_FILTER_TYPE_SCHEMATIZED,
446
+ * - Value="AQABAAAAAA..." is a base64-encoded byte array that is
447
+ * base64-decoded by Windows and passed to the ETW enable callback in
448
+ * the 'PEVENT_FILTER_DESCRIPTOR FilterData' argument; see:
449
+ * https://learn.microsoft.com/en-us/windows/win32/api/evntprov/ns-evntprov-event_filter_descriptor.
450
+ *
451
+ * This array contains a struct EVENT_FILTER_HEADER followed by a
452
+ * variable length payload, and as payload we pass a string in JSON format,
453
+ * with a list of regular expressions that should match the document URL
454
+ * in order to enable ETW tracing:
455
+ * {
456
+ * "version": "1.0",
457
+ * "filtered_urls": [
458
+ * "https:\/\/.*\.chromium\.org\/.*", "https://v8.dev/";, "..."
459
+ * ]
460
+ * }
461
+ */
462
+ using FilterETWSessionByURLCallback =
463
+ bool (*)(Local<Context> context, const std::string& etw_filter_payload);
464
+ #endif // V8_OS_WIN
465
+
422
466
  } // namespace v8
423
467
 
424
468
  #endif // INCLUDE_V8_ISOLATE_CALLBACKS_H_
@@ -395,7 +395,7 @@ Local<Value> Context::GetEmbedderData(int index) {
395
395
  #ifndef V8_ENABLE_CHECKS
396
396
  using A = internal::Address;
397
397
  using I = internal::Internals;
398
- A ctx = *reinterpret_cast<const A*>(this);
398
+ A ctx = internal::ValueHelper::ValueAsAddress(this);
399
399
  A embedder_data =
400
400
  I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
401
401
  int value_offset =
@@ -407,15 +407,9 @@ Local<Value> Context::GetEmbedderData(int index) {
407
407
  value = I::DecompressTaggedField(embedder_data, static_cast<uint32_t>(value));
408
408
  #endif
409
409
 
410
- #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
411
- return Local<Value>(reinterpret_cast<Value*>(value));
412
- #else
413
- internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
414
- *reinterpret_cast<A*>(this));
415
- A* result = HandleScope::CreateHandle(isolate, value);
416
- return Local<Value>(reinterpret_cast<Value*>(result));
417
- #endif
418
-
410
+ auto isolate = reinterpret_cast<v8::Isolate*>(
411
+ internal::IsolateFromNeverReadOnlySpaceObject(ctx));
412
+ return Local<Value>::New(isolate, value);
419
413
  #else
420
414
  return SlowGetEmbedderData(index);
421
415
  #endif
@@ -442,9 +436,12 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
442
436
 
443
437
  template <class T>
444
438
  MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
445
- T* data = reinterpret_cast<T*>(GetDataFromSnapshotOnce(index));
446
- if (data) internal::PerformCastCheck(data);
447
- return Local<T>(data);
439
+ auto slot = GetDataFromSnapshotOnce(index);
440
+ if (slot) {
441
+ internal::PerformCastCheck(
442
+ internal::ValueHelper::SlotAsValue<T, false>(slot));
443
+ }
444
+ return Local<T>::FromSlot(slot);
448
445
  }
449
446
 
450
447
  Context* Context::Cast(v8::Data* data) {
@@ -34,6 +34,8 @@ class V8_EXPORT EmbedderRootsHandler {
34
34
  * for retaining the object. The embedder may use |WrapperClassId()| to
35
35
  * distinguish cases where it wants handles to be treated as roots from not
36
36
  * being treated as roots.
37
+ *
38
+ * The concrete implementations must be thread-safe.
37
39
  */
38
40
  virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
39
41
 
@@ -47,6 +49,16 @@ class V8_EXPORT EmbedderRootsHandler {
47
49
  * handle via the object or class id.
48
50
  */
49
51
  virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
52
+
53
+ /**
54
+ * Similar to |ResetRoot()|, but opportunistic. The function is called in
55
+ * parallel for different handles and as such must be thread-safe. In case,
56
+ * |false| is returned, |ResetRoot()| will be recalled for the same handle.
57
+ */
58
+ virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
59
+ ResetRoot(handle);
60
+ return true;
61
+ }
50
62
  };
51
63
 
52
64
  } // namespace v8
@@ -78,7 +78,6 @@ class ReturnValue {
78
78
 
79
79
  // See FunctionCallbackInfo.
80
80
  static constexpr int kIsolateValueIndex = -2;
81
- static constexpr int kDefaultValueValueIndex = -1;
82
81
 
83
82
  internal::Address* value_;
84
83
  };
@@ -127,16 +126,16 @@ class FunctionCallbackInfo {
127
126
  friend class internal::FunctionCallbackArguments;
128
127
  friend class internal::CustomArguments<FunctionCallbackInfo>;
129
128
  friend class debug::ConsoleCallArguments;
130
- friend class internal::Builtins;
129
+
131
130
  static constexpr int kHolderIndex = 0;
132
131
  static constexpr int kIsolateIndex = 1;
133
- static constexpr int kReturnValueDefaultValueIndex = 2;
132
+ static constexpr int kUnusedIndex = 2;
134
133
  static constexpr int kReturnValueIndex = 3;
135
134
  static constexpr int kDataIndex = 4;
136
135
  static constexpr int kNewTargetIndex = 5;
137
-
138
136
  static constexpr int kArgsLength = 6;
139
- static constexpr int kArgsLengthWithReceiver = 7;
137
+
138
+ static constexpr int kArgsLengthWithReceiver = kArgsLength + 1;
140
139
 
141
140
  // Codegen constants:
142
141
  static constexpr int kSize = 3 * internal::kApiSystemPointerSize;
@@ -147,8 +146,6 @@ class FunctionCallbackInfo {
147
146
  kValuesOffset + internal::kApiSystemPointerSize;
148
147
 
149
148
  static constexpr int kThisValuesIndex = -1;
150
- static_assert(ReturnValue<Value>::kDefaultValueValueIndex ==
151
- kReturnValueDefaultValueIndex - kReturnValueIndex);
152
149
  static_assert(ReturnValue<Value>::kIsolateValueIndex ==
153
150
  kIsolateIndex - kReturnValueIndex);
154
151
 
@@ -258,17 +255,17 @@ class PropertyCallbackInfo {
258
255
  static constexpr int kShouldThrowOnErrorIndex = 0;
259
256
  static constexpr int kHolderIndex = 1;
260
257
  static constexpr int kIsolateIndex = 2;
261
- static constexpr int kReturnValueDefaultValueIndex = 3;
258
+ static constexpr int kUnusedIndex = 3;
262
259
  static constexpr int kReturnValueIndex = 4;
263
260
  static constexpr int kDataIndex = 5;
264
261
  static constexpr int kThisIndex = 6;
265
-
266
262
  static constexpr int kArgsLength = 7;
267
263
 
268
264
  static constexpr int kSize = 1 * internal::kApiSystemPointerSize;
269
265
 
270
266
  V8_INLINE explicit PropertyCallbackInfo(internal::Address* args)
271
267
  : args_(args) {}
268
+
272
269
  internal::Address* args_;
273
270
  };
274
271
 
@@ -286,7 +283,7 @@ void ReturnValue<T>::Set(const Global<S>& handle) {
286
283
  if (V8_UNLIKELY(handle.IsEmpty())) {
287
284
  *value_ = GetDefaultValue();
288
285
  } else {
289
- *value_ = *reinterpret_cast<internal::Address*>(*handle);
286
+ *value_ = handle.ptr();
290
287
  }
291
288
  }
292
289
 
@@ -297,7 +294,7 @@ void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
297
294
  if (V8_UNLIKELY(handle.IsEmpty())) {
298
295
  *value_ = GetDefaultValue();
299
296
  } else {
300
- *value_ = *reinterpret_cast<internal::Address*>(handle.val_);
297
+ *value_ = handle.ptr();
301
298
  }
302
299
  }
303
300
 
@@ -309,7 +306,7 @@ void ReturnValue<T>::Set(const Local<S> handle) {
309
306
  if (V8_UNLIKELY(handle.IsEmpty())) {
310
307
  *value_ = GetDefaultValue();
311
308
  } else {
312
- *value_ = internal::ValueHelper::ValueAsAddress(*handle);
309
+ *value_ = handle.ptr();
313
310
  }
314
311
  }
315
312
 
@@ -378,7 +375,6 @@ void ReturnValue<T>::SetEmptyString() {
378
375
 
379
376
  template <typename T>
380
377
  Isolate* ReturnValue<T>::GetIsolate() const {
381
- // Isolate is always the pointer below the default value on the stack.
382
378
  return *reinterpret_cast<Isolate**>(&value_[kIsolateValueIndex]);
383
379
  }
384
380
 
@@ -403,8 +399,8 @@ void ReturnValue<T>::Set(S* whatever) {
403
399
 
404
400
  template <typename T>
405
401
  internal::Address ReturnValue<T>::GetDefaultValue() {
406
- // Default value is always the pointer below value_ on the stack.
407
- return value_[kDefaultValueValueIndex];
402
+ using I = internal::Internals;
403
+ return I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
408
404
  }
409
405
 
410
406
  template <typename T>
@@ -87,6 +87,12 @@ class V8_EXPORT Function : public Object {
87
87
  */
88
88
  int GetScriptColumnNumber() const;
89
89
 
90
+ /**
91
+ * Returns zero based start position (character offset) of function body and
92
+ * kLineOffsetNotFound if no information available.
93
+ */
94
+ int GetScriptStartPosition() const;
95
+
90
96
  /**
91
97
  * Returns scriptId.
92
98
  */