hotspot/test/compiler/c2/6805724/Test6805724.java
author kshefov
Thu, 15 Oct 2015 18:00:00 +0300
changeset 33187 384728911193
parent 27699 9913b19c0948
child 38152 80e5da81fb2c
permissions -rw-r--r--
8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests Reviewed-by: twisti, kvn, iignatyev, tpivovarova
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     1
/*
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
     2
 * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     4
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     8
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    13
 * accompanied this code).
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    14
 *
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2032
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: 2032
diff changeset
    21
 * questions.
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    22
 */
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    23
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    24
/**
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    25
 * @test
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    26
 * @bug 6805724
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    27
 * @summary ModLNode::Ideal() generates functionally incorrect graph
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    28
 *          when divisor is any (2^k-1) constant.
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    29
 * @library /testlibrary
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    30
 * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    31
 */
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    32
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    33
import jdk.test.lib.Utils;
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    34
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    35
public class Test6805724 implements Runnable {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    36
    // Initialize DIVISOR so that it is final in this class.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    37
    static final long DIVISOR;  // 2^k-1 constant
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    38
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    39
    static {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    40
        long value = 0;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    41
        try {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    42
            value = Long.decode(System.getProperty("divisor"));
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    43
        } catch (Throwable t) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    44
            // This one is required for the Class.forName() in main.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    45
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    46
        DIVISOR = value;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    47
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    48
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    49
    static long fint(long x) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    50
        return x % DIVISOR;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    51
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    52
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    53
    static long fcomp(long x) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    54
        return x % DIVISOR;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    55
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    56
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    57
    public void run() {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    58
        long a = 0x617981E1L;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    59
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    60
        long expected = fint(a);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    61
        long result = fcomp(a);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    62
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    63
        if (result != expected)
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    64
            throw new InternalError(result + " != " + expected);
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    65
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    66
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    67
    public static void main(String args[]) throws Exception {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    68
        Class cl = Class.forName("Test6805724");
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    69
        ClassLoader apploader = cl.getClassLoader();
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    70
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    71
        // Iterate over all 2^k-1 divisors.
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    72
        for (int k = 1; k < Long.SIZE; k++) {
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    73
            long divisor = (1L << k) - 1;
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    74
            System.setProperty("divisor", "" + divisor);
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    75
            ClassLoader loader
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    76
                    = Utils.getTestClassPathURLClassLoader(apploader.getParent());
2032
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    77
            Class c = loader.loadClass("Test6805724");
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    78
            Runnable r = (Runnable) c.newInstance();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    79
            r.run();
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    80
        }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    81
    }
1e27661bff28 6805724: ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.
twisti
parents:
diff changeset
    82
}