Wed, 15 Feb 2017 17:26:37 -0800
8174164: SafePointNode::_replaced_nodes breaks with irreducible loops
Reviewed-by: kvn
1.1 --- a/src/share/vm/opto/callnode.hpp Mon May 01 10:54:10 2017 -0700 1.2 +++ b/src/share/vm/opto/callnode.hpp Wed Feb 15 17:26:37 2017 -0800 1.3 @@ -449,8 +449,8 @@ 1.4 void delete_replaced_nodes() { 1.5 _replaced_nodes.reset(); 1.6 } 1.7 - void apply_replaced_nodes() { 1.8 - _replaced_nodes.apply(this); 1.9 + void apply_replaced_nodes(uint idx) { 1.10 + _replaced_nodes.apply(this, idx); 1.11 } 1.12 void merge_replaced_nodes_with(SafePointNode* sfpt) { 1.13 _replaced_nodes.merge_with(sfpt->_replaced_nodes);
2.1 --- a/src/share/vm/opto/parse1.cpp Mon May 01 10:54:10 2017 -0700 2.2 +++ b/src/share/vm/opto/parse1.cpp Wed Feb 15 17:26:37 2017 -0800 2.3 @@ -1048,7 +1048,7 @@ 2.4 kit.make_dtrace_method_exit(method()); 2.5 } 2.6 if (_replaced_nodes_for_exceptions) { 2.7 - kit.map()->apply_replaced_nodes(); 2.8 + kit.map()->apply_replaced_nodes(_new_idx); 2.9 } 2.10 // Done with exception-path processing. 2.11 ex_map = kit.make_exception_state(ex_oop); 2.12 @@ -1069,7 +1069,7 @@ 2.13 _exits.add_exception_state(ex_map); 2.14 } 2.15 } 2.16 - _exits.map()->apply_replaced_nodes(); 2.17 + _exits.map()->apply_replaced_nodes(_new_idx); 2.18 } 2.19 2.20 //-----------------------------create_entry_map-------------------------------
3.1 --- a/src/share/vm/opto/replacednodes.cpp Mon May 01 10:54:10 2017 -0700 3.2 +++ b/src/share/vm/opto/replacednodes.cpp Wed Feb 15 17:26:37 2017 -0800 3.3 @@ -91,13 +91,17 @@ 3.4 } 3.5 3.6 // Perfom node replacement (used when returning to caller) 3.7 -void ReplacedNodes::apply(Node* n) { 3.8 +void ReplacedNodes::apply(Node* n, uint idx) { 3.9 if (is_empty()) { 3.10 return; 3.11 } 3.12 for (int i = 0; i < _replaced_nodes->length(); i++) { 3.13 ReplacedNode replaced = _replaced_nodes->at(i); 3.14 - n->replace_edge(replaced.initial(), replaced.improved()); 3.15 + // Only apply if improved node was created in a callee to avoid 3.16 + // issues with irreducible loops in the caller 3.17 + if (replaced.improved()->_idx >= idx) { 3.18 + n->replace_edge(replaced.initial(), replaced.improved()); 3.19 + } 3.20 } 3.21 } 3.22
4.1 --- a/src/share/vm/opto/replacednodes.hpp Mon May 01 10:54:10 2017 -0700 4.2 +++ b/src/share/vm/opto/replacednodes.hpp Wed Feb 15 17:26:37 2017 -0800 4.3 @@ -71,7 +71,7 @@ 4.4 void record(Node* initial, Node* improved); 4.5 void transfer_from(const ReplacedNodes& other, uint idx); 4.6 void reset(); 4.7 - void apply(Node* n); 4.8 + void apply(Node* n, uint idx); 4.9 void merge_with(const ReplacedNodes& other); 4.10 bool is_empty() const; 4.11 void dump(outputStream *st) const;