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/6800154/Test6800154.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 6800154
27
* @summary Add comments to long_by_long_mulhi() for better understandability
28
*
29
* @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
30
*/
31
32
import java.net.URLClassLoader;
33
34
public class Test6800154 implements Runnable {
35
static final long[] DIVIDENDS = {
36
0,
37
1,
38
2,
39
1423487,
40
4444441,
41
4918923241323L,
42
-1,
43
-24351,
44
0x3333,
45
0x0000000080000000L,
46
0x7fffffffffffffffL,
47
0x8000000000000000L
48
};
49
50
static final long[] DIVISORS = {
51
1,
52
2,
53
17,
54
12342,
55
24123,
56
143444,
57
123444442344L,
58
-1,
59
-2,
60
-4423423234231423L,
61
0x0000000080000000L,
62
0x7fffffffffffffffL,
63
0x8000000000000000L
64
};
65
66
// Initialize DIVISOR so that it is final in this class.
67
static final long DIVISOR;
68
69
static {
70
long value = 0;
71
try {
72
value = Long.decode(System.getProperty("divisor"));
73
} catch (Throwable e) {
74
}
75
DIVISOR = value;
76
}
77
78
public static void main(String[] args) throws Exception
79
{
80
Class cl = Class.forName("Test6800154");
81
URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
82
83
// Iterate over all divisors.
84
for (int i = 0; i < DIVISORS.length; i++) {
85
System.setProperty("divisor", "" + DIVISORS[i]);
86
ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
87
Class c = loader.loadClass("Test6800154");
88
Runnable r = (Runnable) c.newInstance();
89
r.run();
90
}
91
}
92
93
public void run()
94
{
95
// Iterate over all dividends.
96
for (int i = 0; i < DIVIDENDS.length; i++) {
97
long dividend = DIVIDENDS[i];
98
99
long expected = divint(dividend);
100
long result = divcomp(dividend);
101
102
if (result != expected)
103
throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);
104
}
105
}
106
107
static long divint(long a) { return a / DIVISOR; }
108
static long divcomp(long a) { return a / DIVISOR; }
109
}
110
111