From 773428b348d51c74f2f4e605a62761552585e04d Mon Sep 17 00:00:00 2001 From: Shiv Shah Date: Thu, 7 May 2026 17:53:39 -0500 Subject: [PATCH 1/4] 8384107: Update runtime/contended tests to run the same testing for value classes --- .../contended/OopMapsSameGroupValue.java | 73 ++++++++++ .../jtreg/runtime/contended/OopMapsValue.java | 134 ++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java create mode 100644 test/hotspot/jtreg/runtime/contended/OopMapsValue.java diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java new file mode 100644 index 00000000000..9b856aa0ae5 --- /dev/null +++ b/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import jdk.internal.vm.annotation.Contended; + +/* + * @test + * @bug 8384107 + * @summary Test contended oop maps within the same group with value class instances + * + * @modules java.base/jdk.internal.vm.annotation + * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsSameGroupValue + */ +public class OopMapsSameGroupValue { + public static final int COUNT = 10000; + + public static void main(String[] args) throws Exception { + Integer o01 = Integer.valueOf(101); + Integer o02 = Integer.valueOf(102); + Integer o03 = Integer.valueOf(103); + Integer o04 = Integer.valueOf(104); + + R[] rs = new R[COUNT]; + for (int i = 0; i < COUNT; i++) { + R r = new R(); + r.o01 = o01; + r.o02 = o02; + r.o03 = o03; + r.o04 = o04; + rs[i] = r; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + R r = rs[i]; + if (!o01.equals(r.o01)) throw new Error("Test Error: o01"); + if (!o02.equals(r.o02)) throw new Error("Test Error: o02"); + if (!o03.equals(r.o03)) throw new Error("Test Error: o03"); + if (!o04.equals(r.o04)) throw new Error("Test Error: o04"); + } + } + + public static class R { + @Contended("group1") + Object o01; + @Contended("group1") + Object o02; + @Contended("group2") + Object o03; + @Contended("group2") + Object o04; + } +} diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsValue.java new file mode 100644 index 00000000000..34adfb32ee3 --- /dev/null +++ b/test/hotspot/jtreg/runtime/contended/OopMapsValue.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import jdk.internal.vm.annotation.Contended; + +/* + * @test + * @bug 8384107 + * @summary Test contended oop maps with value class instances + * + * @modules java.base/jdk.internal.vm.annotation + * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsValue + */ +public class OopMapsValue { + public static final int COUNT = 10000; + + public static void main(String[] args) throws Exception { + Integer o01 = Integer.valueOf(101); + Integer o02 = Integer.valueOf(102); + Integer o03 = Integer.valueOf(103); + Integer o04 = Integer.valueOf(104); + Integer o05 = Integer.valueOf(105); + Integer o06 = Integer.valueOf(106); + Integer o07 = Integer.valueOf(107); + Integer o08 = Integer.valueOf(108); + Integer o09 = Integer.valueOf(109); + Integer o10 = Integer.valueOf(110); + Integer o11 = Integer.valueOf(111); + Integer o12 = Integer.valueOf(112); + Integer o13 = Integer.valueOf(113); + Integer o14 = Integer.valueOf(114); + + R1[] rs = new R1[COUNT]; + for (int i = 0; i < COUNT; i++) { + R1 r1 = new R1(); + r1.o01 = o01; + r1.o02 = o02; + r1.o03 = o03; + r1.o04 = o04; + r1.o05 = o05; + r1.o06 = o06; + r1.o07 = o07; + r1.o08 = o08; + r1.o09 = o09; + r1.o10 = o10; + r1.o11 = o11; + r1.o12 = o12; + r1.o13 = o13; + r1.o14 = o14; + r1.i1 = 1; + r1.i2 = 2; + r1.i3 = 3; + r1.i4 = 4; + rs[i] = r1; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + R1 r1 = rs[i]; + if (!o01.equals(r1.o01)) throw new Error("Test Error: o01"); + if (!o02.equals(r1.o02)) throw new Error("Test Error: o02"); + if (!o03.equals(r1.o03)) throw new Error("Test Error: o03"); + if (!o04.equals(r1.o04)) throw new Error("Test Error: o04"); + if (!o05.equals(r1.o05)) throw new Error("Test Error: o05"); + if (!o06.equals(r1.o06)) throw new Error("Test Error: o06"); + if (!o07.equals(r1.o07)) throw new Error("Test Error: o07"); + if (!o08.equals(r1.o08)) throw new Error("Test Error: o08"); + if (!o09.equals(r1.o09)) throw new Error("Test Error: o09"); + if (!o10.equals(r1.o10)) throw new Error("Test Error: o10"); + if (!o11.equals(r1.o11)) throw new Error("Test Error: o11"); + if (!o12.equals(r1.o12)) throw new Error("Test Error: o12"); + if (!o13.equals(r1.o13)) throw new Error("Test Error: o13"); + if (!o14.equals(r1.o14)) throw new Error("Test Error: o14"); + if (r1.i1 != 1) throw new Error("Test Error: i1"); + if (r1.i2 != 2) throw new Error("Test Error: i2"); + if (r1.i3 != 3) throw new Error("Test Error: i3"); + if (r1.i4 != 4) throw new Error("Test Error: i4"); + } + } + + public static class R0 { + int i1; + int i2; + Object o01; + Object o02; + @Contended + Object o03; + @Contended + Object o04; + @Contended + Object o05; + @Contended + Object o06; + @Contended + Object o07; + } + + public static class R1 extends R0 { + int i3; + int i4; + Object o08; + Object o09; + @Contended + Object o10; + @Contended + Object o11; + @Contended + Object o12; + @Contended + Object o13; + @Contended + Object o14; + } +} From 177d8f718ade0fa37f3df82accb252b7b696ec82 Mon Sep 17 00:00:00 2001 From: Shiv Shah Date: Tue, 12 May 2026 08:10:30 -0500 Subject: [PATCH 2/4] 8384107: Add custom value class OopMaps contended test --- .../runtime/contended/OopMapsCustomValue.java | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java new file mode 100644 index 00000000000..70a2d50724d --- /dev/null +++ b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import jdk.internal.vm.annotation.Contended; + +/* + * @test + * @bug 8384107 + * @summary Test contended oop maps with custom value class instances + * + * @modules java.base/jdk.internal.vm.annotation + * @enablePreview + * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsCustomValue + */ +public class OopMapsCustomValue { + public static final int COUNT = 10000; + + static value class Point { + int x; + int y; + Point(int x, int y) { + this.x = x; + this.y = y; + } + } + + public static void main(String[] args) throws Exception { + Point o01 = new Point(1, 1); + Point o02 = new Point(2, 2); + Point o03 = new Point(3, 3); + Point o04 = new Point(4, 4); + Point o05 = new Point(5, 5); + Point o06 = new Point(6, 6); + Point o07 = new Point(7, 7); + Point o08 = new Point(8, 8); + Point o09 = new Point(9, 9); + Point o10 = new Point(10, 10); + Point o11 = new Point(11, 11); + Point o12 = new Point(12, 12); + Point o13 = new Point(13, 13); + Point o14 = new Point(14, 14); + + R1[] rs = new R1[COUNT]; + for (int i = 0; i < COUNT; i++) { + R1 r1 = new R1(); + r1.o01 = o01; + r1.o02 = o02; + r1.o03 = o03; + r1.o04 = o04; + r1.o05 = o05; + r1.o06 = o06; + r1.o07 = o07; + r1.o08 = o08; + r1.o09 = o09; + r1.o10 = o10; + r1.o11 = o11; + r1.o12 = o12; + r1.o13 = o13; + r1.o14 = o14; + r1.i1 = 1; + r1.i2 = 2; + r1.i3 = 3; + r1.i4 = 4; + rs[i] = r1; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + R1 r1 = rs[i]; + if (!o01.equals(r1.o01)) throw new Error("Test Error: o01"); + if (!o02.equals(r1.o02)) throw new Error("Test Error: o02"); + if (!o03.equals(r1.o03)) throw new Error("Test Error: o03"); + if (!o04.equals(r1.o04)) throw new Error("Test Error: o04"); + if (!o05.equals(r1.o05)) throw new Error("Test Error: o05"); + if (!o06.equals(r1.o06)) throw new Error("Test Error: o06"); + if (!o07.equals(r1.o07)) throw new Error("Test Error: o07"); + if (!o08.equals(r1.o08)) throw new Error("Test Error: o08"); + if (!o09.equals(r1.o09)) throw new Error("Test Error: o09"); + if (!o10.equals(r1.o10)) throw new Error("Test Error: o10"); + if (!o11.equals(r1.o11)) throw new Error("Test Error: o11"); + if (!o12.equals(r1.o12)) throw new Error("Test Error: o12"); + if (!o13.equals(r1.o13)) throw new Error("Test Error: o13"); + if (!o14.equals(r1.o14)) throw new Error("Test Error: o14"); + if (r1.i1 != 1) throw new Error("Test Error: i1"); + if (r1.i2 != 2) throw new Error("Test Error: i2"); + if (r1.i3 != 3) throw new Error("Test Error: i3"); + if (r1.i4 != 4) throw new Error("Test Error: i4"); + } + } + + public static class R0 { + int i1; + int i2; + Object o01; + Object o02; + @Contended + Object o03; + @Contended + Object o04; + @Contended + Object o05; + @Contended + Object o06; + @Contended + Object o07; + } + + public static class R1 extends R0 { + int i3; + int i4; + Object o08; + Object o09; + @Contended + Object o10; + @Contended + Object o11; + @Contended + Object o12; + @Contended + Object o13; + @Contended + Object o14; + } +} From 32a4863fdbf7c3bfb11472d9db5e81526b25f3d4 Mon Sep 17 00:00:00 2001 From: Shiv Shah Date: Tue, 12 May 2026 13:48:23 -0500 Subject: [PATCH 3/4] 8384107: Use small flattened value types and exact type declarations for contended oop map tests --- .../runtime/contended/OopMapsCustomValue.java | 204 ++++++++++-------- .../contended/OopMapsSameGroupValue.java | 73 ------- .../jtreg/runtime/contended/OopMapsValue.java | 134 ------------ 3 files changed, 115 insertions(+), 296 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java delete mode 100644 test/hotspot/jtreg/runtime/contended/OopMapsValue.java diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java index 70a2d50724d..13576ffd3e4 100644 --- a/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java +++ b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java @@ -25,7 +25,7 @@ /* * @test * @bug 8384107 - * @summary Test contended oop maps with custom value class instances + * @summary Test contended field layout and oop maps with flattened value types * * @modules java.base/jdk.internal.vm.annotation * @enablePreview @@ -34,111 +34,137 @@ public class OopMapsCustomValue { public static final int COUNT = 10000; - static value class Point { + // Small value type (32 bits) — guaranteed to be flattened + static value class Small { int x; - int y; - Point(int x, int y) { - this.x = x; - this.y = y; - } + Small(int x) { this.x = x; } } - public static void main(String[] args) throws Exception { - Point o01 = new Point(1, 1); - Point o02 = new Point(2, 2); - Point o03 = new Point(3, 3); - Point o04 = new Point(4, 4); - Point o05 = new Point(5, 5); - Point o06 = new Point(6, 6); - Point o07 = new Point(7, 7); - Point o08 = new Point(8, 8); - Point o09 = new Point(9, 9); - Point o10 = new Point(10, 10); - Point o11 = new Point(11, 11); - Point o12 = new Point(12, 12); - Point o13 = new Point(13, 13); - Point o14 = new Point(14, 14); - - R1[] rs = new R1[COUNT]; - for (int i = 0; i < COUNT; i++) { - R1 r1 = new R1(); - r1.o01 = o01; - r1.o02 = o02; - r1.o03 = o03; - r1.o04 = o04; - r1.o05 = o05; - r1.o06 = o06; - r1.o07 = o07; - r1.o08 = o08; - r1.o09 = o09; - r1.o10 = o10; - r1.o11 = o11; - r1.o12 = o12; - r1.o13 = o13; - r1.o14 = o14; - r1.i1 = 1; - r1.i2 = 2; - r1.i3 = 3; - r1.i4 = 4; - rs[i] = r1; - } - - System.gc(); - - for (int i = 0; i < COUNT; i++) { - R1 r1 = rs[i]; - if (!o01.equals(r1.o01)) throw new Error("Test Error: o01"); - if (!o02.equals(r1.o02)) throw new Error("Test Error: o02"); - if (!o03.equals(r1.o03)) throw new Error("Test Error: o03"); - if (!o04.equals(r1.o04)) throw new Error("Test Error: o04"); - if (!o05.equals(r1.o05)) throw new Error("Test Error: o05"); - if (!o06.equals(r1.o06)) throw new Error("Test Error: o06"); - if (!o07.equals(r1.o07)) throw new Error("Test Error: o07"); - if (!o08.equals(r1.o08)) throw new Error("Test Error: o08"); - if (!o09.equals(r1.o09)) throw new Error("Test Error: o09"); - if (!o10.equals(r1.o10)) throw new Error("Test Error: o10"); - if (!o11.equals(r1.o11)) throw new Error("Test Error: o11"); - if (!o12.equals(r1.o12)) throw new Error("Test Error: o12"); - if (!o13.equals(r1.o13)) throw new Error("Test Error: o13"); - if (!o14.equals(r1.o14)) throw new Error("Test Error: o14"); - if (r1.i1 != 1) throw new Error("Test Error: i1"); - if (r1.i2 != 2) throw new Error("Test Error: i2"); - if (r1.i3 != 3) throw new Error("Test Error: i3"); - if (r1.i4 != 4) throw new Error("Test Error: i4"); - } + // Value type with reference + primitive — flattened with compressed oops, + // not flattened with full size oops, creating distinct layout patterns + static value class Opt { + Object o; + boolean b; + Opt(Object o, boolean b) { this.o = o; this.b = b; } } + // Contended fields using exact value types for flattening public static class R0 { int i1; int i2; - Object o01; - Object o02; + Small s01; + Small s02; @Contended - Object o03; + Small s03; @Contended - Object o04; + Small s04; @Contended - Object o05; + Opt opt01; @Contended - Object o06; - @Contended - Object o07; - } + Opt opt02; + } - public static class R1 extends R0 { + public static class R1 extends R0 { int i3; int i4; - Object o08; - Object o09; - @Contended - Object o10; + Small s05; + Small s06; @Contended - Object o11; + Small s07; @Contended - Object o12; + Small s08; @Contended - Object o13; + Opt opt03; @Contended - Object o14; - } + Opt opt04; + } + + // Same-group contended with exact value types + public static class G { + @Contended("g1") + Small s01; + @Contended("g1") + Opt opt01; + @Contended("g2") + Small s02; + @Contended("g2") + Opt opt02; + } + + public static void main(String[] args) throws Exception { + testContendedValueFields(); + testContendedSameGroup(); + } + + static void testContendedValueFields() { + Object anchor = new Object(); + + R1[] rs = new R1[COUNT]; + for (int i = 0; i < COUNT; i++) { + R1 r = new R1(); + r.s01 = new Small(1); + r.s02 = new Small(2); + r.s03 = new Small(3); + r.s04 = new Small(4); + r.opt01 = new Opt(anchor, true); + r.opt02 = new Opt(anchor, false); + r.i1 = 1; + r.i2 = 2; + r.s05 = new Small(5); + r.s06 = new Small(6); + r.s07 = new Small(7); + r.s08 = new Small(8); + r.opt03 = new Opt(anchor, true); + r.opt04 = new Opt(anchor, false); + r.i3 = 3; + r.i4 = 4; + rs[i] = r; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + R1 r = rs[i]; + if (r.s01.x != 1) throw new Error("s01"); + if (r.s02.x != 2) throw new Error("s02"); + if (r.s03.x != 3) throw new Error("s03"); + if (r.s04.x != 4) throw new Error("s04"); + if (r.opt01.o != anchor || r.opt01.b != true) throw new Error("opt01"); + if (r.opt02.o != anchor || r.opt02.b != false) throw new Error("opt02"); + if (r.i1 != 1) throw new Error("i1"); + if (r.i2 != 2) throw new Error("i2"); + if (r.s05.x != 5) throw new Error("s05"); + if (r.s06.x != 6) throw new Error("s06"); + if (r.s07.x != 7) throw new Error("s07"); + if (r.s08.x != 8) throw new Error("s08"); + if (r.opt03.o != anchor || r.opt03.b != true) throw new Error("opt03"); + if (r.opt04.o != anchor || r.opt04.b != false) throw new Error("opt04"); + if (r.i3 != 3) throw new Error("i3"); + if (r.i4 != 4) throw new Error("i4"); + } + } + + static void testContendedSameGroup() { + Object anchor = new Object(); + + G[] gs = new G[COUNT]; + for (int i = 0; i < COUNT; i++) { + G g = new G(); + g.s01 = new Small(1); + g.opt01 = new Opt(anchor, true); + g.s02 = new Small(2); + g.opt02 = new Opt(anchor, false); + gs[i] = g; + } + + System.gc(); + + for (int i = 0; i < COUNT; i++) { + G g = gs[i]; + if (g.s01.x != 1) throw new Error("g1 s01"); + if (g.opt01.o != anchor || g.opt01.b != true) throw new Error("g1 opt01"); + if (g.s02.x != 2) throw new Error("g2 s02"); + if (g.opt02.o != anchor || g.opt02.b != false) throw new Error("g2 opt02"); + } + } } diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java deleted file mode 100644 index 9b856aa0ae5..00000000000 --- a/test/hotspot/jtreg/runtime/contended/OopMapsSameGroupValue.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -import jdk.internal.vm.annotation.Contended; - -/* - * @test - * @bug 8384107 - * @summary Test contended oop maps within the same group with value class instances - * - * @modules java.base/jdk.internal.vm.annotation - * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsSameGroupValue - */ -public class OopMapsSameGroupValue { - public static final int COUNT = 10000; - - public static void main(String[] args) throws Exception { - Integer o01 = Integer.valueOf(101); - Integer o02 = Integer.valueOf(102); - Integer o03 = Integer.valueOf(103); - Integer o04 = Integer.valueOf(104); - - R[] rs = new R[COUNT]; - for (int i = 0; i < COUNT; i++) { - R r = new R(); - r.o01 = o01; - r.o02 = o02; - r.o03 = o03; - r.o04 = o04; - rs[i] = r; - } - - System.gc(); - - for (int i = 0; i < COUNT; i++) { - R r = rs[i]; - if (!o01.equals(r.o01)) throw new Error("Test Error: o01"); - if (!o02.equals(r.o02)) throw new Error("Test Error: o02"); - if (!o03.equals(r.o03)) throw new Error("Test Error: o03"); - if (!o04.equals(r.o04)) throw new Error("Test Error: o04"); - } - } - - public static class R { - @Contended("group1") - Object o01; - @Contended("group1") - Object o02; - @Contended("group2") - Object o03; - @Contended("group2") - Object o04; - } -} diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsValue.java deleted file mode 100644 index 34adfb32ee3..00000000000 --- a/test/hotspot/jtreg/runtime/contended/OopMapsValue.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -import jdk.internal.vm.annotation.Contended; - -/* - * @test - * @bug 8384107 - * @summary Test contended oop maps with value class instances - * - * @modules java.base/jdk.internal.vm.annotation - * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsValue - */ -public class OopMapsValue { - public static final int COUNT = 10000; - - public static void main(String[] args) throws Exception { - Integer o01 = Integer.valueOf(101); - Integer o02 = Integer.valueOf(102); - Integer o03 = Integer.valueOf(103); - Integer o04 = Integer.valueOf(104); - Integer o05 = Integer.valueOf(105); - Integer o06 = Integer.valueOf(106); - Integer o07 = Integer.valueOf(107); - Integer o08 = Integer.valueOf(108); - Integer o09 = Integer.valueOf(109); - Integer o10 = Integer.valueOf(110); - Integer o11 = Integer.valueOf(111); - Integer o12 = Integer.valueOf(112); - Integer o13 = Integer.valueOf(113); - Integer o14 = Integer.valueOf(114); - - R1[] rs = new R1[COUNT]; - for (int i = 0; i < COUNT; i++) { - R1 r1 = new R1(); - r1.o01 = o01; - r1.o02 = o02; - r1.o03 = o03; - r1.o04 = o04; - r1.o05 = o05; - r1.o06 = o06; - r1.o07 = o07; - r1.o08 = o08; - r1.o09 = o09; - r1.o10 = o10; - r1.o11 = o11; - r1.o12 = o12; - r1.o13 = o13; - r1.o14 = o14; - r1.i1 = 1; - r1.i2 = 2; - r1.i3 = 3; - r1.i4 = 4; - rs[i] = r1; - } - - System.gc(); - - for (int i = 0; i < COUNT; i++) { - R1 r1 = rs[i]; - if (!o01.equals(r1.o01)) throw new Error("Test Error: o01"); - if (!o02.equals(r1.o02)) throw new Error("Test Error: o02"); - if (!o03.equals(r1.o03)) throw new Error("Test Error: o03"); - if (!o04.equals(r1.o04)) throw new Error("Test Error: o04"); - if (!o05.equals(r1.o05)) throw new Error("Test Error: o05"); - if (!o06.equals(r1.o06)) throw new Error("Test Error: o06"); - if (!o07.equals(r1.o07)) throw new Error("Test Error: o07"); - if (!o08.equals(r1.o08)) throw new Error("Test Error: o08"); - if (!o09.equals(r1.o09)) throw new Error("Test Error: o09"); - if (!o10.equals(r1.o10)) throw new Error("Test Error: o10"); - if (!o11.equals(r1.o11)) throw new Error("Test Error: o11"); - if (!o12.equals(r1.o12)) throw new Error("Test Error: o12"); - if (!o13.equals(r1.o13)) throw new Error("Test Error: o13"); - if (!o14.equals(r1.o14)) throw new Error("Test Error: o14"); - if (r1.i1 != 1) throw new Error("Test Error: i1"); - if (r1.i2 != 2) throw new Error("Test Error: i2"); - if (r1.i3 != 3) throw new Error("Test Error: i3"); - if (r1.i4 != 4) throw new Error("Test Error: i4"); - } - } - - public static class R0 { - int i1; - int i2; - Object o01; - Object o02; - @Contended - Object o03; - @Contended - Object o04; - @Contended - Object o05; - @Contended - Object o06; - @Contended - Object o07; - } - - public static class R1 extends R0 { - int i3; - int i4; - Object o08; - Object o09; - @Contended - Object o10; - @Contended - Object o11; - @Contended - Object o12; - @Contended - Object o13; - @Contended - Object o14; - } -} From 7dcbb8838ccd0f3ea62b70c256813c75e95d72c5 Mon Sep 17 00:00:00 2001 From: Shiv Shah Date: Wed, 20 May 2026 14:55:45 -0400 Subject: [PATCH 4/4] 8384107: Use @AsValueClass instead of value keyword --- .../jtreg/runtime/contended/OopMapsCustomValue.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java index 13576ffd3e4..5a187d78f55 100644 --- a/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java +++ b/test/hotspot/jtreg/runtime/contended/OopMapsCustomValue.java @@ -21,28 +21,31 @@ * questions. */ import jdk.internal.vm.annotation.Contended; +import jdk.test.lib.valueclass.AsValueClass; /* * @test * @bug 8384107 * @summary Test contended field layout and oop maps with flattened value types * + * @library /test/lib * @modules java.base/jdk.internal.vm.annotation - * @enablePreview * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsCustomValue */ public class OopMapsCustomValue { public static final int COUNT = 10000; // Small value type (32 bits) — guaranteed to be flattened - static value class Small { + @AsValueClass + static class Small { int x; Small(int x) { this.x = x; } } // Value type with reference + primitive — flattened with compressed oops, // not flattened with full size oops, creating distinct layout patterns - static value class Opt { + @AsValueClass + static class Opt { Object o; boolean b; Opt(Object o, boolean b) { this.o = o; this.b = b; }