RFR: 8316493: Remove the caching fields in AbstractMap [v11]

Chen Liang liach at openjdk.org
Sun Mar 3 21:26:59 UTC 2024


On Fri, 10 Nov 2023 08:17:22 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> This PR outlines a solution for making immutable maps `@ValueBased` by removing cacheing of certain values in `AbstractMap`.
>> 
>> By removing these caching fields in `AbstractMap`, we can make the immutable maps `@ValueBased` and at the same time, performance is likely improved because the JVM is probably able to optimize away object creation anyway via escape analysis. Also, all maps will occupy less space as we get rid of a number of objects and references stored for each map.
>> 
>> We need to benchmark this solution to better understand its implications.
>
> Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 14 commits:
> 
>  - Merge branch 'master' into vb-map2
>  - Fix formatting
>  - Remove caching in TreeMap
>  - Remove caching from CHM and CSLM
>  - Move back clone to original position
>  - Reintroduce AbstractMap::clone
>  - Add 'fresh' to implSpec
>  - Remove AbstractMap::clone
>  - Merge master
>  - Merge branch 'master' into vb-map2
>  - ... and 4 more: https://git.openjdk.org/jdk/compare/9cce9fe0...b1bfcd17

src/java.base/share/classes/java/util/AbstractMap.java line 314:

> 312:      * {@code contains} method delegates to this map's
> 313:      * {@code containsKey} method.
> 314:      *

Extra blank line

src/java.base/share/classes/java/util/AbstractMap.java line 336:

> 334:      * method and the {@code contains} method delegates to this map's
> 335:      * {@code containsValue} method.
> 336:      *

Extra blank line

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15614#discussion_r1510400633
PR Review Comment: https://git.openjdk.org/jdk/pull/15614#discussion_r1510400802


More information about the core-libs-dev mailing list