Commit 8ed59cfb authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Drop compilation result if function has TF code

Check the function for TF code before finalizing a maglev compilation,
so that we don't accidentally overwrite the higher tier.

Bug: v8:7700
Change-Id: I20eb4e25f3bf2710b6e65f9d866cad143e77943d
Fixed: chromium:1359114
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3870464Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82929}
parent 09aded54
......@@ -104,6 +104,7 @@ namespace internal {
V(kLiveEdit, "LiveEdit") \
V(kNativeFunctionLiteral, "Native function literal") \
V(kOptimizationDisabled, "Optimization disabled") \
V(kHigherTierAvailable, "A higher tier is already available") \
V(kNeverOptimize, "Optimization is always disabled")
#define ERROR_MESSAGES_CONSTANTS(C, T) C,
......
......@@ -211,6 +211,16 @@ class CompilerTracer : public AllStatic {
PrintTraceSuffix(scope);
}
static void TraceAbortedMaglevCompile(Isolate* isolate,
Handle<JSFunction> function,
BailoutReason bailout_reason) {
if (!FLAG_trace_opt) return;
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintTracePrefix(scope, "aborted compiling", function, CodeKind::MAGLEV);
PrintF(scope.file(), " because: %s", GetBailoutReason(bailout_reason));
PrintTraceSuffix(scope);
}
static void TraceCompletedJob(Isolate* isolate,
OptimizedCompilationInfo* info) {
if (!FLAG_trace_opt) return;
......@@ -3994,24 +4004,30 @@ void Compiler::FinalizeMaglevCompilationJob(maglev::MaglevCompilationJob* job,
#ifdef V8_ENABLE_MAGLEV
VMState<COMPILER> state(isolate);
Handle<JSFunction> function = job->function();
if (function->ActiveTierIsTurbofan()) {
CompilerTracer::TraceAbortedMaglevCompile(
isolate, function, BailoutReason::kHigherTierAvailable);
return;
}
const CompilationJob::Status status = job->FinalizeJob(isolate);
// TODO(v8:7700): Use the result and check if job succeed
// when all the bytecodes are implemented.
USE(status);
Handle<JSFunction> function = job->function();
static constexpr BytecodeOffset osr_offset = BytecodeOffset::None();
ResetTieringState(*function, osr_offset);
if (status == CompilationJob::SUCCEEDED) {
// Note the finalized Code object has already been installed on the
// function by MaglevCompilationJob::FinalizeJobImpl.
const bool kIsContextSpecializing = false;
OptimizedCodeCache::Insert(isolate, *function, BytecodeOffset::None(),
function->code(), kIsContextSpecializing);
// Note the finalized Code object has already been installed on the
// function by MaglevCompilationJob::FinalizeJobImpl.
// Reset ticks just after installation since ticks accumulated in lower
// tiers use a different (lower) budget than ticks collected in Maglev
// code.
......
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