Commit 68c158ab authored by Jakob Linke's avatar Jakob Linke Committed by V8 LUCI CQ

[compiler] Refactor Finalize* signatures

.. to match behavior. According to the old signatures, the functions
returned bool (they actually returned CompilationJob::Status). This only
worked because return values are unused. Change to void return type
instead.

Drive-by: Code reuse in FinalizeMaglevCompilationJob.

Bug: v8:7700
Change-Id: I45f75121c230063dec96a5197cc9fdc3b64aae6f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3822683Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82373}
parent bd5e4b21
......@@ -1180,37 +1180,29 @@ MaybeHandle<CodeT> CompileMaglev(Isolate* isolate, Handle<JSFunction> function,
// Prepare the job.
auto job = maglev::MaglevCompilationJob::New(isolate, function);
CompilationJob::Status status = job->PrepareJob(isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status.
{
CompilationJob::Status status = job->PrepareJob(isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED); // TODO(v8:7700): Use status.
}
if (IsSynchronous(mode)) {
ResetTieringState(*job->function(), osr_offset);
{
// Park the main thread Isolate here, to be in the same state as
// background threads.
ParkedScope parked_scope(isolate->main_thread_local_isolate());
if (job->ExecuteJob(isolate->counters()->runtime_call_stats(),
isolate->main_thread_local_isolate()) !=
CompilationJob::SUCCEEDED) {
return {};
}
CompilationJob::Status status =
job->ExecuteJob(isolate->counters()->runtime_call_stats(),
isolate->main_thread_local_isolate());
CHECK_EQ(status, CompilationJob::SUCCEEDED);
}
if (job->FinalizeJob(isolate) != CompilationJob::SUCCEEDED) {
return {};
{
// TODO(v8:7700): Support OSR in FinalizeMaglevCompilationJob.
DCHECK(osr_offset.IsNone());
Compiler::FinalizeMaglevCompilationJob(job.get(), isolate);
}
RecordMaglevFunctionCompilation(isolate, function);
// TODO(v8:7700): Re-enable caching in a separate feedback vector slot. We
// probably shouldn't reuse the same slot as TF since that makes tiering
// logic from ML to TF more involved (it'd have to check the cached code
// kind).
// const bool kIsContextSpecializing = false;
// OptimizedCodeCache::Insert(isolate, *function, osr_offset,
// function->code(),
// kIsContextSpecializing);
return handle(function->code(), isolate);
}
......@@ -3913,7 +3905,7 @@ void Compiler::DisposeTurbofanCompilationJob(TurbofanCompilationJob* job,
}
// static
bool Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
void Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
Isolate* isolate) {
VMState<COMPILER> state(isolate);
OptimizedCompilationInfo* compilation_info = job->compilation_info();
......@@ -3961,7 +3953,7 @@ bool Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
function->set_code(*compilation_info->code(), kReleaseStore);
}
}
return CompilationJob::SUCCEEDED;
return;
}
}
......@@ -3973,11 +3965,10 @@ bool Compiler::FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
function->set_code(shared->GetCode(), kReleaseStore);
}
}
return CompilationJob::FAILED;
}
// static
bool Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
void Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
Isolate* isolate) {
#ifdef V8_ENABLE_MAGLEV
VMState<COMPILER> state(isolate);
......@@ -4007,10 +3998,6 @@ bool Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
RecordMaglevFunctionCompilation(isolate, job->function());
}
return status;
#else
return CompilationJob::SUCCEEDED;
#endif
}
......
......@@ -123,11 +123,11 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
bool restore_function_code);
// Finalize and install Turbofan code from a previously run job.
static bool FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
static void FinalizeTurbofanCompilationJob(TurbofanCompilationJob* job,
Isolate* isolate);
// Finalize and install Maglev code from a previously run job.
static bool FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
static void FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
Isolate* isolate);
// Give the compiler a chance to perform low-latency initialization tasks of
......
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