On Sat, 16 Dec 2023 16:53:26 GMT, Chen Liang <li...@openjdk.org> wrote:

>> Adam Sotona has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   added missing comment
>
> src/java.base/share/classes/java/lang/invoke/MethodType.java line 1295:
> 
>> 1293:     public Optional<MethodTypeDesc> describeConstable() {
>> 1294:         try {
>> 1295:             var params = new ClassDesc[parameterCount()];
> 
> We can probably handle like this:
> 
> var retDesc = returnType().describeConstable();
> if (retDesc.isEmpty())
>     return Optional.empty();
> 
> if (parameterCount() == 0)
>     return Optional.of(MethodTypeDesc.of(retDesc.get()));
> 
> var params = new ClassDesc[parameterCount()];
> for (int i = 0; i < params.length; i++) {
>     var paramDesc = parameterType(i).describeConstable();
>     if (paramDesc.isEmpty())
>         return Optional.empty();
>     params[i] = paramDesc.get();
> }
> return Optional.of(MethodTypeDesc.of(returnType().get(), params));
> 
> 
> To avoid creating exceptions and allocating array when the params array is 
> empty.

yes, it looks better, thanks.

> src/java.base/share/classes/jdk/internal/classfile/impl/SplitConstantPool.java
>  line 379:
> 
>> 377:     @Override
>> 378:     public ClassEntry classEntry(ClassDesc classDesc) {
>> 379:         if (classDesc == ConstantDescs.CD_Object) {
> 
> What causes the slow lookup of Object CE? If it's because that hashing needs 
> to compute the substring first, I recommend changing the hashing algorithm if 
> that's the case.

Right, I'll take this specific shortcut back and will think about more generic 
performance improvement.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1429863879
PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1429866344

Reply via email to