node-linux-arm64 21.7.3 → 22.1.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 (43) hide show
  1. package/CHANGELOG.md +470 -1502
  2. package/LICENSE +3 -33
  3. package/README.md +61 -55
  4. package/bin/node +0 -0
  5. package/include/node/common.gypi +29 -2
  6. package/include/node/config.gypi +9 -7
  7. package/include/node/cppgc/internal/api-constants.h +1 -1
  8. package/include/node/cppgc/type-traits.h +25 -4
  9. package/include/node/node.h +24 -2
  10. package/include/node/node_api.h +1 -1
  11. package/include/node/node_buffer.h +1 -1
  12. package/include/node/node_version.h +4 -4
  13. package/include/node/v8-array-buffer.h +6 -0
  14. package/include/node/v8-callbacks.h +6 -12
  15. package/include/node/v8-container.h +54 -0
  16. package/include/node/v8-context.h +51 -22
  17. package/include/node/v8-embedder-heap.h +19 -3
  18. package/include/node/v8-embedder-state-scope.h +2 -1
  19. package/include/node/v8-exception.h +15 -9
  20. package/include/node/v8-forward.h +1 -0
  21. package/include/node/v8-function-callback.h +129 -20
  22. package/include/node/v8-handle-base.h +32 -80
  23. package/include/node/v8-internal.h +472 -65
  24. package/include/node/v8-isolate.h +86 -51
  25. package/include/node/v8-local-handle.h +257 -31
  26. package/include/node/v8-memory-span.h +157 -2
  27. package/include/node/v8-message.h +22 -3
  28. package/include/node/v8-object.h +29 -10
  29. package/include/node/v8-persistent-handle.h +5 -3
  30. package/include/node/v8-platform.h +81 -44
  31. package/include/node/v8-script.h +61 -11
  32. package/include/node/v8-snapshot.h +94 -23
  33. package/include/node/v8-statistics.h +10 -24
  34. package/include/node/v8-template.h +410 -131
  35. package/include/node/v8-traced-handle.h +81 -46
  36. package/include/node/v8-typed-array.h +115 -7
  37. package/include/node/v8-value.h +92 -4
  38. package/include/node/v8-version.h +4 -4
  39. package/include/node/v8config.h +35 -10
  40. package/package.json +1 -1
  41. package/share/doc/node/gdbinit +77 -38
  42. package/share/doc/node/lldb_commands.py +59 -29
  43. package/share/man/man1/node.1 +12 -7
@@ -537,6 +537,7 @@ class EmbedderSnapshotData {
537
537
  // If the snapshot is invalid, this returns an empty pointer.
538
538
  static Pointer FromFile(FILE* in);
539
539
  static Pointer FromBlob(const std::vector<char>& in);
540
+ static Pointer FromBlob(std::string_view in);
540
541
 
541
542
  // Write this EmbedderSnapshotData object to an output file.
542
543
  // Calling this method will not close the FILE* handle.
@@ -731,12 +732,33 @@ struct StartExecutionCallbackInfo {
731
732
 
732
733
  using StartExecutionCallback =
733
734
  std::function<v8::MaybeLocal<v8::Value>(const StartExecutionCallbackInfo&)>;
735
+ using EmbedderPreloadCallback =
736
+ std::function<void(Environment* env,
737
+ v8::Local<v8::Value> process,
738
+ v8::Local<v8::Value> require)>;
734
739
 
740
+ // Run initialization for the environment.
741
+ //
742
+ // The |preload| function, usually used by embedders to inject scripts,
743
+ // will be run by Node.js before Node.js executes the entry point.
744
+ // The function is guaranteed to run before the user land module loader running
745
+ // any user code, so it is safe to assume that at this point, no user code has
746
+ // been run yet.
747
+ // The function will be executed with preload(process, require), and the passed
748
+ // require function has access to internal Node.js modules. There is no
749
+ // stability guarantee about the internals exposed to the internal require
750
+ // function. Expect breakages when updating Node.js versions if the embedder
751
+ // imports internal modules with the internal require function.
752
+ // Worker threads created in the environment will also respect The |preload|
753
+ // function, so make sure the function is thread-safe.
735
754
  NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
736
755
  Environment* env,
737
- StartExecutionCallback cb);
756
+ StartExecutionCallback cb,
757
+ EmbedderPreloadCallback preload = nullptr);
738
758
  NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
