RFR: 8295555: Primitive wrapper caches could be `@Stable`

Per Minborg pminborg at openjdk.org
Tue Jun 13 08:41:59 UTC 2023


On Mon, 12 Jun 2023 14:25:42 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> This PR proposes adding `@Stable` to certain wrapper classes' cache arrays (e.g. `Integer` and `Long`).
> 
> Comments are welcome as to how to improve the VM's handling now that the backing cache array is `@Stable`. Are there simplifications to be made or are there other optimizations we might add?

The benchmarks I provided above does not involve constant folding so here is another set of benchmarks (Thanks @cl4es):

Before

Benchmark                     (size)  Mode  Cnt  Score   Error  Units
Integers.constantFoldInteger     500  avgt   15  0.568 ± 0.013  ns/op
Integers.constantFoldInts        500  avgt   15  0.564 ± 0.005  ns/op


After

Benchmark                     (size)  Mode  Cnt  Score   Error  Units
Integers.constantFoldInteger     500  avgt   15  0.558 ± 0.001  ns/op
Integers.constantFoldInts        500  avgt   15  0.559 ± 0.001  ns/op



    @Benchmark
    public int constantFoldInteger() {
        return Integer.valueOf(64) * Integer.valueOf(32);
    }

    @Benchmark
    public int constantFoldInts() {
        return 64 * 32;
    }

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

PR Comment: https://git.openjdk.org/jdk/pull/14418#issuecomment-1588823240


More information about the core-libs-dev mailing list