hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 38152 80e5da81fb2c
child 40631 ed82623d7831
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     1
/*
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 27699
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     4
 *
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    10
 *
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    15
 * accompanied this code).
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    16
 *
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    20
 *
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    23
 * questions.
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    24
 */
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    25
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    26
/*
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    27
 * @test
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 30604
diff changeset
    28
 * @modules java.base/jdk.internal.misc
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    29
 * @library /testlibrary
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 *
27641
fca9ac607ebc 8062742: compiler/EliminateAutoBox/UnsignedLoads.java fails with client vm
iignatyev
parents: 27421
diff changeset
    31
 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    32
 *                   -XX:CompileOnly=::valueOf,::byteValue,::shortValue,::testUnsignedByte,::testUnsignedShort
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 *                   compiler.eliminateAutobox.UnsignedLoads
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    34
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    35
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
package compiler.eliminateAutobox;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 27699
diff changeset
    38
import static jdk.test.lib.Asserts.assertEQ;
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    39
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    40
public class UnsignedLoads {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    41
    public static int testUnsignedByte() {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    42
        byte[] bytes = new byte[] {-1};
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    43
        int res = 0;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    44
        for (int i = 0; i < 100000; i++) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    45
            for (Byte b : bytes) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    46
                res = b & 0xff;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    47
            }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    48
        }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    49
        return res;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    50
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    51
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    52
    public static int testUnsignedShort() {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    53
        int res = 0;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    54
        short[] shorts = new short[] {-1};
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    55
        for (int i = 0; i < 100000; i++) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    56
            for (Short s : shorts) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    57
                res = s & 0xffff;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    58
            }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    59
        }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    60
        return res;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    61
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    62
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    63
    public static void main(String[] args) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    64
        assertEQ(testUnsignedByte(),    255);
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    65
        assertEQ(testUnsignedShort(), 65535);
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    66
        System.out.println("TEST PASSED");
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    67
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    68
}