From 30a584041f4aec532b163a4245f77bdc96b7de61 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Mon, 29 Jan 2024 10:07:51 -0500 Subject: [PATCH 1/7] add TestShenandoahBarrierExpansion --- .../TestShenandoahBarrierExpansion.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java new file mode 100644 index 0000000000000..bc5bae1fb78a6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -0,0 +1,69 @@ +package compiler.gcbarriers; + +import compiler.lib.ir_framework.CompilePhase; +import compiler.lib.ir_framework.IR; +import compiler.lib.ir_framework.IRNode; +import compiler.lib.ir_framework.Test; +import compiler.lib.ir_framework.TestFramework; + +/** + * @test + * @bug 8231569 + * @summary Test that Shenandoah barriers are expanded correctly + * @library /test/lib / + * @requires vm.gc.Shenandoah + * @run driver compiler.gcbarriers.TestShenandoahBarrierExpansion + */ +public class TestShenandoahBarrierExpansion { + public static void main(String[] args) { + TestFramework test = new TestFramework(TestShenandoahBarrierExpansion.class); + test.addFlags( + "-XX:+UseShenandoahGC", + "-XX:-BackgroundCompilation", + "-XX:-UseOnStackReplacement", + "-XX:-UseCompressedOops", + "-XX:CompileCommand=dontinline," + TestShenandoahBarrierExpansion.class.getName() + "::notInlined"); + test.start(); + } + + private static Object staticField; + @Test + @IR(failOn = IRNode.IF, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.BARRIER_EXPANSION) + public Object testLoadFieldObject() { + return staticField; + } + + private static A staticField2 = new A(); + @Test + @IR(counts = { IRNode.IF, "1" }, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) + private static int testLoadObjectFieldWithNullCheck() { + return staticField2.intField; + } + + private static A staticField3 = new A(); + @Test + @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "6" }, phase = CompilePhase.BARRIER_EXPANSION) + private static int testLoadTwoObjectFieldsWithNullCheck() { + return staticField2.intField + staticField3.intField; + } + + @Test + @IR(failOn = IRNode.IF, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) + private static void testLoadTwoFieldObjectAndEscape() { + final A field2 = staticField2; + final A field3 = staticField3; + notInlined(field2, field3); + } + + private static void notInlined(A field2, A field3) { + // noop + } + + private static class A { + public int intField; + } +} From 253e9552886bfaa2da660cf86e196f6f5500b8d8 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Mon, 29 Jan 2024 12:26:47 -0500 Subject: [PATCH 2/7] update vm flags --- .../compiler/gcbarriers/TestShenandoahBarrierExpansion.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index bc5bae1fb78a6..838992f51f557 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -19,9 +19,6 @@ public static void main(String[] args) { TestFramework test = new TestFramework(TestShenandoahBarrierExpansion.class); test.addFlags( "-XX:+UseShenandoahGC", - "-XX:-BackgroundCompilation", - "-XX:-UseOnStackReplacement", - "-XX:-UseCompressedOops", "-XX:CompileCommand=dontinline," + TestShenandoahBarrierExpansion.class.getName() + "::notInlined"); test.start(); } From f4801904277aa92634671c08b7b7397e49dec232 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Tue, 6 Feb 2024 07:17:22 -0500 Subject: [PATCH 3/7] update vm flags --- .../compiler/gcbarriers/TestShenandoahBarrierExpansion.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index 838992f51f557..3deadb18dc2bd 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -1,6 +1,7 @@ package compiler.gcbarriers; import compiler.lib.ir_framework.CompilePhase; +import compiler.lib.ir_framework.DontInline; import compiler.lib.ir_framework.IR; import compiler.lib.ir_framework.IRNode; import compiler.lib.ir_framework.Test; @@ -17,9 +18,7 @@ public class TestShenandoahBarrierExpansion { public static void main(String[] args) { TestFramework test = new TestFramework(TestShenandoahBarrierExpansion.class); - test.addFlags( - "-XX:+UseShenandoahGC", - "-XX:CompileCommand=dontinline," + TestShenandoahBarrierExpansion.class.getName() + "::notInlined"); + test.addFlags("-XX:+UseShenandoahGC"); test.start(); } @@ -56,6 +55,7 @@ private static void testLoadTwoFieldObjectAndEscape() { notInlined(field2, field3); } + @DontInline private static void notInlined(A field2, A field3) { // noop } From 9f10ce43a4b44ddbf1663cfd0df40ec069415e83 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Wed, 17 Apr 2024 09:24:42 -0400 Subject: [PATCH 4/7] update test annotation --- .../compiler/gcbarriers/TestShenandoahBarrierExpansion.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index 3deadb18dc2bd..9f303b99b708e 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -13,7 +13,7 @@ * @summary Test that Shenandoah barriers are expanded correctly * @library /test/lib / * @requires vm.gc.Shenandoah - * @run driver compiler.gcbarriers.TestShenandoahBarrierExpansion + * @run main compiler.gcbarriers.TestShenandoahBarrierExpansion */ public class TestShenandoahBarrierExpansion { public static void main(String[] args) { From 54f52eccd608a2d73387722872a8168ce78bb654 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Wed, 17 Apr 2024 09:26:58 -0400 Subject: [PATCH 5/7] add license header --- .../TestShenandoahBarrierExpansion.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index 9f303b99b708e..ad84dcfd9e260 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -1,3 +1,26 @@ +/* + * Copyright (c) 2024 Red Hat 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. + */ + package compiler.gcbarriers; import compiler.lib.ir_framework.CompilePhase; From de8cbf95b8e7c8c34b7f776eb95730d92a471ee4 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Wed, 17 Apr 2024 11:08:28 -0400 Subject: [PATCH 6/7] change assertion phase from MACRO_EXPANSION to AFTER_MACRO_EXPANSION_STEP --- .../gcbarriers/TestShenandoahBarrierExpansion.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index ad84dcfd9e260..c4fb06ad80748 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -47,7 +47,7 @@ public static void main(String[] args) { private static Object staticField; @Test - @IR(failOn = IRNode.IF, phase = CompilePhase.MACRO_EXPANSION) + @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.BARRIER_EXPANSION) public Object testLoadFieldObject() { return staticField; @@ -55,7 +55,7 @@ public Object testLoadFieldObject() { private static A staticField2 = new A(); @Test - @IR(counts = { IRNode.IF, "1" }, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "1" }, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) private static int testLoadObjectFieldWithNullCheck() { return staticField2.intField; @@ -63,14 +63,14 @@ private static int testLoadObjectFieldWithNullCheck() { private static A staticField3 = new A(); @Test - @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.MACRO_EXPANSION) + @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) @IR(counts = { IRNode.IF, "6" }, phase = CompilePhase.BARRIER_EXPANSION) private static int testLoadTwoObjectFieldsWithNullCheck() { return staticField2.intField + staticField3.intField; } @Test - @IR(failOn = IRNode.IF, phase = CompilePhase.MACRO_EXPANSION) + @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) private static void testLoadTwoFieldObjectAndEscape() { final A field2 = staticField2; From 25801ce60219c952823614c420f64512ce960876 Mon Sep 17 00:00:00 2001 From: Kangcheng Xu Date: Wed, 15 May 2024 12:17:28 -0400 Subject: [PATCH 7/7] update asserted IR phase --- .../gcbarriers/TestShenandoahBarrierExpansion.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java index c4fb06ad80748..84a34695092dd 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestShenandoahBarrierExpansion.java @@ -47,7 +47,7 @@ public static void main(String[] args) { private static Object staticField; @Test - @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) + @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_PARSING) @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.BARRIER_EXPANSION) public Object testLoadFieldObject() { return staticField; @@ -55,7 +55,7 @@ public Object testLoadFieldObject() { private static A staticField2 = new A(); @Test - @IR(counts = { IRNode.IF, "1" }, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) + @IR(counts = { IRNode.IF, "1" }, phase = CompilePhase.AFTER_PARSING) @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) private static int testLoadObjectFieldWithNullCheck() { return staticField2.intField; @@ -63,14 +63,14 @@ private static int testLoadObjectFieldWithNullCheck() { private static A staticField3 = new A(); @Test - @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) + @IR(counts = { IRNode.IF, "2" }, phase = CompilePhase.AFTER_PARSING) @IR(counts = { IRNode.IF, "6" }, phase = CompilePhase.BARRIER_EXPANSION) private static int testLoadTwoObjectFieldsWithNullCheck() { return staticField2.intField + staticField3.intField; } @Test - @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_MACRO_EXPANSION_STEP) + @IR(failOn = IRNode.IF, phase = CompilePhase.AFTER_PARSING) @IR(counts = { IRNode.IF, "3" }, phase = CompilePhase.BARRIER_EXPANSION) private static void testLoadTwoFieldObjectAndEscape() { final A field2 = staticField2;