RFR: 8348556: Inlining fails earlier for MemorySegment::reinterpret

Per Minborg pminborg at openjdk.org
Wed Feb 5 13:27:05 UTC 2025


On Wed, 5 Feb 2025 10:17:09 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes to add some `@ForceInline` annotations in the `Module` class in order to assist inlining of FFM var/method handles.
> 
> Tested and passed tier1-3

src/java.base/share/classes/java/lang/Module.java line 281:

> 279:         @ForceInline
> 280:         private static boolean isNativeAccessEnabled(Module target) {
> 281:             return target.enableNativeAccess || UNSAFE.getBooleanVolatile(target, FIELD_OFFSET);

Tries plain memory semantics first.

src/java.base/share/classes/java/lang/Module.java line 311:

> 309: 
> 310:     @DontInline
> 311:     void ensureNativeAccessSlowPath(Class<?> owner,

This is slow anyhow so we do not need it to be inlined.

src/java.base/share/classes/java/lang/Module.java line 488:

> 486:         // if other is an unnamed module then check if this module reads
> 487:         // all unnamed modules
> 488:         return !other.isNamed()

This is a drive-by simplification.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23460#discussion_r1942603002
PR Review Comment: https://git.openjdk.org/jdk/pull/23460#discussion_r1942606189
PR Review Comment: https://git.openjdk.org/jdk/pull/23460#discussion_r1942604940


More information about the core-libs-dev mailing list