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/6805724/Test6805724.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 6805724
27
* @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
28
*
29
* @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
30
*/
31
32
import java.net.URLClassLoader;
33
34
public class Test6805724 implements Runnable {
35
// Initialize DIVISOR so that it is final in this class.
36
static final long DIVISOR; // 2^k-1 constant
37
38
static {
39
long value = 0;
40
try {
41
value = Long.decode(System.getProperty("divisor"));
42
} catch (Throwable t) {
43
// This one is required for the Class.forName() in main.
44
}
45
DIVISOR = value;
46
}
47
48
static long fint(long x) {
49
return x % DIVISOR;
50
}
51
52
static long fcomp(long x) {
53
return x % DIVISOR;
54
}
55
56
public void run() {
57
long a = 0x617981E1L;
58
59
long expected = fint(a);
60
long result = fcomp(a);
61
62
if (result != expected)
63
throw new InternalError(result + " != " + expected);
64
}
65
66
public static void main(String args[]) throws Exception {
67
Class cl = Class.forName("Test6805724");
68
URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
69
70
// Iterate over all 2^k-1 divisors.
71
for (int k = 1; k < Long.SIZE; k++) {
72
long divisor = (1L << k) - 1;
73
System.setProperty("divisor", "" + divisor);
74
ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
75
Class c = loader.loadClass("Test6805724");
76
Runnable r = (Runnable) c.newInstance();
77
r.run();
78
}
79
}
80
}
81
82