Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/vm/compiler/optimizations/partialpeel/WhileWhile.java
41161 views
1
/*
2
* Copyright (c) 2012, 2018, 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
package vm.compiler.optimizations.partialpeel;
24
25
import nsk.share.GoldChecker;
26
import vm.compiler.share.CompilerTest;
27
import vm.compiler.share.CompilerTestLauncher;
28
import vm.compiler.share.Random;
29
30
import java.util.Arrays;
31
import java.util.List;
32
33
public class WhileWhile {
34
35
36
public static void main(String[] args) {
37
GoldChecker goldChecker = new GoldChecker("WhileWhile");
38
39
for (CompilerTest test : whilewhileTests) {
40
goldChecker.println(test + " = " + CompilerTestLauncher.launch(test));
41
}
42
43
goldChecker.check();
44
}
45
46
private final static int N = 1000;
47
static int x0 = 232;
48
static int x1 = 562;
49
static int x2 = 526;
50
static int x3 = 774;
51
52
public static final List<CompilerTest<Integer>> whilewhileTests = Arrays.asList(
53
54
//invariant condition
55
new CompilerTest<Integer>("whilewhile1") {
56
@Override
57
public Integer execute(Random random) {
58
int k = x0 + random.nextInt(1000);
59
int i = k + x2;
60
int s = x1;
61
int j = x2;
62
63
while (i < N + x3) {
64
i++;
65
while (j < N) {
66
j++;
67
s++;
68
if (x2 > x1) {
69
k += j;
70
}
71
72
}
73
}
74
75
return s + k;
76
}
77
},
78
79
80
//inner while with condition on outer while counter
81
new CompilerTest<Integer>("whilewhile2") {
82
@Override
83
public Integer execute(Random random) {
84
int k = x0 + random.nextInt(1000);
85
int i = k + x2;
86
int s = x1;
87
int j = x2;
88
89
while (i < N + x3) {
90
i++;
91
while (j < N + i) {
92
j++;
93
s++;
94
if (x2 > x1) {
95
k += j;
96
}
97
98
}
99
}
100
return s + k;
101
}
102
},
103
104
//inner while in if branch
105
new CompilerTest<Integer>("whilewhile3") {
106
@Override
107
public Integer execute(Random random) {
108
int k = x0 + random.nextInt(1000);
109
int i = k + x2;
110
int s = x1;
111
int j = x2;
112
113
while (i < N + x3) {
114
i++;
115
if (i > x2) {
116
while (j < N + i) {
117
j++;
118
s += k;
119
if (x2 > x1) {
120
k += j;
121
}
122
}
123
}
124
}
125
return s + k;
126
}
127
},
128
129
//two inner while
130
new CompilerTest<Integer>("whilewhile4") {
131
@Override
132
public Integer execute(Random random) {
133
int k = x0 + random.nextInt(1000);
134
int i = k + x2;
135
int s = x1;
136
int j = x2;
137
138
while (i < N + x3) {
139
i++;
140
s++;
141
if (i > x2) {
142
while (j < N + i) {
143
j++;
144
s++;
145
if (x2 > x1) {
146
k += j;
147
}
148
}
149
}
150
151
j = x2;
152
while (j < x2 + x3) {
153
j++;
154
if (x2 > x1) {
155
j += x0;
156
s++;
157
k += j;
158
}
159
}
160
}
161
return s + k;
162
}
163
}
164
);
165
166
}
167
168