Description
The list of successors of a block in c1 seems to not have a single source of truth, but be duplicated in `BlockBegin::_successors` and `BlockEnd::_sux`. Removing this duplication would simplify a lot of verification code, and remove bug surface area.
Some hints that this is a true duplication:
c1_Instruction performs assertions on matching before element access:
```
inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); }
inline void BlockBegin::add_successor(BlockBegin* sux) { assert(_end == NULL, "Would create mismatch with successors of BlockEnd"); _successors.append(sux); }
```
And the _successor field is commented as "factor out later":
```
// SSA specific fields: (factor out later)
BlockList _successors; // the successors of this block
BlockList _predecessors; // the predecessors of this block
BlockList _dominates; // list of blocks that are dominated by this block
BlockBegin* _dominator; // the dominator of this block
// SSA specific ends
```
It's possible that all four of these fields should be factored out.
Some hints that this is a true duplication:
c1_Instruction performs assertions on matching before element access:
```
inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); }
inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); }
inline void BlockBegin::add_successor(BlockBegin* sux) { assert(_end == NULL, "Would create mismatch with successors of BlockEnd"); _successors.append(sux); }
```
And the _successor field is commented as "factor out later":
```
// SSA specific fields: (factor out later)
BlockList _successors; // the successors of this block
BlockList _predecessors; // the predecessors of this block
BlockList _dominates; // list of blocks that are dominated by this block
BlockBegin* _dominator; // the dominator of this block
// SSA specific ends
```
It's possible that all four of these fields should be factored out.
Attachments
Issue Links
- blocks
-
JDK-8258603 c1 IR::verify is expensive
- Resolved
- duplicates
-
JDK-8277808 Remove dead code (in) BlockEnd::set_begin
- Closed
- is blocked by
-
JDK-8277562 Remove dead method c1 If::swap_sux
- Resolved
- relates to
-
JDK-8279533 Bad indentation and missing curly braces in BlockBegin::set_end
- Resolved
-
JDK-8283890 Changes in CFG file format break C1Visualizer
- Resolved
(2 links to)