RFR: 8305895: Implementation: JEP 450: Compact Object Headers (Experimental) [v3]
Coleen Phillimore
coleenp at openjdk.org
Fri May 12 16:34:06 UTC 2023
On Tue, 9 May 2023 09:20:19 GMT, Roman Kennke <rkennke 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.
>
>> 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
@rkennke Can you merge up with the GenerationalZGC changes because some of our test definitions need it.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13844#issuecomment-1545999675
More information about the hotspot-dev
mailing list