RFR: 8343206: Final graph reshaping should not compress abstract or interface class pointers [v3]
Tobias Hartmann
thartmann at openjdk.org
Mon Nov 4 06:30:32 UTC 2024
On Fri, 1 Nov 2024 08:23:42 GMT, Dean Long <dlong at openjdk.org> wrote:
>> Right, I was hoping for that too and tried to move the assert into `TypeNarrowKlass::make`. We do have all the information there but we hit false positives in rare cases like this when `MyAbstract` does not have any subtypes at compile time (mostly with `-Xcomp`):
>>
>> MyAbstract obj = ...;
>> obj.getClass();
>>
>> C2 will add a dependency that will invalidate the code once a subclass is loaded and then optimizes the narrow class load from `obj` to be of constant narrow class type `MyAbstract`. The assert will trigger but we will never emit a compressed class pointer because the narrow class load + decode is folded to a non-narrow constant.
>>
>> We could move the assert to a later stage though. I'll give that a try.
>
> Do we actually generate an nmethod for the above example? It seems like it could never execute the getClass() because the line above setting `obj` would have to throw an exception if there can be no concrete instances.
Right, this was an oversimplified example. I used this code:
Class test(MyAbstract obj, boolean b) {
if (b) {
return obj.getClass();
}
return null;
}
We pass `null` for `obj` and `false` for `b`. Usually, the branch is then only compiled with Xcomp.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21784#discussion_r1827238258
More information about the hotspot-compiler-dev
mailing list