On Thu, 29 Aug 2024 05:34:37 GMT, Shaojin Wen <s...@openjdk.org> wrote:

> TypeKind.from(Class) is a frequently called method, which provides a 
> specialized method to improve performance.
> 
> The following Compiler log shows that the call stack level is reduced and two 
> reference accesses (descriptorString() -> String.value) are reduced, which 
> can reduce the performance degradation caused by cache misses.
> 
> * baseline
> 
> @ 48   java.lang.classfile.TypeKind::from (25 bytes)   inline
>   @ 1   java.lang.Class::isPrimitive (0 bytes)   intrinsic
>   @ 10   java.lang.Class::descriptorString (170 bytes)   failed to inline: 
> callee is too large
>   @ 15   java.lang.classfile.TypeKind::fromDescriptor (232 bytes)   failed to 
> inline: callee is too large
> 
> 
> * current
> 
> @ 52   java.lang.classfile.TypeKind::from (103 bytes)   failed to inline: 
> callee is too large

Unfortunately, I don't think this is a good API addition, as it significantly 
increases the complexity of this method. If we do want to be performant, we 
should avoid calling this `from`, as in many workloads we don't handle `void` 
and we just want to return the 5 computational types for the class file format. 
We optimize users instead of this API.

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

PR Comment: https://git.openjdk.org/jdk/pull/20762#issuecomment-2371808766

Reply via email to