test/hotspot/jtreg/compiler/c2/Test6800154.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 40631 hotspot/test/compiler/c2/Test6800154.java@ed82623d7831
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
     2
 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     4
 *
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     8
 *
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    13
 * accompanied this code).
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    14
 *
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2031
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2031
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2031
diff changeset
    21
 * questions.
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    22
 */
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    23
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    24
/**
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    25
 * @test
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    26
 * @bug 6800154
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    27
 * @summary Add comments to long_by_long_mulhi() for better understandability
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 33187
diff changeset
    28
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    29
 * @library /test/lib
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    31
 * @run main/othervm -Xcomp
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    32
 *      -XX:CompileCommand=compileonly,compiler.c2.Test6800154::divcomp
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *      compiler.c2.Test6800154
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    34
 */
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    38
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    39
import jdk.test.lib.Utils;
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    40
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    41
public class Test6800154 implements Runnable {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    42
    static final long[] DIVIDENDS = {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    43
        0,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    44
        1,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    45
        2,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    46
        1423487,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    47
        4444441,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    48
        4918923241323L,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    49
        -1,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    50
        -24351,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    51
        0x3333,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    52
        0x0000000080000000L,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    53
        0x7fffffffffffffffL,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    54
        0x8000000000000000L
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    55
    };
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    56
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    57
    static final long[] DIVISORS = {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    58
        1,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    59
        2,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    60
        17,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    61
        12342,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    62
        24123,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    63
        143444,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    64
        123444442344L,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    65
        -1,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    66
        -2,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    67
        -4423423234231423L,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    68
        0x0000000080000000L,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    69
        0x7fffffffffffffffL,
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    70
        0x8000000000000000L
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    71
    };
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    72
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    73
    // Initialize DIVISOR so that it is final in this class.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    74
    static final long DIVISOR;
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    75
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    76
    static {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    77
        long value = 0;
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    78
        try {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    79
            value = Long.decode(System.getProperty("divisor"));
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    80
        } catch (Throwable e) {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    81
        }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    82
        DIVISOR = value;
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    83
    }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    84
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    85
    public static void main(String[] args) throws Exception
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    86
    {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    87
        Class cl = Test6800154.class;
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    88
        ClassLoader apploader = cl.getClassLoader();
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    89
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    90
        // Iterate over all divisors.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    91
        for (int i = 0; i < DIVISORS.length; i++) {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    92
            System.setProperty("divisor", "" + DIVISORS[i]);
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    93
            ClassLoader loader
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    94
                    = Utils.getTestClassPathURLClassLoader(apploader.getParent());
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    95
            Class c = loader.loadClass(Test6800154.class.getName());
2031
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    96
            Runnable r = (Runnable) c.newInstance();
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    97
            r.run();
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    98
        }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
    99
    }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   100
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   101
    public void run()
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   102
    {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   103
        // Iterate over all dividends.
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   104
        for (int i = 0; i < DIVIDENDS.length; i++) {
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   105
            long dividend = DIVIDENDS[i];
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   106
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   107
            long expected = divint(dividend);
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   108
            long result = divcomp(dividend);
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   109
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   110
            if (result != expected)
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   111
                throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   112
        }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   113
    }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   114
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   115
    static long divint(long a)  { return a / DIVISOR; }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   116
    static long divcomp(long a) { return a / DIVISOR; }
24e034f56dcb 6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff changeset
   117
}