Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6805724.java
41149 views
1
/*
2
* Copyright (c) 2009, 2016, 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
28
* when divisor is any (2^k-1) constant.
29
* @modules java.base/jdk.internal.misc
30
* @library /test/lib
31
*
32
* @run main/othervm -Xcomp
33
* -XX:CompileCommand=compileonly,compiler.c2.Test6805724::fcomp
34
* compiler.c2.Test6805724
35
*/
36
37
package compiler.c2;
38
39
import jdk.test.lib.Utils;
40
41
public class Test6805724 implements Runnable {
42
// Initialize DIVISOR so that it is final in this class.
43
static final long DIVISOR; // 2^k-1 constant
44
45
static {
46
long value = 0;
47
try {
48
value = Long.decode(System.getProperty("divisor"));
49
} catch (Throwable t) {
50
// This one is required for the Class.forName() in main.
51
}
52
DIVISOR = value;
53
}
54
55
static long fint(long x) {
56
return x % DIVISOR;
57
}
58
59
static long fcomp(long x) {
60
return x % DIVISOR;
61
}
62
63
public void run() {
64
long a = 0x617981E1L;
65
66
long expected = fint(a);
67
long result = fcomp(a);
68
69
if (result != expected)
70
throw new InternalError(result + " != " + expected);
71
}
72
73
public static void main(String args[]) throws Exception {
74
Class cl = Test6805724.class;
75
ClassLoader apploader = cl.getClassLoader();
76
77
// Iterate over all 2^k-1 divisors.
78
for (int k = 1; k < Long.SIZE; k++) {
79
long divisor = (1L << k) - 1;
80
System.setProperty("divisor", "" + divisor);
81
ClassLoader loader
82
= Utils.getTestClassPathURLClassLoader(apploader.getParent());
83
Class c = loader.loadClass(Test6805724.class.getName());
84
Runnable r = (Runnable) c.newInstance();
85
r.run();
86
}
87
}
88
}
89
90