hotspot/test/compiler/floatingpoint/ModNaN.java
author iklam
Wed, 16 Dec 2015 19:30:10 -0800
changeset 35179 9e364645fdca
parent 35055 a4cf2927e727
child 40059 c2304140ed64
permissions -rw-r--r--
8145620: Disable compiler/floatingpoint/ModNaN.java Reviewed-by: dholmes, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24319
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     1
/*
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     4
 *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     7
 * published by the Free Software Foundation.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     8
 *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    13
 * accompanied this code).
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    14
 *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    18
 *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    21
 * questions.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    22
 */
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    23
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    24
/**
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    25
 * @test
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    26
 * @bug 8015396
35179
9e364645fdca 8145620: Disable compiler/floatingpoint/ModNaN.java
iklam
parents: 35055
diff changeset
    27
 * @ignore 8145543
24319
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    28
 * @summary double a%b returns NaN for some (a,b) (|a| < inf, |b|>0) (on Core i7 980X)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    29
 * @run main ModNaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    30
 */
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    31
public class ModNaN {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    32
    /* This bug was seen in the field for a particular version of the VM,
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    33
     * but never reproduced internally, and the reason was never known,
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    34
     * nor were the exact circumstances of the failure.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    35
     */
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    36
    /*
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    37
     * Failed on Windows 7/Core i7 980X/1.6.0_38 (64-bit):
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    38
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    39
     * NaNs (i.e., when it fails, this is what we expect to see):
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    40
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    41
     * 8.98846567431158E307 % 1.295163E-318 = NaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    42
     * (0x7FE0000000000000L % 0x0000000000040000L)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    43
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    44
     * 1.7976931348623157E308 % 2.59032E-318 = NaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    45
     * (0x7FEFFFFFFFFFFFFFL % 0x000000000007FFFFL)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    46
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    47
     * 1.7976931348623157E308 % 1.060997895E-314 = NaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    48
     * (0x7FEFFFFFFFFFFFFFL % 0x000000007FFFFFFFL)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    49
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    50
     * 1.7976931348623157E308 % 6.767486E-317 = NaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    51
     * (0x7FEFFFFFFFFFFFFFL % 0x0000000000d10208L)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    52
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    53
     * 1.7976931348623157E308 % 7.528725E-318 = NaN
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    54
     * (0x7FEFFFFFFFFFFFFFL % 0x0000000000174077L)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    55
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    56
     * These cases did not fail, even when the previous five did:
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    57
     * 8.98846567431158E307 % 1.29516E-318 = 2.53E-321
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    58
     * (0x7fe0000000000000L % 0x000000000003ffffL)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    59
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    60
     * 1.7976931348623157E308 % 2.590327E-318 = 0.0
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    61
     * (0x7fefffffffffffffL % 0x0000000000080000L)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    62
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    63
     * 1.7976931348623157E308 % 1.060965516E-314 = 9.35818525E-315
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    64
     * (0x7fefffffffffffffL % 0x000000007ffeffffL)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    65
     *
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    66
     */
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    67
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    68
    static double[][] bad = new double[][] {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    69
            /*
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    70
             * These hex numbers correspond to the base-10 doubles in the
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    71
             * comment above; this can be checked by observing the output
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    72
             * of testWithPrint.
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    73
             */
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    74
            new double[] { Double.longBitsToDouble(0x7FE0000000000000L),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    75
                    Double.longBitsToDouble(0x0000000000040000L) },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    76
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    77
                    Double.longBitsToDouble(0x000000000007FFFFL) },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    78
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    79
                    Double.longBitsToDouble(0x000000007FFFFFFFL) },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    80
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    81
                    6.767486E-317 },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    82
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    83
                    7.528725E-318 }, };
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    84
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    85
    static double[][] good = new double[][] {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    86
            new double[] { Double.longBitsToDouble(0x7FE0000000000000L),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    87
                    Double.longBitsToDouble(0x000000000003FFFFL) },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    88
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    89
                    Double.longBitsToDouble(0x0000000000080000L) },
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    90
            new double[] { Double.longBitsToDouble(0x7FEFFFFFFFFFFFFFL),
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    91
                    Double.longBitsToDouble(0x000000007FFEFFFFL) }, };
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    92
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    93
    public static void main(String[] args) throws InterruptedException {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    94
        int N = 10000;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    95
        testWithPrint();
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    96
        for (int i = 0; i < N; i++)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    97
            testStrict();
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    98
        for (int i = 0; i < N; i++)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
    99
            test();
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   100
        Thread.sleep(1000); // pause to let the compiler work
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   101
        for (int i = 0; i < 10; i++)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   102
            testStrict();
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   103
        for (int i = 0; i < 10; i++)
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   104
            test();
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   105
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   106
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   107
    public strictfp static void testWithPrint() {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   108
        for (double[] ab : bad) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   109
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   110
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   111
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   112
            System.out.println("" + a + "("+toHexRep(a)+") mod " +
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   113
                                    b + "("+toHexRep(b)+") yields " +
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   114
                                    mod + "("+toHexRep(mod)+")");
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   115
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   116
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   117
        for (double[] ab : good) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   118
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   119
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   120
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   121
            System.out.println("" + a + "("+toHexRep(a)+") mod " +
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   122
                                    b + "("+toHexRep(b)+") yields " +
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   123
                                    mod + "("+toHexRep(mod)+")");
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   124
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   125
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   126
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   127
    public strictfp static void testStrict() {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   128
        for (double[] ab : bad) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   129
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   130
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   131
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   132
            check(mod);
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   133
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   134
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   135
        for (double[] ab : good) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   136
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   137
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   138
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   139
            check(mod);
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   140
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   141
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   142
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   143
    public static void test() {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   144
        for (double[] ab : bad) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   145
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   146
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   147
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   148
            check(mod);
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   149
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   150
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   151
        for (double[] ab : good) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   152
            double a = ab[0];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   153
            double b = ab[1];
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   154
            double mod = a % b;
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   155
            check(mod);
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   156
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   157
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   158
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   159
    static String toHexRep(double d) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   160
        return "0x" + Long.toHexString(Double.doubleToRawLongBits(d)) + "L";
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   161
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   162
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   163
    static void check(double mod) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   164
        if (Double.isNaN(mod)) {
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   165
            throw new Error("Saw a NaN, fail");
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   166
        }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   167
    }
457a79645387 8039407: Regression test needed for JDK-8015396
drchase
parents:
diff changeset
   168
}