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/5057225/Test5057225.java
32285 views
1
/*
2
* Copyright (c) 2009, 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
* @test
26
* @bug 5057225
27
* @summary Remove useless I2L conversions
28
*
29
* @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225
30
*/
31
32
import java.net.URLClassLoader;
33
34
public class Test5057225 {
35
static byte[] ba = new byte[] { -1 };
36
static short[] sa = new short[] { -1 };
37
static int[] ia = new int[] { -1 };
38
39
static final long[] BYTE_MASKS = {
40
0x0FL,
41
0x7FL, // 7-bit
42
0xFFL,
43
};
44
45
static final long[] SHORT_MASKS = {
46
0x000FL,
47
0x007FL, // 7-bit
48
0x00FFL,
49
0x0FFFL,
50
0x3FFFL, // 14-bit
51
0x7FFFL, // 15-bit
52
0xFFFFL,
53
};
54
55
static final long[] INT_MASKS = {
56
0x0000000FL,
57
0x0000007FL, // 7-bit
58
0x000000FFL,
59
0x00000FFFL,
60
0x00003FFFL, // 14-bit
61
0x00007FFFL, // 15-bit
62
0x0000FFFFL,
63
0x00FFFFFFL,
64
0x7FFFFFFFL, // 31-bit
65
0xFFFFFFFFL,
66
};
67
68
public static void main(String[] args) throws Exception {
69
for (int i = 0; i < BYTE_MASKS.length; i++) {
70
System.setProperty("value", "" + BYTE_MASKS[i]);
71
loadAndRunClass("Test5057225$loadUB2L");
72
}
73
74
for (int i = 0; i < SHORT_MASKS.length; i++) {
75
System.setProperty("value", "" + SHORT_MASKS[i]);
76
loadAndRunClass("Test5057225$loadUS2L");
77
}
78
79
for (int i = 0; i < INT_MASKS.length; i++) {
80
System.setProperty("value", "" + INT_MASKS[i]);
81
loadAndRunClass("Test5057225$loadUI2L");
82
}
83
}
84
85
static void check(long result, long expected) {
86
if (result != expected)
87
throw new InternalError(result + " != " + expected);
88
}
89
90
static void loadAndRunClass(String classname) throws Exception {
91
Class cl = Class.forName(classname);
92
URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
93
ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
94
Class c = loader.loadClass(classname);
95
Runnable r = (Runnable) c.newInstance();
96
r.run();
97
}
98
99
public static class loadUB2L implements Runnable {
100
static final long MASK;
101
static {
102
long value = 0;
103
try {
104
value = Long.decode(System.getProperty("value"));
105
} catch (Throwable e) {}
106
MASK = value;
107
}
108
109
public void run() { check(doload(ba), MASK); }
110
static long doload(byte[] ba) { return ba[0] & MASK; }
111
}
112
113
public static class loadUS2L implements Runnable {
114
static final long MASK;
115
static {
116
long value = 0;
117
try {
118
value = Long.decode(System.getProperty("value"));
119
} catch (Throwable e) {}
120
MASK = value;
121
}
122
123
public void run() { check(doload(sa), MASK); }
124
static long doload(short[] sa) { return sa[0] & MASK; }
125
}
126
127
public static class loadUI2L implements Runnable {
128
static final long MASK;
129
static {
130
long value = 0;
131
try {
132
value = Long.decode(System.getProperty("value"));
133
} catch (Throwable e) {}
134
MASK = value;
135
}
136
137
public void run() { check(doload(ia), MASK); }
138
static long doload(int[] ia) { return ia[0] & MASK; }
139
}
140
}
141
142