hotspot/src/share/vm/opto/domgraph.cpp
author mikael
Tue, 24 Dec 2013 11:48:39 -0800
changeset 22234 da823d78ad65
parent 19717 7819ffdaf0ff
child 24425 53764d2358f9
permissions -rw-r--r--
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 19717
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3676
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3676
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3676
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "libadt/vectset.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/block.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/machnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "opto/rootnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Portions of code courtesy of Clifford Click
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// A data structure that holds all the information needed to find dominators.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
struct Tarjan {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  Block *_block;                // Basic block for this info
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  uint _semi;                   // Semi-dominators
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  uint _size;                   // Used for faster LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  Tarjan *_parent;              // Parent in DFS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  Tarjan *_label;               // Used for LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  Tarjan *_ancestor;            // Used for LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  Tarjan *_child;               // Used for faster LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  Tarjan *_dom;                 // Parent in dominator tree (immediate dom)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  Tarjan *_bucket;              // Set of vertices with given semidominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  Tarjan *_dom_child;           // Child in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  Tarjan *_dom_next;            // Next in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Fast union-find work
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  void COMPRESS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  Tarjan *EVAL(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  void LINK( Tarjan *w, Tarjan *tarjan0 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  void setdepth( uint size );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// Compute the dominator tree of the CFG.  The CFG must already have been
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// constructed.  This is the Lengauer & Tarjan O(E-alpha(E,V)) algorithm.
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    62
void PhaseCFG::build_dominator_tree() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Pre-grow the blocks array, prior to the ResourceMark kicking in
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    64
  _blocks.map(number_of_blocks(), 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // Setup mappings from my Graph to Tarjan's stuff and back
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Note: Tarjan uses 1-based arrays
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    69
  Tarjan* tarjan = NEW_RESOURCE_ARRAY(Tarjan, number_of_blocks() + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Tarjan's algorithm, almost verbatim:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Step 1:
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    73
  uint dfsnum = do_DFS(tarjan, number_of_blocks());
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    74
  if (dfsnum - 1 != number_of_blocks()) { // Check for unreachable loops!
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    // If the returned dfsnum does not match the number of blocks, then we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    // must have some unreachable loops.  These can be made at any time by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // IterGVN.  They are cleaned up by CCP or the loop opts, but the last
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    // IterGVN can always make more that are not cleaned up.  Highly unlikely
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // except in ZKM.jar, where endless irreducible loops cause the loop opts
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // to not get run.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    // Having found unreachable loops, we have made a bad RPO _block layout.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    // We can re-run the above DFS pass with the correct number of blocks,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    // and hack the Tarjan algorithm below to be robust in the presence of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    // such dead loops (as was done for the NTarjan code farther below).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    // Since this situation is so unlikely, instead I've decided to bail out.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    // CNC 7/24/2001
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    C->record_method_not_compilable("unreachable loop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    91
  _blocks._cnt = number_of_blocks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // Tarjan is using 1-based arrays, so these are some initialize flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  tarjan[0]._size = tarjan[0]._semi = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  tarjan[0]._label = &tarjan[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
    97
  for (uint i = number_of_blocks(); i >= 2; i--) { // For all vertices in DFS order
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    Tarjan *w = &tarjan[i];     // Get vertex from DFS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    // Step 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    Node *whead = w->_block->head();
19279
4be3c2e6663c 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 13963
diff changeset
   102
    for (uint j = 1; j < whead->req(); j++) {
4be3c2e6663c 8022284: Hide internal data structure in PhaseCFG
adlertz
parents: 13963
diff changeset
   103
      Block* b = get_block_for_node(whead->in(j));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      Tarjan *vx = &tarjan[b->_pre_order];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
      Tarjan *u = vx->EVAL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
      if( u->_semi < w->_semi )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        w->_semi = u->_semi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    // w is added to a bucket here, and only here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    // Thus w is in at most one bucket and the sum of all bucket sizes is O(n).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    // Thus bucket can be a linked list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    // Thus we do not need a small integer name for each Block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    w->_bucket = tarjan[w->_semi]._bucket;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    tarjan[w->_semi]._bucket = w;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    w->_parent->LINK( w, &tarjan[0] );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    // Step 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    for( Tarjan *vx = w->_parent->_bucket; vx; vx = vx->_bucket ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      Tarjan *u = vx->EVAL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      vx->_dom = (u->_semi < vx->_semi) ? u : w->_parent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // Step 4:
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   127
  for (uint i = 2; i <= number_of_blocks(); i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    Tarjan *w = &tarjan[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    if( w->_dom != &tarjan[w->_semi] )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      w->_dom = w->_dom->_dom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    w->_dom_next = w->_dom_child = NULL;  // Initialize for building tree later
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // No immediate dominator for the root
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   134
  Tarjan *w = &tarjan[get_root_block()->_pre_order];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  w->_dom = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  w->_dom_next = w->_dom_child = NULL;  // Initialize for building tree later
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Convert the dominator tree array into my kind of graph
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   139
  for(uint i = 1; i <= number_of_blocks(); i++){ // For all Tarjan vertices
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    Tarjan *t = &tarjan[i];     // Handy access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    Tarjan *tdom = t->_dom;     // Handy access to immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if( tdom )  {               // Root has no immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      t->_block->_idom = tdom->_block; // Set immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      t->_dom_next = tdom->_dom_child; // Make me a sibling of parent's child
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      tdom->_dom_child = t;     // Make me a child of my parent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      t->_block->_idom = NULL;  // Root
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  }
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   149
  w->setdepth(number_of_blocks() + 1); // Set depth in dominator tree
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
class Block_Stack {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    struct Block_Descr {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
      Block  *block;     // Block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
      int    index;      // Index of block's successor pushed on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      int    freq_idx;   // Index of block's most frequent successor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    Block_Descr *_stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    Block_Descr *_stack_max;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    Block_Descr *_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    Tarjan *_tarjan;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    uint most_frequent_successor( Block *b );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    Block_Stack(Tarjan *tarjan, int size) : _tarjan(tarjan) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      _stack = NEW_RESOURCE_ARRAY(Block_Descr, size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      _stack_max = _stack + size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      _stack_top = _stack - 1; // stack is empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    void push(uint pre_order, Block *b) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
      Tarjan *t = &_tarjan[pre_order]; // Fast local access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      b->_pre_order = pre_order;    // Flag as visited
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      t->_block = b;                // Save actual block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      t->_semi = pre_order;         // Block to DFS map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      t->_label = t;                // DFS to vertex map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      t->_ancestor = NULL;          // Fast LINK & EVAL setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      t->_child = &_tarjan[0];      // Sentenial
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      t->_size = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
      t->_bucket = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      if (pre_order == 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        t->_parent = NULL;          // first block doesn't have parent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
      else {
2131
98f9cef66a34 6810672: Comment typos
twisti
parents: 1
diff changeset
   184
        // Save parent (current top block on stack) in DFS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        t->_parent = &_tarjan[_stack_top->block->_pre_order];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      // Now put this block on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
      ++_stack_top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      assert(_stack_top < _stack_max, ""); // assert if stack have to grow
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      _stack_top->block  = b;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      _stack_top->index  = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
      // Find the index into b->succs[] array of the most frequent successor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      _stack_top->freq_idx = most_frequent_successor(b); // freq_idx >= 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    Block* pop() { Block* b = _stack_top->block; _stack_top--; return b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    bool is_nonempty() { return (_stack_top >= _stack); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    bool last_successor() { return (_stack_top->index == _stack_top->freq_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    Block* next_successor()  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      int i = _stack_top->index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
      if (i == _stack_top->freq_idx) i++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      if (i >= (int)(_stack_top->block->_num_succs)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
        i = _stack_top->freq_idx;   // process most frequent successor last
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      _stack_top->index = i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      return _stack_top->block->_succs[ i ];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
// Find the index into the b->succs[] array of the most frequent successor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
uint Block_Stack::most_frequent_successor( Block *b ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  uint freq_idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  int eidx = b->end_idx();
19717
7819ffdaf0ff 8023691: Create interface for nodes in class Block
adlertz
parents: 19330
diff changeset
   214
  Node *n = b->get_node(eidx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  int op = n->is_Mach() ? n->as_Mach()->ideal_Opcode() : n->Opcode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  switch( op ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  case Op_CountedLoopEnd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  case Op_If: {               // Split frequency amongst children
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    float prob = n->as_MachIf()->_prob;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    // Is succ[0] the TRUE branch or the FALSE branch?
19717
7819ffdaf0ff 8023691: Create interface for nodes in class Block
adlertz
parents: 19330
diff changeset
   221
    if( b->get_node(eidx+1)->Opcode() == Op_IfFalse )
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      prob = 1.0f - prob;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    freq_idx = prob < PROB_FAIR;      // freq=1 for succ[0] < 0.5 prob
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  case Op_Catch:                // Split frequency amongst children
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    for( freq_idx = 0; freq_idx < b->_num_succs; freq_idx++ )
19717
7819ffdaf0ff 8023691: Create interface for nodes in class Block
adlertz
parents: 19330
diff changeset
   228
      if( b->get_node(eidx+1+freq_idx)->as_CatchProj()->_con == CatchProjNode::fall_through_index )
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    // Handle case of no fall-thru (e.g., check-cast MUST throw an exception)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    if( freq_idx == b->_num_succs ) freq_idx = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    // Currently there is no support for finding out the most
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    // frequent successor for jumps, so lets just make it the first one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  case Op_Jump:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  case Op_Root:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  case Op_Goto:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  case Op_NeverBranch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    freq_idx = 0;               // fall thru
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  case Op_TailCall:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  case Op_TailJump:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  case Op_Return:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  case Op_Halt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  case Op_Rethrow:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  return freq_idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
// Perform DFS search.  Setup 'vertex' as DFS to vertex mapping.  Setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// 'semi' as vertex to DFS mapping.  Set 'parent' to DFS parent.
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   255
uint PhaseCFG::do_DFS(Tarjan *tarjan, uint rpo_counter) {
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   256
  Block* root_block = get_root_block();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  uint pre_order = 1;
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   258
  // Allocate stack of size number_of_blocks() + 1 to avoid frequent realloc
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   259
  Block_Stack bstack(tarjan, number_of_blocks() + 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // Push on stack the state for the first block
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   262
  bstack.push(pre_order, root_block);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  ++pre_order;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  while (bstack.is_nonempty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    if (!bstack.last_successor()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
      // Walk over all successors in pre-order (DFS).
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   268
      Block* next_block = bstack.next_successor();
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   269
      if (next_block->_pre_order == 0) { // Check for no-pre-order, not-visited
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
        // Push on stack the state of successor
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   271
        bstack.push(pre_order, next_block);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
        ++pre_order;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      // Build a reverse post-order in the CFG _blocks array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      Block *stack_top = bstack.pop();
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   278
      stack_top->_rpo = --rpo_counter;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
      _blocks.map(stack_top->_rpo, stack_top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  return pre_order;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
void Tarjan::COMPRESS()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  assert( _ancestor != 0, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  if( _ancestor->_ancestor != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    _ancestor->COMPRESS( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    if( _ancestor->_label->_semi < _label->_semi )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
      _label = _ancestor->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    _ancestor = _ancestor->_ancestor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
Tarjan *Tarjan::EVAL() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  if( !_ancestor ) return _label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  COMPRESS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  return (_ancestor->_label->_semi >= _label->_semi) ? _label : _ancestor->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
void Tarjan::LINK( Tarjan *w, Tarjan *tarjan0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  Tarjan *s = w;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  while( w->_label->_semi < s->_child->_label->_semi ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    if( s->_size + s->_child->_child->_size >= (s->_child->_size << 1) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      s->_child->_ancestor = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      s->_child = s->_child->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      s->_child->_size = s->_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      s = s->_ancestor = s->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  s->_label = w->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  _size += w->_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  if( _size < (w->_size << 1) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    Tarjan *tmp = s; s = _child; _child = tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  while( s != tarjan0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    s->_ancestor = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    s = s->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
void Tarjan::setdepth( uint stack_size ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  Tarjan **top  = NEW_RESOURCE_ARRAY(Tarjan*, stack_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  Tarjan **next = top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  Tarjan **last;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  uint depth = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  *top = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  ++top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    // next level
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    ++depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    last = top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      // Set current depth for all tarjans on this level
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      Tarjan *t = *next;     // next tarjan from stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
      ++next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
        t->_block->_dom_depth = depth; // Set depth in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
        Tarjan *dom_child = t->_dom_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        t = t->_dom_next;    // next tarjan
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        if (dom_child != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
          *top = dom_child;  // save child on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
          ++top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      } while (t != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    } while (next < last);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  } while (last < top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
19330
49d6711171e6 8023003: Cleanup the public interface to PhaseCFG
adlertz
parents: 19279
diff changeset
   352
// Compute dominators on the Sea of Nodes form
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
// A data structure that holds all the information needed to find dominators.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
struct NTarjan {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  Node *_control;               // Control node associated with this info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  uint _semi;                   // Semi-dominators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  uint _size;                   // Used for faster LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  NTarjan *_parent;             // Parent in DFS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  NTarjan *_label;              // Used for LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  NTarjan *_ancestor;           // Used for LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  NTarjan *_child;              // Used for faster LINK and EVAL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  NTarjan *_dom;                // Parent in dominator tree (immediate dom)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  NTarjan *_bucket;             // Set of vertices with given semidominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  NTarjan *_dom_child;          // Child in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  NTarjan *_dom_next;           // Next in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  // Perform DFS search.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  // Setup 'vertex' as DFS to vertex mapping.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  // Setup 'semi' as vertex to DFS mapping.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  // Set 'parent' to DFS parent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  static int DFS( NTarjan *ntarjan, VectorSet &visited, PhaseIdealLoop *pil, uint *dfsorder );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  void setdepth( uint size, uint *dom_depth );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  // Fast union-find work
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  void COMPRESS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  NTarjan *EVAL(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  void LINK( NTarjan *w, NTarjan *ntarjan0 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  void dump(int offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
// Compute the dominator tree of the sea of nodes.  This version walks all CFG
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
// nodes (using the is_CFG() call) and places them in a dominator tree.  Thus,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
// it needs a count of the CFG nodes for the mapping table. This is the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
// Lengauer & Tarjan O(E-alpha(E,V)) algorithm.
3676
3bac3e882cd3 6862956: PhaseIdealLoop should have a CFG verification mode
never
parents: 2131
diff changeset
   389
void PhaseIdealLoop::Dominators() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  // Setup mappings from my Graph to Tarjan's stuff and back
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Note: Tarjan uses 1-based arrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  NTarjan *ntarjan = NEW_RESOURCE_ARRAY(NTarjan,C->unique()+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  // Initialize _control field for fast reference
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  for( i= C->unique()-1; i>=0; i-- )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    ntarjan[i]._control = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // Store the DFS order for the main loop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  uint *dfsorder = NEW_RESOURCE_ARRAY(uint,C->unique()+1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  memset(dfsorder, max_uint, (C->unique()+1) * sizeof(uint));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  // Tarjan's algorithm, almost verbatim:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  // Step 1:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  VectorSet visited(Thread::current()->resource_area());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  int dfsnum = NTarjan::DFS( ntarjan, visited, this, dfsorder);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // Tarjan is using 1-based arrays, so these are some initialize flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  ntarjan[0]._size = ntarjan[0]._semi = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  ntarjan[0]._label = &ntarjan[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  for( i = dfsnum-1; i>1; i-- ) {        // For all nodes in reverse DFS order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    NTarjan *w = &ntarjan[i];            // Get Node from DFS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    assert(w->_control != NULL,"bad DFS walk");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    // Step 2:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    Node *whead = w->_control;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    for( uint j=0; j < whead->req(); j++ ) { // For each predecessor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
      if( whead->in(j) == NULL || !whead->in(j)->is_CFG() )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
        continue;                            // Only process control nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      uint b = dfsorder[whead->in(j)->_idx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
      if(b == max_uint) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      NTarjan *vx = &ntarjan[b];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      NTarjan *u = vx->EVAL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      if( u->_semi < w->_semi )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
        w->_semi = u->_semi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    // w is added to a bucket here, and only here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    // Thus w is in at most one bucket and the sum of all bucket sizes is O(n).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    // Thus bucket can be a linked list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    w->_bucket = ntarjan[w->_semi]._bucket;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    ntarjan[w->_semi]._bucket = w;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
    w->_parent->LINK( w, &ntarjan[0] );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    // Step 3:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    for( NTarjan *vx = w->_parent->_bucket; vx; vx = vx->_bucket ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      NTarjan *u = vx->EVAL();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      vx->_dom = (u->_semi < vx->_semi) ? u : w->_parent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
    // Cleanup any unreachable loops now.  Unreachable loops are loops that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
    // flow into the main graph (and hence into ROOT) but are not reachable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    // from above.  Such code is dead, but requires a global pass to detect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    // it; this global pass was the 'build_loop_tree' pass run just prior.
3676
3bac3e882cd3 6862956: PhaseIdealLoop should have a CFG verification mode
never
parents: 2131
diff changeset
   447
    if( !_verify_only && whead->is_Region() ) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
      for( uint i = 1; i < whead->req(); i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
        if (!has_node(whead->in(i))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
          // Kill dead input path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
          assert( !visited.test(whead->in(i)->_idx),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
                  "input with no loop must be dead" );
12958
009b6c9586d8 7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents: 7397
diff changeset
   453
          _igvn.delete_input_of(whead, i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
          for (DUIterator_Fast jmax, j = whead->fast_outs(jmax); j < jmax; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
            Node* p = whead->fast_out(j);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
            if( p->is_Phi() ) {
12958
009b6c9586d8 7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
kvn
parents: 7397
diff changeset
   457
              _igvn.delete_input_of(p, i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
          i--;                  // Rerun same iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
        } // End of if dead input path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
      } // End of for all input paths
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    } // End if if whead is a Region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  } // End of for all Nodes in reverse DFS order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  // Step 4:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  for( i=2; i < dfsnum; i++ ) { // DFS order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    NTarjan *w = &ntarjan[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    assert(w->_control != NULL,"Bad DFS walk");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    if( w->_dom != &ntarjan[w->_semi] )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
      w->_dom = w->_dom->_dom;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    w->_dom_next = w->_dom_child = NULL;  // Initialize for building tree later
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  // No immediate dominator for the root
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  NTarjan *w = &ntarjan[dfsorder[C->root()->_idx]];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  w->_dom = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  w->_parent = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  w->_dom_next = w->_dom_child = NULL;  // Initialize for building tree later
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  // Convert the dominator tree array into my kind of graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  for( i=1; i<dfsnum; i++ ) {          // For all Tarjan vertices
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
    NTarjan *t = &ntarjan[i];          // Handy access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    assert(t->_control != NULL,"Bad DFS walk");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    NTarjan *tdom = t->_dom;           // Handy access to immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    if( tdom )  {                      // Root has no immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
      _idom[t->_control->_idx] = tdom->_control; // Set immediate dominator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      t->_dom_next = tdom->_dom_child; // Make me a sibling of parent's child
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      tdom->_dom_child = t;            // Make me a child of my parent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    } else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
      _idom[C->root()->_idx] = NULL; // Root
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  w->setdepth( C->unique()+1, _dom_depth ); // Set depth in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // Pick up the 'top' node as well
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  _idom     [C->top()->_idx] = C->root();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  _dom_depth[C->top()->_idx] = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  // Debug Print of Dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  if( PrintDominators ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    w->dump(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
// Perform DFS search.  Setup 'vertex' as DFS to vertex mapping.  Setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
// 'semi' as vertex to DFS mapping.  Set 'parent' to DFS parent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
int NTarjan::DFS( NTarjan *ntarjan, VectorSet &visited, PhaseIdealLoop *pil, uint *dfsorder) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  // Allocate stack of size C->unique()/8 to avoid frequent realloc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  GrowableArray <Node *> dfstack(pil->C->unique() >> 3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  Node *b = pil->C->root();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  int dfsnum = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  dfsorder[b->_idx] = dfsnum; // Cache parent's dfsnum for a later use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  dfstack.push(b);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  while (dfstack.is_nonempty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    b = dfstack.pop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    if( !visited.test_set(b->_idx) ) { // Test node and flag it as visited
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      NTarjan *w = &ntarjan[dfsnum];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
      // Only fully process control nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      w->_control = b;                 // Save actual node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      // Use parent's cached dfsnum to identify "Parent in DFS"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      w->_parent = &ntarjan[dfsorder[b->_idx]];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      dfsorder[b->_idx] = dfsnum;      // Save DFS order info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      w->_semi = dfsnum;               // Node to DFS map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      w->_label = w;                   // DFS to vertex map
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      w->_ancestor = NULL;             // Fast LINK & EVAL setup
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      w->_child = &ntarjan[0];         // Sentinal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      w->_size = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
      w->_bucket = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      // Need DEF-USE info for this pass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
      for ( int i = b->outcnt(); i-- > 0; ) { // Put on stack backwards
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        Node* s = b->raw_out(i);       // Get a use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        // CFG nodes only and not dead stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
        if( s->is_CFG() && pil->has_node(s) && !visited.test(s->_idx) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
          dfsorder[s->_idx] = dfsnum;  // Cache parent's dfsnum for a later use
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
          dfstack.push(s);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
      dfsnum++;  // update after parent's dfsnum has been cached.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  return dfsnum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
void NTarjan::COMPRESS()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  assert( _ancestor != 0, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  if( _ancestor->_ancestor != 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
    _ancestor->COMPRESS( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    if( _ancestor->_label->_semi < _label->_semi )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
      _label = _ancestor->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    _ancestor = _ancestor->_ancestor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
NTarjan *NTarjan::EVAL() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  if( !_ancestor ) return _label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  COMPRESS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  return (_ancestor->_label->_semi >= _label->_semi) ? _label : _ancestor->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
void NTarjan::LINK( NTarjan *w, NTarjan *ntarjan0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
  NTarjan *s = w;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  while( w->_label->_semi < s->_child->_label->_semi ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    if( s->_size + s->_child->_child->_size >= (s->_child->_size << 1) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
      s->_child->_ancestor = s;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
      s->_child = s->_child->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
      s->_child->_size = s->_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
      s = s->_ancestor = s->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  s->_label = w->_label;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  _size += w->_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  if( _size < (w->_size << 1) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    NTarjan *tmp = s; s = _child; _child = tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  while( s != ntarjan0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    s->_ancestor = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    s = s->_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
void NTarjan::setdepth( uint stack_size, uint *dom_depth ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  NTarjan **top  = NEW_RESOURCE_ARRAY(NTarjan*, stack_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  NTarjan **next = top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  NTarjan **last;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  uint depth = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  *top = this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  ++top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    // next level
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
    ++depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    last = top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
    do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
      // Set current depth for all tarjans on this level
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
      NTarjan *t = *next;    // next tarjan from stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
      ++next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
      do {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
        dom_depth[t->_control->_idx] = depth; // Set depth in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
        NTarjan *dom_child = t->_dom_child;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
        t = t->_dom_next;    // next tarjan
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
        if (dom_child != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
          *top = dom_child;  // save child on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
          ++top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
      } while (t != NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    } while (next < last);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  } while (last < top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
void NTarjan::dump(int offset) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  // Dump the data from this node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  for(i = offset; i >0; i--)  // Use indenting for tree structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
    tty->print("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  tty->print("Dominator Node: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  _control->dump();               // Control node for this dom node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  tty->print("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  for(i = offset; i >0; i--)      // Use indenting for tree structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    tty->print("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  tty->print("semi:%d, size:%d\n",_semi, _size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  for(i = offset; i >0; i--)      // Use indenting for tree structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    tty->print("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  tty->print("DFS Parent: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  if(_parent != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    _parent->_control->dump();    // Parent in DFS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  tty->print("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  for(i = offset; i >0; i--)      // Use indenting for tree structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    tty->print("  ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  tty->print("Dom Parent: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  if(_dom != NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
    _dom->_control->dump();       // Parent in Dominator Tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  tty->print("\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  // Recurse over remaining tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  if( _dom_child ) _dom_child->dump(offset+2);   // Children in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  if( _dom_next  ) _dom_next ->dump(offset  );   // Siblings in dominator tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
#endif