Commit c7bad606 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Add --sparkplug-filter

Allow filtering what functions compile with Sparkplug.

Bug: v8:11420
Change-Id: Ib70c4405687ec527109f2adbf87b58a51aae9870
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2700671
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72823}
parent 564361d8
......@@ -636,15 +636,39 @@ void UpdateSharedFunctionFlagsAfterCompilation(FunctionLiteral* literal,
shared_info.SetScopeInfo(*literal->scope()->scope_info());
}
bool CanCompileWithBaseline(Isolate* isolate,
Handle<SharedFunctionInfo> shared) {
// Check if we actually have bytecode.
if (!shared->HasBytecodeArray()) return false;
// Do not optimize when debugger needs to hook into every call.
if (isolate->debug()->needs_check_on_function_call()) return false;
// Functions with breakpoints have to stay interpreted.
if (shared->HasBreakInfo()) return false;
// Do not baseline compile if sparkplug is disabled or function doesn't pass
// sparkplug_filter.
if (!FLAG_sparkplug || !shared->PassesFilter(FLAG_sparkplug_filter)) {
return false;
}
return true;
}
bool CompileSharedWithBaseline(Isolate* isolate,
Handle<SharedFunctionInfo> shared,
Compiler::ClearExceptionFlag flag,
IsCompiledScope* is_compiled_scope) {
DCHECK(FLAG_sparkplug);
// We shouldn't be passing uncompiled functions into this function.
DCHECK(is_compiled_scope->is_compiled());
// Early return for already baseline-compiled functions.
if (shared->HasBaselineData()) return true;
// Check if we actually can compile with baseline.
if (!CanCompileWithBaseline(isolate, shared)) return false;
StackLimitCheck check(isolate);
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
if (flag == Compiler::KEEP_EXCEPTION) {
......@@ -653,15 +677,6 @@ bool CompileSharedWithBaseline(Isolate* isolate,
return false;
}
// Check if we actually have bytecode.
if (!shared->HasBytecodeArray()) return false;
// Do not optimize when debugger needs to hook into every call.
if (isolate->debug()->needs_check_on_function_call()) return false;
// Functions with breakpoints have to stay interpreted.
if (shared->HasBreakInfo()) return false;
CompilerTracer::TraceStartBaselineCompile(isolate, shared);
Handle<Code> code;
base::TimeDelta time_taken;
......@@ -1934,10 +1949,7 @@ bool Compiler::Compile(Isolate* isolate, Handle<JSFunction> function,
JSFunction::InitializeFeedbackCell(function, is_compiled_scope, true);
// If --always-sparkplug is enabled, make sure we have baseline code.
// TODO(v8:11429): Extract out the rest of the if into a "can baseline
// compile" predicate, or similar.
if (FLAG_always_sparkplug && !function->shared().HasAsmWasmData() &&
!function->shared().HasDebugInfo()) {
if (FLAG_always_sparkplug && CanCompileWithBaseline(isolate, shared_info)) {
DCHECK(shared_info->HasBaselineData());
}
......
......@@ -582,8 +582,9 @@ DEFINE_INT(ticks_scale_factor_for_top_tier, 10,
"scale factor for profiler ticks when tiering up from midtier")
// Flags for Sparkplug
DEFINE_BOOL(sparkplug, false, "enable experimental sparkplug baseline compiler")
DEFINE_BOOL(always_sparkplug, false, "directly tier up to sparkplug")
DEFINE_BOOL(sparkplug, false, "enable experimental Sparkplug baseline compiler")
DEFINE_STRING(sparkplug_filter, "*", "filter for Sparkplug baseline compiler")
DEFINE_BOOL(always_sparkplug, false, "directly tier up to Sparkplug code")
DEFINE_BOOL(trace_baseline, false, "trace baseline compilation")
DEFINE_NEG_IMPLICATION(sparkplug, write_protect_code_memory)
DEFINE_IMPLICATION(always_sparkplug, sparkplug)
......
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