hotspot/test/compiler/8000805/Test8000805.java
author ccheung
Fri, 04 Oct 2013 21:00:43 -0700
changeset 20384 49bfb2ec8f8f
parent 15864 2757a5eae916
child 22234 da823d78ad65
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14129
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     1
/*
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     4
 *
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     8
 *
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    14
 *
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    18
 *
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    21
 * questions.
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    22
 */
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    23
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    24
/**
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    25
 * @test
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    26
 * @bug 8000805
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    27
 * @summary JMM issue: short loads are non-atomic
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    28
 *
15864
2757a5eae916 7115383: TEST_BUG: some jtreg tests fail because they explicitly specify -server option
collins
parents: 14129
diff changeset
    29
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -Xcomp -XX:+PrintCompilation -XX:CompileOnly=Test8000805.loadS2LmaskFF,Test8000805.loadS2Lmask16,Test8000805.loadS2Lmask13,Test8000805.loadUS_signExt,Test8000805.loadB2L_mask8 Test8000805
14129
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    30
 */
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    31
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    32
public class Test8000805 {
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    33
    static long loadS2LmaskFF   (short[] sa) { return sa[0] & 0xFF; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    34
    static long loadS2LmaskFF_1 (short[] sa) { return sa[0] & 0xFF; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    35
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    36
    static long loadS2Lmask16   (short[] sa) { return sa[0] & 0xFFFE; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    37
    static long loadS2Lmask16_1 (short[] sa) { return sa[0] & 0xFFFE; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    38
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    39
    static long loadS2Lmask13   (short[] sa) { return sa[0] & 0x0FFF; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    40
    static long loadS2Lmask13_1 (short[] sa) { return sa[0] & 0x0FFF; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    41
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    42
    static int loadUS_signExt   (char[] ca) { return (ca[0] << 16) >> 16; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    43
    static int loadUS_signExt_1 (char[] ca) { return (ca[0] << 16) >> 16; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    44
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    45
    static long loadB2L_mask8   (byte[] ba) { return ba[0] & 0x55; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    46
    static long loadB2L_mask8_1 (byte[] ba) { return ba[0] & 0x55; }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    47
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    48
    public static void main(String[] args) {
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    49
        for (int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++) {
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    50
            byte[] ba = new byte[]  { (byte) i};
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    51
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    52
            { long v1 = loadB2L_mask8(ba);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    53
              long v2 = loadB2L_mask8_1(ba);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    54
              if (v1 != v2)
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    55
              throw new InternalError(String.format("loadB2L_mask8 failed: %x != %x", v1, v2)); }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    56
        }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    57
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    58
        for (int i = Short.MIN_VALUE; i < Short.MAX_VALUE; i++) {
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    59
            short[] sa = new short[] { (short)i };
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    60
            char[] ca = new char[] { (char)i };
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    61
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    62
            { long v1 = loadS2LmaskFF(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    63
              long v2 = loadS2LmaskFF_1(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    64
              if (v1 != v2)
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    65
              throw new InternalError(String.format("loadS2LmaskFF failed: %x != %x", v1, v2)); }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    66
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    67
            { long v1 = loadS2Lmask16(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    68
              long v2 = loadS2Lmask16_1(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    69
              if (v1 != v2)
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    70
              throw new InternalError(String.format("loadS2Lmask16 failed: %x != %x", v1, v2)); }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    71
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    72
            { long v1 = loadS2Lmask13(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    73
              long v2 = loadS2Lmask13_1(sa);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    74
              if (v1 != v2)
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    75
              throw new InternalError(String.format("loadS2Lmask13 failed: %x != %x", v1, v2)); }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    76
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    77
            { int v1 = loadUS_signExt(ca);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    78
              int v2 = loadUS_signExt_1(ca);
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    79
              if (v1 != v2)
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    80
                throw new InternalError(String.format("loadUS_signExt failed: %x != %x", v1, v2)); }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    81
        }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    82
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    83
        System.out.println("TEST PASSED.");
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    84
    }
291ac612f0c6 8000805: JMM issue: short loads are non-atomic
vlivanov
parents:
diff changeset
    85
}