Test6805724.java revision 1472
0N/A/*
2273N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A */
0N/A
0N/A/**
1879N/A * @test
1879N/A * @bug 6805724
1879N/A * @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
1879N/A *
1879N/A * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
0N/A */
0N/A
0N/Aimport java.net.URLClassLoader;
0N/A
0N/Apublic class Test6805724 implements Runnable {
0N/A // Initialize DIVISOR so that it is final in this class.
0N/A static final long DIVISOR; // 2^k-1 constant
0N/A
0N/A static {
0N/A long value = 0;
0N/A try {
0N/A value = Long.decode(System.getProperty("divisor"));
0N/A } catch (Throwable t) {
0N/A // This one is required for the Class.forName() in main.
0N/A }
0N/A DIVISOR = value;
0N/A }
0N/A
0N/A static long fint(long x) {
0N/A return x % DIVISOR;
0N/A }
0N/A
0N/A static long fcomp(long x) {
0N/A return x % DIVISOR;
0N/A }
0N/A
0N/A public void run() {
0N/A long a = 0x617981E1L;
0N/A
0N/A long expected = fint(a);
0N/A long result = fcomp(a);
0N/A
0N/A if (result != expected)
0N/A throw new InternalError(result + " != " + expected);
0N/A }
0N/A
2062N/A public static void main(String args[]) throws Exception {
0N/A Class cl = Class.forName("Test6805724");
0N/A URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
0N/A
0N/A // Iterate over all 2^k-1 divisors.
0N/A for (int k = 1; k < Long.SIZE; k++) {
0N/A long divisor = (1L << k) - 1;
0N/A System.setProperty("divisor", "" + divisor);
0N/A ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
0N/A Class c = loader.loadClass("Test6805724");
0N/A Runnable r = (Runnable) c.newInstance();
0N/A r.run();
0N/A }
0N/A }
0N/A}
0N/A