RFR: 8304928: Optimize ClassDesc.resolveConstantDesc
Mandy Chung
mchung at openjdk.org
Thu Mar 30 23:24:20 UTC 2023
On Thu, 30 Mar 2023 20:06:02 GMT, Chen Liang <liach at openjdk.org> wrote:
> This patch optimizes ClassDesc.resolveConstantDesc for array classes. Otherwise, the performance of reference class resolution remain unchanged. https://jmh.morethan.io/?gist=111095eecf7a735fe8c96e4b952b58c1 It also includes a benchmark for MethodTypeDesc resolution, which currently does not yet depend on class desc resolution but can be later optimized if it does switch.
src/java.base/share/classes/java/lang/constant/ConstantUtils.java line 130:
> 128:
> 129: static boolean isPrimitiveArray(String referenceTypeDescriptorString) {
> 130: return referenceTypeDescriptorString.charAt(referenceTypeDescriptorString.length() - 1) != ';';
it also needs to check if it starts with `[`
Suggestion:
return referenceTypeDescriptorString.startsWith("[") &&
referenceTypeDescriptorString.charAt(referenceTypeDescriptorString.length() - 1) != ';';
test/micro/org/openjdk/bench/java/lang/constant/MethodTypeDescResolve.java line 53:
> 51: @Fork(1)
> 52: @State(Scope.Benchmark)
> 53: public class MethodTypeDescResolve {
Better to separate this benchmark from this PR. Probably the optimization done in [PR 10991](https://github.com/openjdk/jdk/pull/10991) should be a separate patch from JDK-8294961 and this benchmark could be included there.
test/micro/org/openjdk/bench/java/lang/constant/ReferenceClassDescResolve.java line 120:
> 118: return resolveReference(lookup, cd);
> 119: }
> 120: },
I think this benchmark doesn't need this case as that's the implementation of `resolveConstantDesc`. Was it there when you developed this fix? Same for MethodTypeDesc benchmark.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13252#discussion_r1153874210
PR Review Comment: https://git.openjdk.org/jdk/pull/13252#discussion_r1153877556
PR Review Comment: https://git.openjdk.org/jdk/pull/13252#discussion_r1153876110
More information about the core-libs-dev
mailing list