[tubofan] Remove .dot output of --trace-turbo

Review URL: https://codereview.chromium.org/1514323002

Cr-Commit-Position: refs/heads/master@{#32813}
This commit is contained in:
danno 2015-12-11 08:58:03 -08:00 committed by Commit bot
parent 5c3bfe8f57
commit bf24486b22
6 changed files with 6 additions and 208 deletions

View File

@ -207,190 +207,6 @@ std::ostream& operator<<(std::ostream& os, const AsJSON& ad) {
}
class GraphVisualizer {
public:
GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph)
: all_(zone, graph), os_(os) {}
void Print();
void PrintNode(Node* node, bool gray);
private:
void PrintEdge(Edge edge);
AllNodes all_;
std::ostream& os_;
DISALLOW_COPY_AND_ASSIGN(GraphVisualizer);
};
static Node* GetControlCluster(Node* node) {
if (OperatorProperties::IsBasicBlockBegin(node->op())) {
return node;
} else if (node->op()->ControlInputCount() == 1) {
Node* control = NodeProperties::GetControlInput(node, 0);
return control != NULL &&
OperatorProperties::IsBasicBlockBegin(control->op())
? control
: NULL;
} else {
return NULL;
}
}
void GraphVisualizer::PrintNode(Node* node, bool gray) {
Node* control_cluster = GetControlCluster(node);
if (control_cluster != NULL) {
os_ << " subgraph cluster_BasicBlock" << control_cluster->id() << " {\n";
}
os_ << " ID" << SafeId(node) << " [\n";
os_ << " shape=\"record\"\n";
switch (node->opcode()) {
case IrOpcode::kEnd:
case IrOpcode::kDead:
case IrOpcode::kStart:
os_ << " style=\"diagonals\"\n";
break;
case IrOpcode::kMerge:
case IrOpcode::kIfTrue:
case IrOpcode::kIfFalse:
case IrOpcode::kLoop:
os_ << " style=\"rounded\"\n";
break;
default:
break;
}
if (gray) {
os_ << " style=\"filled\"\n"
<< " fillcolor=\"" DEAD_COLOR "\"\n";
}
std::ostringstream label;
label << *node->op();
os_ << " label=\"{{#" << SafeId(node) << ":" << Escaped(label);
auto i = node->input_edges().begin();
for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) {
os_ << "|<I" << (*i).index() << ">#" << SafeId((*i).to());
}
for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0;
++i, j--) {
os_ << "|<I" << (*i).index() << ">X #" << SafeId((*i).to());
}
for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0;
++i, j--) {
os_ << "|<I" << (*i).index() << ">F #" << SafeId((*i).to());
}
for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) {
os_ << "|<I" << (*i).index() << ">E #" << SafeId((*i).to());
}
if (OperatorProperties::IsBasicBlockBegin(node->op()) ||
GetControlCluster(node) == NULL) {
for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) {
os_ << "|<I" << (*i).index() << ">C #" << SafeId((*i).to());
}
}
os_ << "}";
if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) {
Type* type = NodeProperties::GetType(node);
std::ostringstream type_out;
type->PrintTo(type_out);
os_ << "|" << Escaped(type_out);
}
os_ << "}\"\n";
os_ << " ]\n";
if (control_cluster != NULL) os_ << " }\n";
}
static bool IsLikelyBackEdge(Node* from, int index, Node* to) {
if (NodeProperties::IsPhi(from)) {
Node* control = NodeProperties::GetControlInput(from, 0);
return control != NULL && control->opcode() != IrOpcode::kMerge &&
control != to && index != 0;
} else if (from->opcode() == IrOpcode::kLoop) {
return index != 0;
} else {
return false;
}
}
void GraphVisualizer::PrintEdge(Edge edge) {
Node* from = edge.from();
int index = edge.index();
Node* to = edge.to();
if (!all_.IsLive(to)) return; // skip inputs that point to dead or NULL.
bool unconstrained = IsLikelyBackEdge(from, index, to);
os_ << " ID" << SafeId(from);
if (OperatorProperties::IsBasicBlockBegin(from->op()) ||
GetControlCluster(from) == NULL ||
(from->op()->ControlInputCount() > 0 &&
NodeProperties::GetControlInput(from) != to)) {
os_ << ":I" << index << ":n -> ID" << SafeId(to) << ":s"
<< "[" << (unconstrained ? "constraint=false, " : "")
<< (NodeProperties::IsControlEdge(edge) ? "style=bold, " : "")
<< (NodeProperties::IsEffectEdge(edge) ? "style=dotted, " : "")
<< (NodeProperties::IsContextEdge(edge) ? "style=dashed, " : "") << "]";
} else {
os_ << " -> ID" << SafeId(to) << ":s [color=transparent, "
<< (unconstrained ? "constraint=false, " : "")
<< (NodeProperties::IsControlEdge(edge) ? "style=dashed, " : "") << "]";
}
os_ << "\n";
}
void GraphVisualizer::Print() {
os_ << "digraph D {\n"
<< " node [fontsize=8,height=0.25]\n"
<< " rankdir=\"BT\"\n"
<< " ranksep=\"1.2 equally\"\n"
<< " overlap=\"false\"\n"
<< " splines=\"true\"\n"
<< " concentrate=\"true\"\n"
<< " \n";
// Find all nodes that are not reachable from end that use live nodes.
std::set<Node*> gray;
for (Node* const node : all_.live) {
for (Node* const use : node->uses()) {
if (!all_.IsLive(use)) gray.insert(use);
}
}
// Make sure all nodes have been output before writing out the edges.
for (Node* const node : all_.live) PrintNode(node, false);
for (Node* const node : gray) PrintNode(node, true);
// With all the nodes written, add the edges.
for (Node* const node : all_.live) {
for (Edge edge : node->use_edges()) {
PrintEdge(edge);
}
}
os_ << "}\n";
}
std::ostream& operator<<(std::ostream& os, const AsDOT& ad) {
Zone tmp_zone;
GraphVisualizer(os, &tmp_zone, &ad.graph).Print();
return os;
}
class GraphC1Visualizer {
public:
GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT

View File

@ -24,14 +24,6 @@ class SourcePositionTable;
FILE* OpenVisualizerLogFile(CompilationInfo* info, const char* phase,
const char* suffix, const char* mode);
struct AsDOT {
explicit AsDOT(const Graph& g) : graph(g) {}
const Graph& graph;
};
std::ostream& operator<<(std::ostream& os, const AsDOT& ad);
struct AsJSON {
AsJSON(const Graph& g, SourcePositionTable* p) : graph(g), positions(p) {}
const Graph& graph;
@ -76,7 +68,6 @@ struct AsC1VRegisterAllocationData {
const RegisterAllocationData* data_;
};
std::ostream& operator<<(std::ostream& os, const AsDOT& ad);
std::ostream& operator<<(std::ostream& os, const AsC1VCompilation& ac);
std::ostream& operator<<(std::ostream& os, const AsC1V& ac);
std::ostream& operator<<(std::ostream& os,

View File

@ -1000,14 +1000,6 @@ struct PrintGraphPhase {
CompilationInfo* info = data->info();
Graph* graph = data->graph();
{ // Print dot.
FILE* dot_file = OpenVisualizerLogFile(info, phase, "dot", "w+");
if (dot_file == nullptr) return;
OFStream dot_of(dot_file);
dot_of << AsDOT(*graph);
fclose(dot_file);
}
{ // Print JSON.
FILE* json_file = OpenVisualizerLogFile(info, NULL, "json", "a+");
if (json_file == nullptr) return;

View File

@ -39,7 +39,6 @@ TEST(NodeWithNullInputReachableFromEnd) {
graph.SetEnd(phi);
OFStream os(stdout);
os << AsDOT(graph);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
}
@ -59,7 +58,6 @@ TEST(NodeWithNullControlReachableFromEnd) {
graph.SetEnd(phi);
OFStream os(stdout);
os << AsDOT(graph);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
}
@ -79,7 +77,6 @@ TEST(NodeWithNullInputReachableFromStart) {
graph.SetEnd(start);
OFStream os(stdout);
os << AsDOT(graph);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
}
@ -97,7 +94,6 @@ TEST(NodeWithNullControlReachableFromStart) {
graph.SetEnd(merge);
OFStream os(stdout);
os << AsDOT(graph);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
}
@ -125,7 +121,6 @@ TEST(NodeNetworkOfDummiesReachableFromEnd) {
graph.SetEnd(end);
OFStream os(stdout);
os << AsDOT(graph);
SourcePositionTable table(&graph);
os << AsJSON(graph, &table);
}

View File

@ -6,6 +6,7 @@
#include "src/compiler/control-equivalence.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/source-position.h"
#include "src/zone-containers.h"
#include "test/unittests/compiler/graph-unittest.h"
@ -30,7 +31,8 @@ class ControlEquivalenceTest : public GraphTest {
graph()->SetEnd(graph()->NewNode(common()->End(1), node));
if (FLAG_trace_turbo) {
OFStream os(stdout);
os << AsDOT(*graph());
SourcePositionTable table(graph());
os << AsJSON(*graph(), &table);
}
ControlEquivalence equivalence(zone(), graph());
equivalence.Run(node);

View File

@ -13,6 +13,7 @@
#include "src/compiler/schedule.h"
#include "src/compiler/scheduler.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/source-position.h"
#include "src/compiler/verifier.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/test-utils.h"
@ -32,7 +33,8 @@ class SchedulerTest : public TestWithIsolateAndZone {
Schedule* ComputeAndVerifySchedule(size_t expected) {
if (FLAG_trace_turbo) {
OFStream os(stdout);
os << AsDOT(*graph());
SourcePositionTable table(graph());
os << AsJSON(*graph(), &table);
}
Schedule* schedule =