Commit 4b712b30 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[sparkplug] Add a bit for de-duplicating concurrent compiles

Concurrent sparkplug adds functions to batches and sends those batches
off for compilation, but doesn't note what functions are currently
compiling. This means that we can spawn multiple compilation jobs for a
function, most of which will be throw away.

Add a bit to SharedFunctionInfo to note whether concurrent compilation
has been started for it.

Change-Id: Ifa442481611044713b2893488387e97f071e408a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3702336
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81116}
parent e37ec406
......@@ -39,6 +39,7 @@ class BaselineCompilerTask {
: shared_function_info_(handles->NewHandle(sfi)),
bytecode_(handles->NewHandle(sfi.GetBytecodeArray(isolate))) {
DCHECK(sfi.is_compiled());
shared_function_info_->set_is_sparkplug_compiling(true);
}
BaselineCompilerTask(const BaselineCompilerTask&) V8_NOEXCEPT = delete;
......@@ -61,6 +62,7 @@ class BaselineCompilerTask {
// Executed in the main thread.
void Install(Isolate* isolate) {
shared_function_info_->set_is_sparkplug_compiling(false);
Handle<Code> code;
if (!maybe_code_.ToHandle(&code)) return;
if (FLAG_print_code) {
......@@ -257,6 +259,8 @@ void BaselineBatchCompiler::EnqueueFunction(Handle<JSFunction> function) {
// Early return if the function is compiled with baseline already or it is not
// suitable for baseline compilation.
if (shared->HasBaselineCode()) return;
// If we're already compiling this function, return.
if (shared->is_sparkplug_compiling()) return;
if (!CanCompileWithBaseline(isolate_, *shared)) return;
// Immediately compile the function if batch compilation is disabled.
......
......@@ -261,6 +261,9 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2,
has_static_private_methods_or_accessors,
SharedFunctionInfo::HasStaticPrivateMethodsOrAccessorsBit)
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, is_sparkplug_compiling,
SharedFunctionInfo::IsSparkplugCompilingBit)
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, maglev_compilation_failed,
SharedFunctionInfo::MaglevCompilationFailedBit)
......
......@@ -445,6 +445,7 @@ class SharedFunctionInfo
DECL_BOOLEAN_ACCESSORS(class_scope_has_private_brand)
DECL_BOOLEAN_ACCESSORS(has_static_private_methods_or_accessors)
DECL_BOOLEAN_ACCESSORS(is_sparkplug_compiling)
DECL_BOOLEAN_ACCESSORS(maglev_compilation_failed)
// Is this function a top-level function (scripts, evals).
......
......@@ -42,6 +42,7 @@ bitfield struct SharedFunctionInfoFlags extends uint32 {
bitfield struct SharedFunctionInfoFlags2 extends uint8 {
class_scope_has_private_brand: bool: 1 bit;
has_static_private_methods_or_accessors: bool: 1 bit;
is_sparkplug_compiling: bool: 1 bit;
maglev_compilation_failed: bool: 1 bit;
}
......
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