RFR: 8340453: C2: Improve encoding of LoadNKlass for compact headers [v2]

Roman Kennke rkennke at openjdk.org
Thu Nov 14 11:36:02 UTC 2024


On Thu, 14 Nov 2024 09:34:02 GMT, Roberto Castañeda Lozano <rcastanedalo at openjdk.org> wrote:

>> Roman Kennke has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Improve opto asm of LoadNKlass
>
> While this does not address IMO the conceptual problem of bending the meaning of `oopDesc::klass_offset_in_bytes()` through the C2 code base, it is a clear improvement over the existing model, thanks.
> 
> An advantage of this model over the one proposed in the JBS issue is that it exposes to C2 the actual address that will be loaded. This improves the confidence that there will not be any issue when matching complex addressing modes, etc. due to a mismatch between what C2 sees and what finally gets emitted.
> 
> It would be good to document the overloaded semantics of LoadNKlass for compact headers. Here is a suggestion: https://github.com/openjdk/jdk/commit/042317434d4644ac8f3591c8b1021e5651b5ed6d. If you agree, feel free to incorporate it as-is or edit it to your liking.

Thanks, @robcasloz ! I made the suggested changes.
Yeah, I agree, it is still not ideal. But it seems the most-correct way to handle it. Re-shaping LoadNKlass as you suggested would break the semantics of a LoadNode and I am not sure about the subtle or not-so-subtle consequences of that. It seems most-correct to have LoadNKlass use offset 0, but that also sounds scary and potentially affecting all mark-word accesses. Actually using the offset 4 currently seems the sanest approach to me.

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

PR Comment: https://git.openjdk.org/jdk/pull/22078#issuecomment-2476121289


More information about the hotspot-compiler-dev mailing list