test/hotspot/jtreg/compiler/c2/Test5057225.java
author epavlova
Mon, 02 Oct 2017 14:31:34 -0700
changeset 47576 7645833d326f
parent 47216 71c04702a3d5
permissions -rw-r--r--
8185134: [Graal] Introduce vm.graal predicate and tag tests which are not applicable for Graal Reviewed-by: kvn, dnsimon
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3177
f467776fc753 5057225: Remove useless I2L conversions
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.
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     4
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     8
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    13
 * accompanied this code).
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    14
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
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: 3177
diff changeset
    21
 * questions.
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    22
 */
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    23
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    24
/**
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    25
 * @test
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    26
 * @bug 5057225
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    27
 * @summary Remove useless I2L conversions
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.Test5057225::doload
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *      compiler.c2.Test5057225
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    34
 */
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
package compiler.c2;
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    37
import jdk.test.lib.Utils;
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    38
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    39
public class Test5057225 {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    40
    static byte[]  ba = new byte[]  { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    41
    static short[] sa = new short[] { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    42
    static int[]   ia = new int[]   { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    43
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    44
    static final long[] BYTE_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    45
         0x0FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    46
         0x7FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    47
         0xFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    48
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    49
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    50
    static final long[] SHORT_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    51
        0x000FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    52
        0x007FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    53
        0x00FFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    54
        0x0FFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    55
        0x3FFFL,  // 14-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    56
        0x7FFFL,  // 15-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    57
        0xFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    58
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    59
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    60
    static final long[] INT_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    61
        0x0000000FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    62
        0x0000007FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    63
        0x000000FFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    64
        0x00000FFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    65
        0x00003FFFL,  // 14-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    66
        0x00007FFFL,  // 15-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    67
        0x0000FFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    68
        0x00FFFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    69
        0x7FFFFFFFL,  // 31-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    70
        0xFFFFFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    71
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    72
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    73
    public static void main(String[] args) throws Exception {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    74
        for (int i = 0; i < BYTE_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    75
            System.setProperty("value", "" + BYTE_MASKS[i]);
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    76
            loadAndRunClass(Test5057225.class.getName() + "$loadUB2L");
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    77
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    78
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    79
        for (int i = 0; i < SHORT_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    80
            System.setProperty("value", "" + SHORT_MASKS[i]);
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    81
            loadAndRunClass(Test5057225.class.getName() + "$loadUS2L");
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    82
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    83
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    84
        for (int i = 0; i < INT_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    85
            System.setProperty("value", "" + INT_MASKS[i]);
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    86
            loadAndRunClass(Test5057225.class.getName() + "$loadUI2L");
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    87
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    88
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    89
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    90
    static void check(long result, long expected) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    91
        if (result != expected)
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    92
            throw new InternalError(result + " != " + expected);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    93
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    94
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    95
    static void loadAndRunClass(String classname) throws Exception {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    96
        Class cl = Class.forName(classname);
33187
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    97
        ClassLoader apploader = cl.getClassLoader();
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    98
        ClassLoader loader
384728911193 8072369: [TESTBUG] Remove potentially insecure class cast in some hotspot tests
kshefov
parents: 27699
diff changeset
    99
                = Utils.getTestClassPathURLClassLoader(apploader.getParent());
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   100
        Class c = loader.loadClass(classname);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   101
        Runnable r = (Runnable) c.newInstance();
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   102
        r.run();
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   103
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   104
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   105
    public static class loadUB2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   106
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   107
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   108
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   109
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   110
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   111
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   112
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   113
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   114
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   115
        public void run() { check(doload(ba), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   116
        static long doload(byte[] ba) { return ba[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   117
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   118
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   119
    public static class loadUS2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   120
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   121
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   122
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   123
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   124
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   125
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   126
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   127
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   128
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   129
        public void run() { check(doload(sa), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   130
        static long doload(short[] sa) { return sa[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   131
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   132
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   133
    public static class loadUI2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   134
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   135
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   136
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   137
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   138
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   139
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   140
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   141
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   142
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   143
        public void run() { check(doload(ia), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   144
        static long doload(int[] ia) { return ia[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   145
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   146
}