567N/A/*
1472N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
567N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
567N/A *
567N/A * This code is free software; you can redistribute it and/or modify it
567N/A * under the terms of the GNU General Public License version 2 only, as
567N/A * published by the Free Software Foundation.
567N/A *
567N/A * This code is distributed in the hope that it will be useful, but WITHOUT
567N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
567N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
567N/A * version 2 for more details (a copy is included in the LICENSE file that
567N/A * accompanied this code).
567N/A *
567N/A * You should have received a copy of the GNU General Public License version
567N/A * 2 along with this work; if not, write to the Free Software Foundation,
567N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
567N/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.
567N/A */
567N/A
567N/A/**
567N/A * @test
567N/A * @bug 6800154
567N/A * @summary Add comments to long_by_long_mulhi() for better understandability
567N/A *
567N/A * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
567N/A */
567N/A
567N/Aimport java.net.URLClassLoader;
567N/A
567N/Apublic class Test6800154 implements Runnable {
567N/A static final long[] DIVIDENDS = {
567N/A 0,
567N/A 1,
567N/A 2,
567N/A 1423487,
567N/A 4444441,
567N/A 4918923241323L,
567N/A -1,
567N/A -24351,
567N/A 0x3333,
567N/A 0x0000000080000000L,
567N/A 0x7fffffffffffffffL,
567N/A 0x8000000000000000L
567N/A };
567N/A
567N/A static final long[] DIVISORS = {
567N/A 1,
567N/A 2,
567N/A 17,
567N/A 12342,
567N/A 24123,
567N/A 143444,
567N/A 123444442344L,
567N/A -1,
567N/A -2,
567N/A -4423423234231423L,
567N/A 0x0000000080000000L,
567N/A 0x7fffffffffffffffL,
567N/A 0x8000000000000000L
567N/A };
567N/A
567N/A // Initialize DIVISOR so that it is final in this class.
567N/A static final long DIVISOR;
567N/A
567N/A static {
567N/A long value = 0;
567N/A try {
567N/A value = Long.decode(System.getProperty("divisor"));
567N/A } catch (Throwable e) {
567N/A }
567N/A DIVISOR = value;
567N/A }
567N/A
567N/A public static void main(String[] args) throws Exception
567N/A {
567N/A Class cl = Class.forName("Test6800154");
567N/A URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
567N/A
567N/A // Iterate over all divisors.
567N/A for (int i = 0; i < DIVISORS.length; i++) {
567N/A System.setProperty("divisor", "" + DIVISORS[i]);
567N/A ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
567N/A Class c = loader.loadClass("Test6800154");
567N/A Runnable r = (Runnable) c.newInstance();
567N/A r.run();
567N/A }
567N/A }
567N/A
567N/A public void run()
567N/A {
567N/A // Iterate over all dividends.
567N/A for (int i = 0; i < DIVIDENDS.length; i++) {
567N/A long dividend = DIVIDENDS[i];
567N/A
567N/A long expected = divint(dividend);
567N/A long result = divcomp(dividend);
567N/A
567N/A if (result != expected)
567N/A throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);
567N/A }
567N/A }
567N/A
567N/A static long divint(long a) { return a / DIVISOR; }
567N/A static long divcomp(long a) { return a / DIVISOR; }
567N/A}