RFR: 8361211: C2: Final graph reshaping generates unencodeable klass constants

Martin Doerr mdoerr at openjdk.org
Mon Aug 4 21:37:03 UTC 2025


On Mon, 4 Aug 2025 13:04:23 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/hotspot/share/opto/compile.cpp line 3663:
>> 
>>> 3661:         n->subsume_by(ConNode::make(t->make_narrowoop()), this);
>>> 3662:       } else if (t->isa_klassptr()) {
>>> 3663:         ciKlass* klass = t->is_klassptr()->exact_klass();
>> 
>> This branch means that we are trying to compress a pointer that cannot be compressed. This seems wrong either way.
>
> Right! This replaces (`ConP` -> `EncodeP`) -> `ConN`. While I agree that it should theoretically be handled on `EncodeP` path, it seems sane to gate the conversion here as well. Issues like this is why I want to disable/revert the optimization that puts us into this situation.

I think it's always bad if we reach here with an abstract or interface class. `ConP` + `EncodeP` will still be wrong. Usage of the result can cause strange issues.
Can we assert that `klass->is_in_encoding_range()`, here?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26559#discussion_r2252624471


More information about the hotspot-compiler-dev mailing list