RFR: 8339113: AccessFlags can be u2 in metadata [v12]

Serguei Spitsyn sspitsyn at openjdk.org
Mon Jan 6 17:10:39 UTC 2025


On Mon, 6 Jan 2025 14:12:56 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Please review this change that makes AccessFlags and modifier_flags u2 types and removes the last remnants of Hotspot adding internal access flags.  This change moves AccessFlags and modifier_flags in Klass to alignment gaps saving 16 bytes.  From pahole: so it's a bit better.
>> 
>> before:
>> 
>>         /* size: 216, cachelines: 4, members: 25, static members: 17 */
>>         /* sum members: 194, holes: 3, sum holes: 18 */
>> 
>> 
>> after:
>> 
>>         /* size: 200, cachelines: 4, members: 25, static members: 17 */
>>         /* sum members: 188, holes: 4, sum holes: 12 */
>> 
>> 
>> We may eventually move the modifiers to java.lang.Class but that's WIP.
>> 
>> Tested with tier1-7 on oracle platforms.  Did test builds on other platforms (please try these changes ppc/arm32 and s390).  Also requires minor Graal changes.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove unused SA function.

Thank you for update with this an unification!
I've posted a couple of comments with similar nits.

src/hotspot/share/interpreter/linkResolver.cpp line 586:

> 584:     // We need to change "protected" to "public".
> 585:     assert(flags.is_protected(), "clone not protected?");
> 586:     u2 new_flags = flags.as_unsigned_short();

Nit: Should this also be replaced with `as_method_flags()`?

src/hotspot/share/opto/memnode.cpp line 1985:

> 1983:     // The field is Klass::_access_flags.  Return its (constant) value.
> 1984:     // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).)
> 1985:     assert(this->Opcode() == Op_LoadUS, "must load an unsigned short from _access_flags");

Nit: This can be unified with line 1979 and also get rid of `this->`.

src/hotspot/share/prims/jvm.cpp line 2472:

> 2470:   u2 field_access_flags = InstanceKlass::cast(k)->field_access_flags(field_index);
> 2471:   // This & should be unnecessary.
> 2472:   assert((field_access_flags & JVM_RECOGNIZED_FIELD_MODIFIERS) == field_access_flags, "already masked");

Nit: Yes, it is better to remove the lines: 2471-2472.

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

PR Review: https://git.openjdk.org/jdk/pull/22246#pullrequestreview-2532540668
PR Review Comment: https://git.openjdk.org/jdk/pull/22246#discussion_r1904386978
PR Review Comment: https://git.openjdk.org/jdk/pull/22246#discussion_r1904405970
PR Review Comment: https://git.openjdk.org/jdk/pull/22246#discussion_r1904404626


More information about the graal-dev mailing list