changeset 8264:3ff8d0b5a04b

8174164: SafePointNode::_replaced_nodes breaks with irreducible loops Reviewed-by: kvn
author roland
date Wed, 15 Feb 2017 17:26:37 -0800
parents a8b80d85ef39
children b1f3fbe39975
files src/share/vm/opto/callnode.hpp src/share/vm/opto/parse1.cpp src/share/vm/opto/replacednodes.cpp src/share/vm/opto/replacednodes.hpp
diffstat 4 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/callnode.hpp	Mon May 01 10:54:10 2017 -0700
+++ b/src/share/vm/opto/callnode.hpp	Wed Feb 15 17:26:37 2017 -0800
@@ -449,8 +449,8 @@
   void delete_replaced_nodes() {
     _replaced_nodes.reset();
   }
-  void apply_replaced_nodes() {
-    _replaced_nodes.apply(this);
+  void apply_replaced_nodes(uint idx) {
+    _replaced_nodes.apply(this, idx);
   }
   void merge_replaced_nodes_with(SafePointNode* sfpt) {
     _replaced_nodes.merge_with(sfpt->_replaced_nodes);
--- a/src/share/vm/opto/parse1.cpp	Mon May 01 10:54:10 2017 -0700
+++ b/src/share/vm/opto/parse1.cpp	Wed Feb 15 17:26:37 2017 -0800
@@ -1048,7 +1048,7 @@
         kit.make_dtrace_method_exit(method());
       }
       if (_replaced_nodes_for_exceptions) {
-        kit.map()->apply_replaced_nodes();
+        kit.map()->apply_replaced_nodes(_new_idx);
       }
       // Done with exception-path processing.
       ex_map = kit.make_exception_state(ex_oop);
@@ -1069,7 +1069,7 @@
       _exits.add_exception_state(ex_map);
     }
   }
-  _exits.map()->apply_replaced_nodes();
+  _exits.map()->apply_replaced_nodes(_new_idx);
 }
 
 //-----------------------------create_entry_map-------------------------------
--- a/src/share/vm/opto/replacednodes.cpp	Mon May 01 10:54:10 2017 -0700
+++ b/src/share/vm/opto/replacednodes.cpp	Wed Feb 15 17:26:37 2017 -0800
@@ -91,13 +91,17 @@
 }
 
 // Perfom node replacement (used when returning to caller)
-void ReplacedNodes::apply(Node* n) {
+void ReplacedNodes::apply(Node* n, uint idx) {
   if (is_empty()) {
     return;
   }
   for (int i = 0; i < _replaced_nodes->length(); i++) {
     ReplacedNode replaced = _replaced_nodes->at(i);
-    n->replace_edge(replaced.initial(), replaced.improved());
+    // Only apply if improved node was created in a callee to avoid
+    // issues with irreducible loops in the caller
+    if (replaced.improved()->_idx >= idx) {
+      n->replace_edge(replaced.initial(), replaced.improved());
+    }
   }
 }
 
--- a/src/share/vm/opto/replacednodes.hpp	Mon May 01 10:54:10 2017 -0700
+++ b/src/share/vm/opto/replacednodes.hpp	Wed Feb 15 17:26:37 2017 -0800
@@ -71,7 +71,7 @@
   void record(Node* initial, Node* improved);
   void transfer_from(const ReplacedNodes& other, uint idx);
   void reset();
-  void apply(Node* n);
+  void apply(Node* n, uint idx);
   void merge_with(const ReplacedNodes& other);
   bool is_empty() const;
   void dump(outputStream *st) const;