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 {
// Executed in the background thread.
void Compile(LocalIsolate* local_isolate) {
base::ElapsedTimer timer;
timer.Start();
BaselineCompiler compiler(local_isolate, shared_function_info_, bytecode_);
compiler.GenerateCode();
maybe_code_ = local_isolate->heap()->NewPersistentMaybeHandle(
......@@ -54,6 +56,7 @@ class BaselineCompilerTask {
if (maybe_code_.ToHandle(&code)) {
local_isolate->heap()->RegisterCodeObject(code);
}
time_taken_ms_ = timer.Elapsed().InMillisecondsF();
}
// Executed in the main thread.
......@@ -68,6 +71,7 @@ class BaselineCompilerTask {
if (!CanCompileWithConcurrentBaseline(*shared_function_info_, isolate)) {
return;
}
shared_function_info_->set_baseline_code(ToCodeT(*code), kReleaseStore);
if (V8_LIKELY(FLAG_use_osr)) {
shared_function_info_->GetBytecodeArray(isolate)
......@@ -82,12 +86,20 @@ class BaselineCompilerTask {
OFStream os(scope.file());
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:
Handle<SharedFunctionInfo> shared_function_info_;
Handle<BytecodeArray> bytecode_;
MaybeHandle<Code> maybe_code_;
double time_taken_ms_;
};
class BaselineBatchCompilerJob {
......@@ -127,6 +139,7 @@ class BaselineBatchCompilerJob {
// Executed in the main thread.
void Install(Isolate* isolate) {
HandleScope local_scope(isolate);
for (auto& task : tasks_) {
task.Install(isolate);
}
......
......@@ -244,13 +244,16 @@ class CompilerTracer : public AllStatic {
}
};
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) {
} // namespace
// static
void Compiler::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) {
DCHECK(!abstract_code.is_null());
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
DCHECK_NE(*abstract_code, FromCodeT(*BUILTIN_CODE(isolate, CompileLazy)));
......@@ -318,8 +321,6 @@ void LogFunctionCompilation(Isolate* isolate,
*debug_name));
}
} // namespace
// Helper that times a scoped region and records the elapsed time.
struct ScopedTimer {
explicit ScopedTimer(base::TimeDelta* location) : location_(location) {
......@@ -429,9 +430,9 @@ void RecordUnoptimizedFunctionCompilation(
time_taken_to_finalize.InMillisecondsF();
Handle<Script> script(Script::cast(shared->script()), isolate);
LogFunctionCompilation(isolate, tag, script, shared, Handle<FeedbackVector>(),
abstract_code, CodeKind::INTERPRETED_FUNCTION,
time_taken_ms);
Compiler::LogFunctionCompilation(
isolate, tag, script, shared, Handle<FeedbackVector>(), abstract_code,
CodeKind::INTERPRETED_FUNCTION, time_taken_ms);
}
} // namespace
......@@ -566,7 +567,7 @@ void TurbofanCompilationJob::RecordFunctionCompilation(
Script::cast(compilation_info()->shared_info()->script()), isolate);
Handle<FeedbackVector> feedback_vector(
compilation_info()->closure()->feedback_vector(), isolate);
LogFunctionCompilation(
Compiler::LogFunctionCompilation(
isolate, tag, script, compilation_info()->shared_info(), feedback_vector,
abstract_code, compilation_info()->code_kind(), time_taken_ms);
}
......@@ -1141,9 +1142,9 @@ void RecordMaglevFunctionCompilation(Isolate* isolate,
// Optimistic estimate.
double time_taken_ms = 0;
LogFunctionCompilation(isolate, LogEventListener::FUNCTION_TAG, script,
shared, feedback_vector, abstract_code,
abstract_code->kind(), time_taken_ms);
Compiler::LogFunctionCompilation(
isolate, LogEventListener::FUNCTION_TAG, script, shared, feedback_vector,
abstract_code, abstract_code->kind(), time_taken_ms);
}
#endif // V8_ENABLE_MAGLEV
......
......@@ -236,6 +236,14 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
static Handle<SharedFunctionInfo> GetSharedFunctionInfo(FunctionLiteral* node,
Handle<Script> script,
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
......
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