[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: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#53279}
This commit is contained in:
parent
1cb19f0e0a
commit
2cd48c74e0
@ -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() {
|
||||
|
@ -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<int64_t>::min()) {}
|
||||
: phase_name_(""),
|
||||
reducer_name_(""),
|
||||
created_from_(std::numeric_limits<int64_t>::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<NodeOrigin, NodeOrigin::Unknown> table_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeOriginTable);
|
||||
|
@ -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<Script> script,
|
||||
|
@ -15,9 +15,10 @@ class GraphView extends View {
|
||||
return pane;
|
||||
}
|
||||
|
||||
constructor(d3, id, broker) {
|
||||
constructor(d3, id, broker, showPhaseByName) {
|
||||
super(id, broker);
|
||||
var graph = this;
|
||||
this.showPhaseByName = showPhaseByName
|
||||
|
||||
var svg = this.divElement.append("svg").attr('version', '1.1')
|
||||
.attr("width", "100%")
|
||||
@ -490,6 +491,7 @@ class GraphView extends View {
|
||||
var filterFunction = function (n) {
|
||||
return (reg.exec(n.getDisplayLabel()) != null ||
|
||||
(graph.state.showTypes && reg.exec(n.getDisplayType())) ||
|
||||
(reg.exec(n.getTitle())) ||
|
||||
reg.exec(n.opcode) != null);
|
||||
};
|
||||
|
||||
@ -653,16 +655,20 @@ class GraphView extends View {
|
||||
selectOrigins() {
|
||||
const state = this.state;
|
||||
const origins = [];
|
||||
let phase = null;
|
||||
for (const n of state.selection) {
|
||||
if (n.origin) {
|
||||
const node = this.nodeMap[n.origin.nodeId];
|
||||
origins.push(node);
|
||||
phase = n.origin.phase;
|
||||
}
|
||||
}
|
||||
if (origins.length) {
|
||||
state.selection.clear();
|
||||
state.selection.select(origins, true);
|
||||
this.updateGraphVisibility();
|
||||
if (phase) {
|
||||
this.showPhaseByName(phase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ var Node = {
|
||||
}
|
||||
let title = this.title + "\n" + propsString + "\n" + this.opinfo;
|
||||
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;
|
||||
},
|
||||
|
@ -33,6 +33,8 @@ class SourceResolver {
|
||||
this.positionToNodes = new Map();
|
||||
// Maps phase ids to phases.
|
||||
this.phases = [];
|
||||
// Maps phase names to phaseIds.
|
||||
this.phaseNames = new Map();
|
||||
// The disassembly phase is stored separately.
|
||||
this.disassemblyPhase = undefined;
|
||||
}
|
||||
@ -217,8 +219,10 @@ class SourceResolver {
|
||||
this.disassemblyPhase = phase;
|
||||
} else if (phase.type == 'schedule') {
|
||||
this.phases.push(this.parseSchedule(phase))
|
||||
this.phaseNames.set(phase.name, this.phases.length);
|
||||
} else {
|
||||
this.phases.push(phase);
|
||||
this.phaseNames.set(phase.name, this.phases.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,6 +235,10 @@ class SourceResolver {
|
||||
return this.phases[phaseId];
|
||||
}
|
||||
|
||||
getPhaseIdByName(phaseName) {
|
||||
return this.phaseNames.get(phaseName);
|
||||
}
|
||||
|
||||
forEachPhase(f) {
|
||||
this.phases.forEach(f);
|
||||
}
|
||||
|
@ -274,7 +274,13 @@ document.onload = (function (d3) {
|
||||
const initialPhaseIndex = sourceResolver.repairPhaseId(+window.sessionStorage.getItem("lastSelectedPhase"));
|
||||
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);
|
||||
|
||||
displayPhase(sourceResolver.getPhase(initialPhaseIndex));
|
||||
|
Loading…
Reference in New Issue
Block a user