Commit 2cd48c74 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbolizer] Add reducer phase to node origin

Bug: v8:7327
Change-Id: Ic1c4a10a251a8243fc337dc149eb057a29cace2b
Reviewed-on: https://chromium-review.googlesource.com/1065670
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53279}
parent 1cb19f0e
...@@ -11,10 +11,11 @@ namespace internal { ...@@ -11,10 +11,11 @@ namespace internal {
namespace compiler { namespace compiler {
void NodeOrigin::PrintJson(std::ostream& out) const { void NodeOrigin::PrintJson(std::ostream& out) const {
out << "{ " out << "{ ";
<< "\"nodeId\" : " << created_from() << ", \"reducer\" : \"" out << "\"nodeId\" : " << created_from();
<< reducer_name() << "\"" out << ", \"reducer\" : \"" << reducer_name() << "\"";
<< "}"; out << ", \"phase\" : \"" << phase_name() << "\"";
out << "}";
} }
class NodeOriginTable::Decorator final : public GraphDecorator { class NodeOriginTable::Decorator final : public GraphDecorator {
...@@ -33,6 +34,7 @@ NodeOriginTable::NodeOriginTable(Graph* graph) ...@@ -33,6 +34,7 @@ NodeOriginTable::NodeOriginTable(Graph* graph)
: graph_(graph), : graph_(graph),
decorator_(nullptr), decorator_(nullptr),
current_origin_(NodeOrigin::Unknown()), current_origin_(NodeOrigin::Unknown()),
current_phase_name_("unknown"),
table_(graph->zone()) {} table_(graph->zone()) {}
void NodeOriginTable::AddDecorator() { void NodeOriginTable::AddDecorator() {
......
...@@ -18,14 +18,18 @@ namespace compiler { ...@@ -18,14 +18,18 @@ namespace compiler {
class NodeOrigin { class NodeOrigin {
public: public:
NodeOrigin(const char* reducer_name, NodeId created_from) NodeOrigin(const char* phase_name, const char* reducer_name,
: reducer_name_(reducer_name), created_from_(created_from) {} NodeId created_from)
: phase_name_(phase_name),
reducer_name_(reducer_name),
created_from_(created_from) {}
NodeOrigin(const NodeOrigin& other) = default; NodeOrigin(const NodeOrigin& other) = default;
static NodeOrigin Unknown() { return NodeOrigin(); } static NodeOrigin Unknown() { return NodeOrigin(); }
bool IsKnown() { return created_from_ >= 0; } bool IsKnown() { return created_from_ >= 0; }
int64_t created_from() const { return created_from_; } int64_t created_from() const { return created_from_; }
const char* reducer_name() const { return reducer_name_; } const char* reducer_name() const { return reducer_name_; }
const char* phase_name() const { return phase_name_; }
bool operator==(const NodeOrigin& o) const { bool operator==(const NodeOrigin& o) const {
return reducer_name_ == o.reducer_name_ && created_from_ == o.created_from_; return reducer_name_ == o.reducer_name_ && created_from_ == o.created_from_;
...@@ -35,7 +39,10 @@ class NodeOrigin { ...@@ -35,7 +39,10 @@ class NodeOrigin {
private: private:
NodeOrigin() NodeOrigin()
: reducer_name_(""), created_from_(std::numeric_limits<int64_t>::min()) {} : phase_name_(""),
reducer_name_(""),
created_from_(std::numeric_limits<int64_t>::min()) {}
const char* phase_name_;
const char* reducer_name_; const char* reducer_name_;
int64_t created_from_; int64_t created_from_;
}; };
...@@ -53,7 +60,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final ...@@ -53,7 +60,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final
: origins_(origins), prev_origin_(NodeOrigin::Unknown()) { : origins_(origins), prev_origin_(NodeOrigin::Unknown()) {
if (origins) { if (origins) {
prev_origin_ = origins->current_origin_; 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 ...@@ -67,6 +75,27 @@ class V8_EXPORT_PRIVATE NodeOriginTable final
DISALLOW_COPY_AND_ASSIGN(Scope); 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); explicit NodeOriginTable(Graph* graph);
void AddDecorator(); void AddDecorator();
...@@ -85,6 +114,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final ...@@ -85,6 +114,8 @@ class V8_EXPORT_PRIVATE NodeOriginTable final
Graph* const graph_; Graph* const graph_;
Decorator* decorator_; Decorator* decorator_;
NodeOrigin current_origin_; NodeOrigin current_origin_;
const char* current_phase_name_;
NodeAuxData<NodeOrigin, NodeOrigin::Unknown> table_; NodeAuxData<NodeOrigin, NodeOrigin::Unknown> table_;
DISALLOW_COPY_AND_ASSIGN(NodeOriginTable); DISALLOW_COPY_AND_ASSIGN(NodeOriginTable);
......
...@@ -706,13 +706,15 @@ class PipelineRunScope { ...@@ -706,13 +706,15 @@ class PipelineRunScope {
: phase_scope_( : phase_scope_(
phase_name == nullptr ? nullptr : data->pipeline_statistics(), phase_name == nullptr ? nullptr : data->pipeline_statistics(),
phase_name), 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(); } Zone* zone() { return zone_scope_.zone(); }
private: private:
PhaseScope phase_scope_; PhaseScope phase_scope_;
ZoneStats::Scope zone_scope_; ZoneStats::Scope zone_scope_;
NodeOriginTable::PhaseScope origin_scope_;
}; };
PipelineStatistics* CreatePipelineStatistics(Handle<Script> script, PipelineStatistics* CreatePipelineStatistics(Handle<Script> script,
......
...@@ -15,9 +15,10 @@ class GraphView extends View { ...@@ -15,9 +15,10 @@ class GraphView extends View {
return pane; return pane;
} }
constructor(d3, id, broker) { constructor(d3, id, broker, showPhaseByName) {
super(id, broker); super(id, broker);
var graph = this; var graph = this;
this.showPhaseByName = showPhaseByName
var svg = this.divElement.append("svg").attr('version', '1.1') var svg = this.divElement.append("svg").attr('version', '1.1')
.attr("width", "100%") .attr("width", "100%")
...@@ -490,6 +491,7 @@ class GraphView extends View { ...@@ -490,6 +491,7 @@ class GraphView extends View {
var filterFunction = function (n) { var filterFunction = function (n) {
return (reg.exec(n.getDisplayLabel()) != null || return (reg.exec(n.getDisplayLabel()) != null ||
(graph.state.showTypes && reg.exec(n.getDisplayType())) || (graph.state.showTypes && reg.exec(n.getDisplayType())) ||
(reg.exec(n.getTitle())) ||
reg.exec(n.opcode) != null); reg.exec(n.opcode) != null);
}; };
...@@ -653,16 +655,20 @@ class GraphView extends View { ...@@ -653,16 +655,20 @@ class GraphView extends View {
selectOrigins() { selectOrigins() {
const state = this.state; const state = this.state;
const origins = []; const origins = [];
let phase = null;
for (const n of state.selection) { for (const n of state.selection) {
if (n.origin) { if (n.origin) {
const node = this.nodeMap[n.origin.nodeId]; const node = this.nodeMap[n.origin.nodeId];
origins.push(node); origins.push(node);
phase = n.origin.phase;
} }
} }
if (origins.length) { if (origins.length) {
state.selection.clear(); state.selection.clear();
state.selection.select(origins, true); state.selection.select(origins, true);
this.updateGraphVisibility(); if (phase) {
this.showPhaseByName(phase);
}
} }
} }
......
...@@ -59,7 +59,7 @@ var Node = { ...@@ -59,7 +59,7 @@ var Node = {
} }
let title = this.title + "\n" + propsString + "\n" + this.opinfo; let title = this.title + "\n" + propsString + "\n" + this.opinfo;
if (this.origin) { if (this.origin) {
title += `\nOrigin: ${this.origin.reducer} from #${this.origin.nodeId}`; title += `\nOrigin: #${this.origin.nodeId} in phase ${this.origin.phase}/${this.origin.reducer}`;
} }
return title; return title;
}, },
......
...@@ -33,6 +33,8 @@ class SourceResolver { ...@@ -33,6 +33,8 @@ class SourceResolver {
this.positionToNodes = new Map(); this.positionToNodes = new Map();
// Maps phase ids to phases. // Maps phase ids to phases.
this.phases = []; this.phases = [];
// Maps phase names to phaseIds.
this.phaseNames = new Map();
// The disassembly phase is stored separately. // The disassembly phase is stored separately.
this.disassemblyPhase = undefined; this.disassemblyPhase = undefined;
} }
...@@ -217,8 +219,10 @@ class SourceResolver { ...@@ -217,8 +219,10 @@ class SourceResolver {
this.disassemblyPhase = phase; this.disassemblyPhase = phase;
} else if (phase.type == 'schedule') { } else if (phase.type == 'schedule') {
this.phases.push(this.parseSchedule(phase)) this.phases.push(this.parseSchedule(phase))
this.phaseNames.set(phase.name, this.phases.length);
} else { } else {
this.phases.push(phase); this.phases.push(phase);
this.phaseNames.set(phase.name, this.phases.length);
} }
} }
} }
...@@ -231,6 +235,10 @@ class SourceResolver { ...@@ -231,6 +235,10 @@ class SourceResolver {
return this.phases[phaseId]; return this.phases[phaseId];
} }
getPhaseIdByName(phaseName) {
return this.phaseNames.get(phaseName);
}
forEachPhase(f) { forEachPhase(f) {
this.phases.forEach(f); this.phases.forEach(f);
} }
......
...@@ -274,7 +274,13 @@ document.onload = (function (d3) { ...@@ -274,7 +274,13 @@ document.onload = (function (d3) {
const initialPhaseIndex = sourceResolver.repairPhaseId(+window.sessionStorage.getItem("lastSelectedPhase")); const initialPhaseIndex = sourceResolver.repairPhaseId(+window.sessionStorage.getItem("lastSelectedPhase"));
selectMenu.selectedIndex = initialPhaseIndex; selectMenu.selectedIndex = initialPhaseIndex;
graph = new GraphView(d3, INTERMEDIATE_PANE_ID, selectionBroker); function displayPhaseByName(phaseName) {
const phaseId = sourceResolver.getPhaseIdByName(phaseName);
selectMenu.selectedIndex = phaseId - 1;
displayPhase(sourceResolver.getPhase(phaseId));
}
graph = new GraphView(d3, INTERMEDIATE_PANE_ID, selectionBroker, displayPhaseByName);
schedule = new ScheduleView(INTERMEDIATE_PANE_ID, selectionBroker); schedule = new ScheduleView(INTERMEDIATE_PANE_ID, selectionBroker);
displayPhase(sourceResolver.getPhase(initialPhaseIndex)); displayPhase(sourceResolver.getPhase(initialPhaseIndex));
......
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