Commit 32634b57 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

Add target code kind to --trace-opt output

.. to distinguish between Maglev and Turbofan targets. Also move one
tracing function to tiering-manager. We may want to move all
--trace-opt code into one place in the future (it's currently split
between here and compiler.cc).

Bug: v8:7700
Change-Id: I9756460124b14fc3213296d083071f338421966a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3500612
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79332}
parent c2fa5fcc
...@@ -54,38 +54,6 @@ std::ostream& operator<<(std::ostream& os, OptimizationReason reason) { ...@@ -54,38 +54,6 @@ std::ostream& operator<<(std::ostream& os, OptimizationReason reason) {
return os << OptimizationReasonToString(reason); return os << OptimizationReasonToString(reason);
} }
namespace {
void TraceInOptimizationQueue(JSFunction function) {
if (FLAG_trace_opt_verbose) {
PrintF("[function ");
function.PrintName();
PrintF(" is already in optimization queue]\n");
}
}
void TraceHeuristicOptimizationDisallowed(JSFunction function) {
if (FLAG_trace_opt_verbose) {
PrintF("[function ");
function.PrintName();
PrintF(" has been marked manually for optimization]\n");
}
}
void TraceRecompile(JSFunction function, OptimizationReason reason,
CodeKind code_kind, Isolate* isolate) {
if (FLAG_trace_opt) {
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[marking ");
function.ShortPrint(scope.file());
PrintF(scope.file(), " for optimized recompilation, reason: %s",
OptimizationReasonToString(reason));
PrintF(scope.file(), "]\n");
}
}
} // namespace
class OptimizationDecision { class OptimizationDecision {
public: public:
static constexpr OptimizationDecision Maglev() { static constexpr OptimizationDecision Maglev() {
...@@ -128,10 +96,55 @@ class OptimizationDecision { ...@@ -128,10 +96,55 @@ class OptimizationDecision {
// Since we pass by value: // Since we pass by value:
STATIC_ASSERT(sizeof(OptimizationDecision) <= kInt32Size); STATIC_ASSERT(sizeof(OptimizationDecision) <= kInt32Size);
namespace {
void TraceInOptimizationQueue(JSFunction function) {
if (FLAG_trace_opt_verbose) {
PrintF("[not marking function ");
function.PrintName();
PrintF(" for optimization: already queued]\n");
}
}
void TraceHeuristicOptimizationDisallowed(JSFunction function) {
if (FLAG_trace_opt_verbose) {
PrintF("[not marking function ");
function.PrintName();
PrintF(
" for optimization: marked with "
"%%PrepareFunctionForOptimization for manual optimization]\n");
}
}
void TraceRecompile(Isolate* isolate, JSFunction function,
OptimizationDecision d) {
if (FLAG_trace_opt) {
CodeTracer::Scope scope(isolate->GetCodeTracer());
PrintF(scope.file(), "[marking ");
function.ShortPrint(scope.file());
PrintF(scope.file(), " for optimization to %s, %s, reason: %s",
CodeKindToString(d.code_kind), ToString(d.concurrency_mode),
OptimizationReasonToString(d.optimization_reason));
PrintF(scope.file(), "]\n");
}
}
} // namespace
void TraceManualRecompile(JSFunction function, CodeKind code_kind,
ConcurrencyMode concurrency_mode) {
if (FLAG_trace_opt) {
PrintF("[manually marking ");
function.ShortPrint();
PrintF(" for optimization to %s, %s]\n", CodeKindToString(code_kind),
ToString(concurrency_mode));
}
}
void TieringManager::Optimize(JSFunction function, CodeKind code_kind, void TieringManager::Optimize(JSFunction function, CodeKind code_kind,
OptimizationDecision d) { OptimizationDecision d) {
DCHECK(d.should_optimize()); DCHECK(d.should_optimize());
TraceRecompile(function, d.optimization_reason, code_kind, isolate_); TraceRecompile(isolate_, function, d);
function.MarkForOptimization(isolate_, d.code_kind, d.concurrency_mode); function.MarkForOptimization(isolate_, d.code_kind, d.concurrency_mode);
} }
......
...@@ -21,6 +21,9 @@ class OptimizationDecision; ...@@ -21,6 +21,9 @@ class OptimizationDecision;
enum class CodeKind : uint8_t; enum class CodeKind : uint8_t;
enum class OptimizationReason : uint8_t; enum class OptimizationReason : uint8_t;
void TraceManualRecompile(JSFunction function, CodeKind code_kind,
ConcurrencyMode concurrency_mode);
class TieringManager { class TieringManager {
public: public:
explicit TieringManager(Isolate* isolate) : isolate_(isolate) {} explicit TieringManager(Isolate* isolate) : isolate_(isolate) {}
......
...@@ -315,12 +315,6 @@ Object OptimizeFunctionOnNextCall(RuntimeArguments& args, Isolate* isolate) { ...@@ -315,12 +315,6 @@ Object OptimizeFunctionOnNextCall(RuntimeArguments& args, Isolate* isolate) {
concurrency_mode = ConcurrencyMode::kConcurrent; concurrency_mode = ConcurrencyMode::kConcurrent;
} }
} }
if (FLAG_trace_opt) {
PrintF("[manually marking ");
function->ShortPrint();
PrintF(" for %s %s optimization]\n", ToString(concurrency_mode),
CodeKindToString(kCodeKind));
}
// This function may not have been lazily compiled yet, even though its shared // This function may not have been lazily compiled yet, even though its shared
// function has. // function has.
...@@ -333,6 +327,7 @@ Object OptimizeFunctionOnNextCall(RuntimeArguments& args, Isolate* isolate) { ...@@ -333,6 +327,7 @@ Object OptimizeFunctionOnNextCall(RuntimeArguments& args, Isolate* isolate) {
function->set_code(codet); function->set_code(codet);
} }
TraceManualRecompile(*function, kCodeKind, concurrency_mode);
JSFunction::EnsureFeedbackVector(isolate, function, &is_compiled_scope); JSFunction::EnsureFeedbackVector(isolate, function, &is_compiled_scope);
function->MarkForOptimization(isolate, CodeKind::TURBOFAN, concurrency_mode); function->MarkForOptimization(isolate, CodeKind::TURBOFAN, concurrency_mode);
...@@ -457,13 +452,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeMaglevOnNextCall) { ...@@ -457,13 +452,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeMaglevOnNextCall) {
// TODO(v8:7700): Support concurrent compiles. // TODO(v8:7700): Support concurrent compiles.
const ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent; const ConcurrencyMode concurrency_mode = ConcurrencyMode::kNotConcurrent;
if (FLAG_trace_opt) { TraceManualRecompile(*function, kCodeKind, concurrency_mode);
PrintF("[manually marking ");
function->ShortPrint();
PrintF(" for %s %s optimization]\n", ToString(concurrency_mode),
CodeKindToString(kCodeKind));
}
JSFunction::EnsureFeedbackVector(isolate, function, &is_compiled_scope); JSFunction::EnsureFeedbackVector(isolate, function, &is_compiled_scope);
function->MarkForOptimization(isolate, kCodeKind, concurrency_mode); function->MarkForOptimization(isolate, kCodeKind, concurrency_mode);
......
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