RFR: 8339358: Optimize TypeKind#from

Claes Redestad redestad at openjdk.org
Sun Sep 1 23:34:57 UTC 2024


On Thu, 29 Aug 2024 05:34:37 GMT, Shaojin Wen <swen at 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

This PR has public API changes that would need a CSR. Perhaps avoidable if the `OfField` override is kept.

With the benefit on `ClassDesc` being a bit dubious I'm not sure how worthwhile this one is?

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

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


More information about the core-libs-dev mailing list