V8 Project
v8::internal::compiler::GraphVisualizer Class Reference
+ Inheritance diagram for v8::internal::compiler::GraphVisualizer:
+ Collaboration diagram for v8::internal::compiler::GraphVisualizer:

Public Member Functions

 GraphVisualizer (OStream &os, Zone *zone, const Graph *graph)
 
void Print ()
 
GenericGraphVisit::Control Pre (Node *node)
 
GenericGraphVisit::Control PreEdge (Node *from, int index, Node *to)
 
- Public Member Functions inherited from v8::internal::compiler::GenericGraphVisit::NullNodeVisitor< B, S >
Control Pre (GenericNode< B, S > *node)
 
Control Post (GenericNode< B, S > *node)
 
void PreEdge (GenericNode< B, S > *from, int index, GenericNode< B, S > *to)
 
void PostEdge (GenericNode< B, S > *from, int index, GenericNode< B, S > *to)
 

Private Member Functions

void AnnotateNode (Node *node)
 
void PrintEdge (Node::Edge edge)
 
 DISALLOW_COPY_AND_ASSIGN (GraphVisualizer)
 

Private Attributes

Zonezone_
 
NodeSet all_nodes_
 
NodeSet white_nodes_
 
bool use_to_def_
 
OStreamos_
 
const Graph *const graph_
 

Detailed Description

Definition at line 160 of file graph-visualizer.cc.

Constructor & Destructor Documentation

◆ GraphVisualizer()

v8::internal::compiler::GraphVisualizer::GraphVisualizer ( OStream os,
Zone zone,
const Graph graph 
)

Definition at line 370 of file graph-visualizer.cc.

372  : zone_(zone),
373  all_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
374  white_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
375  use_to_def_(true),
376  os_(os),
377  graph_(graph) {}

Member Function Documentation

◆ AnnotateNode()

void v8::internal::compiler::GraphVisualizer::AnnotateNode ( Node *  node)
private

Definition at line 238 of file graph-visualizer.cc.

238  {
239  if (!use_to_def_) {
240  os_ << " style=\"filled\"\n"
241  << " fillcolor=\"" DEAD_COLOR "\"\n";
242  }
243 
244  os_ << " shape=\"record\"\n";
245  switch (node->opcode()) {
246  case IrOpcode::kEnd:
247  case IrOpcode::kDead:
248  case IrOpcode::kStart:
249  os_ << " style=\"diagonals\"\n";
250  break;
251  case IrOpcode::kMerge:
252  case IrOpcode::kIfTrue:
253  case IrOpcode::kIfFalse:
254  case IrOpcode::kLoop:
255  os_ << " style=\"rounded\"\n";
256  break;
257  default:
258  break;
259  }
260 
261  OStringStream label;
262  label << *node->op();
263  os_ << " label=\"{{#" << node->id() << ":" << Escaped(label);
264 
265  InputIter i = node->inputs().begin();
266  for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0;
267  ++i, j--) {
268  os_ << "|<I" << i.index() << ">#" << (*i)->id();
269  }
270  for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0;
271  ++i, j--) {
272  os_ << "|<I" << i.index() << ">X #" << (*i)->id();
273  }
274  for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0;
275  ++i, j--) {
276  os_ << "|<I" << i.index() << ">F #" << (*i)->id();
277  }
278  for (int j = OperatorProperties::GetEffectInputCount(node->op()); j > 0;
279  ++i, j--) {
280  os_ << "|<I" << i.index() << ">E #" << (*i)->id();
281  }
282 
284  GetControlCluster(node) == NULL) {
285  for (int j = OperatorProperties::GetControlInputCount(node->op()); j > 0;
286  ++i, j--) {
287  os_ << "|<I" << i.index() << ">C #" << (*i)->id();
288  }
289  }
290  os_ << "}";
291 
292  if (FLAG_trace_turbo_types && !NodeProperties::IsControl(node)) {
293  Bounds bounds = NodeProperties::GetBounds(node);
294  OStringStream upper;
295  bounds.upper->PrintTo(upper);
296  OStringStream lower;
297  bounds.lower->PrintTo(lower);
298  os_ << "|" << Escaped(upper) << "|" << Escaped(lower);
299  }
300  os_ << "}\"\n";
301 }
static int GetEffectInputCount(const Operator *op)
static int GetFrameStateInputCount(const Operator *op)
static int GetContextInputCount(const Operator *op)
static bool IsBasicBlockBegin(const Operator *op)
static int GetValueInputCount(const Operator *op)
static int GetControlInputCount(const Operator *op)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DEAD_COLOR
static Node * GetControlCluster(Node *node)
Node::Inputs::iterator InputIter
Definition: node.h:82
BoundsImpl< ZoneTypeConfig > Bounds
Definition: types.h:1047

