RFR: 8367320: Sort cpu/x86 includes [v2]
Albert Mingkun Yang
ayang at openjdk.org
Fri Sep 12 18:46:21 UTC 2025
On Fri, 12 Sep 2025 16:11:21 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:
>> 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.
> Another think one has to consider is if the includes are written so that the platform files can be included stand-alone or not
If a header file (hpp or inline.hpp) can not be included stand alone, I would even argue it's not really a proper header file.
Even though `#include` is indeed just copy-and-paste, the use of `#include CPU_HEADER(frame)` still feels like an overuse of C/C++ header includes. I think those "improper" header files can "stand out" if they are named differently from ordinary one, maybe sth like `frame_X.partial.hpp`. My 2c.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27189#discussion_r2345139816
More information about the hotspot-dev
mailing list