On Thu, 7 Sep 2023 11:13:44 GMT, Per Minborg <pminb...@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.

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

> 316:      * and returned in response to all subsequent calls.  No 
> synchronization
> 317:      * is performed, so there is a slight chance that multiple calls to 
> this
> 318:      * method will not all return the same set.

The `@implSpec` above is now outdated since caching is removed.

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

> 370:      * returned in response to all subsequent calls.  No synchronization 
> is
> 371:      * performed, so there is a slight chance that multiple calls to this
> 372:      * method will not all return the same collection.

Same outdated `@implSpec`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15614#discussion_r1330809911
PR Review Comment: https://git.openjdk.org/jdk/pull/15614#discussion_r1330809969

Reply via email to