References DEAD_COLOR, v8::internal::compiler::NodeProperties::GetBounds(), v8::internal::compiler::OperatorProperties::GetContextInputCount(), v8::internal::compiler::GetControlCluster(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::OperatorProperties::GetEffectInputCount(), v8::internal::compiler::OperatorProperties::GetFrameStateInputCount(), v8::internal::compiler::OperatorProperties::GetValueInputCount(), v8::internal::compiler::OperatorProperties::IsBasicBlockBegin(), v8::internal::compiler::NodeProperties::IsControl(), v8::internal::BoundsImpl< Config >::lower, NULL, os_, v8::internal::BoundsImpl< Config >::upper, and use_to_def_.

Referenced by Pre().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::compiler::GraphVisualizer::DISALLOW_COPY_AND_ASSIGN ( GraphVisualizer  )
private

◆ Pre()

GenericGraphVisit::Control v8::internal::compiler::GraphVisualizer::Pre ( Node *  node)

Definition at line 197 of file graph-visualizer.cc.

197  {
198  if (all_nodes_.count(node) == 0) {
199  Node* control_cluster = GetControlCluster(node);
200  if (control_cluster != NULL) {
201  os_ << " subgraph cluster_BasicBlock" << control_cluster->id() << " {\n";
202  }
203  os_ << " ID" << node->id() << " [\n";
204  AnnotateNode(node);
205  os_ << " ]\n";
206  if (control_cluster != NULL) os_ << " }\n";
207  all_nodes_.insert(node);
208  if (use_to_def_) white_nodes_.insert(node);
209  }
211 }

References all_nodes_, AnnotateNode(), v8::internal::compiler::GenericGraphVisit::CONTINUE, v8::internal::compiler::GetControlCluster(), NULL, os_, use_to_def_, and white_nodes_.

+ Here is the call graph for this function:

◆ PreEdge()

GenericGraphVisit::Control v8::internal::compiler::GraphVisualizer::PreEdge ( Node *  from,
int  index,
Node *  to 
)

Definition at line 214 of file graph-visualizer.cc.

215  {
217  // When going from def to use, only consider white -> other edges, which are
218  // the dead nodes that use live nodes. We're probably not interested in
219  // dead nodes that only use other dead nodes.
220  if (white_nodes_.count(from) > 0) return GenericGraphVisit::CONTINUE;
222 }

References v8::internal::compiler::GenericGraphVisit::CONTINUE, v8::internal::compiler::GenericGraphVisit::SKIP, use_to_def_, and white_nodes_.

◆ Print()

void v8::internal::compiler::GraphVisualizer::Print ( )

Definition at line 330 of file graph-visualizer.cc.

330  {
331  os_ << "digraph D {\n"
332  << " node [fontsize=8,height=0.25]\n"
333  << " rankdir=\"BT\"\n"
334  << " ranksep=\"1.2 equally\"\n"
335  << " overlap=\"false\"\n"
336  << " splines=\"true\"\n"
337  << " concentrate=\"true\"\n"
338  << " \n";
339 
340  // Make sure all nodes have been output before writing out the edges.
341  use_to_def_ = true;
342  // TODO(svenpanne) Remove the need for the const_casts.
343  const_cast<Graph*>(graph_)->VisitNodeInputsFromEnd(this);
344  white_nodes_.insert(const_cast<Graph*>(graph_)->start());
345 
346  // Visit all uses of white nodes.
347  use_to_def_ = false;
348  GenericGraphVisit::Visit<GraphVisualizer, NodeUseIterationTraits<Node> >(
349  const_cast<Graph*>(graph_), zone_, white_nodes_.begin(),
350  white_nodes_.end(), this);
351 
352  os_ << " DEAD_INPUT [\n"
353  << " style=\"filled\" \n"
354  << " fillcolor=\"" DEAD_COLOR "\"\n"
355  << " ]\n"
356  << "\n";
357 
358  // With all the nodes written, add the edges.
359  for (NodeSetIter i = all_nodes_.begin(); i != all_nodes_.end(); ++i) {
360  Node::Inputs inputs = (*i)->inputs();
361  for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end();
362  ++iter) {
363  PrintEdge(iter.edge());
364  }
365  }
366  os_ << "}\n";
367 }
NodeSet::iterator NodeSetIter
Definition: node.h:69

