Commit 6cf84e9a authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Allow --always-sparkplug to fail

Do --always-sparkplug compilations in a separate function, and
allow that function to return false if a sparkplug compilation
fails. Similarly, don't assert that --always-sparkplug requires
a function to have baseline code, in case a previous sparkplug
compilation failed.

Fixed: chromium:1185735, chromium:1185739
Change-Id: I363fcf271395afa2ec47228fff7a28a76c157f0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2744735
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73292}
parent 8378a1be
......@@ -1350,10 +1350,6 @@ void FinalizeUnoptimizedCompilation(
if (FLAG_interpreted_frames_native_stack) {
InstallInterpreterTrampolineCopy(isolate, shared_info, log_tag);
}
if (FLAG_always_sparkplug) {
CompileSharedWithBaseline(isolate, shared_info, Compiler::KEEP_EXCEPTION,
&is_compiled_scope);
}
Handle<CoverageInfo> coverage_info;
if (finalize_data.coverage_info().ToHandle(&coverage_info)) {
isolate->debug()->InstallCoverageInfo(shared_info, coverage_info);
......@@ -1400,6 +1396,22 @@ void FinalizeUnoptimizedScriptCompilation(
}
}
bool CompileAllWithBaseline(Isolate* isolate,
const FinalizeUnoptimizedCompilationDataList&
finalize_unoptimized_compilation_data_list,
Compiler::ClearExceptionFlag flag) {
for (const auto& finalize_data : finalize_unoptimized_compilation_data_list) {
Handle<SharedFunctionInfo> shared_info = finalize_data.function_handle();
IsCompiledScope is_compiled_scope(*shared_info, isolate);
if (!is_compiled_scope.is_compiled()) continue;
if (!CompileSharedWithBaseline(isolate, shared_info, flag,
&is_compiled_scope)) {
return false;
}
}
return true;
}
// Create shared function info for top level and shared function infos array for
// inner functions.
template <typename LocalIsolate>
......@@ -1468,6 +1480,16 @@ MaybeHandle<SharedFunctionInfo> CompileToplevel(
FinalizeUnoptimizedScriptCompilation(
isolate, script, parse_info->flags(), parse_info->state(),
finalize_unoptimized_compilation_data_list);
if (FLAG_always_sparkplug &&
!CompileAllWithBaseline(isolate,
finalize_unoptimized_compilation_data_list,
Compiler::ClearExceptionFlag::KEEP_EXCEPTION)) {
FailWithPendingException(isolate, script, parse_info,
Compiler::ClearExceptionFlag::KEEP_EXCEPTION);
return MaybeHandle<SharedFunctionInfo>();
}
return shared_info;
}
......@@ -1925,6 +1947,12 @@ bool Compiler::Compile(Isolate* isolate, Handle<SharedFunctionInfo> shared_info,
FinalizeUnoptimizedCompilation(isolate, script, flags, &compile_state,
finalize_unoptimized_compilation_data_list);
if (FLAG_always_sparkplug &&
!CompileAllWithBaseline(
isolate, finalize_unoptimized_compilation_data_list, flag)) {
return FailWithPendingException(isolate, script, &parse_info, flag);
}
DCHECK(!isolate->has_pending_exception());
DCHECK(is_compiled_scope->is_compiled());
return true;
......@@ -1964,11 +1992,6 @@ bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function,
// immediately after a flush would be better.
JSFunction::InitializeFeedbackCell(function, is_compiled_scope, true);
// If --always-sparkplug is enabled, make sure we have baseline code.
if (FLAG_always_sparkplug && CanCompileWithBaseline(isolate, shared_info)) {
DCHECK(shared_info->HasBaselineData());
}
// Optimize now if --always-opt is enabled.
if (FLAG_always_opt && !function->shared().HasAsmWasmData()) {
CompilerTracer::TraceOptimizeForAlwaysOpt(isolate, function,
......
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