test/compiler/6800154/Test6800154.java

Wed, 22 Jan 2014 12:37:28 -0800

author
katleman
date
Wed, 22 Jan 2014 12:37:28 -0800
changeset 6575
2bac854670c0
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag jdk8u5-b05 for changeset b90de55aca30

twisti@1002 1 /*
trims@1907 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
twisti@1002 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
twisti@1002 4 *
twisti@1002 5 * This code is free software; you can redistribute it and/or modify it
twisti@1002 6 * under the terms of the GNU General Public License version 2 only, as
twisti@1002 7 * published by the Free Software Foundation.
twisti@1002 8 *
twisti@1002 9 * This code is distributed in the hope that it will be useful, but WITHOUT
twisti@1002 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
twisti@1002 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
twisti@1002 12 * version 2 for more details (a copy is included in the LICENSE file that
twisti@1002 13 * accompanied this code).
twisti@1002 14 *
twisti@1002 15 * You should have received a copy of the GNU General Public License version
twisti@1002 16 * 2 along with this work; if not, write to the Free Software Foundation,
twisti@1002 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
twisti@1002 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
twisti@1002 22 */
twisti@1002 23
twisti@1002 24 /**
twisti@1002 25 * @test
twisti@1002 26 * @bug 6800154
twisti@1002 27 * @summary Add comments to long_by_long_mulhi() for better understandability
twisti@1002 28 *
twisti@1002 29 * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
twisti@1002 30 */
twisti@1002 31
twisti@1002 32 import java.net.URLClassLoader;
twisti@1002 33
twisti@1002 34 public class Test6800154 implements Runnable {
twisti@1002 35 static final long[] DIVIDENDS = {
twisti@1002 36 0,
twisti@1002 37 1,
twisti@1002 38 2,
twisti@1002 39 1423487,
twisti@1002 40 4444441,
twisti@1002 41 4918923241323L,
twisti@1002 42 -1,
twisti@1002 43 -24351,
twisti@1002 44 0x3333,
twisti@1002 45 0x0000000080000000L,
twisti@1002 46 0x7fffffffffffffffL,
twisti@1002 47 0x8000000000000000L
twisti@1002 48 };
twisti@1002 49
twisti@1002 50 static final long[] DIVISORS = {
twisti@1002 51 1,
twisti@1002 52 2,
twisti@1002 53 17,
twisti@1002 54 12342,
twisti@1002 55 24123,
twisti@1002 56 143444,
twisti@1002 57 123444442344L,
twisti@1002 58 -1,
twisti@1002 59 -2,
twisti@1002 60 -4423423234231423L,
twisti@1002 61 0x0000000080000000L,
twisti@1002 62 0x7fffffffffffffffL,
twisti@1002 63 0x8000000000000000L
twisti@1002 64 };
twisti@1002 65
twisti@1002 66 // Initialize DIVISOR so that it is final in this class.
twisti@1002 67 static final long DIVISOR;
twisti@1002 68
twisti@1002 69 static {
twisti@1002 70 long value = 0;
twisti@1002 71 try {
twisti@1002 72 value = Long.decode(System.getProperty("divisor"));
twisti@1002 73 } catch (Throwable e) {
twisti@1002 74 }
twisti@1002 75 DIVISOR = value;
twisti@1002 76 }
twisti@1002 77
twisti@1002 78 public static void main(String[] args) throws Exception
twisti@1002 79 {
twisti@1002 80 Class cl = Class.forName("Test6800154");
twisti@1002 81 URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
twisti@1002 82
twisti@1002 83 // Iterate over all divisors.
twisti@1002 84 for (int i = 0; i < DIVISORS.length; i++) {
twisti@1002 85 System.setProperty("divisor", "" + DIVISORS[i]);
twisti@1002 86 ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
twisti@1002 87 Class c = loader.loadClass("Test6800154");
twisti@1002 88 Runnable r = (Runnable) c.newInstance();
twisti@1002 89 r.run();
twisti@1002 90 }
twisti@1002 91 }
twisti@1002 92
twisti@1002 93 public void run()
twisti@1002 94 {
twisti@1002 95 // Iterate over all dividends.
twisti@1002 96 for (int i = 0; i < DIVIDENDS.length; i++) {
twisti@1002 97 long dividend = DIVIDENDS[i];
twisti@1002 98
twisti@1002 99 long expected = divint(dividend);
twisti@1002 100 long result = divcomp(dividend);
twisti@1002 101
twisti@1002 102 if (result != expected)
twisti@1002 103 throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);
twisti@1002 104 }
twisti@1002 105 }
twisti@1002 106
twisti@1002 107 static long divint(long a) { return a / DIVISOR; }
twisti@1002 108 static long divcomp(long a) { return a / DIVISOR; }
twisti@1002 109 }

mercurial