Commit 4be7742f authored by Jakob Linke's avatar Jakob Linke Committed by V8 LUCI CQ

[compiler] Extend Maglev tiering tracing

Add tracing for ML compilation begin and end events.

Drive-by: Slight refactors of related tracing functions for other tiers.

Bug: v8:7700
Change-Id: I8d7633c63642fc6d4418c71d87955cf3bcf1d496
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3825779
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Auto-Submit: Jakob Linke <jgruber@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82378}
parent dc84c235
...@@ -102,22 +102,31 @@ void ResetProfilerTicks(JSFunction function, BytecodeOffset osr_offset) { ...@@ -102,22 +102,31 @@ void ResetProfilerTicks(JSFunction function, BytecodeOffset osr_offset) {
class CompilerTracer : public AllStatic { class CompilerTracer : public AllStatic {
public: public:
static void TracePrepareJob(Isolate* isolate, OptimizedCompilationInfo* info,
const char* compiler_name) {
if (!FLAG_trace_opt || !info->IsOptimizing()) return;
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "compiling method", info);
PrintF(scope.file(), " using %s%s", compiler_name,
info->is_osr() ? " OSR" : "");
PrintTraceSuffix(scope);
}
static void TraceStartBaselineCompile(Isolate* isolate, static void TraceStartBaselineCompile(Isolate* isolate,
Handle<SharedFunctionInfo> shared) { Handle<SharedFunctionInfo> shared) {
if (!FLAG_trace_baseline) return; if (!FLAG_trace_baseline) return;
CodeTracer::Scope scope(isolate->GetCodeTracer()); CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "compiling method", shared, CodeKind::BASELINE); PrintTracePrefix(scope, "compiling method", shared, CodeKind::BASELINE);
PrintF(scope.file(), " using Sparkplug"); PrintTraceSuffix(scope);
}
static void TraceStartMaglevCompile(Isolate* isolate,
Handle<JSFunction> function,
ConcurrencyMode mode) {
if (!FLAG_trace_opt) return;
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "compiling method", function, CodeKind::MAGLEV);
PrintF(scope.file(), ", mode: %s", ToString(mode));
PrintTraceSuffix(scope);
}
static void TracePrepareJob(Isolate* isolate, OptimizedCompilationInfo* info,
ConcurrencyMode mode) {
if (!FLAG_trace_opt || !info->IsOptimizing()) return;
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "compiling method", info);
if (info->is_osr()) PrintF(scope.file(), " OSR");
PrintF(scope.file(), ", mode: %s", ToString(mode));
PrintTraceSuffix(scope); PrintTraceSuffix(scope);
} }
...@@ -189,6 +198,14 @@ class CompilerTracer : public AllStatic { ...@@ -189,6 +198,14 @@ class CompilerTracer : public AllStatic {
PrintTraceSuffix(scope); PrintTraceSuffix(scope);
} }
static void TraceFinishMaglevCompile(Isolate* isolate,
Handle<JSFunction> function) {
if (!FLAG_trace_opt) return;
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "completed compiling", function, CodeKind::MAGLEV);
PrintTraceSuffix(scope);
}
static void TraceCompletedJob(Isolate* isolate, static void TraceCompletedJob(Isolate* isolate,
OptimizedCompilationInfo* info) { OptimizedCompilationInfo* info) {
if (!FLAG_trace_opt) return; if (!FLAG_trace_opt) return;
...@@ -973,11 +990,11 @@ class OptimizedCodeCache : public AllStatic { ...@@ -973,11 +990,11 @@ class OptimizedCodeCache : public AllStatic {
// allocated in a persistent handle scope that is detached and handed off to the // allocated in a persistent handle scope that is detached and handed off to the
// {compilation_info} after PrepareJob. // {compilation_info} after PrepareJob.
bool PrepareJobWithHandleScope(OptimizedCompilationJob* job, Isolate* isolate, bool PrepareJobWithHandleScope(OptimizedCompilationJob* job, Isolate* isolate,
OptimizedCompilationInfo* compilation_info) { OptimizedCompilationInfo* compilation_info,
ConcurrencyMode mode) {
CompilationHandleScope compilation(isolate, compilation_info); CompilationHandleScope compilation(isolate, compilation_info);
CanonicalHandleScopeForTurbofan canonical(isolate, compilation_info); CanonicalHandleScopeForTurbofan canonical(isolate, compilation_info);
CompilerTracer::TracePrepareJob(isolate, compilation_info, CompilerTracer::TracePrepareJob(isolate, compilation_info, mode);
job->compiler_name());
compilation_info->ReopenHandlesInNewHandleScope(isolate); compilation_info->ReopenHandlesInNewHandleScope(isolate);
return job->PrepareJob(isolate) == CompilationJob::SUCCEEDED; return job->PrepareJob(isolate) == CompilationJob::SUCCEEDED;
} }
...@@ -992,7 +1009,8 @@ bool CompileTurbofan_NotConcurrent(Isolate* isolate, ...@@ -992,7 +1009,8 @@ bool CompileTurbofan_NotConcurrent(Isolate* isolate,
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.OptimizeNonConcurrent"); "V8.OptimizeNonConcurrent");
if (!PrepareJobWithHandleScope(job, isolate, compilation_info)) { if (!PrepareJobWithHandleScope(job, isolate, compilation_info,
ConcurrencyMode::kSynchronous)) {
CompilerTracer::TraceAbortedJob(isolate, compilation_info); CompilerTracer::TraceAbortedJob(isolate, compilation_info);
return false; return false;
} }
...@@ -1053,7 +1071,8 @@ bool CompileTurbofan_Concurrent(Isolate* isolate, ...@@ -1053,7 +1071,8 @@ bool CompileTurbofan_Concurrent(Isolate* isolate,
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
"V8.OptimizeConcurrentPrepare"); "V8.OptimizeConcurrentPrepare");
if (!PrepareJobWithHandleScope(job.get(), isolate, compilation_info)) { if (!PrepareJobWithHandleScope(job.get(), isolate, compilation_info,
ConcurrencyMode::kConcurrent)) {
return false; return false;
} }
...@@ -1182,6 +1201,7 @@ MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function, ...@@ -1182,6 +1201,7 @@ MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function,
auto job = maglev::MaglevCompilationJob::New(isolate, function); auto job = maglev::MaglevCompilationJob::New(isolate, function);
{ {
CompilerTracer::TraceStartMaglevCompile(isolate, function, mode);
CompilationJob::Status status = job->PrepareJob(isolate); CompilationJob::Status status = job->PrepareJob(isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status. CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status.
} }
...@@ -3997,6 +4017,7 @@ void Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job, ...@@ -3997,6 +4017,7 @@ void Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
// function by MaglevCompilationJob::FinalizeJobImpl. // function by MaglevCompilationJob::FinalizeJobImpl.
RecordMaglevFunctionCompilation(isolate, job->function()); RecordMaglevFunctionCompilation(isolate, job->function());
CompilerTracer::TraceFinishMaglevCompile(isolate, job->function());
} }
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment