Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/GetFlagValueTest.java
41153 views
1
/*
2
* Copyright (c) 2015, 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
/*
25
* @test
26
* @bug 8173912
27
* @requires vm.jvmci
28
* @library / /test/lib
29
* @library ../common/patches
30
* @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot:+open
31
* @build sun.hotspot.WhiteBox
32
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
33
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
34
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
35
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
36
* compiler.jvmci.compilerToVM.GetFlagValueTest
37
*/
38
39
package compiler.jvmci.compilerToVM;
40
41
import jdk.test.lib.Asserts;
42
import jdk.vm.ci.hotspot.CompilerToVMHelper;
43
import jdk.test.lib.process.OutputAnalyzer;
44
import jdk.test.lib.process.ProcessTools;
45
import java.math.BigInteger;
46
import java.util.Arrays;
47
import java.util.regex.Pattern;
48
import java.util.regex.Matcher;
49
import sun.hotspot.WhiteBox;
50
51
public class GetFlagValueTest {
52
public static void main(String[] args) throws Exception {
53
try {
54
CompilerToVMHelper.getFlagValue(null);
55
Asserts.fail("Expected NullPointerException when calling getFlagValue(null)");
56
} catch (NullPointerException e) {
57
// expected
58
}
59
60
Object missing = CompilerToVMHelper.getFlagValue("this is surely not a flag");
61
Asserts.assertEquals(CompilerToVMHelper.CTVM, missing);
62
63
ProcessBuilder pb;
64
OutputAnalyzer out;
65
66
pb = ProcessTools.createJavaProcessBuilder(
67
"-XX:+UnlockExperimentalVMOptions",
68
"-XX:+EnableJVMCI",
69
"-XX:+PrintFlagsFinal",
70
"-version");
71
out = new OutputAnalyzer(pb.start());
72
73
out.shouldHaveExitValue(0);
74
String[] lines = out.getStdout().split("\\r?\\n");
75
Asserts.assertTrue(lines.length > 1, "Expected output from -XX:+PrintFlagsFinal");
76
77
final WhiteBox wb = WhiteBox.getWhiteBox();
78
79
// Line example: ccstr PrintIdealGraphAddress = 127.0.0.1 {C2 notproduct} {default}
80
Pattern flagLine = Pattern.compile("(\\w+)\\s+(\\w+)\\s+:?= (?:(.+))\\{[^}]+\\}\\s+\\{[^}]+\\}");
81
for (String line : lines) {
82
if (line.indexOf('=') != -1) {
83
line = line.trim();
84
Matcher m = flagLine.matcher(line);
85
Asserts.assertTrue(m.matches(), "Unexpected line in -XX:+PrintFlagsFinal output: " + line);
86
String type = m.group(1);
87
String name = m.group(2);
88
String expect = m.group(3).trim();
89
Object value = CompilerToVMHelper.getFlagValue(name);
90
Object wbValue = wb.getVMFlag(name);
91
Asserts.assertEquals(value, wbValue, "Value of flag " + name);
92
}
93
}
94
}
95
}
96
97