Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/c1/TestRangeCheckEliminated.java
41149 views
1
/*
2
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8263707
28
* @summary Test range check for constant array and NewMultiArray is removed properly
29
* @author Hui Shi
30
*
31
* @requires vm.flagless
32
* @requires vm.debug == true & vm.compiler1.enabled
33
*
34
* @library /test/lib
35
*
36
* @run driver compiler.c1.TestRangeCheckEliminated
37
*/
38
39
package compiler.c1;
40
41
import jdk.test.lib.process.OutputAnalyzer;
42
import jdk.test.lib.process.ProcessTools;
43
44
public class TestRangeCheckEliminated {
45
static final String eliminated = "can be fully eliminated";
46
public static void main(String[] args) throws Throwable {
47
boolean error = false;
48
String[] procArgs = new String[] {
49
"-XX:CompileCommand=compileonly,*test_constant_array::constant_array_rc",
50
"-XX:TieredStopAtLevel=1",
51
"-XX:+TraceRangeCheckElimination",
52
"-XX:-BackgroundCompilation",
53
test_constant_array.class.getName()
54
};
55
56
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
57
String output = new OutputAnalyzer(pb.start()).getOutput();
58
// should have 2 "can be fully eliminated"
59
System.out.println(output);
60
if ((output.split(eliminated, -1).length - 1) == 2) {
61
System.out.println("test_constant_array pass");
62
} else {
63
System.out.println("test_constant_array fail");
64
error = true;
65
}
66
67
procArgs = new String[] {
68
"-XX:CompileCommand=compileonly,*test_multi_constant_array::multi_constant_array_rc",
69
"-XX:TieredStopAtLevel=1",
70
"-XX:+TraceRangeCheckElimination",
71
"-XX:-BackgroundCompilation",
72
test_multi_constant_array.class.getName()
73
};
74
75
pb = ProcessTools.createJavaProcessBuilder(procArgs);
76
output = new OutputAnalyzer(pb.start()).getOutput();
77
// should have 1 "can be fully eliminated"
78
System.out.println(output);
79
if ((output.split(eliminated, -1).length - 1) == 1) {
80
System.out.println("test_multi_constant_array pass");
81
} else {
82
System.out.println("test_multi_constant_array fail");
83
error = true;
84
}
85
86
procArgs = new String[] {
87
"-XX:CompileCommand=compileonly,*test_multi_new_array::multi_new_array_rc",
88
"-XX:TieredStopAtLevel=1",
89
"-XX:+TraceRangeCheckElimination",
90
"-XX:-BackgroundCompilation",
91
test_multi_new_array.class.getName()
92
};
93
94
pb = ProcessTools.createJavaProcessBuilder(procArgs);
95
output = new OutputAnalyzer(pb.start()).getOutput();
96
// should have 2 "can be fully eliminated"
97
System.out.println(output);
98
if ((output.split(eliminated, -1).length - 1) == 2) {
99
System.out.println("test_multi_new_array pass");
100
} else {
101
System.out.println("test_multi_new_array fail");
102
error = true;
103
}
104
105
if (error) {
106
throw new InternalError();
107
}
108
}
109
110
public static class test_constant_array {
111
static final int constant_array[] =
112
{50,60,55,67,70,62,65,70,70,81,72,66,77,80,69};
113
static void constant_array_rc() {
114
constant_array[1] += 5;
115
}
116
117
public static void main(String[] args) {
118
for(int i = 0; i < 1_000; i++) {
119
constant_array_rc();
120
}
121
}
122
}
123
124
public static class test_multi_constant_array {
125
static final int constant_multi_array[][] = {
126
{50,60,55,67,70}, {62,65,70,70,81}, {72,66,77,80,69}};
127
static void multi_constant_array_rc() {
128
constant_multi_array[2][3] += 5;
129
}
130
131
public static void main(String[] args) {
132
for(int i = 0; i < 1_000; i++) {
133
multi_constant_array_rc();
134
}
135
}
136
}
137
138
public static class test_multi_new_array {
139
static void foo(int i) {}
140
static void multi_new_array_rc(int index) {
141
int na[] = new int[800];
142
int nma[][] = new int[600][2];
143
nma[20][1] += 5; // optimize rc on NewMultiArray first dimension
144
nma[index][0] = 0; // index < 600 after this statement
145
foo(na[index]); // index must < 800, remove rc
146
}
147
148
public static void main(String[] args) {
149
for(int i = 0; i < 600; i++) {
150
multi_new_array_rc(i);
151
}
152
}
153
}
154
}
155
156