5#ifndef V8_LIBPLATFORM_V8_TRACING_H_
6#define V8_LIBPLATFORM_V8_TRACING_H_
10#include <unordered_set>
17namespace trace_processor {
18class TraceProcessorStorage;
32class TraceEventListener;
49 char phase,
const uint8_t* category_enabled_flag,
const char* name,
50 const char* scope, uint64_t
id, uint64_t bind_id,
int num_args,
51 const char** arg_names,
const uint8_t* arg_types,
52 const uint64_t* arg_values,
53 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
54 unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
55 void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
56 void InitializeForTesting(
57 char phase,
const uint8_t* category_enabled_flag,
const char* name,
58 const char* scope, uint64_t
id, uint64_t bind_id,
int num_args,
59 const char** arg_names,
const uint8_t* arg_types,
60 const uint64_t* arg_values,
61 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
62 unsigned int flags,
int pid,
int tid, int64_t ts, int64_t tts,
63 uint64_t duration, uint64_t cpu_duration);
65 int pid()
const {
return pid_; }
66 int tid()
const {
return tid_; }
67 char phase()
const {
return phase_; }
69 return category_enabled_flag_;
73 uint64_t
id()
const {
return id_; }
74 uint64_t
bind_id()
const {
return bind_id_; }
80 return arg_convertables_;
83 int64_t
ts() {
return ts_; }
84 int64_t
tts() {
return tts_; }
101 std::unique_ptr<v8::ConvertableToTraceFormat>
103 char* parameter_copy_storage_ =
nullptr;
122 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
123 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
124 const std::string& tag);
138 void Reset(uint32_t new_seq);
139 bool IsFull()
const {
return next_free_ == kChunkSize; }
143 uint32_t
seq()
const {
return seq_; }
144 size_t size()
const {
return next_free_; }
146 static const size_t kChunkSize = 64;
149 size_t next_free_ = 0;
167 static const size_t kRingBufferChunks = 1024;
169 static TraceBuffer* CreateTraceBufferRingBuffer(
size_t max_chunks,
200 TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
203 return included_categories_;
212 void AddIncludedCategory(
const char* included_category);
214 bool IsCategoryGroupEnabled(
const char* category_group)
const;
228#define V8_PLATFORM_NON_EXPORTED_BASE(code) \
229 __pragma(warning(suppress : 4275)) code
231#define V8_PLATFORM_NON_EXPORTED_BASE(code) code
240#if defined(V8_USE_PERFETTO)
243 void InitializeForPerfetto(std::ostream* output_stream);
254 ENABLED_FOR_RECORDING = 1 << 0,
256 ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
258 ENABLED_FOR_ETW_EXPORT = 1 << 3
265 const uint8_t* GetCategoryGroupEnabled(
const char* category_group)
override;
267 char phase,
const uint8_t* category_enabled_flag,
const char* name,
268 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
269 const char** arg_names,
const uint8_t* arg_types,
270 const uint64_t* arg_values,
271 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
272 unsigned int flags)
override;
274 char phase,
const uint8_t* category_enabled_flag,
const char* name,
275 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
276 const char** arg_names,
const uint8_t* arg_types,
277 const uint64_t* arg_values,
278 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
279 unsigned int flags, int64_t timestamp)
override;
280 void UpdateTraceEventDuration(
const uint8_t* category_enabled_flag,
281 const char* name, uint64_t handle)
override;
283 static const char* GetCategoryGroupName(
const uint8_t* category_enabled_flag);
285 void AddTraceStateObserver(
287 void RemoveTraceStateObserver(
295#if !defined(V8_USE_PERFETTO)
296 virtual int64_t CurrentTimestampMicroseconds();
297 virtual int64_t CurrentCpuTimestampMicroseconds();
301#if !defined(V8_USE_PERFETTO)
302 void UpdateCategoryGroupEnabledFlag(
size_t category_index);
303 void UpdateCategoryGroupEnabledFlags();
308 std::atomic_bool recording_{
false};
310#if defined(V8_USE_PERFETTO)
311 std::ostream* output_stream_ =
nullptr;
312 std::unique_ptr<perfetto::trace_processor::TraceProcessorStorage>
315 std::unique_ptr<perfetto::TracingSession> tracing_session_;
317 std::unordered_set<v8::TracingController::TraceStateObserver*>
observers_;
326#undef V8_PLATFORM_NON_EXPORTED_BASE
DeclarationScope * scope_
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
MutablePageMetadata * chunk_
#define V8_PLATFORM_NON_EXPORTED_BASE(code)