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/While.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 While {
34
private final static int N = 1000;
35
static int x0 = 232;
36
static int x1 = 562;
37
static int x2 = 526;
38
static int x3 = 774;
39
40
public static void main(String[] args) {
41
GoldChecker goldChecker = new GoldChecker("While");
42
43
for(CompilerTest test: whileTests) {
44
goldChecker.println(test + " = " + CompilerTestLauncher.launch(test));
45
}
46
47
goldChecker.check();
48
}
49
50
public static final List<CompilerTest<Integer>> whileTests = Arrays.asList(
51
52
//while + invariant condition
53
new CompilerTest<Integer>("while1") {
54
@Override
55
public Integer execute(Random random) {
56
int i = x0;
57
int j = x1;
58
int k = x2 + random.nextInt(1000);
59
60
while (i < N) {
61
i++;
62
if (x2 > x1) {
63
j += i;
64
k += j;
65
}
66
67
}
68
return k + i;
69
}
70
},
71
72
//while + break on shifted inductive vars + invariant condition
73
new CompilerTest<Integer>("while2") {
74
@Override
75
public Integer execute(Random random) {
76
int i = x0;
77
int j = x1;
78
int k = x2 + random.nextInt(1000);
79
80
while (i < N) {
81
if (x3 + k < x0) {
82
break;
83
}
84
i++;
85
if (x2 > x1) {
86
j += i;
87
k += j + i;
88
}
89
90
}
91
return k + i;
92
}
93
},
94
95
//while + break on shifted inductive vars + invariant condition
96
new CompilerTest<Integer>("while3") {
97
@Override
98
public Integer execute(Random random) {
99
int i = x0;
100
int j = x1;
101
int k = x2 + random.nextInt(1000);
102
103
while (i < N) {
104
if (x3 < x0) {
105
break;
106
}
107
i++;
108
if (x2 > x1) {
109
x3 += k;
110
j += i;
111
k += i;
112
}
113
114
}
115
return k + i;
116
}
117
},
118
119
//while + break on hidden inductive vars + invariant condition
120
new CompilerTest<Integer>("while4") {
121
@Override
122
public Integer execute(Random random) {
123
int i = x0;
124
int j = x1;
125
int k = x2 + random.nextInt(1000);
126
127
while (i < N) {
128
if (x3 < x0) {
129
break;
130
}
131
k++;
132
i++;
133
if (x2 > x1) {
134
x3 += k;
135
j += i;
136
k += j;
137
}
138
139
}
140
return k + i;
141
}
142
}
143
);
144
145
146
}
147
148