On Wed, 5 Apr 2023 18:28:15 GMT, Chen Liang <li...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java line 
>> 225:
>> 
>>> 223:     private record LocalMethodInfo(MethodTypeDesc desc, 
>>> List<ClassDesc> thrown) {}
>>> 224: 
>>> 225:     private record InterfaceInfo(@Stable MethodType[] types, Lookup 
>>> lookup, @Stable byte[] template) {}
>> 
>> Use of `@Stable` here is not needed. We don't constant fold through 
>> `InterfaceInfo` instances.
>> Suggestion:
>> 
>>     private record InterfaceInfo(MethodType[] types, Lookup lookup, byte[] 
>> template) {}
>
> Hmm, I thought records are constant-folded. 
> https://github.com/openjdk/jdk/blob/44f33ad1a9617fc23864c9ba5f063b3fc2f1e18c/src/hotspot/share/ci/ciField.cpp#L240
>  Per https://github.com/openjdk/jdk/pull/9143#discussion_r912239501, array 
> cloning sees 10% less time per operation with the annotation.
> 
> I will try with and without these annotations and report the creation 
> benchmark results to see if they are worth it.

The `InterfaceInfo` instance would have to be constant as well in order for 
loads of the fields & array elements to be constant folded (the same applies to 
records in general). However, the instances come from a call from 
`ClassValue::get` so they are not constant. (See also: 
https://bugs.openjdk.org/browse/JDK-8238260)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13197#discussion_r1158884810

Reply via email to