Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/debug/TestStressCM.java
41149 views
1
/*
2
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package compiler.debug;
25
26
import jdk.test.lib.process.OutputAnalyzer;
27
import jdk.test.lib.process.ProcessTools;
28
import jdk.test.lib.Asserts;
29
30
/*
31
* @test
32
* @bug 8253765
33
* @requires vm.debug == true & vm.compiler2.enabled
34
* @summary Tests that, when compiling with StressLCM or StressGCM, using the
35
* same seed yields the same code motion trace.
36
* @library /test/lib /
37
* @run driver compiler.debug.TestStressCM StressLCM
38
* @run driver compiler.debug.TestStressCM StressGCM
39
*/
40
41
public class TestStressCM {
42
43
static String cmTrace(String stressOpt, int stressSeed) throws Exception {
44
String className = TestStressCM.class.getName();
45
String[] procArgs = {
46
"-Xcomp", "-XX:-TieredCompilation", "-XX:-Inline",
47
"-XX:CompileOnly=" + className + "::sum",
48
"-XX:+TraceOptoPipelining", "-XX:+" + stressOpt,
49
"-XX:StressSeed=" + stressSeed, className, "10"};
50
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
51
OutputAnalyzer out = new OutputAnalyzer(pb.start());
52
out.shouldHaveExitValue(0);
53
// Extract the trace of our method (the last one after those of all
54
// mandatory stubs such as _new_instance_Java, etc.).
55
String [] traces = out.getStdout().split("\\R");
56
int start = -1;
57
for (int i = traces.length - 1; i >= 0; i--) {
58
if (traces[i].contains("Start GlobalCodeMotion")) {
59
start = i;
60
break;
61
}
62
}
63
// We should have found the start of the trace.
64
Asserts.assertTrue(start >= 0,
65
"could not find the code motion trace");
66
String trace = "";
67
for (int i = start; i < traces.length; i++) {
68
trace += traces[i] + "\n";
69
}
70
return trace;
71
}
72
73
static void sum(int n) {
74
int acc = 0;
75
for (int i = 0; i < n; i++) acc += i;
76
System.out.println(acc);
77
}
78
79
public static void main(String[] args) throws Exception {
80
if (args[0].startsWith("Stress")) {
81
String stressOpt = args[0];
82
for (int s = 0; s < 10; s++) {
83
Asserts.assertEQ(cmTrace(stressOpt, s), cmTrace(stressOpt, s),
84
"got different code motion traces for the same seed " + s);
85
}
86
} else if (args.length > 0) {
87
sum(Integer.parseInt(args[0]));
88
}
89
}
90
}
91
92