Skip to content
Permalink
Browse files
8265914: Duplicated NotANode and not_a_node
Reviewed-by: thartmann
  • Loading branch information
Yi Yang authored and TobiHartmann committed Apr 27, 2021
1 parent 9481fad commit fbfd4ea3ceb4e19ebc0f77c4e2aa6728894dfc31
@@ -287,13 +287,6 @@ void Compile::gvn_replace_by(Node* n, Node* nn) {
}


static inline bool not_a_node(const Node* n) {
if (n == NULL) return true;
if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc.
if (*(address*)n == badAddress) return true; // kill by Node::destruct
return false;
}

// Identify all nodes that are reachable from below, useful.
// Use breadth-first pass that records state in a Unique_Node_List,
// recursive traversal is slower.
@@ -140,7 +140,7 @@ void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is
void ProjNode::dump_compact_spec(outputStream *st) const {
for (DUIterator i = this->outs(); this->has_out(i); i++) {
Node* o = this->out(i);
if (NotANode(o)) {
if (not_a_node(o)) {
st->print("[?]");
} else if (o == NULL) {
st->print("[_]");
@@ -1659,7 +1659,7 @@ Node* Node::find(const int idx, bool only_ctrl) {
}

bool Node::add_to_worklist(Node* n, Node_List* worklist, Arena* old_arena, VectorSet* old_space, VectorSet* new_space) {
if (NotANode(n)) {
if (not_a_node(n)) {
return false; // Gracefully handle NULL, -1, 0xabababab, etc.
}

@@ -1687,14 +1687,14 @@ static bool is_disconnected(const Node* n) {
void Node::dump_orig(outputStream *st, bool print_key) const {
Compile* C = Compile::current();
Node* orig = _debug_orig;
if (NotANode(orig)) orig = NULL;
if (not_a_node(orig)) orig = NULL;
if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
if (orig == NULL) return;
if (print_key) {
st->print(" !orig=");
}
Node* fast = orig->debug_orig(); // tortoise & hare algorithm to detect loops
if (NotANode(fast)) fast = NULL;
if (not_a_node(fast)) fast = NULL;
while (orig != NULL) {
bool discon = is_disconnected(orig); // if discon, print [123] else 123
if (discon) st->print("[");
@@ -1703,16 +1703,16 @@ void Node::dump_orig(outputStream *st, bool print_key) const {
st->print("%d", orig->_idx);
if (discon) st->print("]");
orig = orig->debug_orig();
if (NotANode(orig)) orig = NULL;
if (not_a_node(orig)) orig = NULL;
if (orig != NULL && !C->node_arena()->contains(orig)) orig = NULL;
if (orig != NULL) st->print(",");
if (fast != NULL) {
// Step fast twice for each single step of orig:
fast = fast->debug_orig();
if (NotANode(fast)) fast = NULL;
if (not_a_node(fast)) fast = NULL;
if (fast != NULL && fast != orig) {
fast = fast->debug_orig();
if (NotANode(fast)) fast = NULL;
if (not_a_node(fast)) fast = NULL;
}
if (fast == orig) {
st->print("...");
@@ -1725,7 +1725,7 @@ void Node::dump_orig(outputStream *st, bool print_key) const {
void Node::set_debug_orig(Node* orig) {
_debug_orig = orig;
if (BreakAtNode == 0) return;
if (NotANode(orig)) orig = NULL;
if (not_a_node(orig)) orig = NULL;
int trip = 10;
while (orig != NULL) {
if (orig->debug_idx() == BreakAtNode || (int)orig->_idx == BreakAtNode) {
@@ -1734,7 +1734,7 @@ void Node::set_debug_orig(Node* orig) {
BREAKPOINT;
}
orig = orig->debug_orig();
if (NotANode(orig)) orig = NULL;
if (not_a_node(orig)) orig = NULL;
if (trip-- <= 0) break;
}
}
@@ -1830,8 +1830,8 @@ void Node::dump_req(outputStream *st) const {
Node* d = in(i);
if (d == NULL) {
st->print("_ ");
} else if (NotANode(d)) {
st->print("NotANode "); // uninitialized, sentinel, garbage, etc.
} else if (not_a_node(d)) {
st->print("not_a_node "); // uninitialized, sentinel, garbage, etc.
} else {
st->print("%c%d ", Compile::current()->node_arena()->contains(d) ? ' ' : 'o', d->_idx);
}
@@ -1847,7 +1847,7 @@ void Node::dump_prec(outputStream *st) const {
Node* p = in(i);
if (p != NULL) {
if (!any_prec++) st->print(" |");
if (NotANode(p)) { st->print("NotANode "); continue; }
if (not_a_node(p)) { st->print("not_a_node "); continue; }
st->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx);
}
}
@@ -1862,8 +1862,8 @@ void Node::dump_out(outputStream *st) const {
Node* u = _out[i];
if (u == NULL) {
st->print("_ ");
} else if (NotANode(u)) {
st->print("NotANode ");
} else if (not_a_node(u)) {
st->print("not_a_node ");
} else {
st->print("%c%d ", Compile::current()->node_arena()->contains(u) ? ' ' : 'o', u->_idx);
}
@@ -1900,7 +1900,7 @@ static void collect_nodes_i(GrowableArray<Node*>* queue, const Node* start, int
for(uint k = 0; k < limit; k++) {
Node* n = direction > 0 ? tp->in(k) : tp->raw_out(k);

if (NotANode(n)) continue;
if (not_a_node(n)) continue;
// do not recurse through top or the root (would reach unrelated stuff)
if (n->is_Root() || n->is_top()) continue;
if (only_ctrl && !n->is_CFG()) continue;
@@ -1921,7 +1921,7 @@ static void collect_nodes_i(GrowableArray<Node*>* queue, const Node* start, int

//------------------------------dump_nodes-------------------------------------
static void dump_nodes(const Node* start, int d, bool only_ctrl) {
if (NotANode(start)) return;
if (not_a_node(start)) return;

GrowableArray <Node *> queue(Compile::current()->live_nodes());
collect_nodes_i(&queue, start, d, (uint) ABS(d), true, only_ctrl, false);
@@ -2089,7 +2089,7 @@ static void collect_nodes_in(Node* start, GrowableArray<Node*> *ns, bool primary
Node* current = nodes.at(n_idx++);
for (uint i = 0; i < current->len(); i++) {
Node* n = current->in(i);
if (NotANode(n)) {
if (not_a_node(n)) {
continue;
}
if ((primary_is_data && n->is_CFG()) || (!primary_is_data && !n->is_CFG())) {
@@ -2151,7 +2151,7 @@ void Node::collect_nodes_out_all_ctrl_boundary(GrowableArray<Node*> *ns) const {
nodes.push((Node*) this);
while (nodes.length() > 0) {
Node* current = nodes.pop();
if (NotANode(current)) {
if (not_a_node(current)) {
continue;
}
ns->append_if_missing(current);
@@ -1250,20 +1250,13 @@ class Node {
}
};


#ifndef PRODUCT

// Used in debugging code to avoid walking across dead or uninitialized edges.
inline bool NotANode(const Node* n) {
inline bool not_a_node(const Node* n) {
if (n == NULL) return true;
if (((intptr_t)n & 1) != 0) return true; // uninitialized, etc.
if (*(address*)n == badAddress) return true; // kill by Node::destruct
return false;
}

#endif


//-----------------------------------------------------------------------------
// Iterators over DU info, and associated Node functions.

@@ -152,7 +152,7 @@ public Node in(int i) {
for(int k = 0; k < limit; k++) {
Node n = d > 0 ? tp.in(k) : tp.rawOut(k);

// if (NotANode(n)) continue;
// if (not_a_node(n)) continue;
if (n == null) continue;
// do not recurse through top or the root (would reach unrelated stuff)
// if (n.isRoot() || n.isTop()) continue;
@@ -254,8 +254,8 @@ void dumpOut(PrintStream out) {
Node u = rawOut(i);
if (u == null) {
out.print("_ ");
// } else if (NotANode(u)) {
// out.print("NotANode ");
// } else if (not_a_node(u)) {
// out.print("not_a_node ");
} else {
// out.print("%c%d ", Compile::current()->nodeArena()->contains(u) ? ' ' : 'o', u->_idx);
out.print(' ');

1 comment on commit fbfd4ea

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on fbfd4ea Apr 27, 2021

Please sign in to comment.