Skip to content

Commit

Permalink
8254369: Node::disconnect_inputs may skip precedences
Browse files Browse the repository at this point in the history
disconnect_inputs() needs to iterate precedences edges in reverse order because rm_prec(i) may backfill _in[i] with a value afterward.
also remove the predicate if (n != NULL) in set_prec because it's always true.

Reviewed-by: kvn, redestad
  • Loading branch information
Xin Liu authored and Vladimir Kozlov committed Oct 16, 2020
1 parent 96bb6e7 commit bdda205
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/hotspot/share/opto/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,14 @@ int Node::replace_edges_in_range(Node* old, Node* neww, int start, int end) {
//-------------------------disconnect_inputs-----------------------------------
// NULL out all inputs to eliminate incoming Def-Use edges.
void Node::disconnect_inputs(Compile* C) {
// the layout of Node::_in
// r: a required input, null is allowed
// p: a precedence, null values are all at the end
// -----------------------------------
// |r|...|r|p|...|p|null|...|null|
// | |
// req() len()
// -----------------------------------
for (uint i = 0; i < req(); ++i) {
if (in(i) != nullptr) {
set_req(i, nullptr);
Expand All @@ -903,10 +911,17 @@ void Node::disconnect_inputs(Compile* C) {

// Remove precedence edges if any exist
// Note: Safepoints may have precedence edges, even during parsing
for (uint i = req(); i < len(); ++i) {
set_prec(i, nullptr);
for (uint i = len(); i > req(); ) {
rm_prec(--i); // no-op if _in[i] is nullptr
}

#ifdef ASSERT
// sanity check
for (uint i = 0; i < len(); ++i) {
assert(_in[i] == nullptr, "disconnect_inputs() failed!");
}
#endif

// Node::destruct requires all out edges be deleted first
// debug_only(destruct();) // no reuse benefit expected
C->record_dead_node(_idx);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class Node {
}
if (_in[i] != NULL) _in[i]->del_out((Node *)this);
_in[i] = n;
if (n != NULL) n->add_out((Node *)this);
n->add_out((Node *)this);
}

// Set this node's index, used by cisc_version to replace current node
Expand Down

1 comment on commit bdda205

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on bdda205 Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.