node-bin-darwin-arm64 16.4.2 → 16.6.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.
@@ -0,0 +1,334 @@
1
+ // Copyright 2016 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 V8_LIBPLATFORM_V8_TRACING_H_
6
+ #define V8_LIBPLATFORM_V8_TRACING_H_
7
+
8
+ #include <atomic>
9
+ #include <fstream>
10
+ #include <memory>
11
+ #include <unordered_set>
12
+ #include <vector>
13
+
14
+ #include "libplatform/libplatform-export.h"
15
+ #include "v8-platform.h" // NOLINT(build/include_directory)
16
+
17
+ namespace perfetto {
18
+ namespace trace_processor {
19
+ class TraceProcessorStorage;
20
+ }
21
+ class TracingSession;
22
+ }
23
+
24
+ namespace v8 {
25
+
26
+ namespace base {
27
+ class Mutex;
28
+ } // namespace base
29
+
30
+ namespace platform {
31
+ namespace tracing {
32
+
33
+ class TraceEventListener;
34
+
35
+ const int kTraceMaxNumArgs = 2;
36
+
37
+ class V8_PLATFORM_EXPORT TraceObject {
38
+ public:
39
+ union ArgValue {
40
+ V8_DEPRECATED("use as_uint ? true : false") bool as_bool;
41
+ uint64_t as_uint;
42
+ int64_t as_int;
43
+ double as_double;
44
+ const void* as_pointer;
45
+ const char* as_string;
46
+ };
47
+
48
+ TraceObject() = default;
49
+ ~TraceObject();
50
+ void Initialize(
51
+ char phase, const uint8_t* category_enabled_flag, const char* name,
52
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
53
+ const char** arg_names, const uint8_t* arg_types,
54
+ const uint64_t* arg_values,
55
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
56
+ unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
57
+ void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
58
+ void InitializeForTesting(
59
+ char phase, const uint8_t* category_enabled_flag, const char* name,
60
+ const char* scope, uint64_t id, uint64_t bind_id, int num_args,
61
+ const char** arg_names, const uint8_t* arg_types,
62
+ const uint64_t* arg_values,
63
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
64
+ unsigned int flags, int pid, int tid, int64_t ts, int64_t tts,
65
+ uint64_t duration, uint64_t cpu_duration);
66
+
67
+ int pid() const { return pid_; }
68
+ int tid() const { return tid_; }
69
+ char phase() const { return phase_; }
70
+ const uint8_t* category_enabled_flag() const {
71
+ return category_enabled_flag_;
72
+ }
73
+ const char* name() const { return name_; }
74
+ const char* scope() const { return scope_; }
75
+ uint64_t id() const { return id_; }
76
+ uint64_t bind_id() const { return bind_id_; }
77
+ int num_args() const { return num_args_; }
78
+ const char** arg_names() { return arg_names_; }
79
+ uint8_t* arg_types() { return arg_types_; }
80
+ ArgValue* arg_values() { return arg_values_; }
81
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables() {
82
+ return arg_convertables_;
83
+ }
84
+ unsigned int flags() const { return flags_; }
85
+ int64_t ts() { return ts_; }
86
+ int64_t tts() { return tts_; }
87
+ uint64_t duration() { return duration_; }
88
+ uint64_t cpu_duration() { return cpu_duration_; }
89
+
90
+ private:
91
+ int pid_;
92
+ int tid_;
93
+ char phase_;
94
+ const char* name_;
95
+ const char* scope_;
96
+ const uint8_t* category_enabled_flag_;
97
+ uint64_t id_;
98
+ uint64_t bind_id_;
99
+ int num_args_ = 0;
100
+ const char* arg_names_[kTraceMaxNumArgs];
101
+ uint8_t arg_types_[kTraceMaxNumArgs];
102
+ ArgValue arg_values_[kTraceMaxNumArgs];
103
+ std::unique_ptr<v8::ConvertableToTraceFormat>
104
+ arg_convertables_[kTraceMaxNumArgs];
105
+ char* parameter_copy_storage_ = nullptr;
106
+ unsigned int flags_;
107
+ int64_t ts_;
108
+ int64_t tts_;
109
+ uint64_t duration_;
110
+ uint64_t cpu_duration_;
111
+
112
+ // Disallow copy and assign
113
+ TraceObject(const TraceObject&) = delete;
114
+ void operator=(const TraceObject&) = delete;
115
+ };
116
+
117
+ class V8_PLATFORM_EXPORT TraceWriter {
118
+ public:
119
+ TraceWriter() = default;
120
+ virtual ~TraceWriter() = default;
121
+ virtual void AppendTraceEvent(TraceObject* trace_event) = 0;
122
+ virtual void Flush() = 0;
123
+
124
+ static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
125
+ static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
126
+ const std::string& tag);
127
+
128
+ static TraceWriter* CreateSystemInstrumentationTraceWriter();
129
+
130
+ private:
131
+ // Disallow copy and assign
132
+ TraceWriter(const TraceWriter&) = delete;
133
+ void operator=(const TraceWriter&) = delete;
134
+ };
135
+
136
+ class V8_PLATFORM_EXPORT TraceBufferChunk {
137
+ public:
138
+ explicit TraceBufferChunk(uint32_t seq);
139
+
140
+ void Reset(uint32_t new_seq);
141
+ bool IsFull() const { return next_free_ == kChunkSize; }
142
+ TraceObject* AddTraceEvent(size_t* event_index);
143
+ TraceObject* GetEventAt(size_t index) { return &chunk_[index]; }
144
+
145
+ uint32_t seq() const { return seq_; }
146
+ size_t size() const { return next_free_; }
147
+
148
+ static const size_t kChunkSize = 64;
149
+
150
+ private:
151
+ size_t next_free_ = 0;
152
+ TraceObject chunk_[kChunkSize];
153
+ uint32_t seq_;
154
+
155
+ // Disallow copy and assign
156
+ TraceBufferChunk(const TraceBufferChunk&) = delete;
157
+ void operator=(const TraceBufferChunk&) = delete;
158
+ };
159
+
160
+ class V8_PLATFORM_EXPORT TraceBuffer {
161
+ public:
162
+ TraceBuffer() = default;
163
+ virtual ~TraceBuffer() = default;
164
+
165
+ virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0;
166
+ virtual TraceObject* GetEventByHandle(uint64_t handle) = 0;
167
+ virtual bool Flush() = 0;
168
+
169
+ static const size_t kRingBufferChunks = 1024;
170
+
171
+ static TraceBuffer* CreateTraceBufferRingBuffer(size_t max_chunks,
172
+ TraceWriter* trace_writer);
173
+
174
+ private:
175
+ // Disallow copy and assign
176
+ TraceBuffer(const TraceBuffer&) = delete;
177
+ void operator=(const TraceBuffer&) = delete;
178
+ };
179
+
180
+ // Options determines how the trace buffer stores data.
181
+ enum TraceRecordMode {
182
+ // Record until the trace buffer is full.
183
+ RECORD_UNTIL_FULL,
184
+
185
+ // Record until the user ends the trace. The trace buffer is a fixed size
186
+ // and we use it as a ring buffer during recording.
187
+ RECORD_CONTINUOUSLY,
188
+
189
+ // Record until the trace buffer is full, but with a huge buffer size.
190
+ RECORD_AS_MUCH_AS_POSSIBLE,
191
+
192
+ // Echo to console. Events are discarded.
193
+ ECHO_TO_CONSOLE,
194
+ };
195
+
196
+ class V8_PLATFORM_EXPORT TraceConfig {
197
+ public:
198
+ typedef std::vector<std::string> StringList;
199
+
200
+ static TraceConfig* CreateDefaultTraceConfig();
201
+
202
+ TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
203
+ TraceRecordMode GetTraceRecordMode() const { return record_mode_; }
204
+ const StringList& GetEnabledCategories() const {
205
+ return included_categories_;
206
+ }
207
+ bool IsSystraceEnabled() const { return enable_systrace_; }
208
+ bool IsArgumentFilterEnabled() const { return enable_argument_filter_; }
209
+
210
+ void SetTraceRecordMode(TraceRecordMode mode) { record_mode_ = mode; }
211
+ void EnableSystrace() { enable_systrace_ = true; }
212
+ void EnableArgumentFilter() { enable_argument_filter_ = true; }
213
+
214
+ void AddIncludedCategory(const char* included_category);
215
+
216
+ bool IsCategoryGroupEnabled(const char* category_group) const;
217
+
218
+ private:
219
+ TraceRecordMode record_mode_;
220
+ bool enable_systrace_ : 1;
221
+ bool enable_argument_filter_ : 1;
222
+ StringList included_categories_;
223
+
224
+ // Disallow copy and assign
225
+ TraceConfig(const TraceConfig&) = delete;
226
+ void operator=(const TraceConfig&) = delete;
227
+ };
228
+
229
+ #if defined(_MSC_VER)
230
+ #define V8_PLATFORM_NON_EXPORTED_BASE(code) \
231
+ __pragma(warning(suppress : 4275)) code
232
+ #else
233
+ #define V8_PLATFORM_NON_EXPORTED_BASE(code) code
234
+ #endif // defined(_MSC_VER)
235
+
236
+ class V8_PLATFORM_EXPORT TracingController
237
+ : public V8_PLATFORM_NON_EXPORTED_BASE(v8::TracingController) {
238
+ public:
239
+ TracingController();
240
+ ~TracingController() override;
241
+
242
+ #if defined(V8_USE_PERFETTO)
243
+ // Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides
244
+ // the output stream for the JSON trace data.
245
+ void InitializeForPerfetto(std::ostream* output_stream);
246
+ // Provide an optional listener for testing that will receive trace events.
247
+ // Must be called before StartTracing().
248
+ void SetTraceEventListenerForTesting(TraceEventListener* listener);
249
+ #else // defined(V8_USE_PERFETTO)
250
+ // The pointer returned from GetCategoryGroupEnabled() points to a value with
251
+ // zero or more of the following bits. Used in this class only. The
252
+ // TRACE_EVENT macros should only use the value as a bool. These values must
253
+ // be in sync with macro values in TraceEvent.h in Blink.
254
+ enum CategoryGroupEnabledFlags {
255
+ // Category group enabled for the recording mode.
256
+ ENABLED_FOR_RECORDING = 1 << 0,
257
+ // Category group enabled by SetEventCallbackEnabled().
258
+ ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
259
+ // Category group enabled to export events to ETW.
260
+ ENABLED_FOR_ETW_EXPORT = 1 << 3
261
+ };
262
+
263
+ // Takes ownership of |trace_buffer|.
264
+ void Initialize(TraceBuffer* trace_buffer);
265
+
266
+ // v8::TracingController implementation.
267
+ const uint8_t* GetCategoryGroupEnabled(const char* category_group) override;
268
+ uint64_t AddTraceEvent(
269
+ char phase, const uint8_t* category_enabled_flag, const char* name,
270
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
271
+ const char** arg_names, const uint8_t* arg_types,
272
+ const uint64_t* arg_values,
273
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
274
+ unsigned int flags) override;
275
+ uint64_t AddTraceEventWithTimestamp(
276
+ char phase, const uint8_t* category_enabled_flag, const char* name,
277
+ const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
278
+ const char** arg_names, const uint8_t* arg_types,
279
+ const uint64_t* arg_values,
280
+ std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
281
+ unsigned int flags, int64_t timestamp) override;
282
+ void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
283
+ const char* name, uint64_t handle) override;
284
+
285
+ static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
286
+ #endif // !defined(V8_USE_PERFETTO)
287
+
288
+ void AddTraceStateObserver(
289
+ v8::TracingController::TraceStateObserver* observer) override;
290
+ void RemoveTraceStateObserver(
291
+ v8::TracingController::TraceStateObserver* observer) override;
292
+
293
+ void StartTracing(TraceConfig* trace_config);
294
+ void StopTracing();
295
+
296
+ protected:
297
+ #if !defined(V8_USE_PERFETTO)
298
+ virtual int64_t CurrentTimestampMicroseconds();
299
+ virtual int64_t CurrentCpuTimestampMicroseconds();
300
+ #endif // !defined(V8_USE_PERFETTO)
301
+
302
+ private:
303
+ #if !defined(V8_USE_PERFETTO)
304
+ void UpdateCategoryGroupEnabledFlag(size_t category_index);
305
+ void UpdateCategoryGroupEnabledFlags();
306
+ #endif // !defined(V8_USE_PERFETTO)
307
+
308
+ std::unique_ptr<base::Mutex> mutex_;
309
+ std::unique_ptr<TraceConfig> trace_config_;
310
+ std::atomic_bool recording_{false};
311
+ std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
312
+
313
+ #if defined(V8_USE_PERFETTO)
314
+ std::ostream* output_stream_ = nullptr;
315
+ std::unique_ptr<perfetto::trace_processor::TraceProcessorStorage>
316
+ trace_processor_;
317
+ TraceEventListener* listener_for_testing_ = nullptr;
318
+ std::unique_ptr<perfetto::TracingSession> tracing_session_;
319
+ #else // !defined(V8_USE_PERFETTO)
320
+ std::unique_ptr<TraceBuffer> trace_buffer_;
321
+ #endif // !defined(V8_USE_PERFETTO)
322
+
323
+ // Disallow copy and assign
324
+ TracingController(const TracingController&) = delete;
325
+ void operator=(const TracingController&) = delete;
326
+ };
327
+
328
+ #undef V8_PLATFORM_NON_EXPORTED_BASE
329
+
330
+ } // namespace tracing
331
+ } // namespace platform
332
+ } // namespace v8
333
+
334
+ #endif // V8_LIBPLATFORM_V8_TRACING_H_
@@ -23,8 +23,8 @@
23
23
  #define SRC_NODE_VERSION_H_
