# HG changeset patch # User roland # Date 1487208397 28800 # Wed Feb 15 17:26:37 2017 -0800 # Node ID a9cbaff50d3d7e3a1d2dbdc0121c470142b87270 # Parent 15922b2f31db4857ec84efdf533c41b19e68030b 8174164, PR3334, RH1417266: SafePointNode::_replaced_nodes breaks with irreducible loops Reviewed-by: kvn diff --git a/src/share/vm/opto/callnode.hpp b/src/share/vm/opto/callnode.hpp --- openjdk/hotspot/src/share/vm/opto/callnode.hpp +++ openjdk/hotspot/src/share/vm/opto/callnode.hpp @@ -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); diff --git a/src/share/vm/opto/parse1.cpp b/src/share/vm/opto/parse1.cpp --- openjdk/hotspot/src/share/vm/opto/parse1.cpp +++ openjdk/hotspot/src/share/vm/opto/parse1.cpp @@ -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------------------------------- diff --git a/src/share/vm/opto/replacednodes.cpp b/src/share/vm/opto/replacednodes.cpp --- openjdk/hotspot/src/share/vm/opto/replacednodes.cpp +++ openjdk/hotspot/src/share/vm/opto/replacednodes.cpp @@ -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()); + } } } diff --git a/src/share/vm/opto/replacednodes.hpp b/src/share/vm/opto/replacednodes.hpp --- openjdk/hotspot/src/share/vm/opto/replacednodes.hpp +++ openjdk/hotspot/src/share/vm/opto/replacednodes.hpp @@ -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;