RFR: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles [v2]
Adam Sotona
asotona at openjdk.org
Mon Dec 18 10:24:45 UTC 2023
On Sat, 16 Dec 2023 16:53:26 GMT, Chen Liang <liach at 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
More information about the core-libs-dev
mailing list