Commit a38b010c authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[compiler] Add runtime stats for every pipeline phase

Each Pipeline phase now declares kRuntimeCallCounterId which is used to
record the runtime stats for the duration of the phase. As a result
some manually instantiated counters are removed.

All counters have the same name as the phase name with the v8.TF prefix
replaced with Optimize. To enforce this, the existing phase_name
declaration in each phase has been replaced with a macro that also
declares the counter id and its mode.

Bug: v8:10006
Change-Id: I836582298b60c30eb794f4c45a8bb16efa17a38e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1943161Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65289}
parent db2f0f0a
...@@ -863,10 +863,15 @@ void AddReducer(PipelineData* data, GraphReducer* graph_reducer, ...@@ -863,10 +863,15 @@ void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
class PipelineRunScope { class PipelineRunScope {
public: public:
PipelineRunScope(PipelineData* data, const char* phase_name) PipelineRunScope(
PipelineData* data, const char* phase_name,
RuntimeCallCounterId runtime_call_counter_id,
RuntimeCallStats::CounterMode counter_mode = RuntimeCallStats::kExact)
: phase_scope_(data->pipeline_statistics(), phase_name), : phase_scope_(data->pipeline_statistics(), phase_name),
zone_scope_(data->zone_stats(), phase_name), zone_scope_(data->zone_stats(), phase_name),
origin_scope_(data->node_origins(), phase_name) { origin_scope_(data->node_origins(), phase_name),
runtime_call_timer_scope(data->runtime_call_stats(),
runtime_call_counter_id, counter_mode) {
DCHECK_NOT_NULL(phase_name); DCHECK_NOT_NULL(phase_name);
} }
...@@ -876,6 +881,7 @@ class PipelineRunScope { ...@@ -876,6 +881,7 @@ class PipelineRunScope {
PhaseScope phase_scope_; PhaseScope phase_scope_;
ZoneStats::Scope zone_scope_; ZoneStats::Scope zone_scope_;
NodeOriginTable::PhaseScope origin_scope_; NodeOriginTable::PhaseScope origin_scope_;
RuntimeCallTimerScope runtime_call_timer_scope;
}; };
PipelineStatistics* CreatePipelineStatistics(Handle<Script> script, PipelineStatistics* CreatePipelineStatistics(Handle<Script> script,
...@@ -1278,13 +1284,26 @@ CompilationJob::Status WasmHeapStubCompilationJob::FinalizeJobImpl( ...@@ -1278,13 +1284,26 @@ CompilationJob::Status WasmHeapStubCompilationJob::FinalizeJobImpl(
template <typename Phase, typename... Args> template <typename Phase, typename... Args>
void PipelineImpl::Run(Args&&... args) { void PipelineImpl::Run(Args&&... args) {
PipelineRunScope scope(this->data_, Phase::phase_name()); PipelineRunScope scope(this->data_, Phase::phase_name(),
Phase::kRuntimeCallCounterId, Phase::kCounterMode);
Phase phase; Phase phase;
phase.Run(this->data_, scope.zone(), std::forward<Args>(args)...); phase.Run(this->data_, scope.zone(), std::forward<Args>(args)...);
} }
#define DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, Mode) \
static const char* phase_name() { return "V8.TF" #Name; } \
static constexpr RuntimeCallCounterId kRuntimeCallCounterId = \
RuntimeCallCounterId::kOptimize##Name; \
static constexpr RuntimeCallStats::CounterMode kCounterMode = Mode;
#define DECL_PIPELINE_PHASE_CONSTANTS(Name) \
DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, RuntimeCallStats::kThreadSpecific)
#define DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(Name) \
DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, RuntimeCallStats::kExact)
struct GraphBuilderPhase { struct GraphBuilderPhase {
static const char* phase_name() { return "V8.TFBytecodeGraphBuilder"; } DECL_PIPELINE_PHASE_CONSTANTS(BytecodeGraphBuilder)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
BytecodeGraphBuilderFlags flags; BytecodeGraphBuilderFlags flags;
...@@ -1306,7 +1325,7 @@ struct GraphBuilderPhase { ...@@ -1306,7 +1325,7 @@ struct GraphBuilderPhase {
}; };
struct InliningPhase { struct InliningPhase {
static const char* phase_name() { return "V8.TFInlining"; } DECL_PIPELINE_PHASE_CONSTANTS(Inlining)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
OptimizedCompilationInfo* info = data->info(); OptimizedCompilationInfo* info = data->info();
...@@ -1362,7 +1381,7 @@ struct InliningPhase { ...@@ -1362,7 +1381,7 @@ struct InliningPhase {
struct TyperPhase { struct TyperPhase {
static const char* phase_name() { return "V8.TFTyper"; } DECL_PIPELINE_PHASE_CONSTANTS(Typer)
void Run(PipelineData* data, Zone* temp_zone, Typer* typer) { void Run(PipelineData* data, Zone* temp_zone, Typer* typer) {
NodeVector roots(temp_zone); NodeVector roots(temp_zone);
...@@ -1380,7 +1399,7 @@ struct TyperPhase { ...@@ -1380,7 +1399,7 @@ struct TyperPhase {
}; };
struct UntyperPhase { struct UntyperPhase {
static const char* phase_name() { return "V8.TFUntyper"; } DECL_PIPELINE_PHASE_CONSTANTS(Untyper)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
class RemoveTypeReducer final : public Reducer { class RemoveTypeReducer final : public Reducer {
...@@ -1411,22 +1430,17 @@ struct UntyperPhase { ...@@ -1411,22 +1430,17 @@ struct UntyperPhase {
}; };
struct HeapBrokerInitializationPhase { struct HeapBrokerInitializationPhase {
static const char* phase_name() { return "V8.TFHeapBrokerInitialization"; } DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(HeapBrokerInitialization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
RuntimeCallTimerScope runtimeTimer(
data->isolate(),
RuntimeCallCounterId::kOptimizeHeapBrokerInitialization);
data->broker()->InitializeAndStartSerializing(data->native_context()); data->broker()->InitializeAndStartSerializing(data->native_context());
} }
}; };
struct CopyMetadataForConcurrentCompilePhase { struct CopyMetadataForConcurrentCompilePhase {
static const char* phase_name() { return "V8.TFSerializeMetadata"; } DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(SerializeMetadata)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
RuntimeCallTimerScope runtimeTimer(
data->isolate(), RuntimeCallCounterId::kOptimizeSerializeMetadata);
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
&data->info()->tick_counter(), &data->info()->tick_counter(),
data->jsgraph()->Dead()); data->jsgraph()->Dead());
...@@ -1442,11 +1456,9 @@ struct CopyMetadataForConcurrentCompilePhase { ...@@ -1442,11 +1456,9 @@ struct CopyMetadataForConcurrentCompilePhase {
}; };
struct SerializationPhase { struct SerializationPhase {
static const char* phase_name() { return "V8.TFSerialization"; } DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(Serialization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
RuntimeCallTimerScope runtimeTimer(
data->isolate(), RuntimeCallCounterId::kOptimizeSerialize);
SerializerForBackgroundCompilationFlags flags; SerializerForBackgroundCompilationFlags flags;
if (data->info()->is_bailout_on_uninitialized()) { if (data->info()->is_bailout_on_uninitialized()) {
flags |= SerializerForBackgroundCompilationFlag::kBailoutOnUninitialized; flags |= SerializerForBackgroundCompilationFlag::kBailoutOnUninitialized;
...@@ -1472,7 +1484,7 @@ struct SerializationPhase { ...@@ -1472,7 +1484,7 @@ struct SerializationPhase {
}; };
struct TypedLoweringPhase { struct TypedLoweringPhase {
static const char* phase_name() { return "V8.TFTypedLowering"; } DECL_PIPELINE_PHASE_CONSTANTS(TypedLowering)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1509,7 +1521,7 @@ struct TypedLoweringPhase { ...@@ -1509,7 +1521,7 @@ struct TypedLoweringPhase {
struct EscapeAnalysisPhase { struct EscapeAnalysisPhase {
static const char* phase_name() { return "V8.TFEscapeAnalysis"; } DECL_PIPELINE_PHASE_CONSTANTS(EscapeAnalysis)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
EscapeAnalysis escape_analysis(data->jsgraph(), EscapeAnalysis escape_analysis(data->jsgraph(),
...@@ -1529,7 +1541,7 @@ struct EscapeAnalysisPhase { ...@@ -1529,7 +1541,7 @@ struct EscapeAnalysisPhase {
}; };
struct TypeAssertionsPhase { struct TypeAssertionsPhase {
static const char* phase_name() { return "V8.TFTypeAssertions"; } DECL_PIPELINE_PHASE_CONSTANTS(TypeAssertions)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1543,7 +1555,7 @@ struct TypeAssertionsPhase { ...@@ -1543,7 +1555,7 @@ struct TypeAssertionsPhase {
}; };
struct SimplifiedLoweringPhase { struct SimplifiedLoweringPhase {
static const char* phase_name() { return "V8.TFSimplifiedLowering"; } DECL_PIPELINE_PHASE_CONSTANTS(SimplifiedLowering)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SimplifiedLowering lowering(data->jsgraph(), data->broker(), temp_zone, SimplifiedLowering lowering(data->jsgraph(), data->broker(), temp_zone,
...@@ -1555,7 +1567,7 @@ struct SimplifiedLoweringPhase { ...@@ -1555,7 +1567,7 @@ struct SimplifiedLoweringPhase {
}; };
struct LoopPeelingPhase { struct LoopPeelingPhase {
static const char* phase_name() { return "V8.TFLoopPeeling"; } DECL_PIPELINE_PHASE_CONSTANTS(LoopPeeling)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphTrimmer trimmer(temp_zone, data->graph()); GraphTrimmer trimmer(temp_zone, data->graph());
...@@ -1572,7 +1584,7 @@ struct LoopPeelingPhase { ...@@ -1572,7 +1584,7 @@ struct LoopPeelingPhase {
}; };
struct LoopExitEliminationPhase { struct LoopExitEliminationPhase {
static const char* phase_name() { return "V8.TFLoopExitElimination"; } DECL_PIPELINE_PHASE_CONSTANTS(LoopExitElimination)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
LoopPeeler::EliminateLoopExits(data->graph(), temp_zone); LoopPeeler::EliminateLoopExits(data->graph(), temp_zone);
...@@ -1580,7 +1592,7 @@ struct LoopExitEliminationPhase { ...@@ -1580,7 +1592,7 @@ struct LoopExitEliminationPhase {
}; };
struct GenericLoweringPhase { struct GenericLoweringPhase {
static const char* phase_name() { return "V8.TFGenericLowering"; } DECL_PIPELINE_PHASE_CONSTANTS(GenericLowering)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1594,7 +1606,7 @@ struct GenericLoweringPhase { ...@@ -1594,7 +1606,7 @@ struct GenericLoweringPhase {
}; };
struct EarlyOptimizationPhase { struct EarlyOptimizationPhase {
static const char* phase_name() { return "V8.TFEarlyOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(EarlyOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1621,7 +1633,7 @@ struct EarlyOptimizationPhase { ...@@ -1621,7 +1633,7 @@ struct EarlyOptimizationPhase {
}; };
struct ControlFlowOptimizationPhase { struct ControlFlowOptimizationPhase {
static const char* phase_name() { return "V8.TFControlFlowOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(ControlFlowOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
ControlFlowOptimizer optimizer(data->graph(), data->common(), ControlFlowOptimizer optimizer(data->graph(), data->common(),
...@@ -1632,7 +1644,7 @@ struct ControlFlowOptimizationPhase { ...@@ -1632,7 +1644,7 @@ struct ControlFlowOptimizationPhase {
}; };
struct EffectControlLinearizationPhase { struct EffectControlLinearizationPhase {
static const char* phase_name() { return "V8.TFEffectLinearization"; } DECL_PIPELINE_PHASE_CONSTANTS(EffectLinearization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
{ {
...@@ -1690,7 +1702,7 @@ struct EffectControlLinearizationPhase { ...@@ -1690,7 +1702,7 @@ struct EffectControlLinearizationPhase {
}; };
struct StoreStoreEliminationPhase { struct StoreStoreEliminationPhase {
static const char* phase_name() { return "V8.TFStoreStoreElimination"; } DECL_PIPELINE_PHASE_CONSTANTS(StoreStoreElimination)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphTrimmer trimmer(temp_zone, data->graph()); GraphTrimmer trimmer(temp_zone, data->graph());
...@@ -1704,7 +1716,7 @@ struct StoreStoreEliminationPhase { ...@@ -1704,7 +1716,7 @@ struct StoreStoreEliminationPhase {
}; };
struct LoadEliminationPhase { struct LoadEliminationPhase {
static const char* phase_name() { return "V8.TFLoadElimination"; } DECL_PIPELINE_PHASE_CONSTANTS(LoadElimination)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1744,7 +1756,7 @@ struct LoadEliminationPhase { ...@@ -1744,7 +1756,7 @@ struct LoadEliminationPhase {
}; };
struct MemoryOptimizationPhase { struct MemoryOptimizationPhase {
static const char* phase_name() { return "V8.TFMemoryOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(MemoryOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
// The memory optimizer requires the graphs to be trimmed, so trim now. // The memory optimizer requires the graphs to be trimmed, so trim now.
...@@ -1765,7 +1777,7 @@ struct MemoryOptimizationPhase { ...@@ -1765,7 +1777,7 @@ struct MemoryOptimizationPhase {
}; };
struct LateOptimizationPhase { struct LateOptimizationPhase {
static const char* phase_name() { return "V8.TFLateOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(LateOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1793,7 +1805,7 @@ struct LateOptimizationPhase { ...@@ -1793,7 +1805,7 @@ struct LateOptimizationPhase {
}; };
struct MachineOperatorOptimizationPhase { struct MachineOperatorOptimizationPhase {
static const char* phase_name() { return "V8.TFMachineOperatorOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(MachineOperatorOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1809,7 +1821,7 @@ struct MachineOperatorOptimizationPhase { ...@@ -1809,7 +1821,7 @@ struct MachineOperatorOptimizationPhase {
}; };
struct DecompressionOptimizationPhase { struct DecompressionOptimizationPhase {
static const char* phase_name() { return "V8.TFDecompressionOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(DecompressionOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
if (COMPRESS_POINTERS_BOOL) { if (COMPRESS_POINTERS_BOOL) {
...@@ -1821,9 +1833,7 @@ struct DecompressionOptimizationPhase { ...@@ -1821,9 +1833,7 @@ struct DecompressionOptimizationPhase {
}; };
struct ScheduledEffectControlLinearizationPhase { struct ScheduledEffectControlLinearizationPhase {
static const char* phase_name() { DECL_PIPELINE_PHASE_CONSTANTS(ScheduledEffectControlLinearization)
return "V8.TFScheduledEffectControlLinearizationPhase";
}
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
MaskArrayIndexEnable mask_array_index = MaskArrayIndexEnable mask_array_index =
...@@ -1849,9 +1859,7 @@ struct ScheduledEffectControlLinearizationPhase { ...@@ -1849,9 +1859,7 @@ struct ScheduledEffectControlLinearizationPhase {
}; };
struct ScheduledMachineLoweringPhase { struct ScheduledMachineLoweringPhase {
static const char* phase_name() { DECL_PIPELINE_PHASE_CONSTANTS(ScheduledMachineLowering)
return "V8.TFScheduledMachineLoweringPhase";
}
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
ScheduledMachineLowering machine_lowering( ScheduledMachineLowering machine_lowering(
...@@ -1868,7 +1876,7 @@ struct ScheduledMachineLoweringPhase { ...@@ -1868,7 +1876,7 @@ struct ScheduledMachineLoweringPhase {
}; };
struct CsaEarlyOptimizationPhase { struct CsaEarlyOptimizationPhase {
static const char* phase_name() { return "V8.CSAEarlyOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(CSAEarlyOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1894,7 +1902,7 @@ struct CsaEarlyOptimizationPhase { ...@@ -1894,7 +1902,7 @@ struct CsaEarlyOptimizationPhase {
}; };
struct CsaOptimizationPhase { struct CsaOptimizationPhase {
static const char* phase_name() { return "V8.CSAOptimization"; } DECL_PIPELINE_PHASE_CONSTANTS(CSAOptimization)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphReducer graph_reducer(temp_zone, data->graph(), GraphReducer graph_reducer(temp_zone, data->graph(),
...@@ -1917,7 +1925,8 @@ struct CsaOptimizationPhase { ...@@ -1917,7 +1925,8 @@ struct CsaOptimizationPhase {
}; };
struct EarlyGraphTrimmingPhase { struct EarlyGraphTrimmingPhase {
static const char* phase_name() { return "V8.TFEarlyTrimming"; } DECL_PIPELINE_PHASE_CONSTANTS(EarlyTrimming)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphTrimmer trimmer(temp_zone, data->graph()); GraphTrimmer trimmer(temp_zone, data->graph());
NodeVector roots(temp_zone); NodeVector roots(temp_zone);
...@@ -1928,7 +1937,8 @@ struct EarlyGraphTrimmingPhase { ...@@ -1928,7 +1937,8 @@ struct EarlyGraphTrimmingPhase {
struct LateGraphTrimmingPhase { struct LateGraphTrimmingPhase {
static const char* phase_name() { return "V8.TFLateGraphTrimming"; } DECL_PIPELINE_PHASE_CONSTANTS(LateGraphTrimming)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
GraphTrimmer trimmer(temp_zone, data->graph()); GraphTrimmer trimmer(temp_zone, data->graph());
NodeVector roots(temp_zone); NodeVector roots(temp_zone);
...@@ -1941,7 +1951,7 @@ struct LateGraphTrimmingPhase { ...@@ -1941,7 +1951,7 @@ struct LateGraphTrimmingPhase {
struct ComputeSchedulePhase { struct ComputeSchedulePhase {
static const char* phase_name() { return "V8.TFScheduling"; } DECL_PIPELINE_PHASE_CONSTANTS(Scheduling)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
Schedule* schedule = Scheduler::ComputeSchedule( Schedule* schedule = Scheduler::ComputeSchedule(
...@@ -1986,7 +1996,7 @@ std::ostream& operator<<(std::ostream& out, const InstructionRangesAsJSON& s) { ...@@ -1986,7 +1996,7 @@ std::ostream& operator<<(std::ostream& out, const InstructionRangesAsJSON& s) {
} }
struct InstructionSelectionPhase { struct InstructionSelectionPhase {
static const char* phase_name() { return "V8.TFSelectInstructions"; } DECL_PIPELINE_PHASE_CONSTANTS(SelectInstructions)
void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) {
InstructionSelector selector( InstructionSelector selector(
...@@ -2027,8 +2037,7 @@ struct InstructionSelectionPhase { ...@@ -2027,8 +2037,7 @@ struct InstructionSelectionPhase {
struct MeetRegisterConstraintsPhase { struct MeetRegisterConstraintsPhase {
static const char* phase_name() { return "V8.TFMeetRegisterConstraints"; } DECL_PIPELINE_PHASE_CONSTANTS(MeetRegisterConstraints)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
ConstraintBuilder builder(data->register_allocation_data()); ConstraintBuilder builder(data->register_allocation_data());
builder.MeetRegisterConstraints(); builder.MeetRegisterConstraints();
...@@ -2037,7 +2046,7 @@ struct MeetRegisterConstraintsPhase { ...@@ -2037,7 +2046,7 @@ struct MeetRegisterConstraintsPhase {
struct ResolvePhisPhase { struct ResolvePhisPhase {
static const char* phase_name() { return "V8.TFResolvePhis"; } DECL_PIPELINE_PHASE_CONSTANTS(ResolvePhis)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
ConstraintBuilder builder(data->register_allocation_data()); ConstraintBuilder builder(data->register_allocation_data());
...@@ -2047,7 +2056,7 @@ struct ResolvePhisPhase { ...@@ -2047,7 +2056,7 @@ struct ResolvePhisPhase {
struct BuildLiveRangesPhase { struct BuildLiveRangesPhase {
static const char* phase_name() { return "V8.TFBuildLiveRanges"; } DECL_PIPELINE_PHASE_CONSTANTS(BuildLiveRanges)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
LiveRangeBuilder builder(data->register_allocation_data(), temp_zone); LiveRangeBuilder builder(data->register_allocation_data(), temp_zone);
...@@ -2056,7 +2065,7 @@ struct BuildLiveRangesPhase { ...@@ -2056,7 +2065,7 @@ struct BuildLiveRangesPhase {
}; };
struct BuildBundlesPhase { struct BuildBundlesPhase {
static const char* phase_name() { return "V8.TFBuildLiveRangeBundles"; } DECL_PIPELINE_PHASE_CONSTANTS(BuildLiveRangeBundles)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
BundleBuilder builder(data->register_allocation_data()); BundleBuilder builder(data->register_allocation_data());
...@@ -2065,7 +2074,7 @@ struct BuildBundlesPhase { ...@@ -2065,7 +2074,7 @@ struct BuildBundlesPhase {
}; };
struct SplinterLiveRangesPhase { struct SplinterLiveRangesPhase {
static const char* phase_name() { return "V8.TFSplinterLiveRanges"; } DECL_PIPELINE_PHASE_CONSTANTS(SplinterLiveRanges)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
LiveRangeSeparator live_range_splinterer(data->register_allocation_data(), LiveRangeSeparator live_range_splinterer(data->register_allocation_data(),
...@@ -2077,7 +2086,7 @@ struct SplinterLiveRangesPhase { ...@@ -2077,7 +2086,7 @@ struct SplinterLiveRangesPhase {
template <typename RegAllocator> template <typename RegAllocator>
struct AllocateGeneralRegistersPhase { struct AllocateGeneralRegistersPhase {
static const char* phase_name() { return "V8.TFAllocateGeneralRegisters"; } DECL_PIPELINE_PHASE_CONSTANTS(AllocateGeneralRegisters)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
RegAllocator allocator(data->register_allocation_data(), GENERAL_REGISTERS, RegAllocator allocator(data->register_allocation_data(), GENERAL_REGISTERS,
...@@ -2088,7 +2097,7 @@ struct AllocateGeneralRegistersPhase { ...@@ -2088,7 +2097,7 @@ struct AllocateGeneralRegistersPhase {
template <typename RegAllocator> template <typename RegAllocator>
struct AllocateFPRegistersPhase { struct AllocateFPRegistersPhase {
static const char* phase_name() { return "V8.TFAllocateFPRegisters"; } DECL_PIPELINE_PHASE_CONSTANTS(AllocateFPRegisters)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
RegAllocator allocator(data->register_allocation_data(), FP_REGISTERS, RegAllocator allocator(data->register_allocation_data(), FP_REGISTERS,
...@@ -2099,7 +2108,8 @@ struct AllocateFPRegistersPhase { ...@@ -2099,7 +2108,8 @@ struct AllocateFPRegistersPhase {
struct MergeSplintersPhase { struct MergeSplintersPhase {
static const char* phase_name() { return "V8.TFMergeSplinteredRanges"; } DECL_PIPELINE_PHASE_CONSTANTS(MergeSplinteredRanges)
void Run(PipelineData* pipeline_data, Zone* temp_zone) { void Run(PipelineData* pipeline_data, Zone* temp_zone) {
RegisterAllocationData* data = pipeline_data->register_allocation_data(); RegisterAllocationData* data = pipeline_data->register_allocation_data();
LiveRangeMerger live_range_merger(data, temp_zone); LiveRangeMerger live_range_merger(data, temp_zone);
...@@ -2109,7 +2119,7 @@ struct MergeSplintersPhase { ...@@ -2109,7 +2119,7 @@ struct MergeSplintersPhase {
struct LocateSpillSlotsPhase { struct LocateSpillSlotsPhase {
static const char* phase_name() { return "V8.TFLocateSpillSlots"; } DECL_PIPELINE_PHASE_CONSTANTS(LocateSpillSlots)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
SpillSlotLocator locator(data->register_allocation_data()); SpillSlotLocator locator(data->register_allocation_data());
...@@ -2118,7 +2128,7 @@ struct LocateSpillSlotsPhase { ...@@ -2118,7 +2128,7 @@ struct LocateSpillSlotsPhase {
}; };
struct DecideSpillingModePhase { struct DecideSpillingModePhase {
static const char* phase_name() { return "V8.TFDecideSpillingMode"; } DECL_PIPELINE_PHASE_CONSTANTS(DecideSpillingMode)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
OperandAssigner assigner(data->register_allocation_data()); OperandAssigner assigner(data->register_allocation_data());
...@@ -2127,7 +2137,7 @@ struct DecideSpillingModePhase { ...@@ -2127,7 +2137,7 @@ struct DecideSpillingModePhase {
}; };
struct AssignSpillSlotsPhase { struct AssignSpillSlotsPhase {
static const char* phase_name() { return "V8.TFAssignSpillSlots"; } DECL_PIPELINE_PHASE_CONSTANTS(AssignSpillSlots)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
OperandAssigner assigner(data->register_allocation_data()); OperandAssigner assigner(data->register_allocation_data());
...@@ -2137,7 +2147,7 @@ struct AssignSpillSlotsPhase { ...@@ -2137,7 +2147,7 @@ struct AssignSpillSlotsPhase {
struct CommitAssignmentPhase { struct CommitAssignmentPhase {
static const char* phase_name() { return "V8.TFCommitAssignment"; } DECL_PIPELINE_PHASE_CONSTANTS(CommitAssignment)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
OperandAssigner assigner(data->register_allocation_data()); OperandAssigner assigner(data->register_allocation_data());
...@@ -2147,7 +2157,7 @@ struct CommitAssignmentPhase { ...@@ -2147,7 +2157,7 @@ struct CommitAssignmentPhase {
struct PopulateReferenceMapsPhase { struct PopulateReferenceMapsPhase {
static const char* phase_name() { return "V8.TFPopulatePointerMaps"; } DECL_PIPELINE_PHASE_CONSTANTS(PopulatePointerMaps)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
ReferenceMapPopulator populator(data->register_allocation_data()); ReferenceMapPopulator populator(data->register_allocation_data());
...@@ -2157,7 +2167,7 @@ struct PopulateReferenceMapsPhase { ...@@ -2157,7 +2167,7 @@ struct PopulateReferenceMapsPhase {
struct ConnectRangesPhase { struct ConnectRangesPhase {
static const char* phase_name() { return "V8.TFConnectRanges"; } DECL_PIPELINE_PHASE_CONSTANTS(ConnectRanges)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
LiveRangeConnector connector(data->register_allocation_data()); LiveRangeConnector connector(data->register_allocation_data());
...@@ -2167,7 +2177,7 @@ struct ConnectRangesPhase { ...@@ -2167,7 +2177,7 @@ struct ConnectRangesPhase {
struct ResolveControlFlowPhase { struct ResolveControlFlowPhase {
static const char* phase_name() { return "V8.TFResolveControlFlow"; } DECL_PIPELINE_PHASE_CONSTANTS(ResolveControlFlow)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
LiveRangeConnector connector(data->register_allocation_data()); LiveRangeConnector connector(data->register_allocation_data());
...@@ -2177,7 +2187,7 @@ struct ResolveControlFlowPhase { ...@@ -2177,7 +2187,7 @@ struct ResolveControlFlowPhase {
struct OptimizeMovesPhase { struct OptimizeMovesPhase {
static const char* phase_name() { return "V8.TFOptimizeMoves"; } DECL_PIPELINE_PHASE_CONSTANTS(OptimizeMoves)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
MoveOptimizer move_optimizer(temp_zone, data->sequence()); MoveOptimizer move_optimizer(temp_zone, data->sequence());
...@@ -2187,7 +2197,7 @@ struct OptimizeMovesPhase { ...@@ -2187,7 +2197,7 @@ struct OptimizeMovesPhase {
struct FrameElisionPhase { struct FrameElisionPhase {
static const char* phase_name() { return "V8.TFFrameElision"; } DECL_PIPELINE_PHASE_CONSTANTS(FrameElision)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
FrameElider(data->sequence()).Run(); FrameElider(data->sequence()).Run();
...@@ -2196,7 +2206,7 @@ struct FrameElisionPhase { ...@@ -2196,7 +2206,7 @@ struct FrameElisionPhase {
struct JumpThreadingPhase { struct JumpThreadingPhase {
static const char* phase_name() { return "V8.TFJumpThreading"; } DECL_PIPELINE_PHASE_CONSTANTS(JumpThreading)
void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) {
ZoneVector<RpoNumber> result(temp_zone); ZoneVector<RpoNumber> result(temp_zone);
...@@ -2208,7 +2218,7 @@ struct JumpThreadingPhase { ...@@ -2208,7 +2218,7 @@ struct JumpThreadingPhase {
}; };
struct AssembleCodePhase { struct AssembleCodePhase {
static const char* phase_name() { return "V8.TFAssembleCode"; } DECL_PIPELINE_PHASE_CONSTANTS(AssembleCode)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
data->code_generator()->AssembleCode(); data->code_generator()->AssembleCode();
...@@ -2216,7 +2226,7 @@ struct AssembleCodePhase { ...@@ -2216,7 +2226,7 @@ struct AssembleCodePhase {
}; };
struct FinalizeCodePhase { struct FinalizeCodePhase {
static const char* phase_name() { return "V8.TFFinalizeCode"; } DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(FinalizeCode)
void Run(PipelineData* data, Zone* temp_zone) { void Run(PipelineData* data, Zone* temp_zone) {
data->set_code(data->code_generator()->FinalizeCode()); data->set_code(data->code_generator()->FinalizeCode());
...@@ -2225,7 +2235,7 @@ struct FinalizeCodePhase { ...@@ -2225,7 +2235,7 @@ struct FinalizeCodePhase {
struct PrintGraphPhase { struct PrintGraphPhase {
static const char* phase_name() { return "V8.TFPrintGraph"; } DECL_PIPELINE_PHASE_CONSTANTS(PrintGraph)
void Run(PipelineData* data, Zone* temp_zone, const char* phase) { void Run(PipelineData* data, Zone* temp_zone, const char* phase) {
OptimizedCompilationInfo* info = data->info(); OptimizedCompilationInfo* info = data->info();
...@@ -2266,7 +2276,7 @@ struct PrintGraphPhase { ...@@ -2266,7 +2276,7 @@ struct PrintGraphPhase {
struct VerifyGraphPhase { struct VerifyGraphPhase {
static const char* phase_name() { return "V8.TFVerifyGraph"; } DECL_PIPELINE_PHASE_CONSTANTS(VerifyGraph)
void Run(PipelineData* data, Zone* temp_zone, const bool untyped, void Run(PipelineData* data, Zone* temp_zone, const bool untyped,
bool values_only = false) { bool values_only = false) {
...@@ -2289,6 +2299,10 @@ struct VerifyGraphPhase { ...@@ -2289,6 +2299,10 @@ struct VerifyGraphPhase {
} }
}; };
#undef DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS
#undef DECL_PIPELINE_PHASE_CONSTANTS
#undef DECL_PIPELINE_PHASE_CONSTANTS_HELPER
void PipelineImpl::RunPrintAndVerify(const char* phase, bool untyped) { void PipelineImpl::RunPrintAndVerify(const char* phase, bool untyped) {
if (info()->trace_turbo_json_enabled() || if (info()->trace_turbo_json_enabled() ||
info()->trace_turbo_graph_enabled()) { info()->trace_turbo_graph_enabled()) {
...@@ -2866,7 +2880,8 @@ void Pipeline::GenerateCodeForWasmFunction( ...@@ -2866,7 +2880,8 @@ void Pipeline::GenerateCodeForWasmFunction(
data.info()->MarkAsSplittingEnabled(); data.info()->MarkAsSplittingEnabled();
} }
if (FLAG_wasm_opt || is_asm_js) { if (FLAG_wasm_opt || is_asm_js) {
PipelineRunScope scope(&data, "V8.WasmFullOptimization"); PipelineRunScope scope(&data, "V8.WasmFullOptimization",
RuntimeCallCounterId::kOptimizeWasmFullOptimization);
GraphReducer graph_reducer(scope.zone(), data.graph(), GraphReducer graph_reducer(scope.zone(), data.graph(),
&data.info()->tick_counter(), &data.info()->tick_counter(),
data.mcgraph()->Dead()); data.mcgraph()->Dead());
...@@ -2885,7 +2900,8 @@ void Pipeline::GenerateCodeForWasmFunction( ...@@ -2885,7 +2900,8 @@ void Pipeline::GenerateCodeForWasmFunction(
AddReducer(&data, &graph_reducer, &value_numbering); AddReducer(&data, &graph_reducer, &value_numbering);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
} else { } else {
PipelineRunScope scope(&data, "V8.WasmBaseOptimization"); PipelineRunScope scope(&data, "V8.OptimizeWasmBaseOptimization",
RuntimeCallCounterId::kOptimizeWasmBaseOptimization);
GraphReducer graph_reducer(scope.zone(), data.graph(), GraphReducer graph_reducer(scope.zone(), data.graph(),
&data.info()->tick_counter(), &data.info()->tick_counter(),
data.mcgraph()->Dead()); data.mcgraph()->Dead());
...@@ -3171,9 +3187,6 @@ std::ostream& operator<<(std::ostream& out, ...@@ -3171,9 +3187,6 @@ std::ostream& operator<<(std::ostream& out,
void PipelineImpl::AssembleCode(Linkage* linkage, void PipelineImpl::AssembleCode(Linkage* linkage,
std::unique_ptr<AssemblerBuffer> buffer) { std::unique_ptr<AssemblerBuffer> buffer) {
PipelineData* data = this->data_; PipelineData* data = this->data_;
RuntimeCallTimerScope scope(data_->runtime_call_stats(),
RuntimeCallCounterId::kOptimizeAssembleCode,
RuntimeCallStats::kThreadSpecific);
data->BeginPhaseKind("V8.TFCodeGeneration"); data->BeginPhaseKind("V8.TFCodeGeneration");
data->InitializeCodeGenerator(linkage, std::move(buffer)); data->InitializeCodeGenerator(linkage, std::move(buffer));
......
...@@ -905,7 +905,61 @@ class RuntimeCallTimer final { ...@@ -905,7 +905,61 @@ class RuntimeCallTimer final {
ADD_THREAD_SPECIFIC_COUNTER(V, Compile, RewriteReturnResult) \ ADD_THREAD_SPECIFIC_COUNTER(V, Compile, RewriteReturnResult) \
ADD_THREAD_SPECIFIC_COUNTER(V, Compile, ScopeAnalysis) \ ADD_THREAD_SPECIFIC_COUNTER(V, Compile, ScopeAnalysis) \
ADD_THREAD_SPECIFIC_COUNTER(V, Compile, Script) \ ADD_THREAD_SPECIFIC_COUNTER(V, Compile, Script) \
\
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, AllocateFPRegisters) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, AllocateGeneralRegisters) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, AssembleCode) \ ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, AssembleCode) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, AssignSpillSlots) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, BuildLiveRangeBundles) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, BuildLiveRanges) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, CommitAssignment) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, ConnectRanges) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, ControlFlowOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, CSAEarlyOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, CSAOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, DecideSpillingMode) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, DecompressionOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, EarlyOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, EarlyTrimming) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, EffectLinearization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, EscapeAnalysis) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, FinalizeCode) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, FrameElision) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, GenericLowering) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, BytecodeGraphBuilder) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, Inlining) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, JumpThreading) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LateGraphTrimming) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LateOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LoadElimination) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LocateSpillSlots) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LoopExitElimination) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, LoopPeeling) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, MachineOperatorOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, MeetRegisterConstraints) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, MemoryOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, MergeSplinteredRanges) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, OptimizeMoves) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, PopulatePointerMaps) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, PrintGraph) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, ResolveControlFlow) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, ResolvePhis) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, \
ScheduledEffectControlLinearization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, ScheduledMachineLowering) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, Scheduling) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, SelectInstructions) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, SimplifiedLowering) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, SplinterLiveRanges) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, StoreStoreElimination) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, TypeAssertions) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, TypedLowering) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, Typer) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, Untyper) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, VerifyGraph) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, WasmBaseOptimization) \
ADD_THREAD_SPECIFIC_COUNTER(V, Optimize, WasmFullOptimization) \
\
ADD_THREAD_SPECIFIC_COUNTER(V, Parse, ArrowFunctionLiteral) \ ADD_THREAD_SPECIFIC_COUNTER(V, Parse, ArrowFunctionLiteral) \
ADD_THREAD_SPECIFIC_COUNTER(V, Parse, FunctionLiteral) \ ADD_THREAD_SPECIFIC_COUNTER(V, Parse, FunctionLiteral) \
ADD_THREAD_SPECIFIC_COUNTER(V, Parse, Program) \ ADD_THREAD_SPECIFIC_COUNTER(V, Parse, Program) \
...@@ -975,7 +1029,7 @@ class RuntimeCallTimer final { ...@@ -975,7 +1029,7 @@ class RuntimeCallTimer final {
V(OptimizeFinalizePipelineJob) \ V(OptimizeFinalizePipelineJob) \
V(OptimizeHeapBrokerInitialization) \ V(OptimizeHeapBrokerInitialization) \
V(OptimizeNonConcurrent) \ V(OptimizeNonConcurrent) \
V(OptimizeSerialize) \ V(OptimizeSerialization) \
V(OptimizeSerializeMetadata) \ V(OptimizeSerializeMetadata) \
V(ParseEval) \ V(ParseEval) \
V(ParseFunction) \ V(ParseFunction) \
......
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