hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java
author fzhinkin
Fri, 12 Dec 2014 21:37:37 +0300
changeset 28181 ce5d307551ea
parent 27699 9913b19c0948
child 30604 b8d532cb6420
permissions -rw-r--r--
8066862: TestMutuallyExclusivePlatformPredicates fails on all platforms Reviewed-by: iignatyev, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     1
/*
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    28
 * @library /testlibrary
27641
fca9ac607ebc 8062742: compiler/EliminateAutoBox/UnsignedLoads.java fails with client vm
iignatyev
parents: 27421
diff changeset
    29
 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox
27421
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    30
 *                   -XX:CompileOnly=::valueOf,::byteValue,::shortValue,::testUnsignedByte,::testUnsignedShort
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    31
 *                   UnsignedLoads
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    32
 */
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    33
import static com.oracle.java.testlibrary.Asserts.assertEQ;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    34
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    35
public class UnsignedLoads {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    36
    public static int testUnsignedByte() {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    37
        byte[] bytes = new byte[] {-1};
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    38
        int res = 0;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    39
        for (int i = 0; i < 100000; i++) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    40
            for (Byte b : bytes) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    41
                res = b & 0xff;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    42
            }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    43
        }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    44
        return res;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    45
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    46
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    47
    public static int testUnsignedShort() {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    48
        int res = 0;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    49
        short[] shorts = new short[] {-1};
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    50
        for (int i = 0; i < 100000; i++) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    51
            for (Short s : shorts) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    52
                res = s & 0xffff;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    53
            }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    54
        }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    55
        return res;
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    56
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    57
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    58
    public static void main(String[] args) {
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    59
        assertEQ(testUnsignedByte(),    255);
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    60
        assertEQ(testUnsignedShort(), 65535);
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    61
        System.out.println("TEST PASSED");
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    62
    }
df2b6ff5c959 8058847: C2: EliminateAutoBox regression after 8042786
vlivanov
parents:
diff changeset
    63
}