Commit 35f774c7 authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[sparkplug] Add a flag making sparkplug depend on short builtin calls

In case we find that Sparkplug benefits require short builtin calls, add
a --sparkplug-needs-short-builtins flag to make the former depend on the
latter.

Change-Id: I5b23abbd9ad6e0d11d7033497d5755f08c2ab876
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2988753
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75392}
parent ee307c74
...@@ -41,7 +41,7 @@ bool BaselineBatchCompiler::EnqueueFunction(Handle<JSFunction> function) { ...@@ -41,7 +41,7 @@ bool BaselineBatchCompiler::EnqueueFunction(Handle<JSFunction> function) {
// Early return if the function is compiled with baseline already or it is not // Early return if the function is compiled with baseline already or it is not
// suitable for baseline compilation. // suitable for baseline compilation.
if (shared->HasBaselineData()) return true; if (shared->HasBaselineData()) return true;
if (!CanCompileWithBaseline(isolate_, shared)) return false; if (!CanCompileWithBaseline(isolate_, *shared)) return false;
// Immediately compile the function if batch compilation is disabled. // Immediately compile the function if batch compilation is disabled.
if (!is_enabled()) { if (!is_enabled()) {
......
...@@ -23,22 +23,29 @@ ...@@ -23,22 +23,29 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
bool CanCompileWithBaseline(Isolate* isolate, bool CanCompileWithBaseline(Isolate* isolate, SharedFunctionInfo shared) {
Handle<SharedFunctionInfo> shared) { DisallowGarbageCollection no_gc;
// Check that baseline compiler is enabled. // Check that baseline compiler is enabled.
if (!FLAG_sparkplug) return false; if (!FLAG_sparkplug) return false;
// Check that short builtin calls are enabled if needed.
if (FLAG_sparkplug_needs_short_builtins &&
!isolate->is_short_builtin_calls_enabled()) {
return false;
}
// Check if we actually have bytecode. // Check if we actually have bytecode.
if (!shared->HasBytecodeArray()) return false; if (!shared.HasBytecodeArray()) return false;
// Do not optimize when debugger needs to hook into every call. // Do not optimize when debugger needs to hook into every call.
if (isolate->debug()->needs_check_on_function_call()) return false; if (isolate->debug()->needs_check_on_function_call()) return false;
// Functions with breakpoints have to stay interpreted. // Functions with breakpoints have to stay interpreted.
if (shared->HasBreakInfo()) return false; if (shared.HasBreakInfo()) return false;
// Do not baseline compile if function doesn't pass sparkplug_filter. // Do not baseline compile if function doesn't pass sparkplug_filter.
if (!shared->PassesFilter(FLAG_sparkplug_filter)) return false; if (!shared.PassesFilter(FLAG_sparkplug_filter)) return false;
return true; return true;
} }
...@@ -89,8 +96,7 @@ void EmitReturnBaseline(MacroAssembler* masm) { ...@@ -89,8 +96,7 @@ void EmitReturnBaseline(MacroAssembler* masm) {
namespace v8 { namespace v8 {
namespace internal { namespace internal {
bool CanCompileWithBaseline(Isolate* isolate, bool CanCompileWithBaseline(Isolate* isolate, SharedFunctionInfo shared) {
Handle<SharedFunctionInfo> shared) {
return false; return false;
} }
......
...@@ -14,8 +14,7 @@ class Code; ...@@ -14,8 +14,7 @@ class Code;
class SharedFunctionInfo; class SharedFunctionInfo;
class MacroAssembler; class MacroAssembler;
bool CanCompileWithBaseline(Isolate* isolate, bool CanCompileWithBaseline(Isolate* isolate, SharedFunctionInfo shared);
Handle<SharedFunctionInfo> shared);
MaybeHandle<Code> GenerateBaselineCode(Isolate* isolate, MaybeHandle<Code> GenerateBaselineCode(Isolate* isolate,
Handle<SharedFunctionInfo> shared); Handle<SharedFunctionInfo> shared);
......
...@@ -1311,7 +1311,7 @@ void CompileAllWithBaseline(Isolate* isolate, ...@@ -1311,7 +1311,7 @@ void CompileAllWithBaseline(Isolate* isolate,
Handle<SharedFunctionInfo> shared_info = finalize_data.function_handle(); Handle<SharedFunctionInfo> shared_info = finalize_data.function_handle();
IsCompiledScope is_compiled_scope(*shared_info, isolate); IsCompiledScope is_compiled_scope(*shared_info, isolate);
if (!is_compiled_scope.is_compiled()) continue; if (!is_compiled_scope.is_compiled()) continue;
if (!CanCompileWithBaseline(isolate, shared_info)) continue; if (!CanCompileWithBaseline(isolate, *shared_info)) continue;
Compiler::CompileSharedWithBaseline( Compiler::CompileSharedWithBaseline(
isolate, shared_info, Compiler::CLEAR_EXCEPTION, &is_compiled_scope); isolate, shared_info, Compiler::CLEAR_EXCEPTION, &is_compiled_scope);
} }
...@@ -1941,7 +1941,7 @@ bool Compiler::CompileSharedWithBaseline(Isolate* isolate, ...@@ -1941,7 +1941,7 @@ bool Compiler::CompileSharedWithBaseline(Isolate* isolate,
if (shared->HasBaselineData()) return true; if (shared->HasBaselineData()) return true;
// Check if we actually can compile with baseline. // Check if we actually can compile with baseline.
if (!CanCompileWithBaseline(isolate, shared)) return false; if (!CanCompileWithBaseline(isolate, *shared)) return false;
StackLimitCheck check(isolate); StackLimitCheck check(isolate);
if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) { if (check.JsHasOverflowed(kStackSpaceRequiredForCompilation * KB)) {
......
...@@ -668,6 +668,9 @@ DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code") ...@@ -668,6 +668,9 @@ DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code")
DEFINE_BOOL(baseline_batch_compilation, false, "batch compile Sparkplug code") DEFINE_BOOL(baseline_batch_compilation, false, "batch compile Sparkplug code")
#endif #endif
DEFINE_STRING(sparkplug_filter, "*", "filter for Sparkplug baseline compiler") DEFINE_STRING(sparkplug_filter, "*", "filter for Sparkplug baseline compiler")
DEFINE_BOOL(sparkplug_needs_short_builtins, false,
"only enable Sparkplug baseline compiler when "
"--short-builtin-calls are also enabled")
DEFINE_INT(baseline_batch_compilation_threshold, 4 * KB, DEFINE_INT(baseline_batch_compilation_threshold, 4 * KB,
"the estimated instruction size of a batch to trigger compilation") "the estimated instruction size of a batch to trigger compilation")
DEFINE_BOOL(trace_baseline, false, "trace baseline compilation") DEFINE_BOOL(trace_baseline, false, "trace baseline compilation")
......
...@@ -345,7 +345,8 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromBytecode) { ...@@ -345,7 +345,8 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterruptFromBytecode) {
// a non zero invocation count so we can inline functions. // a non zero invocation count so we can inline functions.
function->feedback_vector().set_invocation_count(1); function->feedback_vector().set_invocation_count(1);
} }
if (FLAG_sparkplug && !function->ActiveTierIsBaseline()) { if (CanCompileWithBaseline(isolate, function->shared()) &&
!function->ActiveTierIsBaseline()) {
if (V8_LIKELY(FLAG_baseline_batch_compilation)) { if (V8_LIKELY(FLAG_baseline_batch_compilation)) {
isolate->baseline_batch_compiler()->EnqueueFunction(function); isolate->baseline_batch_compiler()->EnqueueFunction(function);
} else { } else {
......
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