libv8-node 20.12.1.0-arm64-darwin → 22.5.1.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/internal/api-constants.h +24 -5
  5. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +16 -6
  6. data/vendor/v8/include/cppgc/internal/caged-heap.h +12 -5
  7. data/vendor/v8/include/cppgc/internal/gc-info.h +82 -91
  8. data/vendor/v8/include/cppgc/internal/member-storage.h +16 -8
  9. data/vendor/v8/include/cppgc/member.h +25 -0
  10. data/vendor/v8/include/cppgc/persistent.h +4 -0
  11. data/vendor/v8/include/cppgc/platform.h +6 -1
  12. data/vendor/v8/include/cppgc/sentinel-pointer.h +7 -0
  13. data/vendor/v8/include/cppgc/source-location.h +2 -78
  14. data/vendor/v8/include/cppgc/trace-trait.h +8 -0
  15. data/vendor/v8/include/cppgc/type-traits.h +25 -4
  16. data/vendor/v8/include/cppgc/visitor.h +82 -4
  17. data/vendor/v8/include/libplatform/libplatform.h +7 -1
  18. data/vendor/v8/include/v8-array-buffer.h +6 -0
  19. data/vendor/v8/include/v8-callbacks.h +57 -19
  20. data/vendor/v8/include/v8-container.h +54 -0
  21. data/vendor/v8/include/v8-context.h +58 -32
  22. data/vendor/v8/include/v8-embedder-heap.h +31 -3
  23. data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
  24. data/vendor/v8/include/v8-exception.h +15 -9
  25. data/vendor/v8/include/v8-fast-api-calls.h +58 -31
  26. data/vendor/v8/include/v8-forward.h +1 -0
  27. data/vendor/v8/include/v8-function-callback.h +135 -30
  28. data/vendor/v8/include/v8-function.h +6 -0
  29. data/vendor/v8/include/v8-handle-base.h +137 -0
  30. data/vendor/v8/include/v8-inspector.h +35 -13
  31. data/vendor/v8/include/v8-internal.h +510 -71
  32. data/vendor/v8/include/v8-isolate.h +176 -100
  33. data/vendor/v8/include/v8-local-handle.h +383 -112
  34. data/vendor/v8/include/v8-memory-span.h +157 -2
  35. data/vendor/v8/include/v8-message.h +22 -3
  36. data/vendor/v8/include/v8-metrics.h +1 -0
  37. data/vendor/v8/include/v8-object.h +98 -77
  38. data/vendor/v8/include/v8-persistent-handle.h +68 -90
  39. data/vendor/v8/include/v8-platform.h +191 -23
  40. data/vendor/v8/include/v8-primitive.h +12 -8
  41. data/vendor/v8/include/v8-profiler.h +16 -2
  42. data/vendor/v8/include/v8-script.h +88 -14
  43. data/vendor/v8/include/v8-snapshot.h +96 -22
  44. data/vendor/v8/include/v8-source-location.h +92 -0
  45. data/vendor/v8/include/v8-statistics.h +31 -10
  46. data/vendor/v8/include/v8-template.h +410 -131
  47. data/vendor/v8/include/v8-traced-handle.h +108 -90
  48. data/vendor/v8/include/v8-typed-array.h +115 -7
  49. data/vendor/v8/include/v8-unwinder.h +1 -1
  50. data/vendor/v8/include/v8-util.h +23 -20
  51. data/vendor/v8/include/v8-value-serializer.h +14 -0
  52. data/vendor/v8/include/v8-value.h +105 -3
  53. data/vendor/v8/include/v8-version.h +4 -4
  54. data/vendor/v8/include/v8config.h +54 -20
  55. metadata +5 -3
@@ -6,6 +6,7 @@
6
6
  #define INCLUDE_V8_SNAPSHOT_H_
7
7
 
8
8
  #include "v8-internal.h" // NOLINT(build/include_directory)
9
+ #include "v8-isolate.h" // NOLINT(build/include_directory)
9
10
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
10
11
  #include "v8config.h" // NOLINT(build/include_directory)
11
12
 
