[lworld] RFR: 8376171: [lworld] Enable storing the hash code in the mark word of value objects [v2]

Paul Hübner phubner at openjdk.org
Mon Jan 26 10:46:00 UTC 2026


On Mon, 26 Jan 2026 06:52:19 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> src/hotspot/share/prims/jvm.cpp line 799:
>> 
>>> 797:       }
>>> 798:     }
>>> 799:     hash = result.get_jint() & markWord::hash_mask;
>> 
>> I don't think it's a good idea to do mask ops outside of the markWord, because it gets difficult to find them and maintain them. Can we introduce a helper function inside the markWord to do this for us?
>
> Actually, `markWord::copy_set_hash` just below already does the marking, so we could go with something like this:
> 
> 
> // Store hash in the mark word
> markWord mark = ho->mark().copy_set_hash(result.get_jint());
> ho->set_mark(mark);
> 
> return checked_cast<jint>(mark.hash());
> 
> 
> What do you think?

I think that looks good and would make the code a lot more maintainable.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1954#discussion_r2727127717


More information about the valhalla-dev mailing list