diff --git a/src/compiler/node-origin-table.cc b/src/compiler/node-origin-table.cc index 3e1f4ff453..406d634812 100644 --- a/src/compiler/node-origin-table.cc +++ b/src/compiler/node-origin-table.cc @@ -11,10 +11,11 @@ namespace internal { namespace compiler { void NodeOrigin::PrintJson(std::ostream& out) const { - out << "{ " - << "\"nodeId\" : " << created_from() << ", \"reducer\" : \"" - << reducer_name() << "\"" - << "}"; + out << "{ "; + out << "\"nodeId\" : " << created_from(); + out << ", \"reducer\" : \"" << reducer_name() << "\""; + out << ", \"phase\" : \"" << phase_name() << "\""; + out << "}"; } class NodeOriginTable::Decorator final : public GraphDecorator { @@ -33,6 +34,7 @@ NodeOriginTable::NodeOriginTable(Graph* graph) : graph_(graph), decorator_(nullptr), current_origin_(NodeOrigin::Unknown()), + current_phase_name_("unknown"), table_(graph->zone()) {} void NodeOriginTable::AddDecorator() { diff --git a/src/compiler/node-origin-table.h b/src/compiler/node-origin-table.h index e2a2db75db..fae53c5788 100644 --- a/src/compiler/node-origin-table.h +++ b/src/compiler/node-origin-table.h @@ -18,14 +18,18 @@ namespace compiler { class NodeOrigin { public: - NodeOrigin(const char* reducer_name, NodeId created_from) - : reducer_name_(reducer_name), created_from_(created_from) {} + NodeOrigin(const char* phase_name, const char* reducer_name, + NodeId created_from) + : phase_name_(phase_name), + reducer_name_(reducer_name), + created_from_(created_from) {} NodeOrigin(const NodeOrigin& other) = default; static NodeOrigin Unknown() { return NodeOrigin(); } bool IsKnown() { return created_from_ >= 0; } int64_t created_from() const { return created_from_; } const char* reducer_name() const { return reducer_name_; } + const char* phase_name() const { return phase_name_; } bool operator==(const NodeOrigin& o) const { return reducer_name_ == o.reducer_name_ && created_from_ == o.created_from_; @@ -35,7 +39,10 @@ class NodeOrigin { private: NodeOrigin() - : reducer_name_(""), created_from_(std::numeric_limits::min()) {} + : phase_name_(""), + reducer_name_(""), + created_from_(std::numeric_limits::min()) {} + const char* phase_name_; const char* reducer_name_; int64_t created_from_; }; @@ -53,7 +60,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final : origins_(origins), prev_origin_(NodeOrigin::Unknown()) { if (origins) { prev_origin_ = origins->current_origin_; - origins->current_origin_ = NodeOrigin(reducer_name, node->id()); + origins->current_origin_ = + NodeOrigin(origins->current_phase_name_, reducer_name, node->id()); } } @@ -67,6 +75,27 @@ class V8_EXPORT_PRIVATE NodeOriginTable final DISALLOW_COPY_AND_ASSIGN(Scope); }; + class PhaseScope final { + public: + PhaseScope(NodeOriginTable* origins, const char* phase_name) + : origins_(origins) { + if (origins != nullptr) { + prev_phase_name_ = origins->current_phase_name_; + origins->current_phase_name_ = + phase_name == nullptr ? "unnamed" : phase_name; + } + } + + ~PhaseScope() { + if (origins_) origins_->current_phase_name_ = prev_phase_name_; + } + + private: + NodeOriginTable* const origins_; + const char* prev_phase_name_; + DISALLOW_COPY_AND_ASSIGN(PhaseScope); + }; + explicit NodeOriginTable(Graph* graph); void AddDecorator(); @@ -85,6 +114,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final Graph* const graph_; Decorator* decorator_; NodeOrigin current_origin_; + + const char* current_phase_name_; NodeAuxData table_; DISALLOW_COPY_AND_ASSIGN(NodeOriginTable); diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index aba79a2c9d..779457bcf7 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -706,13 +706,15 @@ class PipelineRunScope { : phase_scope_( phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name), - zone_scope_(data->zone_stats(), ZONE_NAME) {} + zone_scope_(data->zone_stats(), ZONE_NAME), + origin_scope_(data->node_origins(), phase_name) {} Zone* zone() { return zone_scope_.zone(); } private: PhaseScope phase_scope_; ZoneStats::Scope zone_scope_; + NodeOriginTable::PhaseScope origin_scope_; }; PipelineStatistics* CreatePipelineStatistics(Handle