RFR: 8306889: Convert MethodTypeDescImpl parameter storage from array to immutable list [v3]

Chen Liang liach at openjdk.org
Wed May 24 02:18:01 UTC 2023


> This patch moves the parameters to an immutable list, to avoid allocations on `parameterList` as well. In addition, it fixes 8304932, the bug where if a caller keeps a reference to the array passed into `MethodTypeDesc.of`, the caller may mutate the Desc via the array and can create invalid MethodTypeDesc.
> 
> This patch has minor performance gains on `ofDescriptor` factory, even compared to Adam's patch that optimized `ofDescriptor` in #12945.
> 
> Benchmark of Oracle JDK 20: https://gist.github.com/683c6219e183cbc2b336224fc2c0d50a
> Benchmark of this patch: https://gist.github.com/22be9371a2370fb4a7b44f1684750ec4
> Benchmark of [asotona's patch](https://github.com/openjdk/jdk/pull/12945/files#diff-ac8e413d3e13532a2b0d34a90253c6ddd7a4f04082f792b9d076e9b5a33f2078): https://gist.github.com/eb98579c3b51cafae481049a95a78f80
> 
> [sotona vs this](https://jmh.morethan.io/?gists=eb98579c3b51cafae481049a95a78f80,22be9371a2370fb4a7b44f1684750ec4); [20 vs this](https://jmh.morethan.io/?gists=683c6219e183cbc2b336224fc2c0d50a,22be9371a2370fb4a7b44f1684750ec4); [20 vs sotona](https://jmh.morethan.io/?gists=683c6219e183cbc2b336224fc2c0d50a,eb98579c3b51cafae481049a95a78f80), for reference

Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains seven commits:

 - Finish merge, also examine the improved performance of descriptor string computation
 - Merge branch 'master' into fix/mtd-immutable
 - Merge branch 'mtd-desc-cache' into fix/mtd-immutable
 - commit
 - Fix some inconsistencies in the method descriptor derivation methods
 - Add benchmark
 - 8304932: MethodTypeDescImpl can be mutated by argument passed to MethodTypeDesc.of

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

Changes: https://git.openjdk.org/jdk/pull/13186/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13186&range=02
  Stats: 415 lines in 6 files changed: 275 ins; 75 del; 65 mod
  Patch: https://git.openjdk.org/jdk/pull/13186.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13186/head:pull/13186

PR: https://git.openjdk.org/jdk/pull/13186


More information about the core-libs-dev mailing list