JDK-8277496 : Remove duplication in c1 Block successor lists
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 18
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-11-19
  • Updated: 2022-03-30
  • Resolved: 2021-12-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 b27Fixed
Related Reports
Blocks :  
Blocks :  
Duplicate :  
Relates :  
Relates :  
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. 
Comments
Changeset: 8d190dd0 Author: Ludvig Janiuk <ludvig.j.janiuk@oracle.com> Committer: Nils Eliasson <neliasso@openjdk.org> Date: 2021-12-06 08:58:41 +0000 URL: https://git.openjdk.java.net/jdk/commit/8d190dd003c58aa9ebb403e95a73a128af7e8941
06-12-2021

Looks like backport to 11 would be pretty clean too
03-12-2021

Backport to 17 would be very clean
03-12-2021

I think it would be valuable to backport this to 17. 11 is a different question - I need to investigate how much the code in this area has been changing.
02-12-2021