RFR: 8372040: Remove Prefetch header vs inline header separation

Stefan Karlsson stefank at openjdk.org
Thu Jan 8 09:19:39 UTC 2026


On Thu, 8 Jan 2026 06:20:12 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > I wouldn't be surprised if the casual reader would go "wait, what, where does the class Prefetch come from?"
> 
> Is that any different to looking in, for example, the platform dependent os_XXX.cpp and wondering where the class OS comes from?

I think think that the os_XXX.cpp file is different. It has implicit includes all the way to the os.hpp file which defines the OS class:

os_linux.cpp:
. #include "os_linux.inline.hpp" 
.. #include "os_linux.hpp"
... #include "runtime/os.hpp"


Maybe a better example would be orderAccess_linux_x86.hpp, which has a similar layout. In that file we have this comment that shows that this is an odd file compared to most files:


#ifndef OS_CPU_LINUX_X86_ORDERACCESS_LINUX_X86_HPP
#define OS_CPU_LINUX_X86_ORDERACCESS_LINUX_X86_HPP

// Included in orderAccess.hpp header file.


Here we have an orderAccess.hpp and not an orderAccess.inline.hpp. The reason for that is that so much code is currently using the OrderAccess API from headers.

While looking at this I wonder if we couldn't get both wishes by adding an explicit include to prefetch.inline.hpp and relying on the include guards to sort out the circular dependencies:

prefetch.inline.hpp:

#ifndef SHARE_RUNTIME_PREFETCH_INLINE_HPP
#define SHARE_RUNTIME_PREFETCH_INLINE_HPP

class Prefetch {...};

#include OS_CPU_HEADER_INLINE(prefetch)

#endif // SHARE_RUNTIME_PREFETCH_INLINE_HPP


prefetch_linux_x86.inline.hpp:

#ifndef OS_CPU_LINUX_X86_PREFETCH_LINUX_X86_INLINE_HPP
#define OS_CPU_LINUX_X86_PREFETCH_LINUX_X86_INLINE_HPP

#include "runtime/prefetch.inline.hpp"

... implementation of class Prefetch 

#endif // OS_CPU_LINUX_X86_PREFETCH_LINUX_X86_INLINE_HPP


If this works then there not be any mixups of prefetch.hpp vs prefetch.inline.hpp usages (because prefetch.hpp is gone), and at the same time the os_linux_x64.inline.hpp will be complete on its own.

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

PR Comment: https://git.openjdk.org/jdk/pull/29096#issuecomment-3722938306


More information about the hotspot-dev mailing list