739
- Environment* env, std::string_view main_script_source_utf8);
759
+ Environment* env,
760
+ std::string_view main_script_source_utf8,
761
+ EmbedderPreloadCallback preload = nullptr);
740
762
  NODE_EXTERN void FreeEnvironment(Environment* env);
741
763
 
742
764
  // Set a callback that is called when process.exit() is called from JS,
@@ -209,7 +209,7 @@ napi_create_threadsafe_function(napi_env env,
209
209
  size_t max_queue_size,
210
210
  size_t initial_thread_count,
211
211
  void* thread_finalize_data,
212
- node_api_nogc_finalize thread_finalize_cb,
212
+ napi_finalize thread_finalize_cb,
213
213
  void* context,
214
214
  napi_threadsafe_function_call_js call_js_cb,
215
215
  napi_threadsafe_function* result);
@@ -29,7 +29,7 @@ namespace node {
29
29
 
30
30
  namespace Buffer {
31
31
 
32
- static const size_t kMaxLength = v8::TypedArray::kMaxLength;
32
+ static const size_t kMaxLength = v8::Uint8Array::kMaxLength;
33
33
 
34
34
  typedef void (*FreeCallback)(char* data, void* hint);
35
35
 
@@ -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 21
26
- #define NODE_MINOR_VERSION 7
27
- #define NODE_PATCH_VERSION 3
25
+ #define NODE_MAJOR_VERSION 22
26
+ #define NODE_MINOR_VERSION 1
27
+ #define NODE_PATCH_VERSION 0
28
28
 
29
29
  #define NODE_VERSION_IS_LTS 0
30
30
  #define NODE_VERSION_LTS_CODENAME ""
@@ -95,7 +95,7 @@
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 120
98
+ #define NODE_MODULE_VERSION 127
99
99
  #endif
100
100
 
101
101
  // The NAPI_VERSION supported by the runtime. This is the inclusive range of
@@ -318,6 +318,12 @@ class V8_EXPORT ArrayBuffer : public Object {
318
318
  */
319
319
  std::shared_ptr<BackingStore> GetBackingStore();
320
320
 
321
+ /**
322
+ * More efficient shortcut for
323
+ * GetBackingStore()->IsResizableByUserJavaScript().
324
+ */
325
+ bool IsResizableByUserJavaScript() const;
326
+
321
327
  /**
322
328
  * More efficient shortcut for GetBackingStore()->Data(). The returned pointer
323
329
  * is valid as long as the ArrayBuffer is alive.
@@ -327,10 +327,6 @@ using WasmAsyncResolvePromiseCallback = void (*)(
327
327
  using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
328
328
  const char* name);
329
329
 
330
- // --- Callback for checking if WebAssembly GC is enabled ---
331
- // If the callback returns true, it will also enable Wasm stringrefs.
332
- using WasmGCEnabledCallback = bool (*)(Local<Context> context);
333
-
334
330
  // --- Callback for checking if WebAssembly imported strings are enabled ---
335
331
  using WasmImportedStringsEnabledCallback = bool (*)(Local<Context> context);
336
332
 
@@ -342,6 +338,9 @@ using SharedArrayBufferConstructorEnabledCallback =
342
338
  using JavaScriptCompileHintsMagicEnabledCallback =
343
339
  bool (*)(Local<Context> context);
344
340
 
341
+ // --- Callback for checking if WebAssembly JSPI is enabled ---
342
+ using WasmJSPIEnabledCallback = bool (*)(Local<Context> context);
343
+
345
344
  /**
346
345
  * HostImportModuleDynamicallyCallback is called when we
347
346
  * require the embedder to load a module. This is used as part of the dynamic
@@ -352,11 +351,11 @@ using JavaScriptCompileHintsMagicEnabledCallback =
352
351
  *
353
352
  * The specifier is the name of the module that should be imported.
354
353
  *
355
- * The import_assertions are import assertions for this request in the form:
354
+ * The import_attributes are import attributes for this request in the form:
356
355
  * [key1, value1, key2, value2, ...] where the keys and values are of type
357
356
  * v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
358
357
  * returned from ModuleRequest::GetImportAssertions(), this array does not
359
- * contain the source Locations of the assertions.
358
+ * contain the source Locations of the attributes.
360
359
  *
361
360
  * The embedder must compile, instantiate, evaluate the Module, and
362
361
  * obtain its namespace object.
@@ -368,15 +367,10 @@ using JavaScriptCompileHintsMagicEnabledCallback =
368
367
  * fails (e.g. due to stack overflow), the embedder must propagate
369
368
  * that exception by returning an empty MaybeLocal.
370
369
  */
371
- using HostImportModuleDynamicallyWithImportAssertionsCallback =
372
- MaybeLocal<Promise> (*)(Local<Context> context,
373
- Local<ScriptOrModule> referrer,
374
- Local<String> specifier,
375
- Local<FixedArray> import_assertions);
376
370
  using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
377
371
  Local<Context> context, Local<Data> host_defined_options,
378
372
  Local<Value> resource_name, Local<String> specifier,
379
- Local<FixedArray> import_assertions);
373
+ Local<FixedArray> import_attributes);
380
374
 
381
375
  /**
382
376
  * Callback for requesting a compile hint for a function from the embedder. The
@@ -8,6 +8,8 @@
8
8
  #include <stddef.h>
9
9
  #include <stdint.h>
10
10
 
11
+ #include <functional>
12
+
11
13
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
12
14
  #include "v8-object.h" // NOLINT(build/include_directory)
13
15
  #include "v8config.h" // NOLINT(build/include_directory)
@@ -43,6 +45,58 @@ class V8_EXPORT Array : public Object {
43
45
  return static_cast<Array*>(value);
44
46
  }
45
47
 
48
+ /**
49
+ * Creates a JavaScript array from a provided callback.
50
+ *
51
+ * \param context The v8::Context to create the array in.
52
+ * \param length The length of the array to be created.
53
+ * \param next_value_callback The callback that is invoked to retrieve
54
+ * elements for the array. The embedder can signal that the array
55
+ * initialization should be aborted by throwing an exception and returning
56
+ * an empty MaybeLocal.
57
+ * \returns The v8::Array if all elements were constructed successfully and an
58
+ * empty MaybeLocal otherwise.
59
+ */
60
+ static MaybeLocal<Array> New(
61
+ Local<Context> context, size_t length,
62
+ std::function<MaybeLocal<v8::Value>()> next_value_callback);
63
+
64
+ enum class CallbackResult {
65
+ kException,
66
+ kBreak,
67
+ kContinue,
68
+ };
69
+ using IterationCallback = CallbackResult (*)(uint32_t index,
70
+ Local<Value> element,
71
+ void* data);
72
+
73
+ /**
74
+ * Calls {callback} for every element of this array, passing {callback_data}
75
+ * as its {data} parameter.
76
+ * This function will typically be faster than calling {Get()} repeatedly.
77
+ * As a consequence of being optimized for low overhead, the provided
78
+ * callback must adhere to the following restrictions:
79
+ * - It must not allocate any V8 objects and continue iterating; it may
80
+ * allocate (e.g. an error message/object) and then immediately terminate
81
+ * the iteration.
82
+ * - It must not modify the array being iterated.
83
+ * - It must not call back into V8 (unless it can guarantee that such a
84
+ * call does not violate the above restrictions, which is difficult).
85
+ * - The {Local<Value> element} must not "escape", i.e. must not be assigned
86
+ * to any other {Local}. Creating a {Global} from it, or updating a
87
+ * v8::TypecheckWitness with it, is safe.
88
+ * These restrictions may be lifted in the future if use cases arise that
89
+ * justify a slower but more robust implementation.
90
+ *
91
+ * Returns {Nothing} on exception; use a {TryCatch} to catch and handle this
92
+ * exception.
93
+ * When the {callback} returns {kException}, iteration is terminated
94
+ * immediately, returning {Nothing}. By returning {kBreak}, the callback
95
+ * can request non-exceptional early termination of the iteration.
96
+ */
97
+ Maybe<void> Iterate(Local<Context> context, IterationCallback callback,
98
+ void* callback_data);
99
+
46
100
  private:
47
101
  Array();
48
102
  static void CheckCast(Value* obj);
@@ -84,6 +84,29 @@ class V8_EXPORT Context : public Data {
84
84
  * created by a previous call to Context::New with the same global
85
85
  * template. The state of the global object will be completely reset
86
86
  * and only object identify will remain.
87
+ *
88
+ * \param internal_fields_deserializer An optional callback used
89
+ * to deserialize fields set by
90
+ * v8::Object::SetAlignedPointerInInternalField() in wrapper objects
91
+ * from the default context snapshot. It should match the
92
+ * SerializeInternalFieldsCallback() used by
93
+ * v8::SnapshotCreator::SetDefaultContext() when the default context
94
+ * snapshot is created. It does not need to be configured if the default
95
+ * context snapshot contains no wrapper objects with pointer internal
96
+ * fields, or if no custom startup snapshot is configured
97
+ * in the v8::CreateParams used to create the isolate.
98
+ *
99
+ * \param microtask_queue An optional microtask queue used to manage
100
+ * the microtasks created in this context. If not set the per-isolate
101
+ * default microtask queue would be used.
102
+ *
103
+ * \param context_data_deserializer An optional callback used
104
+ * to deserialize embedder data set by
105
+ * v8::Context::SetAlignedPointerInEmbedderData() in the default
106
+ * context from the default context snapshot. It does not need to be
107
+ * configured if the default context snapshot contains no pointer embedder
108
+ * data, or if no custom startup snapshot is configured in the
109
+ * v8::CreateParams used to create the isolate.
87
110
  */
88
111
  static Local<Context> New(
89
112
  Isolate* isolate, ExtensionConfiguration* extensions = nullptr,
@@ -91,7 +114,9 @@ class V8_EXPORT Context : public Data {
91
114
  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
92
115
  DeserializeInternalFieldsCallback internal_fields_deserializer =
93
116
  DeserializeInternalFieldsCallback(),
94
- MicrotaskQueue* microtask_queue = nullptr);
117
+ MicrotaskQueue* microtask_queue = nullptr,
118
+ DeserializeContextDataCallback context_data_deserializer =
119
+ DeserializeContextDataCallback());
95
120
 
96
121
  /**
97
122
  * Create a new context from a (non-default) context snapshot. There
@@ -103,21 +128,37 @@ class V8_EXPORT Context : public Data {
103
128
  * \param context_snapshot_index The index of the context snapshot to
104
129
  * deserialize from. Use v8::Context::New for the default snapshot.
105
130
  *
106
- * \param embedder_fields_deserializer Optional callback to deserialize
107
- * internal fields. It should match the SerializeInternalFieldCallback used
108
- * to serialize.
131
+ * \param internal_fields_deserializer An optional callback used
132
+ * to deserialize fields set by
133
+ * v8::Object::SetAlignedPointerInInternalField() in wrapper objects
134
+ * from the default context snapshot. It does not need to be
135
+ * configured if there are no wrapper objects with no internal
136
+ * pointer fields in the default context snapshot or if no startup
137
+ * snapshot is configured when the isolate is created.
109
138
  *
110
139
  * \param extensions See v8::Context::New.
111
140
  *
112
141
  * \param global_object See v8::Context::New.
142
+ *
143
+ * \param internal_fields_deserializer Similar to
144
+ * internal_fields_deserializer in v8::Context::New but applies to
145
+ * the context specified by the context_snapshot_index.
146
+ *
147
+ * \param microtask_queue See v8::Context::New.
148
+ *
149
+ * \param context_data_deserializer Similar to
150
+ * context_data_deserializer in v8::Context::New but applies to
151
+ * the context specified by the context_snapshot_index.
113
152
  */
114
153
  static MaybeLocal<Context> FromSnapshot(
115
154
  Isolate* isolate, size_t context_snapshot_index,
116
- DeserializeInternalFieldsCallback embedder_fields_deserializer =
155
+ DeserializeInternalFieldsCallback internal_fields_deserializer =
117
156
  DeserializeInternalFieldsCallback(),
118
157
  ExtensionConfiguration* extensions = nullptr,
119
158
  MaybeLocal<Value> global_object = MaybeLocal<Value>(),
120
- MicrotaskQueue* microtask_queue = nullptr);
159
+ MicrotaskQueue* microtask_queue = nullptr,
160
+ DeserializeContextDataCallback context_data_deserializer =
161
+ DeserializeContextDataCallback());
121
162
 
122
163
  /**
123
164
  * Returns an global object that isn't backed by an actual context.
@@ -182,7 +223,7 @@ class V8_EXPORT Context : public Data {
182
223
  * parameter. Returns true if the operation completed successfully.
183
224
  */
184
225
  virtual bool FreezeEmbedderObjectAndGetChildren(
185
- Local<Object> obj, std::vector<Local<Object>>& children_out) = 0;
226
+ Local<Object> obj, LocalVector<Object>& children_out) = 0;
186
227
  };
