From 4c7ed1706eb7f4dace16116d60f93f4e2fdb469f Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Fri, 21 Mar 2025 13:08:26 +0100 Subject: [PATCH 1/5] Fix TestBadFormat --- .../ir_framework/tests/TestBadFormat.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestBadFormat.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestBadFormat.java index 8e6085708ed69..ac8867f398552 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestBadFormat.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestBadFormat.java @@ -1163,15 +1163,17 @@ public void machNode() {} public void duplicatedPhase() {} @Test - @FailCount(4) - @IR(failOn = IRNode.ALLOC, phase = {CompilePhase.FINAL_CODE, CompilePhase.AFTER_MACRO_EXPANSION}) - @IR(failOn = IRNode.ALLOC, phase = CompilePhase.PRINT_IDEAL) + @FailCount(6) + @IR(failOn = IRNode.ALLOC, phase = {CompilePhase.FINAL_CODE, CompilePhase.AFTER_MACRO_EXPANSION}) // FINAL_CODE not available + @IR(failOn = IRNode.ALLOC, phase = CompilePhase.PRINT_IDEAL) // PRINT_IDEAL not available + @IR(failOn = IRNode.ALLOC, phase = {CompilePhase.ITER_GVN1, CompilePhase.AFTER_PARSING}) // works @IR(failOn = IRNode.ALLOC, phase = {CompilePhase.ITER_GVN1, CompilePhase.AFTER_PARSING, - CompilePhase.PRINT_OPTO_ASSEMBLY}) // works - @IR(failOn = IRNode.ALLOC_ARRAY, phase = {CompilePhase.FINAL_CODE, CompilePhase.AFTER_MACRO_EXPANSION}) - @IR(failOn = IRNode.ALLOC_ARRAY, phase = CompilePhase.PRINT_IDEAL) + CompilePhase.PRINT_OPTO_ASSEMBLY}) // PRINT_OPTO_ASSEMBLY not available + @IR(failOn = IRNode.ALLOC_ARRAY, phase = {CompilePhase.FINAL_CODE, CompilePhase.AFTER_MACRO_EXPANSION}) // FINAL_CODE not available + @IR(failOn = IRNode.ALLOC_ARRAY, phase = CompilePhase.PRINT_IDEAL) // PRINT_IDEAL not available + @IR(failOn = IRNode.ALLOC_ARRAY, phase = {CompilePhase.ITER_GVN1, CompilePhase.AFTER_PARSING}) // works @IR(failOn = IRNode.ALLOC_ARRAY, phase = {CompilePhase.ITER_GVN1, CompilePhase.AFTER_PARSING, - CompilePhase.PRINT_OPTO_ASSEMBLY}) // works + CompilePhase.PRINT_OPTO_ASSEMBLY}) // PRINT_OPTO_ASSEMBLY not available public void alloc() {} @Test From ee3cc6f9d580ea6d17724763e34e9caeb0400fbb Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Fri, 21 Mar 2025 13:49:24 +0100 Subject: [PATCH 2/5] Fix TestPhaseIRMatching.java --- .../tests/TestPhaseIRMatching.java | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java index ca0e37de166a8..804831f384179 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java @@ -107,6 +107,16 @@ class Basics { Object obj3; Object obj4; + public class Helper { + private String s; + + public Helper(String s, int i) { + this.s = s; + } + + public String getString() { return s; } + } + @Test @IR(failOn = IRNode.STORE, phase = {CompilePhase.DEFAULT, CompilePhase.PRINT_IDEAL}) @ExpectedFailure(ruleId = 1, failOn = 1) // Only one failure - remove duplicated phases after mapping DEFAULT @@ -118,14 +128,14 @@ public void removeDuplicates() { @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.COUNTED_LOOP}, counts = {IRNode.STORE, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 3}) - @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 2) + @ExpectedFailure(ruleId = 1, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 2) @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.COUNTED_LOOP}) @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_IDEAL, failOn = 1) @IR(counts = {IRNode.STORE, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) - @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 2) + @ExpectedFailure(ruleId = 3, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 2) @IR(counts = {IRNode.STORE_I, "2"}) @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, counts = 1) @@ -135,50 +145,50 @@ public void defaultOnIdeal() { } @Test - @IR(failOn = {IRNode.STORE_F, IRNode.ALLOC, IRNode.COUNTED_LOOP}, - counts = {IRNode.STORE_F, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) + @IR(failOn = {IRNode.STORE_F, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}, + counts = {IRNode.STORE_F, "3", IRNode.FIELD_ACCESS, "1", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) - @IR(failOn = {IRNode.STORE_F, IRNode.ALLOC, IRNode.COUNTED_LOOP}) + @IR(failOn = {IRNode.STORE_F, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}) @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) - @IR(counts = {IRNode.STORE_F, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) + @IR(counts = {IRNode.STORE_F, "3", IRNode.FIELD_ACCESS, "1", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) - @IR(failOn = {IRNode.STORE_F, IRNode.ALLOC, IRNode.COUNTED_LOOP}, - counts = {IRNode.STORE_F, "3", IRNode.ALLOC, "2", IRNode.COUNTED_LOOP, "2"}) + @IR(failOn = {IRNode.STORE_F, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}, + counts = {IRNode.STORE_F, "3", IRNode.FIELD_ACCESS, "2", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2, counts = 2) @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) - @IR(counts = {IRNode.ALLOC, "2"}) + @IR(counts = {IRNode.FIELD_ACCESS, "2"}) @ExpectedFailure(ruleId = 5, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 1) - public Object defaultOnOptoAssembly() { - return new Object(); + public Object defaultOnOptoAssembly(Helper h) { + return h.getString(); } @Test @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}, counts = {IRNode.STORE, "20", IRNode.ALLOC, "1", IRNode.ALLOC_OF, "Object", "1", IRNode.COUNTED_LOOP, "2"}) - @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = {2, 3}) + @ExpectedFailure(ruleId = 1, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}) @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 4}) @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}) @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_IDEAL, failOn = 1) - @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = {2, 3}) + @ExpectedFailure(ruleId = 2, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}) @IR(counts = {IRNode.STORE, "20", IRNode.ALLOC, "1", IRNode.ALLOC_OF, "Object", "2", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 4}) - @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 3) + @ExpectedFailure(ruleId = 3, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 3) @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}, counts = {IRNode.STORE, "20", IRNode.ALLOC, "2", IRNode.ALLOC_OF, "Object", "2", IRNode.COUNTED_LOOP, "2"}) - @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = {2, 3}, counts = {2, 3}) + @ExpectedFailure(ruleId = 4, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}, counts = {2, 3}) @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 4}) @IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_OF, "Object", "1"}) - @ExpectedFailure(ruleId = 5, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 1) + @ExpectedFailure(ruleId = 5, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 1) public void defaultOnBoth() { obj = new Object(); } @@ -202,7 +212,7 @@ public int removeLoopsWithMultipleCompilations(int k) { return x; } - @Run(test = "removeLoopsWithMultipleCompilations") + @Run(test = {"removeLoopsWithMultipleCompilations", "defaultOnOptoAssembly"}) @Warmup(1) public void run() { for (int i = 0; i < 10000; i++) { @@ -211,6 +221,7 @@ public void run() { for (int i = 0; i < 10000; i++) { removeLoopsWithMultipleCompilations(3); } + defaultOnOptoAssembly(new Helper("a", 1)); } @Test @@ -238,9 +249,9 @@ public int limit() { @Test @IR(failOn = {IRNode.ALLOC, IRNode.ALLOC_ARRAY}, counts = {IRNode.ALLOC, "0", IRNode.ALLOC_ARRAY, "0"}, - phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.PRINT_OPTO_ASSEMBLY, CompilePhase.DEFAULT}) + phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.DEFAULT}) @ExpectedFailure(ruleId = 1, failOn = {1, 2}, counts = {1, 2}, - phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.PRINT_OPTO_ASSEMBLY}) + phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.BEFORE_MACRO_EXPANSION}) public void alloc() { obj = new Object(); obj2 = new Object[1]; @@ -248,7 +259,7 @@ public void alloc() { @Test @IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_ARRAY, "2"}, // works for all phases - phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.PRINT_OPTO_ASSEMBLY, CompilePhase.DEFAULT}) + phase = {CompilePhase.BEFORE_REMOVEUSELESS, CompilePhase.CCP1, CompilePhase.DEFAULT}) public void alloc2() { obj = new Object(); obj2 = new Object[1]; From 17e11d4abfc484a25271437e968678a6243f7289 Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Fri, 21 Mar 2025 14:21:44 +0100 Subject: [PATCH 3/5] Fix TestCompilePhaseCollector.java --- .../tests/flag/TestCompilePhaseCollector.java | 63 ++++++++++--------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java index d8f2e2d6e617d..37ea463253670 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java @@ -113,12 +113,12 @@ public void testMixedPhases() { assertContainsOnly(methodToCompilePhases, testClass, "mix7", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix8", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, - OPTIMIZE_FINISHED, PRINT_IDEAL, PRINT_OPTO_ASSEMBLY); + OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix9", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix10", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY); - assertContainsOnly(methodToCompilePhases, testClass, "mix11", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY, + assertContainsOnly(methodToCompilePhases, testClass, "mix11", PHASEIDEALLOOP1, PHASEIDEALLOOP2, BEFORE_MACRO_EXPANSION, FINAL_CODE, OPTIMIZE_FINISHED); - assertContainsOnly(methodToCompilePhases, testClass, "mix12", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY, + assertContainsOnly(methodToCompilePhases, testClass, "mix12", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix13", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_IDEAL, FINAL_CODE, OPTIMIZE_FINISHED); @@ -129,7 +129,7 @@ public void testMixedPhases() { assertContainsOnly(methodToCompilePhases, testClass, "mix16", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix17", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, - OPTIMIZE_FINISHED, PRINT_OPTO_ASSEMBLY); + OPTIMIZE_FINISHED, PRINT_IDEAL); } private void testDefault(Class testClass, CompilePhase... compilePhases) { @@ -147,9 +147,9 @@ private void assertContainsOnly(Map> methodToCompilePh String simpleMethodName, CompilePhase... compilePhases) { String methodName = getFullMethodName(testClass, simpleMethodName); Set compilePhaseSet = methodToCompilePhases.get(methodName); - Assert.assertEquals("must be equal", compilePhases.length, compilePhaseSet.size()); + Assert.assertEquals("In method " + simpleMethodName + ": must be equal", compilePhases.length, compilePhaseSet.size()); for (CompilePhase compilePhase : compilePhases) { - Assert.assertTrue("did not find " + compilePhase + " for " + methodName, + Assert.assertTrue("In method " + simpleMethodName + ": did not find " + compilePhase + " for " + methodName, methodToCompilePhases.get(methodName).contains(compilePhase)); } } @@ -193,44 +193,45 @@ public void test6() {} } static class Opto { + @Test - @IR(failOn = IRNode.ALLOC) + @IR(counts = {IRNode.SCOPE_OBJECT, "2"}) public void test1() {} - @Test - @IR(failOn = {IRNode.ALLOC_OF, "Foo"}) + @IR(counts = {IRNode.OOPMAP_WITH, "Foo", "2"}) public void test2() {} @Test - @IR(counts = {IRNode.SCOPE_OBJECT, "2"}) + @IR(failOn = IRNode.FIELD_ACCESS) + @IR(counts = {IRNode.CHECKCAST_ARRAY, "2"}) public void test3() {} @Test - @IR(counts = {IRNode.ALLOC_ARRAY_OF, "Foo", "!= 4"}) + @IR(failOn = {IRNode.CHECKCAST_ARRAYCOPY, IRNode.CHECKCAST_ARRAY_OF, "Foo"}) + @IR(counts = {IRNode.CBZ_HI, "> 1"}) public void test4() {} - @Test - @IR(failOn = IRNode.FIELD_ACCESS) - @IR(counts = {IRNode.CHECKCAST_ARRAY, "2"}) + @IR(failOn = {IRNode.CBNZW_HI}) + @IR(counts = {IRNode.CBZ_LS, "2", IRNode.CBZW_LS, "> 1"}) public void test5() {} @Test - @IR(failOn = {IRNode.CHECKCAST_ARRAYCOPY, IRNode.CHECKCAST_ARRAY_OF, "Foo"}) - @IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_ARRAY_OF, "Foo", "> 1"}) + @IR(failOn = {IRNode.CBNZW_HI}) + @IR(counts = {IRNode.CBZW_LS, "> 1"}) public void test6() {} } static class IdealAndOpto { @Test - @IR(failOn = IRNode.ALLOC) + @IR(failOn = IRNode.FIELD_ACCESS) @IR(failOn = IRNode.STORE) public void test1() {} @Test - @IR(failOn = {IRNode.ALLOC_OF, "Foo"}) + @IR(failOn = {IRNode.CHECKCAST_ARRAY_OF, "Foo"}) @IR(failOn = {IRNode.STORE_OF_FIELD, "iFld"}) public void test2() {} @@ -241,7 +242,7 @@ public void test3() {} @Test @IR(counts = {IRNode.LOAD_OF_FIELD, "iFld", "!= 4"}) - @IR(counts = {IRNode.ALLOC_ARRAY_OF, "Foo", "!= 4"}) + @IR(counts = {IRNode.OOPMAP_WITH, "Foo", "!= 4"}) public void test4() {} @@ -254,7 +255,7 @@ public void test5() {} @Test @IR(failOn = {IRNode.STORE, IRNode.CHECKCAST_ARRAY_OF, "Foo"}) - @IR(counts = {IRNode.ALLOC, "2", IRNode.STORE_OF_FIELD, "iFld", "> 1"}) + @IR(counts = {IRNode.FIELD_ACCESS, "2", IRNode.STORE_OF_FIELD, "iFld", "> 1"}) public void test6() {} } @@ -308,7 +309,7 @@ public void test2() {} @Test @IR(failOn = IRNode.ALLOC, phase = AFTER_PARSING) - @IR(failOn = {IRNode.ALLOC_ARRAY_OF, "Foo"}, phase = DEFAULT) + @IR(failOn = {IRNode.OOPMAP_WITH, "Foo"}, phase = DEFAULT) public void test3() {} @Test @@ -326,7 +327,7 @@ public void test6() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(failOn = IRNode.ALLOC, phase = DEFAULT) + @IR(failOn = IRNode.FIELD_ACCESS, phase = DEFAULT) @IR(failOn = IRNode.STORE, phase = {FINAL_CODE, OPTIMIZE_FINISHED}) public void test7() {} @@ -346,7 +347,7 @@ public void test2A() {} @Test @IR(counts = {IRNode.ALLOC, "< 3"}, phase = AFTER_PARSING) - @IR(counts = {IRNode.ALLOC_ARRAY_OF, "Foo", ">=3"}, phase = DEFAULT) + @IR(counts = {IRNode.OOPMAP_WITH, "Foo", ">=3"}, phase = DEFAULT) public void test3A() {} @Test @@ -364,7 +365,7 @@ public void test6A() {} @Test @IR(counts = {IRNode.STORE, "3"}, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.ALLOC, "3"}, phase = DEFAULT) + @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = DEFAULT) @IR(counts = {IRNode.STORE, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED}) public void test7A() {} @@ -386,13 +387,13 @@ public void mix2() {} @Test @IR(failOn = IRNode.STORE, phase = AFTER_PARSING) @IR(counts = {IRNode.STORE, "3"}, phase = DEFAULT) - @IR(failOn = {IRNode.ALLOC_OF, "Foo"}, phase = DEFAULT) + @IR(failOn = {IRNode.OOPMAP_WITH, "Foo"}, phase = DEFAULT) public void mix3() {} @Test @IR(counts = {IRNode.STORE, "3"}, phase = AFTER_PARSING) @IR(counts = {IRNode.STORE_OF_CLASS, "Foo", "3"}, phase = DEFAULT) - @IR(failOn = IRNode.ALLOC, phase = DEFAULT) + @IR(failOn = IRNode.FIELD_ACCESS, phase = DEFAULT) public void mix4() {} @Test @@ -402,7 +403,7 @@ public void mix5() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.ALLOC, "3"}, phase = DEFAULT) + @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = DEFAULT) @IR(failOn = IRNode.STORE, phase = {FINAL_CODE, OPTIMIZE_FINISHED}) public void mix6() {} @@ -413,7 +414,7 @@ public void mix7() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, DEFAULT, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.ALLOC, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(counts = {IRNode.LOOP, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix8() {} @Test @@ -425,13 +426,13 @@ public void mix9() {} public void mix10() {} @Test - @IR(failOn = IRNode.ALLOC, phase = {PHASEIDEALLOOP1, PRINT_OPTO_ASSEMBLY, PHASEIDEALLOOP2}) + @IR(failOn = IRNode.ALLOC, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) @IR(counts = {IRNode.ALLOC, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix11() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, PRINT_IDEAL, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.ALLOC, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(counts = {IRNode.LOOP, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix12() {} @Test @@ -456,7 +457,7 @@ public void mix16() {} @Test @IR(counts = {"foo", "3"}, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(failOn = IRNode.ALLOC, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(failOn = IRNode.LOOP, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix17() {} } } From 98febc9d503818d13adcc1420dd5937ba25fb2cc Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Mon, 24 Mar 2025 14:57:17 +0100 Subject: [PATCH 4/5] wip --- .../tests/TestPhaseIRMatching.java | 52 ++++++++++--------- .../tests/flag/TestCompilePhaseCollector.java | 18 +++---- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java index 804831f384179..f2dd871ae83a9 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java @@ -125,17 +125,18 @@ public void removeDuplicates() { } @Test - @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.COUNTED_LOOP}, - counts = {IRNode.STORE, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) + @IR(failOn = {IRNode.STORE, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}, + counts = {IRNode.STORE, "3", IRNode.FIELD_ACCESS, "2", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 3}) - @ExpectedFailure(ruleId = 1, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 2) + @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) - @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.COUNTED_LOOP}) + @IR(failOn = {IRNode.STORE, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}) @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_IDEAL, failOn = 1) + @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) - @IR(counts = {IRNode.STORE, "3", IRNode.ALLOC, "1", IRNode.COUNTED_LOOP, "2"}) + @IR(counts = {IRNode.STORE, "3", IRNode.FIELD_ACCESS, "1", IRNode.COUNTED_LOOP, "2"}) @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) - @ExpectedFailure(ruleId = 3, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 2) + @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 2) @IR(counts = {IRNode.STORE_I, "2"}) @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, counts = 1) @@ -169,28 +170,30 @@ public Object defaultOnOptoAssembly(Helper h) { } @Test - @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}, - counts = {IRNode.STORE, "20", IRNode.ALLOC, "1", IRNode.ALLOC_OF, "Object", "1", IRNode.COUNTED_LOOP, "2"}) - @ExpectedFailure(ruleId = 1, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}) - @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 4}) + @IR(failOn = {IRNode.STORE, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}, + counts = {IRNode.STORE, "20", IRNode.FIELD_ACCESS, "3", IRNode.COUNTED_LOOP, "2"}) + @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) + @ExpectedFailure(ruleId = 1, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 3}) - @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}) + @IR(failOn = {IRNode.STORE, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}) @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_IDEAL, failOn = 1) - @ExpectedFailure(ruleId = 2, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}) + @ExpectedFailure(ruleId = 2, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2) - @IR(counts = {IRNode.STORE, "20", IRNode.ALLOC, "1", IRNode.ALLOC_OF, "Object", "2", IRNode.COUNTED_LOOP, "2"}) - @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 4}) - @ExpectedFailure(ruleId = 3, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 3) + @IR(counts = {IRNode.STORE, "20", IRNode.FIELD_ACCESS, "2", IRNode.COUNTED_LOOP, "2"}) + @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_IDEAL, counts = {1, 3}) + @ExpectedFailure(ruleId = 3, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 2) - @IR(failOn = {IRNode.STORE, IRNode.ALLOC, IRNode.ALLOC_OF, "Object", IRNode.COUNTED_LOOP}, - counts = {IRNode.STORE, "20", IRNode.ALLOC, "2", IRNode.ALLOC_OF, "Object", "2", IRNode.COUNTED_LOOP, "2"}) - @ExpectedFailure(ruleId = 4, phase = CompilePhase.BEFORE_MACRO_EXPANSION, failOn = {2, 3}, counts = {2, 3}) - @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 4}) + @IR(failOn = {IRNode.STORE, IRNode.FIELD_ACCESS, IRNode.COUNTED_LOOP}, + counts = {IRNode.STORE, "20", IRNode.FIELD_ACCESS, "2", IRNode.COUNTED_LOOP, "2"}) + @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, failOn = 2, counts = 2) + @ExpectedFailure(ruleId = 4, phase = CompilePhase.PRINT_IDEAL, failOn = 1, counts = {1, 3}) - @IR(counts = {IRNode.ALLOC, "2", IRNode.ALLOC_OF, "Object", "1"}) - @ExpectedFailure(ruleId = 5, phase = CompilePhase.BEFORE_MACRO_EXPANSION, counts = 1) - public void defaultOnBoth() { - obj = new Object(); + @IR(counts = {IRNode.FIELD_ACCESS, "2"}) + @ExpectedFailure(ruleId = 5, phase = CompilePhase.PRINT_OPTO_ASSEMBLY, counts = 1) + public Object defaultOnBoth(Helper h) { + i = 34; + l = 34; + return h.getString(); } @Test @@ -212,7 +215,7 @@ public int removeLoopsWithMultipleCompilations(int k) { return x; } - @Run(test = {"removeLoopsWithMultipleCompilations", "defaultOnOptoAssembly"}) + @Run(test = {"removeLoopsWithMultipleCompilations", "defaultOnOptoAssembly", "defaultOnBoth"}) @Warmup(1) public void run() { for (int i = 0; i < 10000; i++) { @@ -222,6 +225,7 @@ public void run() { removeLoopsWithMultipleCompilations(3); } defaultOnOptoAssembly(new Helper("a", 1)); + defaultOnBoth(new Helper("a", 1)); } @Test diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java index 37ea463253670..1fbfd73f43b5f 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java @@ -113,12 +113,12 @@ public void testMixedPhases() { assertContainsOnly(methodToCompilePhases, testClass, "mix7", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix8", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, - OPTIMIZE_FINISHED, PRINT_IDEAL); + OPTIMIZE_FINISHED, PRINT_IDEAL, PRINT_OPTO_ASSEMBLY); assertContainsOnly(methodToCompilePhases, testClass, "mix9", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix10", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY); - assertContainsOnly(methodToCompilePhases, testClass, "mix11", PHASEIDEALLOOP1, PHASEIDEALLOOP2, BEFORE_MACRO_EXPANSION, + assertContainsOnly(methodToCompilePhases, testClass, "mix11", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY, FINAL_CODE, OPTIMIZE_FINISHED); - assertContainsOnly(methodToCompilePhases, testClass, "mix12", PHASEIDEALLOOP1, PHASEIDEALLOOP2, + assertContainsOnly(methodToCompilePhases, testClass, "mix12", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_OPTO_ASSEMBLY, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix13", PHASEIDEALLOOP1, PHASEIDEALLOOP2, PRINT_IDEAL, FINAL_CODE, OPTIMIZE_FINISHED); @@ -129,7 +129,7 @@ public void testMixedPhases() { assertContainsOnly(methodToCompilePhases, testClass, "mix16", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, OPTIMIZE_FINISHED, PRINT_IDEAL); assertContainsOnly(methodToCompilePhases, testClass, "mix17", PHASEIDEALLOOP1, PHASEIDEALLOOP2, FINAL_CODE, - OPTIMIZE_FINISHED, PRINT_IDEAL); + OPTIMIZE_FINISHED, PRINT_OPTO_ASSEMBLY); } private void testDefault(Class testClass, CompilePhase... compilePhases) { @@ -414,7 +414,7 @@ public void mix7() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, DEFAULT, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.LOOP, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix8() {} @Test @@ -426,13 +426,13 @@ public void mix9() {} public void mix10() {} @Test - @IR(failOn = IRNode.ALLOC, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.ALLOC, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(failOn = IRNode.FIELD_ACCESS, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) + @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix11() {} @Test @IR(failOn = IRNode.STORE, phase = {PHASEIDEALLOOP1, PRINT_IDEAL, PHASEIDEALLOOP2}) - @IR(counts = {IRNode.LOOP, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix12() {} @Test @@ -457,7 +457,7 @@ public void mix16() {} @Test @IR(counts = {"foo", "3"}, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) - @IR(failOn = IRNode.LOOP, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) + @IR(failOn = IRNode.FIELD_ACCESS, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix17() {} } } From b125df8a5ac79c9cb278fe16322f9a4074ac1512 Mon Sep 17 00:00:00 2001 From: Marc Chevalier Date: Mon, 24 Mar 2025 14:59:16 +0100 Subject: [PATCH 5/5] wip --- .../ir_framework/tests/flag/TestCompilePhaseCollector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java index 1fbfd73f43b5f..acb900fbdc09c 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/tests/flag/TestCompilePhaseCollector.java @@ -426,7 +426,7 @@ public void mix9() {} public void mix10() {} @Test - @IR(failOn = IRNode.FIELD_ACCESS, phase = {PHASEIDEALLOOP1, PHASEIDEALLOOP2}) + @IR(failOn = IRNode.FIELD_ACCESS, phase = {PHASEIDEALLOOP1, PRINT_OPTO_ASSEMBLY, PHASEIDEALLOOP2}) @IR(counts = {IRNode.FIELD_ACCESS, "3"}, phase = {FINAL_CODE, OPTIMIZE_FINISHED, DEFAULT}) public void mix11() {}