Commit 0d9bac04 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[baseline] Log ConcurrentSP compilation

Adds LogFunctionCompilation as a static member of Compiler.
Calls the log function after installing the code on the main thread.

Bug: v8:12054, v8:12818
Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel_ng
Change-Id: I664b2c890292a207720efe311b7c55757c7c6470
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3599472Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80080}
parent 3a05e3cb
...@@ -46,6 +46,8 @@ class BaselineCompilerTask { ...@@ -46,6 +46,8 @@ class BaselineCompilerTask {
// Executed in the background thread. // Executed in the background thread.
void Compile(LocalIsolate* local_isolate) { void Compile(LocalIsolate* local_isolate) {
base::ElapsedTimer timer;
timer.Start();
BaselineCompiler compiler(local_isolate, shared_function_info_, bytecode_); BaselineCompiler compiler(local_isolate, shared_function_info_, bytecode_);
compiler.GenerateCode(); compiler.GenerateCode();
maybe_code_ = local_isolate->heap()->NewPersistentMaybeHandle( maybe_code_ = local_isolate->heap()->NewPersistentMaybeHandle(
...@@ -54,6 +56,7 @@ class BaselineCompilerTask { ...@@ -54,6 +56,7 @@ class BaselineCompilerTask {
if (maybe_code_.ToHandle(&code)) { if (maybe_code_.ToHandle(&code)) {
local_isolate->heap()->RegisterCodeObject(code); local_isolate->heap()->RegisterCodeObject(code);
} }
time_taken_ms_ = timer.Elapsed().InMillisecondsF();
} }
// Executed in the main thread. // Executed in the main thread.
...@@ -68,6 +71,7 @@ class BaselineCompilerTask { ...@@ -68,6 +71,7 @@ class BaselineCompilerTask {
if (!CanCompileWithConcurrentBaseline(*shared_function_info_, isolate)) { if (!CanCompileWithConcurrentBaseline(*shared_function_info_, isolate)) {
return; return;
} }
shared_function_info_->set_baseline_code(ToCodeT(*code), kReleaseStore); shared_function_info_->set_baseline_code(ToCodeT(*code), kReleaseStore);
if (V8_LIKELY(FLAG_use_osr)) { if (V8_LIKELY(FLAG_use_osr)) {
shared_function_info_->GetBytecodeArray(isolate) shared_function_info_->GetBytecodeArray(isolate)
...@@ -82,12 +86,20 @@ class BaselineCompilerTask { ...@@ -82,12 +86,20 @@ class BaselineCompilerTask {
OFStream os(scope.file()); OFStream os(scope.file());
os << ss.str(); os << ss.str();
} }
if (shared_function_info_->script().IsScript()) {
Compiler::LogFunctionCompilation(
isolate, LogEventListener::FUNCTION_TAG,
handle(Script::cast(shared_function_info_->script()), isolate),
shared_function_info_, Handle<FeedbackVector>(),
Handle<AbstractCode>::cast(code), CodeKind::BASELINE, time_taken_ms_);
}
} }
private: private:
Handle<SharedFunctionInfo> shared_function_info_; Handle<SharedFunctionInfo> shared_function_info_;
Handle<BytecodeArray> bytecode_; Handle<BytecodeArray> bytecode_;
MaybeHandle<Code> maybe_code_; MaybeHandle<Code> maybe_code_;
double time_taken_ms_;
}; };
class BaselineBatchCompilerJob { class BaselineBatchCompilerJob {
...@@ -127,6 +139,7 @@ class BaselineBatchCompilerJob { ...@@ -127,6 +139,7 @@ class BaselineBatchCompilerJob {
// Executed in the main thread. // Executed in the main thread.
void Install(Isolate* isolate) { void Install(Isolate* isolate) {
HandleScope local_scope(isolate);
for (auto& task : tasks_) { for (auto& task : tasks_) {
task.Install(isolate); task.Install(isolate);
} }
......
...@@ -244,13 +244,16 @@ class CompilerTracer : public AllStatic { ...@@ -244,13 +244,16 @@ class CompilerTracer : public AllStatic {
} }
}; };
void LogFunctionCompilation(Isolate* isolate, } // namespace
// static
void Compiler::LogFunctionCompilation(Isolate* isolate,
LogEventListener::LogEventsAndTags tag, LogEventListener::LogEventsAndTags tag,
Handle<Script> script, Handle<Script> script,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> vector, Handle<FeedbackVector> vector,
Handle<AbstractCode> abstract_code, CodeKind kind, Handle<AbstractCode> abstract_code,
double time_taken_ms) { CodeKind kind, double time_taken_ms) {
DCHECK(!abstract_code.is_null()); DCHECK(!abstract_code.is_null());
if (V8_EXTERNAL_CODE_SPACE_BOOL) { if (V8_EXTERNAL_CODE_SPACE_BOOL) {
DCHECK_NE(*abstract_code, FromCodeT(*BUILTIN_CODE(isolate, CompileLazy))); DCHECK_NE(*abstract_code, FromCodeT(*BUILTIN_CODE(isolate, CompileLazy)));
...@@ -318,8 +321,6 @@ void LogFunctionCompilation(Isolate* isolate, ...@@ -318,8 +321,6 @@ void LogFunctionCompilation(Isolate* isolate,
*debug_name)); *debug_name));
} }
} // namespace
// Helper that times a scoped region and records the elapsed time. // Helper that times a scoped region and records the elapsed time.
struct ScopedTimer { struct ScopedTimer {
explicit ScopedTimer(base::TimeDelta* location) : location_(location) { explicit ScopedTimer(base::TimeDelta* location) : location_(location) {
...@@ -429,9 +430,9 @@ void RecordUnoptimizedFunctionCompilation( ...@@ -429,9 +430,9 @@ void RecordUnoptimizedFunctionCompilation(
time_taken_to_finalize.InMillisecondsF(); time_taken_to_finalize.InMillisecondsF();
Handle<Script> script(Script::cast(shared->script()), isolate); Handle<Script> script(Script::cast(shared->script()), isolate);
LogFunctionCompilation(isolate, tag, script, shared, Handle<FeedbackVector>(), Compiler::LogFunctionCompilation(
abstract_code, CodeKind::INTERPRETED_FUNCTION, isolate, tag, script, shared, Handle<FeedbackVector>(), abstract_code,
time_taken_ms); CodeKind::INTERPRETED_FUNCTION, time_taken_ms);
} }
} // namespace } // namespace
...@@ -566,7 +567,7 @@ void TurbofanCompilationJob::RecordFunctionCompilation( ...@@ -566,7 +567,7 @@ void TurbofanCompilationJob::RecordFunctionCompilation(
Script::cast(compilation_info()->shared_info()->script()), isolate); Script::cast(compilation_info()->shared_info()->script()), isolate);
Handle<FeedbackVector> feedback_vector( Handle<FeedbackVector> feedback_vector(
compilation_info()->closure()->feedback_vector(), isolate); compilation_info()->closure()->feedback_vector(), isolate);
LogFunctionCompilation( Compiler::LogFunctionCompilation(
isolate, tag, script, compilation_info()->shared_info(), feedback_vector, isolate, tag, script, compilation_info()->shared_info(), feedback_vector,
abstract_code, compilation_info()->code_kind(), time_taken_ms); abstract_code, compilation_info()->code_kind(), time_taken_ms);
} }
...@@ -1141,9 +1142,9 @@ void RecordMaglevFunctionCompilation(Isolate* isolate, ...@@ -1141,9 +1142,9 @@ void RecordMaglevFunctionCompilation(Isolate* isolate,
// Optimistic estimate. // Optimistic estimate.
double time_taken_ms = 0; double time_taken_ms = 0;
LogFunctionCompilation(isolate, LogEventListener::FUNCTION_TAG, script, Compiler::LogFunctionCompilation(
shared, feedback_vector, abstract_code, isolate, LogEventListener::FUNCTION_TAG, script, shared, feedback_vector,
abstract_code->kind(), time_taken_ms); abstract_code, abstract_code->kind(), time_taken_ms);
} }
#endif // V8_ENABLE_MAGLEV #endif // V8_ENABLE_MAGLEV
......
...@@ -236,6 +236,14 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic { ...@@ -236,6 +236,14 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node, static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
Handle<Script> script, Handle<Script> script,
IsolateT* isolate); IsolateT* isolate);
static void LogFunctionCompilation(Isolate* isolate,
LogEventListener::LogEventsAndTags tag,
Handle<Script> script,
Handle<SharedFunctionInfo> shared,
Handle<FeedbackVector> vector,
Handle<AbstractCode> abstract_code,
CodeKind kind, double time_taken_ms);
}; };
// A base class for compilation jobs intended to run concurrent to the main // A base class for compilation jobs intended to run concurrent to the main
......
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