187
228
 
188
229
  /**
@@ -309,18 +350,6 @@ class V8_EXPORT Context : public Data {
309
350
  Local<Context> context);
310
351
  void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
311
352
 
312
- /**
313
- * Returns the value that was set or restored by
314
- * SetContinuationPreservedEmbedderData(), if any.
315
- */
316
- Local<Value> GetContinuationPreservedEmbedderData() const;
317
-
318
- /**
319
- * Sets a value that will be stored on continuations and reset while the
320
- * continuation runs.
321
- */
322
- void SetContinuationPreservedEmbedderData(Local<Value> context);
323
-
324
353
  /**
325
354
  * Set or clear hooks to be invoked for promise lifecycle operations.
326
355
  * To clear a hook, set it to an empty v8::Function. Each function will
@@ -436,12 +465,12 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
436
465
 
437
466
  template <class T>
438
467
  MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
439
- auto slot = GetDataFromSnapshotOnce(index);
440
- if (slot) {
468
+ if (auto slot = GetDataFromSnapshotOnce(index); slot) {
441
469
  internal::PerformCastCheck(
442
470
  internal::ValueHelper::SlotAsValue<T, false>(slot));
471
+ return Local<T>::FromSlot(slot);
443
472
  }
444
- return Local<T>::FromSlot(slot);
473
+ return {};
445
474
  }
446
475
 
447
476
  Context* Context::Cast(v8::Data* data) {
@@ -9,6 +9,9 @@
9
9
  #include "v8config.h" // NOLINT(build/include_directory)
10
10
 
11
11
  namespace v8 {
12
+ namespace internal {
13
+ class TracedHandles;
14
+ } // namespace internal
12
15
 
13
16
  class Isolate;
14
17
  class Value;
@@ -18,8 +21,17 @@ class Value;
18
21
  */
