< prev index next >

test/hotspot/jtreg/compiler/sharedstubs/SharedStubToInterpTest.java

Print this page

 34  *
 35  * @test id=C2
 36  * @requires vm.opt.TieredStopAtLevel == null & vm.opt.TieredCompilation == null
 37  * @requires vm.simpleArch == "x86" | vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64"
 38  * @requires vm.debug
 39  * @run driver compiler.sharedstubs.SharedStubToInterpTest -XX:-TieredCompilation
 40  *
 41  */
 42 
 43 package compiler.sharedstubs;
 44 
 45 import java.util.ArrayList;
 46 import java.util.List;
 47 import java.util.regex.Pattern;
 48 import jdk.test.lib.process.OutputAnalyzer;
 49 import jdk.test.lib.process.ProcessTools;
 50 
 51 public class SharedStubToInterpTest {
 52     private final static int ITERATIONS_TO_HEAT_LOOP = 20_000;
 53 
 54     private static void runTest(String test) throws Exception {
 55         String testClassName = SharedStubToInterpTest.class.getName() + "$" + test;
 56         ArrayList<String> command = new ArrayList<String>();

 57         command.add("-XX:+UnlockDiagnosticVMOptions");
 58         command.add("-Xbatch");
 59         command.add("-XX:+PrintRelocations");
 60         command.add("-XX:CompileCommand=compileonly," + testClassName + "::" + "test");
 61         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "test");
 62         command.add("-XX:CompileCommand=print," + testClassName + "::" + "test");
 63         command.add("-XX:CompileCommand=exclude," + testClassName + "::" + "log01");
 64         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "log01");
 65         command.add("-XX:CompileCommand=exclude," + testClassName + "::" + "log02");
 66         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "log02");
 67         command.add(testClassName);
 68 
 69         ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command);
 70 
 71         OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
 72 
 73         analyzer.shouldHaveExitValue(0);
 74 
 75         System.out.println(analyzer.getOutput());
 76 
 77         checkOutput(analyzer);
 78     }
 79 
 80     public static void main(String[] args) throws Exception {
 81         String[] methods = new String[] { "StaticMethodTest", "FinalClassTest", "FinalMethodTest"};
 82         for (String methodName : methods) {
 83             runTest(methodName);
 84         }
 85     }
 86 
 87     private static void checkOutput(OutputAnalyzer output) {
 88         List<String> addrs = Pattern.compile("\\(static_stub\\) addr=(\\w+) .*\\[static_call=")
 89             .matcher(output.getStdout())
 90             .results()
 91             .map(m -> m.group(1))
 92             .toList();
 93         if (addrs.stream().distinct().count() >= addrs.size()) {
 94             throw new RuntimeException("No static stubs reused: distinct " + addrs.stream().distinct().count() + ", in total " + addrs.size());
 95         }
 96     }
 97 
 98     public static class StaticMethodTest {
 99         static void log01(int i) {
100         }
101         static void log02(int i) {
102         }
103 

 34  *
 35  * @test id=C2
 36  * @requires vm.opt.TieredStopAtLevel == null & vm.opt.TieredCompilation == null
 37  * @requires vm.simpleArch == "x86" | vm.simpleArch == "x64" | vm.simpleArch == "aarch64" | vm.simpleArch == "riscv64"
 38  * @requires vm.debug
 39  * @run driver compiler.sharedstubs.SharedStubToInterpTest -XX:-TieredCompilation
 40  *
 41  */
 42 
 43 package compiler.sharedstubs;
 44 
 45 import java.util.ArrayList;
 46 import java.util.List;
 47 import java.util.regex.Pattern;
 48 import jdk.test.lib.process.OutputAnalyzer;
 49 import jdk.test.lib.process.ProcessTools;
 50 
 51 public class SharedStubToInterpTest {
 52     private final static int ITERATIONS_TO_HEAT_LOOP = 20_000;
 53 
 54     private static void runTest(String compiler, String test) throws Exception {
 55         String testClassName = SharedStubToInterpTest.class.getName() + "$" + test;
 56         ArrayList<String> command = new ArrayList<String>();
 57         command.add(compiler);
 58         command.add("-XX:+UnlockDiagnosticVMOptions");
 59         command.add("-Xbatch");
 60         command.add("-XX:+PrintRelocations");
 61         command.add("-XX:CompileCommand=compileonly," + testClassName + "::" + "test");
 62         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "test");
 63         command.add("-XX:CompileCommand=print," + testClassName + "::" + "test");
 64         command.add("-XX:CompileCommand=exclude," + testClassName + "::" + "log01");
 65         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "log01");
 66         command.add("-XX:CompileCommand=exclude," + testClassName + "::" + "log02");
 67         command.add("-XX:CompileCommand=dontinline," + testClassName + "::" + "log02");
 68         command.add(testClassName);
 69 
 70         ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(command);
 71 
 72         OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
 73 
 74         analyzer.shouldHaveExitValue(0);
 75 
 76         System.out.println(analyzer.getOutput());
 77 
 78         checkOutput(analyzer);
 79     }
 80 
 81     public static void main(String[] args) throws Exception {
 82         String[] methods = new String[] { "StaticMethodTest", "FinalClassTest", "FinalMethodTest"};
 83         for (String methodName : methods) {
 84             runTest(args[0], methodName);
 85         }
 86     }
 87 
 88     private static void checkOutput(OutputAnalyzer output) {
 89         List<String> addrs = Pattern.compile("\\(static_stub\\) addr=(\\w+) .*\\[static_call=")
 90             .matcher(output.getStdout())
 91             .results()
 92             .map(m -> m.group(1))
 93             .toList();
 94         if (addrs.stream().distinct().count() >= addrs.size()) {
 95             throw new RuntimeException("No static stubs reused: distinct " + addrs.stream().distinct().count() + ", in total " + addrs.size());
 96         }
 97     }
 98 
 99     public static class StaticMethodTest {
100         static void log01(int i) {
101         }
102         static void log02(int i) {
103         }
104 
< prev index next >