11 #include "include/v8-profiler.h" 12 #include "src/allocation.h" 13 #include "src/base/compiler-specific.h" 14 #include "src/base/platform/elapsed-timer.h" 15 #include "src/base/platform/platform.h" 16 #include "src/code-events.h" 17 #include "src/isolate.h" 18 #include "src/log-utils.h" 19 #include "src/objects.h" 20 #include "src/objects/string.h" 67 class CodeEventListener;
73 class PerfBasicLogger;
76 class RuntimeCallTimer;
80 #define LOG(isolate, Call) \ 82 v8::internal::Logger* logger = (isolate)->logger(); \ 83 if (logger->is_logging()) logger->Call; \ 86 #define LOG_CODE_EVENT(isolate, Call) \ 88 v8::internal::Logger* logger = (isolate)->logger(); \ 89 if (logger->is_listening_to_code_events()) logger->Call; \ 96 : isolate_(isolate), listener_(listener) {}
98 void LogCodeObjects();
100 void LogCompiledFunctions();
103 CodeEventListener::LogEventsAndTags tag =
104 CodeEventListener::LAZY_COMPILE_TAG);
105 void LogCodeObject(
Object*
object);
114 enum StartEnd { START = 0, END = 1, STAMP = 2 };
116 enum class ScriptEventType {
125 static const LogSeparator kNext = LogSeparator::kSeparator;
131 void SetCodeEventHandler(
uint32_t options,
132 JitCodeEventHandler event_handler);
136 void StopProfilerThread();
144 void StringEvent(
const char* name,
const char* value);
147 void IntPtrTEvent(
const char* name, intptr_t value);
150 void HandleEvent(
const char* name,
Address* location);
153 void NewEvent(
const char* name,
void*
object,
size_t size);
154 void DeleteEvent(
const char* name,
void*
object);
160 void ResourceEvent(
const char* name,
const char* tag);
164 void SuspectReadEvent(
Name name,
Object* obj);
167 void FunctionEvent(
const char* reason,
int script_id,
double time_delta_ms,
168 int start_position = -1,
int end_position = -1,
170 void FunctionEvent(
const char* reason,
int script_id,
double time_delta_ms,
171 int start_position,
int end_position,
172 const char* function_name =
nullptr,
173 size_t function_name_length = 0);
175 void CompilationCacheEvent(
const char* action,
const char* cache_type,
177 void ScriptEvent(ScriptEventType
type,
int script_id);
178 void ScriptDetails(
Script* script);
181 void ApiSecurityCheck();
182 void ApiNamedPropertyAccess(
const char* tag,
JSObject* holder,
Object* name);
183 void ApiIndexedPropertyAccess(
const char* tag,
186 void ApiObjectAccess(
const char* tag,
JSObject* obj);
187 void ApiEntryCall(
const char* name);
194 void CallbackEvent(
Name name,
Address entry_point)
override;
195 void GetterCallbackEvent(
Name name,
Address entry_point)
override;
196 void SetterCallbackEvent(
Name name,
Address entry_point)
override;
198 void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
200 void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
202 void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
205 void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
207 Name source,
int line,
int column)
override;
208 void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
214 void CodeMovingGCEvent()
override;
220 void CodeLinePosInfoRecordEvent(
Address code_start,
222 void CodeLinePosInfoRecordEvent(
Address code_start,
225 void SharedFunctionInfoMoveEvent(
Address from,
Address to)
override;
227 void CodeNameEvent(
Address addr,
int pos,
const char* code_name);
229 void CodeDeoptEvent(
Code code, DeoptimizeKind kind,
Address pc,
230 int fp_to_sp_delta)
override;
232 void ICEvent(
const char*
type,
bool keyed,
Map map,
Object* key,
233 char old_state,
char new_state,
const char* modifier,
234 const char* slow_stub_reason);
236 void MapEvent(
const char*
type,
Map from,
Map to,
237 const char* reason =
nullptr,
239 void MapCreate(
Map map);
240 void MapDetails(
Map map);
242 void SharedLibraryEvent(
const std::string& library_path,
uintptr_t start,
245 void CurrentTimeEvent();
247 V8_EXPORT_PRIVATE
void TimerEvent(StartEnd se,
const char* name);
249 static void EnterExternal(
Isolate* isolate);
250 static void LeaveExternal(
Isolate* isolate);
252 static void DefaultEventLoggerSentinel(
const char* name,
int event) {}
254 V8_INLINE
static void CallEventLogger(
Isolate* isolate,
const char* name,
255 StartEnd se,
bool expose_to_api);
261 bool is_listening_to_code_events()
override {
262 return is_logging() || jit_logger_ !=
nullptr;
272 void LogCompiledFunctions();
274 void LogAccessorCallbacks();
276 void LogCodeObjects();
281 V8_INLINE
static CodeEventListener::LogEventsAndTags ToNativeByScript(
282 CodeEventListener::LogEventsAndTags,
Script*);
288 void LogCodeObject(
Object* code_object);
295 void ProfilerBeginEvent();
298 void CallbackEventInternal(
const char* prefix,
Name name,
302 void MoveEventInternal(CodeEventListener::LogEventsAndTags event,
306 void InitNameBuffer(CodeEventListener::LogEventsAndTags tag);
309 void TickEvent(
TickSample* sample,
bool overflow);
310 void RuntimeCallTimerEvent();
313 void UncheckedStringEvent(
const char* name,
const char* value);
316 void UncheckedIntPtrTEvent(
const char* name, intptr_t value);
320 bool EnsureLogScriptSource(
Script* script);
333 const char*
const* log_events_;
337 friend class EventLog;
339 friend class TimeLog;
341 template <StateTag Tag>
friend class VMState;
342 friend class LoggerTestHelper;
350 std::set<int> logged_source_code_;
355 bool is_initialized_;
364 #define TIMER_EVENTS_LIST(V) \ 365 V(RecompileSynchronous, true) \ 366 V(RecompileConcurrent, true) \ 367 V(CompileIgnition, true) \ 368 V(CompileFullCode, true) \ 369 V(OptimizeCode, true) \ 370 V(CompileCode, true) \ 371 V(CompileCodeBackground, true) \ 372 V(DeoptimizeCode, true) \ 376 #define V(TimerName, expose) \ 377 class TimerEvent##TimerName : public AllStatic { \ 379 static const char* name(void* unused = nullptr) { \ 380 return "V8." #TimerName; \ 382 static bool expose_to_api() { return expose; } \ 388 template <
class TimerEvent>
392 LogTimerEvent(Logger::START);
398 void LogTimerEvent(Logger::StartEnd se);
407 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
408 const char* comment)
override;
409 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
411 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
413 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
415 int column)
override;
416 void CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code,
420 void CallbackEvent(
Name name,
Address entry_point)
override {}
421 void GetterCallbackEvent(
Name name,
Address entry_point)
override {}
422 void SetterCallbackEvent(
Name name,
Address entry_point)
override {}
423 void SharedFunctionInfoMoveEvent(
Address from,
Address to)
override {}
424 void CodeMovingGCEvent()
override {}
425 void CodeDeoptEvent(
Code code, DeoptimizeKind kind,
Address pc,
426 int fp_to_sp_delta)
override {}
435 const char* name,
int length) = 0;
436 virtual void LogRecordedBuffer(
const wasm::WasmCode* code,
const char* name,
459 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
460 const char* comment)
override;
461 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
463 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
465 void CodeCreateEvent(LogEventsAndTags tag,
AbstractCode code,
467 int column)
override;
468 void CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code,
472 void CallbackEvent(
Name name,
Address entry_point)
override {}
473 void GetterCallbackEvent(
Name name,
Address entry_point)
override {}
474 void SetterCallbackEvent(
Name name,
Address entry_point)
override {}
475 void SharedFunctionInfoMoveEvent(
Address from,
Address to)
override {}
479 void CodeMovingGCEvent()
override {}
480 void CodeDeoptEvent(
Code code, DeoptimizeKind kind,
Address pc,
481 int fp_to_sp_delta)
override {}
484 void StopListening();
486 bool is_listening_to_code_events()
override {
return true; }
489 void LogExistingCode();