19
22
  class V8_EXPORT EmbedderRootsHandler {
20
23
  public:
24
+ enum class RootHandling {
25
+ kQueryEmbedderForNonDroppableReferences,
26
+ kDontQueryEmbedderForAnyReference,
27
+ };
28
+
21
29
  virtual ~EmbedderRootsHandler() = default;
22
30
 
31
+ EmbedderRootsHandler() = default;
32
+ explicit EmbedderRootsHandler(RootHandling default_traced_reference_handling)
33
+ : default_traced_reference_handling_(default_traced_reference_handling) {}
34
+
23
35
  /**
24
36
  * Returns true if the |TracedReference| handle should be considered as root
25
37
  * for the currently running non-tracing garbage collection and false
@@ -31,9 +43,7 @@ class V8_EXPORT EmbedderRootsHandler {
31
43
  * |TracedReference|.
32
44
  *
33
45
  * Note that the `handle` is different from the handle that the embedder holds
34
- * for retaining the object. The embedder may use |WrapperClassId()| to
35
- * distinguish cases where it wants handles to be treated as roots from not
36
- * being treated as roots.
46
+ * for retaining the object.
37
47
  *
38
48
  * The concrete implementations must be thread-safe.
39
49
  */
@@ -59,6 +69,12 @@ class V8_EXPORT EmbedderRootsHandler {
59
69
  ResetRoot(handle);
60
70
  return true;
61
71
  }
72
+
73
+ private:
74
+ const RootHandling default_traced_reference_handling_ =
75
+ RootHandling::kQueryEmbedderForNonDroppableReferences;
76
+
77
+ friend class internal::TracedHandles;
62
78
  };