References all_nodes_, DEAD_COLOR, graph_, os_, PrintEdge(), v8::internal::compiler::GenericGraph< V >::start(), use_to_def_, white_nodes_, and zone_.

Referenced by v8::internal::compiler::operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintEdge()

void v8::internal::compiler::GraphVisualizer::PrintEdge ( Node::Edge  edge)
private

Definition at line 304 of file graph-visualizer.cc.

304  {
305  Node* from = edge.from();
306  int index = edge.index();
307  Node* to = edge.to();
308  bool unconstrained = IsLikelyBackEdge(from, index, to);
309  os_ << " ID" << from->id();
310  if (all_nodes_.count(to) == 0) {
311  os_ << ":I" << index << ":n -> DEAD_INPUT";
312  } else if (OperatorProperties::IsBasicBlockBegin(from->op()) ||
313  GetControlCluster(from) == NULL ||
314  (OperatorProperties::GetControlInputCount(from->op()) > 0 &&
316  os_ << ":I" << index << ":n -> ID" << to->id() << ":s"
317  << "[" << (unconstrained ? "constraint=false, " : "")
318  << (NodeProperties::IsControlEdge(edge) ? "style=bold, " : "")
319  << (NodeProperties::IsEffectEdge(edge) ? "style=dotted, " : "")
320  << (NodeProperties::IsContextEdge(edge) ? "style=dashed, " : "") << "]";
321  } else {
322  os_ << " -> ID" << to->id() << ":s [color=transparent, "
323  << (unconstrained ? "constraint=false, " : "")
324  << (NodeProperties::IsControlEdge(edge) ? "style=dashed, " : "") << "]";
325  }
326  os_ << "\n";
327 }
static bool IsContextEdge(Node::Edge edge)
static bool IsControlEdge(Node::Edge edge)
static bool IsEffectEdge(Node::Edge edge)
static Node * GetControlInput(Node *node, int index=0)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
static bool IsLikelyBackEdge(Node *from, int index, Node *to)

References all_nodes_, v8::internal::compiler::GetControlCluster(), v8::internal::compiler::NodeProperties::GetControlInput(), v8::internal::compiler::OperatorProperties::GetControlInputCount(), v8::internal::compiler::OperatorProperties::IsBasicBlockBegin(), v8::internal::compiler::NodeProperties::IsContextEdge(), v8::internal::compiler::NodeProperties::IsControlEdge(), v8::internal::compiler::NodeProperties::IsEffectEdge(), v8::internal::compiler::IsLikelyBackEdge(), NULL, os_, and to().

Referenced by Print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ all_nodes_

NodeSet v8::internal::compiler::GraphVisualizer::all_nodes_
private

Definition at line 174 of file graph-visualizer.cc.

Referenced by Pre(), Print(), and PrintEdge().

◆ graph_

const Graph* const v8::internal::compiler::GraphVisualizer::graph_
private

Definition at line 178 of file graph-visualizer.cc.

Referenced by Print().

◆ os_

OStream& v8::internal::compiler::GraphVisualizer::os_
private

Definition at line 177 of file graph-visualizer.cc.

Referenced by AnnotateNode(), Pre(), Print(), and PrintEdge().

◆ use_to_def_

bool v8::internal::compiler::GraphVisualizer::use_to_def_
private

Definition at line 176 of file graph-visualizer.cc.

Referenced by AnnotateNode(), Pre(), PreEdge(), and Print().

◆ white_nodes_

NodeSet v8::internal::compiler::GraphVisualizer::white_nodes_
private

Definition at line 175 of file graph-visualizer.cc.

Referenced by Pre(), PreEdge(), and Print().

◆ zone_

Zone* v8::internal::compiler::GraphVisualizer::zone_
private

Definition at line 173 of file graph-visualizer.cc.

Referenced by Print().


The documentation for this class was generated from the following file: