RFR: 8265473: Move os::Linux to its own header file [v4]

Thomas Stuefe stuefe at openjdk.org
Wed Jul 13 07:19:48 UTC 2022


On Sat, 9 Jul 2022 23:27:31 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> Another step of moving unnecessary stuff outside of os.hpp
>> 
>> The `os::Linux` class is used only by the Linux-specific code in HotSpot. Therefore, it should be moved outside of os.hpp, which is used by platform-independent code.
>> 
>> I don't have a good name for the new header. `os_linux.hpp` would have been a good name, but that's already taken, so I am settling on os_linux.impl.hpp. Suggestions are welcome.
>
> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
> 
>   renamed to os_linux_impl.hpp

> So my revised proposal is:
> 
> * Get rid of the "include a header file in the middle of the declaration of the os class" travesty
> * `os.hpp` declares a platform-independent API
> * `os_<os>.hpp` declares utility functions that are used by the OS-specific implementation of the `os` class. This header file should be included by only the files under `src/hotspot/<os>` or `src/hotspot/<os>_<cpu>`
> * Platform-specific implementations should usually be in the `os_<os>.cpp` or `os_<os>_<cpu>.cpp`.
> * When inlining is necessary for performance reasons, generic code should include `os.inline.hpp`, which in turn includes `os_<os>.hpp`, which includes `os_<os>_<cpu>.hpp`.
> 
> This way, `os::Linux` can happily live inside `os_linux.hpp`, and won't be included transitively by `os.hpp`
> 
> I have done a prototype here. Only Linux/x64 is working. I'll probably discover some problems when doing other os/cpus
> 
> [master...iklam:jdk:xxtemp-normalize-os-hpp-inclusion](https://github.com/openjdk/jdk/compare/master...iklam:jdk:xxtemp-normalize-os-hpp-inclusion)
> 
> If people think this is worth pursuing, I will probably close this PR and open a new one, because the changes are much larger than I originally anticipated.

I like everything about this proposal :-)

os.hpp and friends have a long history, a lot of ports started by copy-pasting parts around, and its common property without a clear maintainer. That could explain its current state.

One small addition, functions that are clearly both declared and used within os_xxx.cpp and nowhere else I would like to have removed from headers completely and converted to local statics.

Cheers, Thomas

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

PR: https://git.openjdk.org/jdk/pull/9423


More information about the hotspot-dev mailing list