[lworld] RFR: 8352647: [lworld] Remove larval InlineTypeNode in Unsafe intrinsics [v2]

Quan Anh Mai qamai at openjdk.org
Sun Mar 30 15:23:49 UTC 2025


On Sun, 30 Mar 2025 13:42:21 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

> From user standpoint be it C1 or C2 compiler, JVM needs to be consistent w.r.t to undefined behavior and crash is not acceptable.

Using `Unsafe` is inherently unsafe and we cannot have any promise regarding the behaviour of a program. For example, this will crash the VM:

    UNSAFE.getInt(null, 0);

Worse, consider this program, given `v0 == v1` and `v0.v == 0`:

    static class Int {
        int v;
    }

    void test(int[] array, Int v0, int v1) {
        int x = v0.v;
        Unsafe.putInt(array, someOffset, 1);
        int y = v1.v;
        int z = v0.v;
    }

Now if `array + someOffset` somehow points to `v0.v`, we will see that 3 consecutive loads from the same memory location return impossible results with `x == z == 0` and `y == 1`.

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

PR Comment: https://git.openjdk.org/valhalla/pull/1406#issuecomment-2764611340


More information about the valhalla-dev mailing list