Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/TestStripMinedLimitBelowInit.java
41149 views
1
/*
2
* Copyright (c) 2020, Red Hat, Inc. 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 8244086
27
* @summary Following 8241492, strip mined loop may run extra iterations
28
* @requires vm.compiler2.enabled
29
*
30
* @run main/othervm -XX:-BackgroundCompilation -XX:LoopUnrollLimit=0 -XX:-TieredCompilation TestStripMinedLimitBelowInit
31
*
32
*/
33
34
public class TestStripMinedLimitBelowInit {
35
public static void main(String[] args) {
36
for (int i = 0; i < 20_000; i++) {
37
test1(0, 1000);
38
test2(1000, 0);
39
}
40
int sum = test1(1000, 0);
41
if (sum != 1000) {
42
throw new RuntimeException("wrong result: " + sum);
43
}
44
sum = test2(0, 1000);
45
if (sum != 0) {
46
throw new RuntimeException("wrong result: " + sum);
47
}
48
}
49
50
private static int test1(int start, int stop) {
51
int sum = 0;
52
int i = start;
53
do {
54
// So ciTypeFlow doesn't clone the loop head
55
synchronized (new Object()) {
56
}
57
sum += i;
58
i++;
59
} while (i < stop);
60
return sum;
61
}
62
63
private static int test2(int start, int stop) {
64
int sum = 0;
65
int i = start;
66
do {
67
synchronized (new Object()) {
68
}
69
sum += i;
70
i--;
71
} while (i >= stop);
72
return sum;
73
}
74
}
75
76