RFR: 8305895: Implementation: JEP 450: Compact Object Headers (Experimental) [v3]

Roman Kennke rkennke at openjdk.org
Tue May 9 09:23:33 UTC 2023


On Tue, 9 May 2023 02:59:51 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

> I'm not sure if this is trivial or significant, but if you limit the class pointer to 30 bit, and use the upper 2 bits for locking, then you can obtain the class pointer in less instructions:
> 
> ```
> movl dst, [obj + 4]
> andl dst, 0xBFFFFFFF
> jl slow_path
> ```
> 
> This exploits the fact that the most significant bit represents a negative number, so it clears the unrelated bit and checks for valid header at the same time, the sequence is only 2 instructions long after macro fusion, compared to the current value of 3.
> 
> This also allows quick class comparisons against constants, assuming that most instance is in unlock state, the comparison when equality is likely can be done:
> 
> ```
> cmpl [obj + 4], con | 0x40000000
> jne slow_path
> ```
> 
> This can be matched on an `If` so that the `slow_path` can branch to the `IfTrue` label directly, and the fast path has only 1 comparison and 1 conditional jump.
> 
> Thanks.

These are great suggestions! I would shy away from doing it in this PR, though, because this also affects the locking subsystem and would cause quite intrusive changes and invalidate all the testing that we've done. Let's consider this in the Lilliput project and upstream the optimization separately, ok?

Thanks!
Roman

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

PR Comment: https://git.openjdk.org/jdk/pull/13844#issuecomment-1539763841


More information about the hotspot-dev mailing list