24
24
 
25
25
  #define NODE_MAJOR_VERSION 16
26
- #define NODE_MINOR_VERSION 4
27
- #define NODE_PATCH_VERSION 2
26
+ #define NODE_MINOR_VERSION 6
27
+ #define NODE_PATCH_VERSION 0
28
28
 
29
29
  #define NODE_VERSION_IS_LTS 0
30
30
  #define NODE_VERSION_LTS_CODENAME ""
@@ -40,6 +40,13 @@ const int kWeakHeapObjectTag = 3;
40
40
  const int kHeapObjectTagSize = 2;
41
41
  const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
42
42
 
43
+ // Tag information for fowarding pointers stored in object headers.
44
+ // 0b00 at the lowest 2 bits in the header indicates that the map word is a
45
+ // forwarding pointer.
46
+ const int kForwardingTag = 0;
47
+ const int kForwardingTagSize = 2;
48
+ const intptr_t kForwardingTagMask = (1 << kForwardingTagSize) - 1;
49
+
43
50
  // Tag information for Smi.
44
51
  const int kSmiTag = 0;
45
52
  const int kSmiTagSize = 1;
@@ -120,23 +127,28 @@ constexpr bool HeapSandboxIsEnabled() {
120
127
 
121
128
  using ExternalPointer_t = Address;
122
129
 
123
- // If the heap sandbox is enabled, these tag values will be XORed with the
130
+ // If the heap sandbox is enabled, these tag values will be ORed with the
124
131
  // external pointers in the external pointer table to prevent use of pointers of
125
- // the wrong type.
126
- enum ExternalPointerTag : Address {
127
- kExternalPointerNullTag = static_cast<Address>(0ULL),
128
- kArrayBufferBackingStoreTag = static_cast<Address>(1ULL << 48),
129
- kTypedArrayExternalPointerTag = static_cast<Address>(2ULL << 48),
130
- kDataViewDataPointerTag = static_cast<Address>(3ULL << 48),
131
- kExternalStringResourceTag = static_cast<Address>(4ULL << 48),
132
- kExternalStringResourceDataTag = static_cast<Address>(5ULL << 48),
133
- kForeignForeignAddressTag = static_cast<Address>(6ULL << 48),
134
- kNativeContextMicrotaskQueueTag = static_cast<Address>(7ULL << 48),
135
- // TODO(v8:10391, saelo): Currently has to be zero so that raw zero values are
136
- // also nullptr
137
- kEmbedderDataSlotPayloadTag = static_cast<Address>(0ULL << 48),
132
+ // the wrong type. When a pointer is loaded, it is ANDed with the inverse of the
133
+ // expected type's tag. The tags are constructed in a way that guarantees that a
134
+ // failed type check will result in one or more of the top bits of the pointer
135
+ // to be set, rendering the pointer inacessible. This construction allows
136
+ // performing the type check and removing GC marking bits from the pointer at
137
+ // the same time.
138
+ enum ExternalPointerTag : uint64_t {
139
+ kExternalPointerNullTag = 0x0000000000000000,
140
+ kArrayBufferBackingStoreTag = 0x00ff000000000000, // 0b000000011111111
141
+ kTypedArrayExternalPointerTag = 0x017f000000000000, // 0b000000101111111
142
+ kDataViewDataPointerTag = 0x01bf000000000000, // 0b000000110111111
143
+ kExternalStringResourceTag = 0x01df000000000000, // 0b000000111011111
144
+ kExternalStringResourceDataTag = 0x01ef000000000000, // 0b000000111101111
145
+ kForeignForeignAddressTag = 0x01f7000000000000, // 0b000000111110111
146
+ kNativeContextMicrotaskQueueTag = 0x01fb000000000000, // 0b000000111111011
147
+ kEmbedderDataSlotPayloadTag = 0x01fd000000000000, // 0b000000111111101
138
148
  };
139
149
 
150
+ constexpr uint64_t kExternalPointerTagMask = 0xffff000000000000;
151
+
140
152
  #ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
141
153
  using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
142
154
  #else
@@ -177,6 +189,14 @@ V8_EXPORT bool ShouldThrowOnError(v8::internal::Isolate* isolate);
177
189
  * depend on functions and constants defined here.
178
190
  */
179
191
  class Internals {
192
+ #ifdef V8_MAP_PACKING
193
+ V8_INLINE static constexpr internal::Address UnpackMapWord(
194
+ internal::Address mapword) {
195
+ // TODO(wenyuzhao): Clear header metadata.
196
+ return mapword ^ kMapWordXorMask;
197
+ }
198
+ #endif
199
+
180
200
  public:
181
201
  // These values match non-compiler-dependent values defined within
182
202
  // the implementation of v8.
@@ -253,6 +273,17 @@ class Internals {
253
273
  // incremental GC once the external memory reaches this limit.
254
274
  static constexpr int kExternalAllocationSoftLimit = 64 * 1024 * 1024;
255
275
 
276
+ #ifdef V8_MAP_PACKING
277
+ static const uintptr_t kMapWordMetadataMask = 0xffffULL << 48;
278
+ // The lowest two bits of mapwords are always `0b10`
279
+ static const uintptr_t kMapWordSignature = 0b10;
280
+ // XORing a (non-compressed) map with this mask ensures that the two
281
+ // low-order bits are 0b10. The 0 at the end makes this look like a Smi,
282
+ // although real Smis have all lower 32 bits unset. We only rely on these
283
+ // values passing as Smis in very few places.
284
+ static const int kMapWordXorMask = 0b11;
285
+ #endif
286
+
256
287
  V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate);
257
288
  V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
258
289
  #ifdef V8_ENABLE_CHECKS
@@ -279,6 +310,9 @@ class Internals {
279
310
  V8_INLINE static int GetInstanceType(const internal::Address obj) {
280
311
  typedef internal::Address A;
281
312
  A map = ReadTaggedPointerField(obj, kHeapObjectMapOffset);
313
+ #ifdef V8_MAP_PACKING
314
+ map = UnpackMapWord(map);
315
+ #endif
282
316
  return ReadRawField<uint16_t>(map, kMapInstanceTypeOffset);
283
317
  }
284
318
 
@@ -492,7 +492,7 @@ class V8_EXPORT HeapGraphNode {
492
492
  /**
493
493
  * An interface for exporting data from V8, using "push" model.
494
494
  */
495
- class V8_EXPORT OutputStream { // NOLINT
495
+ class V8_EXPORT OutputStream {
496
496
  public:
497
497
  enum WriteResult {
498
498
  kContinue = 0,
@@ -519,7 +519,6 @@ class V8_EXPORT OutputStream { // NOLINT
519
519
  }
520
520
  };
521
521
 
522
-
523
522
  /**
524
523
  * HeapSnapshots record the state of the JS heap at some moment.
525
524
  */
@@ -586,7 +585,7 @@ class V8_EXPORT HeapSnapshot {
586
585
  * An interface for reporting progress and controlling long-running
587
586
  * activities.
588
587
  */
589
- class V8_EXPORT ActivityControl { // NOLINT
588
+ class V8_EXPORT ActivityControl {
590
589
  public:
591
590
  enum ControlOption {
592
591
  kContinue = 0,
@@ -600,7 +599,6 @@ class V8_EXPORT ActivityControl { // NOLINT
600
599
  virtual ControlOption ReportProgressValue(int done, int total) = 0;
601
600
  };
602
601
 
603
-
604
602
  /**
605
603
  * AllocationProfile is a sampled profile of allocations done by the program.
606
604
  * This is structured as a call-graph.
@@ -902,6 +900,15 @@ class V8_EXPORT HeapProfiler {
902
900
  ObjectNameResolver* global_object_name_resolver = nullptr,
903
901
  bool treat_global_objects_as_roots = true);
904
902
 
903
+ /**
904
+ * Takes a heap snapshot and returns it.
905
+ */
906
+ const HeapSnapshot* TakeHeapSnapshotV8_92(
907
+ ActivityControl* control = nullptr,
908
+ ObjectNameResolver* global_object_name_resolver = nullptr,
909
+ bool treat_global_objects_as_roots = true,
910
+ bool capture_numeric_value = false);
911
+
905
912
  /**
906
913
  * Starts tracking of heap objects population statistics. After calling
907
914
  * this method, all heap objects relocations done by the garbage collector
@@ -9,9 +9,9 @@
9
9
  // NOTE these macros are used by some of the tool scripts and the build
10
10
  // system so their names cannot be changed without changing the scripts.
11
11
  #define V8_MAJOR_VERSION 9
12
- #define V8_MINOR_VERSION 1
13
- #define V8_BUILD_NUMBER 269
14
- #define V8_PATCH_LEVEL 36
12
+ #define V8_MINOR_VERSION 2
13
+ #define V8_BUILD_NUMBER 230
14
+ #define V8_PATCH_LEVEL 21
15
15
 
16
16
  // Use 1 for candidates and 0 otherwise.
17
17
  // (Boolean macro values are not supported by all preprocessors.)