On Sun, 25 Aug 2024 14:29:16 GMT, Shaojin Wen <d...@openjdk.org> wrote:
>> This is a follow-up to PR #20273, which improves performance when the number >> of parameters exceeds 20. >> >> When the number of parameters is large, the possibility of reuse will be >> lower, so we can use the static concat method and write the length and coder >> directly into the bytecode to solve the performance regression problem. > > Shaojin Wen has updated the pull request incrementally with one additional > commit since the last revision: > > add control flag `reuseThreshold` As the `paramTypes` passed to `MethodType::methodType(…)` and `MethodTypeDesc::of(…)` are guaranteed valid and aren’t mutated afterwards, this can use `MethodType::methodType(…, trusted = true)` and `MethodTypeDescImpl::ofValidated(…)`: src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1202: > 1200: paramTypes[i + prefixArgs] = needStringOf(cl) ? > CD_String : ConstantUtils.classDesc(cl); > 1201: } > 1202: return MethodTypeDesc.of(CD_int, paramTypes); Suggestion: return MethodTypeDescImpl.ofValidated(CD_int, paramTypes); src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1219: > 1217: } > 1218: } > 1219: return MethodTypeDesc.of(CD_int, paramTypes); Suggestion: return MethodTypeDescImpl.ofValidated(CD_int, paramTypes.toArray(ConstantUtils.EMPTY_CLASSDESC)); src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1234: > 1232: paramTypes[i + 1] = needStringOf(cl) ? CD_String : > ConstantUtils.classDesc(cl); > 1233: } > 1234: return MethodTypeDesc.of(CD_int, paramTypes); Suggestion: return MethodTypeDescImpl.ofValidated(CD_int, paramTypes); ------------- PR Review: https://git.openjdk.org/jdk/pull/20675#pullrequestreview-2259314494 PR Review Comment: https://git.openjdk.org/jdk/pull/20675#discussion_r1730377690 PR Review Comment: https://git.openjdk.org/jdk/pull/20675#discussion_r1730377709 PR Review Comment: https://git.openjdk.org/jdk/pull/20675#discussion_r1730377739