test/compiler/6800154/Test6800154.java

Wed, 21 May 2014 10:56:41 -0700

author
katleman
date
Wed, 21 May 2014 10:56:41 -0700
changeset 6672
fb9d124d9192
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag jdk8u20-b15 for changeset 8c785f9bde6f

     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  */
    24 /**
    25  * @test
    26  * @bug 6800154
    27  * @summary Add comments to long_by_long_mulhi() for better understandability
    28  *
    29  * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154
    30  */
    32 import java.net.URLClassLoader;
    34 public class Test6800154 implements Runnable {
    35     static final long[] DIVIDENDS = {
    36         0,
    37         1,
    38         2,
    39         1423487,
    40         4444441,
    41         4918923241323L,
    42         -1,
    43         -24351,
    44         0x3333,
    45         0x0000000080000000L,
    46         0x7fffffffffffffffL,
    47         0x8000000000000000L
    48     };
    50     static final long[] DIVISORS = {
    51         1,
    52         2,
    53         17,
    54         12342,
    55         24123,
    56         143444,
    57         123444442344L,
    58         -1,
    59         -2,
    60         -4423423234231423L,
    61         0x0000000080000000L,
    62         0x7fffffffffffffffL,
    63         0x8000000000000000L
    64     };
    66     // Initialize DIVISOR so that it is final in this class.
    67     static final long DIVISOR;
    69     static {
    70         long value = 0;
    71         try {
    72             value = Long.decode(System.getProperty("divisor"));
    73         } catch (Throwable e) {
    74         }
    75         DIVISOR = value;
    76     }
    78     public static void main(String[] args) throws Exception
    79     {
    80         Class cl = Class.forName("Test6800154");
    81         URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
    83         // Iterate over all divisors.
    84         for (int i = 0; i < DIVISORS.length; i++) {
    85             System.setProperty("divisor", "" + DIVISORS[i]);
    86             ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
    87             Class c = loader.loadClass("Test6800154");
    88             Runnable r = (Runnable) c.newInstance();
    89             r.run();
    90         }
    91     }
    93     public void run()
    94     {
    95         // Iterate over all dividends.
    96         for (int i = 0; i < DIVIDENDS.length; i++) {
    97             long dividend = DIVIDENDS[i];
    99             long expected = divint(dividend);
   100             long result = divcomp(dividend);
   102             if (result != expected)
   103                 throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);
   104         }
   105     }
   107     static long divint(long a)  { return a / DIVISOR; }
   108     static long divcomp(long a) { return a / DIVISOR; }
   109 }

mercurial