RFR: 8367320: Sort cpu/x86 includes [v2]

Stefan Karlsson stefank at openjdk.org
Fri Sep 12 15:02:24 UTC 2025


On Fri, 12 Sep 2025 13:27:52 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

>> Just note that we currently don't have a consistent way that we structure the inclusions of our the platform dependent files. When making the patch that followed the  "corresponding .hpp" rule I had to handle the includes on case-by-case basis. Just be warned that you might create a rule that we can't adhere to without rewriting some of the includes patterns.
>
> Hi @stefank, I've just opened #27259.
> 
>> Just be warned that you might create a rule that we can't adhere to without rewriting some of the includes patterns.
> 
> What do you mean? Do you have an example?

For example, take a look at the various frame* files:

frame.inline.hpp include frame.hpp - this is according to our rules
frame.hpp does one of our weird tricks to include the frame_<cpu>.hpp straight into the middle of the frame class (via the CPU_HEADER macro).
frame_<cpu>.inline.hpp can therefore not include the corresponding frame_<cpu>.hpp because if it did it would include the cpu-dependent parts of the frame class and that will not work.

Another think one has to consider is if the includes are written so that the platform files can be included stand-alone or not:

Sometimes we have this include order:
file.inline.hpp includes file.hpp and file_<cpu>.inline.hpp
file_<cpu>.inline.hpp doesn't include file.hpp because the only way to use file_<cpu>.inline.hpp is to include file.inline.hpp. file_<cpu>.inline.hpp can't be included stand-alone.

Sometimes we the opposite include order:
file_<cpu>.inline.hpp includes file.inline.hpp, which includes file.hpp, and file_<cpu>.inline.hpp can be included stand-alone.

If you are going to write a style guide for the platform includes you need to go through our includes and see if your proposal matches what we have. If not, you need to figure out if there's some refactoring that can be done to change files to match the proposal.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27189#discussion_r2344516463


More information about the hotspot-dev mailing list