11/*
2- * Copyright (c) 1997, 2016 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 2020 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -329,6 +329,7 @@ Node::Node(uint req)
329329 : _idx(Init(req))
330330#ifdef ASSERT
331331 , _parse_idx(_idx)
332+ , _indent(0 )
332333#endif
333334{
334335 assert ( req < Compile::current ()->max_node_limit () - NodeLimitFudgeFactor, " Input limit exceeded" );
@@ -349,6 +350,7 @@ Node::Node(Node *n0)
349350 : _idx(Init(1 ))
350351#ifdef ASSERT
351352 , _parse_idx(_idx)
353+ , _indent(0 )
352354#endif
353355{
354356 debug_only ( verify_construction () );
@@ -362,6 +364,7 @@ Node::Node(Node *n0, Node *n1)
362364 : _idx(Init(2 ))
363365#ifdef ASSERT
364366 , _parse_idx(_idx)
367+ , _indent(0 )
365368#endif
366369{
367370 debug_only ( verify_construction () );
@@ -377,6 +380,7 @@ Node::Node(Node *n0, Node *n1, Node *n2)
377380 : _idx(Init(3 ))
378381#ifdef ASSERT
379382 , _parse_idx(_idx)
383+ , _indent(0 )
380384#endif
381385{
382386 debug_only ( verify_construction () );
@@ -394,6 +398,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3)
394398 : _idx(Init(4 ))
395399#ifdef ASSERT
396400 , _parse_idx(_idx)
401+ , _indent(0 )
397402#endif
398403{
399404 debug_only ( verify_construction () );
@@ -413,6 +418,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4)
413418 : _idx(Init(5 ))
414419#ifdef ASSERT
415420 , _parse_idx(_idx)
421+ , _indent(0 )
416422#endif
417423{
418424 debug_only ( verify_construction () );
@@ -435,6 +441,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
435441 : _idx(Init(6 ))
436442#ifdef ASSERT
437443 , _parse_idx(_idx)
444+ , _indent(0 )
438445#endif
439446{
440447 debug_only ( verify_construction () );
@@ -459,6 +466,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3,
459466 : _idx(Init(7 ))
460467#ifdef ASSERT
461468 , _parse_idx(_idx)
469+ , _indent(0 )
462470#endif
463471{
464472 debug_only ( verify_construction () );
@@ -1718,7 +1726,12 @@ void Node::dump(const char* suffix, bool mark, outputStream *st) const {
17181726 Compile* C = Compile::current ();
17191727 bool is_new = C->node_arena ()->contains (this );
17201728 C->_in_dump_cnt ++;
1721- st->print (" %c%d%s\t %s\t === " , is_new ? ' ' : ' o' , _idx, mark ? " >" : " " , Name ());
1729+
1730+ if (_indent > 0 ) {
1731+ st->print (" %*s" , (_indent << 1 ), " " );
1732+ }
1733+
1734+ st->print (" %c%d%s%s === " , is_new ? ' ' : ' o' , _idx, mark ? " >" : " " , Name ());
17221735
17231736 // Dump the required and precedence inputs
17241737 dump_req (st);
@@ -1843,23 +1856,26 @@ void Node::dump_out(outputStream *st) const {
18431856// moving in a given direction until a certain depth (distance from the start
18441857// node) is reached. Duplicates are ignored.
18451858// Arguments:
1846- // nstack: the nodes are collected into this array.
1859+ // queue: the nodes are collected into this array.
18471860// start: the node at which to start collecting.
18481861// direction: if this is a positive number, collect input nodes; if it is
18491862// a negative number, collect output nodes.
18501863// depth: collect nodes up to this distance from the start node.
18511864// include_start: whether to include the start node in the result collection.
18521865// only_ctrl: whether to regard control edges only during traversal.
18531866// only_data: whether to regard data edges only during traversal.
1854- static void collect_nodes_i (GrowableArray<Node*> *nstack, const Node* start, int direction, uint depth, bool include_start, bool only_ctrl, bool only_data) {
1867+ static void collect_nodes_i (GrowableArray<Node*>* queue, const Node* start, int direction, uint depth, bool include_start, bool only_ctrl, bool only_data) {
1868+ bool indent = depth <= PrintIdealIndentThreshold;
18551869 Node* s = (Node*) start; // remove const
1856- nstack ->append (s);
1870+ queue ->append (s);
18571871 int begin = 0 ;
18581872 int end = 0 ;
1873+
1874+ s->set_indent (0 );
18591875 for (uint i = 0 ; i < depth; i++) {
1860- end = nstack ->length ();
1876+ end = queue ->length ();
18611877 for (int j = begin; j < end; j++) {
1862- Node* tp = nstack ->at (j);
1878+ Node* tp = queue ->at (j);
18631879 uint limit = direction > 0 ? tp->len () : tp->outcnt ();
18641880 for (uint k = 0 ; k < limit; k++) {
18651881 Node* n = direction > 0 ? tp->in (k) : tp->raw_out (k);
@@ -1869,35 +1885,35 @@ static void collect_nodes_i(GrowableArray<Node*> *nstack, const Node* start, int
18691885 if (n->is_Root () || n->is_top ()) continue ;
18701886 if (only_ctrl && !n->is_CFG ()) continue ;
18711887 if (only_data && n->is_CFG ()) continue ;
1872-
1873- bool on_stack = nstack-> contains (n);
1874- if (!on_stack) {
1875- nstack-> append (n );
1888+ bool in_queue = queue-> contains (n);
1889+ if (!in_queue) {
1890+ queue-> append (n);
1891+ n-> set_indent (indent ? (i + 1 ) : 0 );
18761892 }
18771893 }
18781894 }
18791895 begin = end;
18801896 }
18811897 if (!include_start) {
1882- nstack ->remove (s);
1898+ queue ->remove (s);
18831899 }
18841900}
18851901
18861902// ------------------------------dump_nodes-------------------------------------
18871903static void dump_nodes (const Node* start, int d, bool only_ctrl) {
18881904 if (NotANode (start)) return ;
18891905
1890- GrowableArray <Node *> nstack (Compile::current ()->live_nodes ());
1891- collect_nodes_i (&nstack , start, d, (uint) ABS (d), true , only_ctrl, false );
1906+ GrowableArray <Node *> queue (Compile::current ()->live_nodes ());
1907+ collect_nodes_i (&queue , start, d, (uint) ABS (d), true , only_ctrl, false );
18921908
1893- int end = nstack .length ();
1909+ int end = queue .length ();
18941910 if (d > 0 ) {
18951911 for (int j = end-1 ; j >= 0 ; j--) {
1896- nstack .at (j)->dump ();
1912+ queue .at (j)->dump ();
18971913 }
18981914 } else {
18991915 for (int j = 0 ; j < end; j++) {
1900- nstack .at (j)->dump ();
1916+ queue .at (j)->dump ();
19011917 }
19021918 }
19031919}
0 commit comments