changeset 50648:b3e97e932e05

8201532: Update idom to get correct dom depth calculation Summary: Assert due to dom depth calculation on old idom Reviewed-by: roland
author neliasso
date Mon, 14 May 2018 14:10:50 +0200
parents 92560438d306
children 78d93a34b81d
files src/hotspot/share/opto/loopnode.cpp src/hotspot/share/opto/loopnode.hpp
diffstat 2 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/loopnode.cpp	Mon May 14 09:40:48 2018 -0300
+++ b/src/hotspot/share/opto/loopnode.cpp	Mon May 14 14:10:50 2018 +0200
@@ -3218,10 +3218,16 @@
 void PhaseIdealLoop::recompute_dom_depth() {
   uint no_depth_marker = C->unique();
   uint i;
-  // Initialize depth to "no depth yet"
+  // Initialize depth to "no depth yet" and realize all lazy updates
   for (i = 0; i < _idom_size; i++) {
+    // Only indices with a _dom_depth has a Node* or NULL (otherwise uninitalized).
     if (_dom_depth[i] > 0 && _idom[i] != NULL) {
-     _dom_depth[i] = no_depth_marker;
+      _dom_depth[i] = no_depth_marker;
+
+      // heal _idom if it has a fwd mapping in _nodes
+      if (_idom[i]->in(0) == NULL) {
+        idom(i);
+      }
     }
   }
   if (_dom_stk == NULL) {
--- a/src/hotspot/share/opto/loopnode.hpp	Mon May 14 09:40:48 2018 -0300
+++ b/src/hotspot/share/opto/loopnode.hpp	Mon May 14 14:10:50 2018 +0200
@@ -852,27 +852,35 @@
   // Array of immediate dominance info for each CFG node indexed by node idx
 private:
   uint _idom_size;
-  Node **_idom;                 // Array of immediate dominators
-  uint *_dom_depth;           // Used for fast LCA test
+  Node **_idom;                  // Array of immediate dominators
+  uint *_dom_depth;              // Used for fast LCA test
   GrowableArray<uint>* _dom_stk; // For recomputation of dom depth
 
   Node* idom_no_update(Node* d) const {
-    assert(d->_idx < _idom_size, "oob");
-    Node* n = _idom[d->_idx];
+    return idom_no_update(d->_idx);
+  }
+
+  Node* idom_no_update(uint didx) const {
+    assert(didx < _idom_size, "oob");
+    Node* n = _idom[didx];
     assert(n != NULL,"Bad immediate dominator info.");
-    while (n->in(0) == NULL) {  // Skip dead CFG nodes
-      //n = n->in(1);
+    while (n->in(0) == NULL) { // Skip dead CFG nodes
       n = (Node*)(((intptr_t)_nodes[n->_idx]) & ~1);
       assert(n != NULL,"Bad immediate dominator info.");
     }
     return n;
   }
+
   Node *idom(Node* d) const {
-    uint didx = d->_idx;
-    Node *n = idom_no_update(d);
-    _idom[didx] = n;            // Lazily remove dead CFG nodes from table.
+    return idom(d->_idx);
+  }
+
+  Node *idom(uint didx) const {
+    Node *n = idom_no_update(didx);
+    _idom[didx] = n; // Lazily remove dead CFG nodes from table.
     return n;
   }
+
   uint dom_depth(Node* d) const {
     guarantee(d != NULL, "Null dominator info.");
     guarantee(d->_idx < _idom_size, "");