5#ifndef V8_LOGGING_LOG_H_
6#define V8_LOGGING_LOG_H_
62class LogEventListener;
67class LinuxPerfBasicLogger;
68class LinuxPerfJitLogger;
73#if defined(V8_ENABLE_ETW_STACK_WALKING)
78#define LOG(isolate, Call) \
80 if (v8::internal::v8_flags.log) (isolate)->v8_file_logger()->Call; \
83#define LOG_CODE_EVENT(isolate, Call) \
85 auto&& logger = (isolate)->v8_file_logger(); \
86 if (logger->is_listening_to_code_events()) logger->Call; \
105#if defined(V8_ENABLE_ETW_STACK_WALKING)
106 void LogInterpretedFunctions();
138#if defined(V8_ENABLE_ETW_STACK_WALKING)
139 void SetEtwCodeEventHandler(uint32_t options);
140 void ResetEtwCodeEventHandler();
155 void NewEvent(
const char* name,
void*
object,
size_t size);
159 void FunctionEvent(
const char* reason,
int script_id,
double time_delta_ms,
160 int start_position,
int end_position,
162 void FunctionEvent(
const char* reason,
int script_id,
double time_delta_ms,
163 int start_position,
int end_position,
164 const char* function_name =
nullptr,
165 size_t function_name_length = 0,
bool is_one_byte =
true);
174 const char* name)
override;
183 int column)
override;
184#if V8_ENABLE_WEBASSEMBLY
187 int code_offset,
int script_id)
override;
208 int fp_to_sp_delta)
override;
211 const char* reason)
override;
217 const char*
kind,
const char* reason);
223#if V8_ENABLE_WEBASSEMBLY
224 void WasmCodeLinePosInfoRecordEvent(
232 const char* modifier,
const char* slow_stub_reason);
236 const char* reason =
nullptr,
243 uintptr_t
end, intptr_t aslr_slide);
255 bool expose_to_api) {
258 isolate->event_logger()(
name, se);
264 bool expose_to_api) {
274#if defined(V8_ENABLE_ETW_STACK_WALKING)
275 etw_jit_logger_ !=
nullptr ||
281#if defined(V8_ENABLE_ETW_STACK_WALKING)
282 return etw_jit_logger_ ==
nullptr;
292 bool ensure_source_positions_available =
true);
304#if defined(V8_ENABLE_ETW_STACK_WALKING)
305 void LogInterpretedFunctions();
367 std::unique_ptr<LinuxPerfBasicLogger> perf_basic_logger_;
368 std::unique_ptr<LinuxPerfJitLogger> perf_jit_logger_;
372#ifdef ENABLE_GDB_JIT_INTERFACE
373 std::unique_ptr<JitLogger> gdb_jit_logger_;
375#if defined(V8_ENABLE_ETW_STACK_WALKING)
376 std::unique_ptr<ETWJitLogger> etw_jit_logger_;
390#define TIMER_EVENTS_LIST(V) \
391 V(RecompileSynchronous, true) \
392 V(RecompileConcurrent, true) \
393 V(CompileIgnition, true) \
394 V(CompileFullCode, true) \
395 V(OptimizeCode, true) \
396 V(CompileCode, true) \
397 V(CompileCodeBackground, true) \
398 V(DeoptimizeCode, true) \
401#define V(TimerName, expose) \
402 class TimerEvent##TimerName : public AllStatic { \
404 static const char* name(void* unused = nullptr) { \
405 return "V8." #TimerName; \
407 static bool expose_to_api() { return expose; } \
412template <
class TimerEvent>
433 const char* name)
override;
442 int column)
override;
443#if V8_ENABLE_WEBASSEMBLY
446 int code_offset,
int script_id)
override;
454 Address entry_point)
override {}
456 Address entry_point)
override {}
461 int fp_to_sp_delta)
override {}
464 const char* reason)
override {}
479#if V8_ENABLE_WEBASSEMBLY
480 virtual void LogRecordedBuffer(
const wasm::WasmCode* code,
const char* name,
506 const char* comment)
override;
515 int column)
override;
516#if V8_ENABLE_WEBASSEMBLY
519 int code_offset,
int script_id)
override;
527 Address entry_point)
override {}
529 Address entry_point)
override {}
540 int fp_to_sp_delta)
override {}
543 const char* reason)
override {}
void GetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
void CodeMovingGCEvent() override
void SetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
void WeakCodeClearEvent() override
std::unique_ptr< NameBuffer > name_buffer_
bool is_listening_to_code_events() override
void CallbackEvent(DirectHandle< Name > name, Address entry_point) override
void NativeContextMoveEvent(Address from, Address to) override
virtual void LogRecordedBuffer(Tagged< AbstractCode > code, MaybeDirectHandle< SharedFunctionInfo > maybe_shared, const char *name, size_t length)=0
~CodeEventLogger() override
void CodeDeoptEvent(DirectHandle< Code > code, DeoptimizeKind kind, Address pc, int fp_to_sp_delta) override
void SharedFunctionInfoMoveEvent(Address from, Address to) override
void CodeDependencyChangeEvent(DirectHandle< Code > code, DirectHandle< SharedFunctionInfo > sfi, const char *reason) override
void LogCompiledFunctions(bool ensure_source_positions_available=true)
ExistingCodeLogger(Isolate *isolate, LogEventListener *listener=nullptr)
void LogExistingFunction(DirectHandle< SharedFunctionInfo > shared, DirectHandle< AbstractCode > code, LogEventListener::CodeTag tag=LogEventListener::CodeTag::kFunction)
LogEventListener * listener_
void LogCodeObject(Tagged< AbstractCode > object)
void StartListening(v8::CodeEventHandler *code_event_handler)
void CodeMoveEvent(Tagged< InstructionStream > from, Tagged< InstructionStream > to) override
void RegExpCodeCreateEvent(DirectHandle< AbstractCode > code, DirectHandle< String > source, RegExpFlags flags) override
void BytecodeMoveEvent(Tagged< BytecodeArray > from, Tagged< BytecodeArray > to) override
void CallbackEvent(DirectHandle< Name > name, Address entry_point) override
void CodeDeoptEvent(DirectHandle< Code > code, DeoptimizeKind kind, Address pc, int fp_to_sp_delta) override
void NativeContextMoveEvent(Address from, Address to) override
void SetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
void CodeCreateEvent(CodeTag tag, DirectHandle< AbstractCode > code, const char *comment) override
void CodeDisableOptEvent(DirectHandle< AbstractCode > code, DirectHandle< SharedFunctionInfo > shared) override
void CodeMovingGCEvent() override
ExternalLogEventListener(Isolate *isolate)
void GetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
~ExternalLogEventListener() override
void SharedFunctionInfoMoveEvent(Address from, Address to) override
void WeakCodeClearEvent() override
bool is_listening_to_code_events() override
void CodeDependencyChangeEvent(DirectHandle< Code > code, DirectHandle< SharedFunctionInfo > sfi, const char *reason) override
v8::CodeEventHandler * code_event_handler_
TimerEventScope(Isolate *isolate)
V8_EXPORT_PRIVATE std::string file_name() const
std::set< int > logged_source_code_
V8_NOINLINE static V8_PRESERVE_MOST void CallEventLoggerInternal(Isolate *isolate, const char *name, v8::LogEventStatus se, bool expose_to_api)
void SetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
void MapCreate(Tagged< Map > map)
void MapMoveEvent(Tagged< Map > from, Tagged< Map > to)
void WriteApiEntryCall(const char *name)
void IntPtrTEvent(const char *name, intptr_t value)
V8_EXPORT_PRIVATE bool is_logging()
std::unique_ptr< Ticker > ticker_
void LogCodeDisassemble(DirectHandle< AbstractCode > code)
void WeakCodeClearEvent() override
void CodeDependencyChangeEvent(DirectHandle< Code > code, DirectHandle< SharedFunctionInfo > sfi, const char *reason) override
void CodeDisableOptEvent(DirectHandle< AbstractCode > code, DirectHandle< SharedFunctionInfo > shared) override
void WriteApiSecurityCheck()
static void LeaveExternal(Isolate *isolate)
void FeedbackVectorEvent(Tagged< FeedbackVector > vector, Tagged< AbstractCode > code)
void DeleteEvent(const char *name, void *object)
std::unique_ptr< JitLogger > jit_logger_
static void EnterExternal(Isolate *isolate)
V8_EXPORT_PRIVATE void StopProfilerThread()
void InitNameBuffer(Event tag)
void MapDetails(Tagged< Map > map)
std::unique_ptr< Profiler > profiler_
void BytecodeMoveEvent(Tagged< BytecodeArray > from, Tagged< BytecodeArray > to) override
void MoveEventInternal(Event event, Address from, Address to)
static V8_INLINE void CallEventLogger(Isolate *isolate, const char *name, v8::LogEventStatus se, bool expose_to_api)
void CompilationCacheEvent(const char *action, const char *cache_type, Tagged< SharedFunctionInfo > sfi)
std::atomic< bool > is_logging_
V8_EXPORT_PRIVATE FILE * TearDownAndGetLogFile()
void RegExpCodeCreateEvent(DirectHandle< AbstractCode > code, DirectHandle< String > source, RegExpFlags flags) override
void ProfilerBeginEvent()
void WriteApiIndexedPropertyAccess(const char *tag, Tagged< JSObject > holder, uint32_t index)
bool is_listening_to_code_events() override
void NativeContextMoveEvent(Address from, Address to) override
void LogExistingFunction(DirectHandle< SharedFunctionInfo > shared, DirectHandle< AbstractCode > code)
void ScriptEvent(ScriptEventType type, int script_id)
V8_EXPORT_PRIVATE void LogAccessorCallbacks()
bool EnsureLogScriptSource(Tagged< Script > script)
void UncheckedStringEvent(const char *name, const char *value)
void WriteApiNamedPropertyAccess(const char *tag, Tagged< JSObject > holder, Tagged< Object > name)
V8_EXPORT_PRIVATE void LogCompiledFunctions(bool ensure_source_positions_available=true)
void CodeMoveEvent(Tagged< InstructionStream > from, Tagged< InstructionStream > to) override
void CodeDeoptEvent(DirectHandle< Code > code, DeoptimizeKind kind, Address pc, int fp_to_sp_delta) override
void CallbackEvent(DirectHandle< Name > name, Address entry_point) override
void SharedFunctionInfoMoveEvent(Address from, Address to) override
void LateSetup(Isolate *isolate)
void CodeNameEvent(Address addr, int pos, const char *code_name)
V8_EXPORT_PRIVATE void LogBuiltins()
sampler::Sampler * sampler()
void ProcessDeoptEvent(DirectHandle< Code > code, SourcePosition position, const char *kind, const char *reason)
void UpdateIsLogging(bool value)
void SetCodeEventHandler(uint32_t options, JitCodeEventHandler event_handler)
uint32_t next_source_info_id_
void SharedLibraryEvent(const std::string &library_path, uintptr_t start, uintptr_t end, intptr_t aslr_slide)
V8_EXPORT_PRIVATE void TimerEvent(v8::LogEventStatus se, const char *name)
void WriteApiObjectAccess(const char *tag, Tagged< JSReceiver > obj)
void MapEvent(const char *type, DirectHandle< Map > from, DirectHandle< Map > to, const char *reason=nullptr, DirectHandle< HeapObject > name_or_sfi=DirectHandle< HeapObject >())
bool SetUp(Isolate *isolate)
bool allows_code_compaction() override
void TickEvent(TickSample *sample, bool overflow)
std::unique_ptr< LogFile > log_file_
void FunctionEvent(const char *reason, int script_id, double time_delta_ms, int start_position, int end_position, Tagged< String > function_name)
void CodeLinePosInfoRecordEvent(Address code_start, Tagged< TrustedByteArray > source_position_table, JitCodeEvent::CodeType code_type)
void ScriptDetails(Tagged< Script > script)
void CodeCreateEvent(CodeTag tag, DirectHandle< AbstractCode > code, const char *name) override
void ICEvent(const char *type, bool keyed, DirectHandle< Map > map, DirectHandle< Object > key, char old_state, char new_state, const char *modifier, const char *slow_stub_reason)
V8_EXPORT_PRIVATE void StringEvent(const char *name, const char *value)
void NewEvent(const char *name, void *object, size_t size)
V8_EXPORT_PRIVATE void LogCodeObjects()
static const LogSeparator kNext
void RuntimeCallTimerEvent()
void GetterCallbackEvent(DirectHandle< Name > name, Address entry_point) override
void LogSourceCodeInformation(DirectHandle< AbstractCode > code, DirectHandle< SharedFunctionInfo > shared)
V8FileLogger(Isolate *isolate)
std::unique_ptr< LowLevelLogger > ll_logger_
void CodeMovingGCEvent() override
void CallbackEventInternal(const char *prefix, DirectHandle< Name > name, Address entry_point)
base::ElapsedTimer timer_
ExistingCodeLogger existing_code_logger_
static V8_INLINE CodeTag ToNativeByScript(CodeTag tag, Tagged< Script > script)
#define LOG(isolate, Call)
#define TIMER_EVENTS_LIST(V)
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 name
V8_EXPORT_PRIVATE FlagValues v8_flags
void(*)(const JitCodeEvent *event) JitCodeEventHandler
#define V8_EXPORT_PRIVATE
DirectHandle< String > script_name
uintptr_t code_start_address
uintptr_t previous_code_start_address
DirectHandle< String > function_name
#define V8_UNLIKELY(condition)