RFR: 8367320: Sort cpu/x86 includes [v2]
Francesco Andreuzzi
fandreuzzi at openjdk.org
Fri Sep 12 16:14:22 UTC 2025
On Fri, 12 Sep 2025 14:59:45 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> 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.
Thanks for the detailed summary, indeed it looks like my initial proposal is not enough to address all cases. I'll think about it and go through the cases as you suggested.
For the time being, I moved #27259 to draft.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27189#discussion_r2344728131
More information about the hotspot-dev
mailing list