Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java
41152 views
1
/*
2
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*/
24
25
/*
26
* @test
27
* @bug 8033441
28
* @summary Test to ensure that line numbers are now present with the -XX:+PrintOptoAssembly command line option
29
*
30
* @requires vm.flagless
31
* @requires vm.compiler2.enabled & vm.debug == true
32
*
33
* @library /test/lib
34
* @run driver compiler.arguments.TestPrintOptoAssemblyLineNumbers
35
*/
36
37
package compiler.arguments;
38
39
import jdk.test.lib.process.OutputAnalyzer;
40
import jdk.test.lib.process.ProcessTools;
41
42
// THIS TEST IS LINE NUMBER SENSITIVE
43
44
public class TestPrintOptoAssemblyLineNumbers {
45
public static void main(String[] args) throws Throwable {
46
// create subprocess to run some code with -XX:+PrintOptoAssembly enabled
47
String[] procArgs = new String[] {
48
"-XX:+UnlockDiagnosticVMOptions",
49
"-XX:-TieredCompilation",
50
"-XX:+PrintOptoAssembly",
51
CheckC2OptoAssembly.class.getName()
52
};
53
54
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
55
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
56
oa.shouldHaveExitValue(0);
57
58
if (oa.getOutput().contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")) {
59
// if C2 optimizer invoked ensure output includes line numbers:
60
oa.stdoutShouldContain("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 72)");
61
}
62
}
63
64
public static class CheckC2OptoAssembly { // contents of this class serves to just invoke C2
65
public static boolean foo(String arg) {
66
return arg.contains("45");
67
}
68
69
public static void main(String[] args) {
70
int count = 0;
71
for (int x = 0; x < 200_000; x++) {
72
if (foo("something" + x)) { // <- test expects this line of code to be on line 72
73
count += 1;
74
}
75
}
76
System.out.println("count: " + count);
77
}
78
}
79
}
80
81