Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/eliminateAutobox/TestEliminateBoxInDebugInfo.java
41149 views
1
/*
2
* Copyright (c) 2021, Huawei Technologies Co., Ltd. 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 8261137
27
* @requires vm.flagless
28
* @requires vm.debug == true & vm.compiler2.enabled
29
* @summary Verify that box object is scalarized in case it is directly referenced by debug info.
30
* @library /test/lib
31
*
32
* @run driver compiler.eliminateAutobox.TestEliminateBoxInDebugInfo
33
*/
34
package compiler.eliminateAutobox;
35
36
import jdk.test.lib.process.OutputAnalyzer;
37
import jdk.test.lib.process.ProcessTools;
38
39
public class TestEliminateBoxInDebugInfo {
40
public static void runTest() throws Exception {
41
String[] arguments = {
42
"-XX:CompileCommand=compileonly,compiler/eliminateAutobox/TestEliminateBoxInDebugInfo$Test.foo",
43
"-XX:CompileCommand=dontinline,compiler/eliminateAutobox/TestEliminateBoxInDebugInfo$Test.black",
44
"-Xbatch",
45
"-XX:+PrintEliminateAllocations",
46
Test.class.getName()
47
};
48
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);
49
OutputAnalyzer output = new OutputAnalyzer(pb.start());
50
output.shouldHaveExitValue(0)
51
.stdoutShouldContain("++++ Eliminated: ");
52
}
53
54
public static void main(String[] args) throws Exception {
55
runTest();
56
}
57
58
static class Test {
59
public static void main(String[] args) throws Exception {
60
// warmup
61
for (int i = 0; i < 100000; i++) {
62
foo(1000 + (i % 1000));
63
}
64
}
65
66
public static int foo(int value) {
67
Integer ii = Integer.valueOf(value);
68
int sum = 0;
69
if (value > 999) {
70
sum += ii.intValue();
71
}
72
black();
73
return sum;
74
}
75
76
public static void black() {}
77
}
78
}
79
80