63
79
 
64
80
  } // namespace v8
@@ -7,12 +7,13 @@
7
7
 
8
8
  #include <memory>
9
9
 
10
- #include "v8-context.h" // NOLINT(build/include_directory)
11
10
  #include "v8-internal.h" // NOLINT(build/include_directory)
12
11
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
13
12
 
14
13
  namespace v8 {
15
14
 
15
+ class Context;
16
+
16
17
  namespace internal {
17
18
  class EmbedderState;
18
19
  } // namespace internal
@@ -30,14 +30,21 @@ class ThreadLocalTop;
30
30
  */
31
31
  class V8_EXPORT Exception {
32
32
  public:
33
- static Local<Value> RangeError(Local<String> message);
34
- static Local<Value> ReferenceError(Local<String> message);
35
- static Local<Value> SyntaxError(Local<String> message);
36
- static Local<Value> TypeError(Local<String> message);
37
- static Local<Value> WasmCompileError(Local<String> message);
38
- static Local<Value> WasmLinkError(Local<String> message);
39
- static Local<Value> WasmRuntimeError(Local<String> message);
40
- static Local<Value> Error(Local<String> message);
33
+ static Local<Value> RangeError(Local<String> message,
34
+ Local<Value> options = {});
35
+ static Local<Value> ReferenceError(Local<String> message,
36
+ Local<Value> options = {});
37
+ static Local<Value> SyntaxError(Local<String> message,
38
+ Local<Value> options = {});
39
+ static Local<Value> TypeError(Local<String> message,
40
+ Local<Value> options = {});
41
+ static Local<Value> WasmCompileError(Local<String> message,
42
+ Local<Value> options = {});
43
+ static Local<Value> WasmLinkError(Local<String> message,
44
+ Local<Value> options = {});
45
+ static Local<Value> WasmRuntimeError(Local<String> message,
46
+ Local<Value> options = {});
47
+ static Local<Value> Error(Local<String> message, Local<Value> options = {});
41
48
 
42
49
  /**
43
50
  * Creates an error message for the given exception.
@@ -206,7 +213,6 @@ class V8_EXPORT TryCatch {
206
213
  bool can_continue_ : 1;
207
214
  bool capture_message_ : 1;
208
215
  bool rethrow_ : 1;
209
- bool has_terminated_ : 1;
210
216
 
211
217
  friend class internal::Isolate;
212
218
  friend class internal::ThreadLocalTop;
@@ -27,6 +27,7 @@ class Context;
27
27
  class DataView;
28
28
  class Data;
29
29
  class Date;
30
+ class DictionaryTemplate;
30
31
  class Extension;
31
32
  class External;
32
33
  class FixedArray;