Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6443505/Test6443505.java
32285 views
1
/*
2
* Copyright (c) 2013, 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
*/
24
25
/**
26
* @test
27
* @bug 6443505
28
* @summary Some cases for CmpLTMask missed; also wrong code.
29
*
30
* @run main/othervm -Xcomp -XX:CompileOnly="Test6443505.compiled" Test6443505
31
*/
32
33
public class Test6443505 {
34
35
public static void main(String[] args) throws InterruptedException {
36
test(Integer.MIN_VALUE, 0);
37
test(0, Integer.MIN_VALUE);
38
test(Integer.MIN_VALUE, -1);
39
test(-1, Integer.MIN_VALUE);
40
test(Integer.MIN_VALUE, 1);
41
test(1, Integer.MIN_VALUE);
42
43
test(Integer.MAX_VALUE, 0);
44
test(0, Integer.MAX_VALUE);
45
test(Integer.MAX_VALUE, -1);
46
test(-1, Integer.MAX_VALUE);
47
test(Integer.MAX_VALUE, 1);
48
test(1, Integer.MAX_VALUE);
49
50
test(Integer.MIN_VALUE, Integer.MAX_VALUE);
51
test(Integer.MAX_VALUE, Integer.MIN_VALUE);
52
53
test(1, -1);
54
test(1, 0);
55
test(1, 1);
56
test(-1, -1);
57
test(-1, 0);
58
test(-1, 1);
59
test(0, -1);
60
test(0, 0);
61
test(0, 1);
62
}
63
64
public static void test(int a, int b) throws InterruptedException {
65
int C = compiled(4, a, b);
66
int I = interpreted(4, a, b);
67
if (C != I) {
68
System.err.println("#1 C = " + C + ", I = " + I);
69
System.err.println("#1 C != I, FAIL");
70
System.exit(97);
71
}
72
73
C = compiled(a, b, q, 4);
74
I = interpreted(a, b, q, 4);
75
if (C != I) {
76
System.err.println("#2 C = " + C + ", I = " + I);
77
System.err.println("#2 C != I, FAIL");
78
System.exit(97);
79
}
80
81
}
82
83
static int q = 4;
84
85
// If improperly compiled, uses carry/borrow bit, which is wrong.
86
// with -XX:+PrintOptoAssembly, look for cadd_cmpLTMask
87
static int compiled(int p, int x, int y) {
88
return (x < y) ? q + (x - y) : (x - y);
89
}
90
91
// interpreted reference
92
static int interpreted(int p, int x, int y) {
93
return (x < y) ? q + (x - y) : (x - y);
94
}
95
96
// Test new code with a range of cases
97
// with -XX:+PrintOptoAssembly, look for and_cmpLTMask
98
static int compiled(int x, int y, int q, int p) {
99
return (x < y) ? p + q : q;
100
}
101
102
// interpreted reference
103
static int interpreted(int x, int y, int q, int p) {
104
return (x < y) ? p + q : q;
105
}
106
107
}
108
109