@@ -13,6 +14,10 @@ namespace v8 {
13
14
 
14
15
  class Object;
15
16
 
17
+ namespace internal {
18
+ class SnapshotCreatorImpl;
19
+ } // namespace internal
20
+
16
21
  class V8_EXPORT StartupData {
17
22
  public:
18
23
  /**
@@ -33,7 +38,7 @@ class V8_EXPORT StartupData {
33
38
 
34
39
  /**
35
40
  * Callback and supporting data used in SnapshotCreator to implement embedder
36
- * logic to serialize internal fields.
41
+ * logic to serialize internal fields of v8::Objects.
37
42
  * Internal fields that directly reference V8 objects are serialized without
38
43
  * calling this callback. Internal fields that contain aligned pointers are
39
44
  * serialized by this callback if it returns non-zero result. Otherwise it is
@@ -48,13 +53,24 @@ struct SerializeInternalFieldsCallback {
48
53
  CallbackFunction callback;
49
54
  void* data;
50
55
  };
51
- // Note that these fields are called "internal fields" in the API and called
52
- // "embedder fields" within V8.
53
- using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback;
56
+
57
+ /**
58
+ * Similar to SerializeInternalFieldsCallback, but works with the embedder data
59
+ * in a v8::Context.
60
+ */
61
+ struct SerializeContextDataCallback {
62
+ using CallbackFunction = StartupData (*)(Local<Context> holder, int index,
63
+ void* data);
64
+ SerializeContextDataCallback(CallbackFunction function = nullptr,
65
+ void* data_arg = nullptr)
66
+ : callback(function), data(data_arg) {}
67
+ CallbackFunction callback;
68
+ void* data;
69
+ };
54
70
 
55
71
  /**
56
72
  * Callback and supporting data used to implement embedder logic to deserialize
57
- * internal fields.
73
+ * internal fields of v8::Objects.
58
74
  */
59
75
  struct DeserializeInternalFieldsCallback {
60
76
  using CallbackFunction = void (*)(Local<Object> holder, int index,
@@ -62,12 +78,24 @@ struct DeserializeInternalFieldsCallback {
62
78
  DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
63
79
  void* data_arg = nullptr)
64
80
  : callback(function), data(data_arg) {}
65
- void (*callback)(Local<Object> holder, int index, StartupData payload,
66
- void* data);
81
+
82
+ CallbackFunction callback;
67
83
  void* data;
68
84
  };
69
85
 
70
- using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback;
86
+ /**
87
+ * Similar to DeserializeInternalFieldsCallback, but works with the embedder
88
+ * data in a v8::Context.
89
+ */
90
+ struct DeserializeContextDataCallback {
91
+ using CallbackFunction = void (*)(Local<Context> holder, int index,
92
+ StartupData payload, void* data);
93
+ DeserializeContextDataCallback(CallbackFunction function = nullptr,
94
+ void* data_arg = nullptr)
95
+ : callback(function), data(data_arg) {}
96
+ CallbackFunction callback;
97
+ void* data;
98
+ };
71
99
 
72
100
  /**
73
101
  * Helper class to create a snapshot data blob.
@@ -88,10 +116,14 @@ class V8_EXPORT SnapshotCreator {
88
116
  * \param existing_blob existing snapshot from which to create this one.
89
117
  * \param external_references a null-terminated array of external references
90
118
  * that must be equivalent to CreateParams::external_references.
119
+ * \param owns_isolate whether this SnapshotCreator should call
120
+ * v8::Isolate::Dispose() during its destructor.
91
121
  */
92
- SnapshotCreator(Isolate* isolate,
93
- const intptr_t* external_references = nullptr,
94
- const StartupData* existing_blob = nullptr);
122
+ V8_DEPRECATE_SOON("Use the version that passes CreateParams instead.")
123
+ explicit SnapshotCreator(Isolate* isolate,
124
+ const intptr_t* external_references = nullptr,
125
+ const StartupData* existing_blob = nullptr,
126
+ bool owns_isolate = true);
95
127
 
96
128
  /**
97
129
  * Create and enter an isolate, and set it up for serialization.
@@ -101,8 +133,35 @@ class V8_EXPORT SnapshotCreator {
101
133
  * \param external_references a null-terminated array of external references
102
134
  * that must be equivalent to CreateParams::external_references.
103
135
  */
104
- SnapshotCreator(const intptr_t* external_references = nullptr,
105
- const StartupData* existing_blob = nullptr);
136
+ V8_DEPRECATE_SOON("Use the version that passes CreateParams instead.")
137
+ explicit SnapshotCreator(const intptr_t* external_references = nullptr,
138
+ const StartupData* existing_blob = nullptr);
139
+
140
+ /**
141
+ * Creates an Isolate for serialization and enters it. The creator fully owns
142
+ * the Isolate and will invoke `v8::Isolate::Dispose()` during destruction.
143
+ *
144
+ * \param params The parameters to initialize the Isolate for. Details:
145
+ * - `params.external_references` are expected to be a
146
+ * null-terminated array of external references.
147
+ * - `params.existing_blob` is an optional snapshot blob from
148
+ * which can be used to initialize the new blob.
149
+ */
150
+ explicit SnapshotCreator(const v8::Isolate::CreateParams& params);
151
+
152
+ /**
153
+ * Initializes an Isolate for serialization and enters it. The creator does
154
+ * not own the Isolate but merely initialize it properly.
155
+ *
156
+ * \param isolate The isolate that was allocated by `Isolate::Allocate()~.
157
+ * \param params The parameters to initialize the Isolate for. Details:
158
+ * - `params.external_references` are expected to be a
159
+ * null-terminated array of external references.
160
+ * - `params.existing_blob` is an optional snapshot blob from
161
+ * which can be used to initialize the new blob.
162
+ */
163
+ SnapshotCreator(v8::Isolate* isolate,
164
+ const v8::Isolate::CreateParams& params);
106
165
 
107
166
  /**
108
167
  * Destroy the snapshot creator, and exit and dispose of the Isolate
@@ -120,23 +179,37 @@ class V8_EXPORT SnapshotCreator {
120
179
  * The snapshot will not contain the global proxy, and we expect one or a
121
180
  * global object template to create one, to be provided upon deserialization.
122
181
  *
123
- * \param callback optional callback to serialize internal fields.
182
+ * \param internal_fields_serializer An optional callback used to serialize
183
+ * internal pointer fields set by
184
+ * v8::Object::SetAlignedPointerInInternalField().
185
+ *
186
+ * \param context_data_serializer An optional callback used to serialize
187
+ * context embedder data set by
188
+ * v8::Context::SetAlignedPointerInEmbedderData().
189
+ *
124
190
  */
125
- void SetDefaultContext(Local<Context> context,
126
- SerializeInternalFieldsCallback callback =
127
- SerializeInternalFieldsCallback());
191
+ void SetDefaultContext(
192
+ Local<Context> context,
193
+ SerializeInternalFieldsCallback internal_fields_serializer =
194
+ SerializeInternalFieldsCallback(),
195
+ SerializeContextDataCallback context_data_serializer =
196
+ SerializeContextDataCallback());
128
197
 
129
198
  /**
130
199
  * Add additional context to be included in the snapshot blob.
131
200
  * The snapshot will include the global proxy.
132
201
  *
133
- * \param callback optional callback to serialize internal fields.
202
+ * \param internal_fields_serializer Similar to internal_fields_serializer
203
+ * in SetDefaultContext() but only applies to the context being added.
134
204
  *
135
- * \returns the index of the context in the snapshot blob.
205
+ * \param context_data_serializer Similar to context_data_serializer
206
+ * in SetDefaultContext() but only applies to the context being added.
136
207
  */
137
208
  size_t AddContext(Local<Context> context,
138
- SerializeInternalFieldsCallback callback =
139
- SerializeInternalFieldsCallback());
209
+ SerializeInternalFieldsCallback internal_fields_serializer =
210
+ SerializeInternalFieldsCallback(),
211
+ SerializeContextDataCallback context_data_serializer =
212
+ SerializeContextDataCallback());
140
213
 
141
214
  /**
142
215
  * Attach arbitrary V8::Data to the context snapshot, which can be retrieved
@@ -174,7 +247,8 @@ class V8_EXPORT SnapshotCreator {
174
247
  size_t AddData(Local<Context> context, internal::Address object);
175
248
  size_t AddData(internal::Address object);
176
249
 
177
- void* data_;
250
+ internal::SnapshotCreatorImpl* impl_;
251
+ friend class internal::SnapshotCreatorImpl;
178
252
  };
179
253
 
180
254
  template <class T>
@@ -0,0 +1,92 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_SOURCE_LOCATION_H_
6
+ #define INCLUDE_SOURCE_LOCATION_H_
7
+
8
+ #include <cstddef>
9
+ #include <string>
10
+
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ #if defined(__has_builtin)
14
+ #define V8_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 V8_SUPPORTS_SOURCE_LOCATION 1
19
+ #elif defined(V8_CC_INTEL) && __ICC >= 1800
20
+ #define V8_SUPPORTS_SOURCE_LOCATION 1
21
+ #else
22
+ #define V8_SUPPORTS_SOURCE_LOCATION 0
23
+ #endif
24
+
25
+ namespace v8 {
26
+
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 V8_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 // V8_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
+ };
89
+
90
+ } // namespace v8
91
+
92
+ #endif // INCLUDE_SOURCE_LOCATION_H_
@@ -13,6 +13,7 @@
13
13
  #include <vector>
14
14
 
15
15
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
16
+ #include "v8-memory-span.h" // NOLINT(build/include_directory)
16
17
  #include "v8-promise.h" // NOLINT(build/include_directory)
17
18
  #include "v8config.h" // NOLINT(build/include_directory)
18
19
 
@@ -46,6 +47,10 @@ enum class MeasureMemoryExecution { kDefault, kEager, kLazy };
46
47
  *
47
48
  * It specifies the contexts that need to be measured and gets called when
48
49
  * the measurement is completed to report the results.
50
+ *
51
+ * Both MeasurementComplete() callbacks will be invoked on completion.
52
+ * Each implementation of this class should hence implement only one of them,
53
+ * and leave the other empty.
49
54
  */
50
55
  class V8_EXPORT MeasureMemoryDelegate {
51
56
  public:
@@ -56,20 +61,36 @@ class V8_EXPORT MeasureMemoryDelegate {
56
61
  */
57
62
  virtual bool ShouldMeasure(Local<Context> context) = 0;
58
63
 
64
+ /** Holds the result of a memory measurement request. */
65
+ struct Result {
66
+ /**
67
+ * Two spans of equal length: the first includes each context for which
68
+ * ShouldMeasure returned true and that was not garbage collected while
69
+ * the memory measurement was in progress; the second includes the size
70
+ * of the respective context.
71
+ */
72
+ const MemorySpan<const Local<Context>>& contexts;
73
+ const MemorySpan<const size_t>& sizes_in_bytes;
74
+
75
+ /**
76
+ * Total size of objects that were not attributed to any context (i.e. are
77
+ * likely shared objects).
78
+ */
79
+ size_t unattributed_size_in_bytes;
80
+
81
+ /** Total size of generated code for Wasm (shared across contexts). */
82
+ size_t wasm_code_size_in_bytes;
83
+
84
+ /** Total size of Wasm metadata (except code; shared across contexts). */
85
+ size_t wasm_metadata_size_in_bytes;
86
+ };
87
+
59
88
  /**
60
89
  * This function is called when memory measurement finishes.
61
90
  *
62
- * \param context_sizes_in_bytes a vector of (context, size) pairs that
63
- * includes each context for which ShouldMeasure returned true and that
64
- * was not garbage collected while the memory measurement was in progress.
65
- *
66
- * \param unattributed_size_in_bytes total size of objects that were not
67
- * attributed to any context (i.e. are likely shared objects).
91
+ * \param result the result of the measurement.
68
92
  */
69
- virtual void MeasurementComplete(
70
- const std::vector<std::pair<Local<Context>, size_t>>&
71
- context_sizes_in_bytes,
72
- size_t unattributed_size_in_bytes) = 0;
93
+ virtual void MeasurementComplete(Result result) {}
73
94
 
74
95
  /**
75
96
  * Returns a default delegate that resolves the given promise when