On Sat, 22 Apr 2023 18:40:45 GMT, Chen Liang <li...@openjdk.org> wrote:

>> Add a method `internalName` to `ClassDesc`, and unifies handling of string 
>> representation of a class constant in CONSTANT_Class_info via 
>> `ofInternalName` and `internalName` APIs, documented in `ClassDesc` itself. 
>> In particular, `ofInternalName` now accepts arrays.
>> 
>> The motivation of this API is that avoiding frequent String creations via 
>> caching (enabled by this new API, will be in a separate patch) would speed 
>> up Classfile API's [writing of simple class 
>> files](https://github.com/openjdk/jdk/blob/master/test/micro/org/openjdk/bench/jdk/classfile/Write.java)
>>  by 1/3. See 
>> https://mail.openjdk.org/pipermail/classfile-api-dev/2023-April/000296.html 
>> for more context.
>> 
>> This API is futureproof: for Valhalla's Q-types, it will return their string 
>> representation in CONSTANT_Class_info, which is most likely their full 
>> descriptor string.
>> 
>> Javadoc: 
>> https://cr.openjdk.org/~liach/8306697/java.base/java/lang/constant/ClassDesc.html
>
> Chen Liang has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Unify ofInternalName and internalName, document about CONSTANT_Class_info, 
> remove misleading JVMS 4.4.1 links

I support this addition. Classfile API contains utility method obtaining 
internal name from `ClassDesc` and it is one of the core pieces.
I don't have any exact measured numbers in my hands now, however `String` 
conversions are significant CPU consumers in our benchmarks.
In #13671 we are targeting to support conversion-less paths for class building 
and transformations (by passing the original `ClassDesc` instances through the 
process). External utility for conversions from `ClassDesc` to internal name 
does not allow to effectively cache the names and so every repeated need of 
internal name of the same `ClassDesc` instance will produce a new substring.

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

PR Comment: https://git.openjdk.org/jdk/pull/13598#issuecomment-1525168031

Reply via email to