RFR: 8343019: Primitive caches must use boxed instances from the archive [v2]
Aleksey Shipilev
shade at openjdk.org
Tue Oct 29 13:12:56 UTC 2024
On Mon, 28 Oct 2024 22:36:44 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:
>> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - IllegalStateException -> InternalError
>> - Merge branch 'master' into JDK-8343019-cds-use-boxed
>> - Exception messages
>> - Fix
>
> src/java.base/share/classes/java/lang/Integer.java line 964:
>
>> 962: Integer[] c = new Integer[size];
>> 963: int j = low;
>> 964: // Use all cached values from the archive to avoid breaking
>
> Alternatively, you could use a separate array to store **only** the runtime created cached instances, without copying the references from the archived cache. Both the archived cache and runtime added cache are used. That has slightly less memory and efficiency overhead, but almost unnoticeable.
I don't think I understand. The whole point is to make sure the runtime cache instances are the same as archive cache instances, right? Using both archived and runtime caches leads to identity inconsistencies: if we `==` compare the archived `Integer` box and the runtime `Integer` box of the same value in [-128; 127], they should equal each other. So we have to make sure we use the parts we have already committed to use (from the archive), and add whatever cache elements are missing at runtime. I don't see how it works otherwise.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21737#discussion_r1820757074
More information about the core-libs-dev
mailing list