hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
author jcm
Tue, 17 Jan 2017 21:38:07 -0800
changeset 43455 96560cffef4d
parent 40631 ed82623d7831
permissions -rw-r--r--
8166002: Emulate client build on platforms with reduced virtual address space Summary: The default VM ergonomics on Windows/x86 (32-bit) are changed to client like. Reviewed-by: kvn, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     1
/*
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     4
 *
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    10
 *
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    15
 * accompanied this code).
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    16
 *
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    20
 *
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    23
 * questions.
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    24
 */
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    25
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    26
/*
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    27
 * @test
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    28
 * @summary tests on constant folding of unsafe get operations from stable arrays
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40067
diff changeset
    29
 * @library /test/lib
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    30
 *
43455
96560cffef4d 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 40631
diff changeset
    31
 * @requires vm.flavor == "server" & !vm.emulatedClient
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    32
 *
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    33
 * @modules java.base/jdk.internal.vm.annotation
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    34
 *          java.base/jdk.internal.misc
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    35
38188
e76af590ea2f 8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents: 38030
diff changeset
    36
 * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    37
 *                   -Xbatch -XX:-TieredCompilation
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    38
 *                   -XX:+FoldStableValues
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    39
 *                   -XX:CompileCommand=dontinline,*Test::test*
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    40
 *                   compiler.unsafe.UnsafeGetStableArrayElement
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    41
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38188
diff changeset
    42
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    43
package compiler.unsafe;
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    44
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    45
import jdk.internal.misc.Unsafe;
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    46
import jdk.internal.vm.annotation.Stable;
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
    47
import jdk.test.lib.Platform;
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    48
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38188
diff changeset
    49
import java.util.concurrent.Callable;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38188
diff changeset
    50
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    51
import static jdk.internal.misc.Unsafe.*;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38188
diff changeset
    52
import static jdk.test.lib.Asserts.assertEQ;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38188
diff changeset
    53
import static jdk.test.lib.Asserts.assertNE;
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    54
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    55
public class UnsafeGetStableArrayElement {
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    56
    @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    57
    @Stable static final    byte[]    STABLE_BYTE_ARRAY = new    byte[16];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    58
    @Stable static final   short[]   STABLE_SHORT_ARRAY = new   short[8];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    59
    @Stable static final    char[]    STABLE_CHAR_ARRAY = new    char[8];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    60
    @Stable static final     int[]     STABLE_INT_ARRAY = new     int[4];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    61
    @Stable static final    long[]    STABLE_LONG_ARRAY = new    long[2];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    62
    @Stable static final   float[]   STABLE_FLOAT_ARRAY = new   float[4];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    63
    @Stable static final  double[]  STABLE_DOUBLE_ARRAY = new  double[2];
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    64
    @Stable static final  Object[]  STABLE_OBJECT_ARRAY = new  Object[4];
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    65
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    66
    static {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    67
        Setter.reset();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    68
    }
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    69
    static final Unsafe U = Unsafe.getUnsafe();
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    70
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    71
    static class Setter {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    72
        private static void setZ(boolean defaultVal) { STABLE_BOOLEAN_ARRAY[0] = defaultVal ? false :                true; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    73
        private static void setB(boolean defaultVal) { STABLE_BYTE_ARRAY[0]    = defaultVal ?     0 :      Byte.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    74
        private static void setS(boolean defaultVal) { STABLE_SHORT_ARRAY[0]   = defaultVal ?     0 :     Short.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    75
        private static void setC(boolean defaultVal) { STABLE_CHAR_ARRAY[0]    = defaultVal ?     0 : Character.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    76
        private static void setI(boolean defaultVal) { STABLE_INT_ARRAY[0]     = defaultVal ?     0 :   Integer.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    77
        private static void setJ(boolean defaultVal) { STABLE_LONG_ARRAY[0]    = defaultVal ?     0 :      Long.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    78
        private static void setF(boolean defaultVal) { STABLE_FLOAT_ARRAY[0]   = defaultVal ?     0 :     Float.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    79
        private static void setD(boolean defaultVal) { STABLE_DOUBLE_ARRAY[0]  = defaultVal ?     0 :    Double.MAX_VALUE; }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    80
        private static void setL(boolean defaultVal) { STABLE_OBJECT_ARRAY[0]  = defaultVal ?  null :        new Object(); }
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    81
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    82
        static void reset() {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    83
            setZ(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    84
            setB(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    85
            setS(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    86
            setC(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    87
            setI(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    88
            setJ(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    89
            setF(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    90
            setD(false);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    91
            setL(false);
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    92
        }
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    93
    }
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
    94
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    95
    static class Test {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    96
        static void changeZ() { Setter.setZ(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    97
        static void changeB() { Setter.setB(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    98
        static void changeS() { Setter.setS(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
    99
        static void changeC() { Setter.setC(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   100
        static void changeI() { Setter.setI(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   101
        static void changeJ() { Setter.setJ(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   102
        static void changeF() { Setter.setF(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   103
        static void changeD() { Setter.setD(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   104
        static void changeL() { Setter.setL(true); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   105
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   106
        static boolean testZ_Z() { return U.getBoolean(STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   107
        static byte    testZ_B() { return U.getByte(   STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   108
        static short   testZ_S() { return U.getShort(  STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   109
        static char    testZ_C() { return U.getChar(   STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   110
        static int     testZ_I() { return U.getInt(    STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   111
        static long    testZ_J() { return U.getLong(   STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   112
        static float   testZ_F() { return U.getFloat(  STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   113
        static double  testZ_D() { return U.getDouble( STABLE_BOOLEAN_ARRAY, ARRAY_BOOLEAN_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   114
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   115
        static boolean testB_Z() { return U.getBoolean(STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   116
        static byte    testB_B() { return U.getByte(   STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   117
        static short   testB_S() { return U.getShort(  STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   118
        static char    testB_C() { return U.getChar(   STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   119
        static int     testB_I() { return U.getInt(    STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   120
        static long    testB_J() { return U.getLong(   STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   121
        static float   testB_F() { return U.getFloat(  STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   122
        static double  testB_D() { return U.getDouble( STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   123
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   124
        static boolean testS_Z() { return U.getBoolean(STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   125
        static byte    testS_B() { return U.getByte(   STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   126
        static short   testS_S() { return U.getShort(  STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   127
        static char    testS_C() { return U.getChar(   STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   128
        static int     testS_I() { return U.getInt(    STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   129
        static long    testS_J() { return U.getLong(   STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   130
        static float   testS_F() { return U.getFloat(  STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   131
        static double  testS_D() { return U.getDouble( STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   132
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   133
        static boolean testC_Z() { return U.getBoolean(STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   134
        static byte    testC_B() { return U.getByte(   STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   135
        static short   testC_S() { return U.getShort(  STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   136
        static char    testC_C() { return U.getChar(   STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   137
        static int     testC_I() { return U.getInt(    STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   138
        static long    testC_J() { return U.getLong(   STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   139
        static float   testC_F() { return U.getFloat(  STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   140
        static double  testC_D() { return U.getDouble( STABLE_CHAR_ARRAY, ARRAY_CHAR_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   141
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   142
        static boolean testI_Z() { return U.getBoolean(STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   143
        static byte    testI_B() { return U.getByte(   STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   144
        static short   testI_S() { return U.getShort(  STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   145
        static char    testI_C() { return U.getChar(   STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   146
        static int     testI_I() { return U.getInt(    STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   147
        static long    testI_J() { return U.getLong(   STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   148
        static float   testI_F() { return U.getFloat(  STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   149
        static double  testI_D() { return U.getDouble( STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   150
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   151
        static boolean testJ_Z() { return U.getBoolean(STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   152
        static byte    testJ_B() { return U.getByte(   STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   153
        static short   testJ_S() { return U.getShort(  STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   154
        static char    testJ_C() { return U.getChar(   STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   155
        static int     testJ_I() { return U.getInt(    STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   156
        static long    testJ_J() { return U.getLong(   STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   157
        static float   testJ_F() { return U.getFloat(  STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   158
        static double  testJ_D() { return U.getDouble( STABLE_LONG_ARRAY, ARRAY_LONG_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   159
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   160
        static boolean testF_Z() { return U.getBoolean(STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   161
        static byte    testF_B() { return U.getByte(   STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   162
        static short   testF_S() { return U.getShort(  STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   163
        static char    testF_C() { return U.getChar(   STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   164
        static int     testF_I() { return U.getInt(    STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   165
        static long    testF_J() { return U.getLong(   STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   166
        static float   testF_F() { return U.getFloat(  STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   167
        static double  testF_D() { return U.getDouble( STABLE_FLOAT_ARRAY, ARRAY_FLOAT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   168
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   169
        static boolean testD_Z() { return U.getBoolean(STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   170
        static byte    testD_B() { return U.getByte(   STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   171
        static short   testD_S() { return U.getShort(  STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   172
        static char    testD_C() { return U.getChar(   STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   173
        static int     testD_I() { return U.getInt(    STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   174
        static long    testD_J() { return U.getLong(   STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   175
        static float   testD_F() { return U.getFloat(  STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   176
        static double  testD_D() { return U.getDouble( STABLE_DOUBLE_ARRAY, ARRAY_DOUBLE_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   177
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   178
        static Object  testL_L() { return U.getObject( STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   179
        static boolean testL_Z() { return U.getBoolean(STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   180
        static byte    testL_B() { return U.getByte(   STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   181
        static short   testL_S() { return U.getShort(  STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   182
        static char    testL_C() { return U.getChar(   STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   183
        static int     testL_I() { return U.getInt(    STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   184
        static long    testL_J() { return U.getLong(   STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   185
        static float   testL_F() { return U.getFloat(  STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   186
        static double  testL_D() { return U.getDouble( STABLE_OBJECT_ARRAY, ARRAY_OBJECT_BASE_OFFSET); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   187
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   188
        static short   testS_U() { return U.getShortUnaligned(STABLE_SHORT_ARRAY, ARRAY_SHORT_BASE_OFFSET + 1); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   189
        static char    testC_U() { return U.getCharUnaligned(  STABLE_CHAR_ARRAY,  ARRAY_CHAR_BASE_OFFSET + 1); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   190
        static int     testI_U() { return U.getIntUnaligned(    STABLE_INT_ARRAY,   ARRAY_INT_BASE_OFFSET + 1); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   191
        static long    testJ_U() { return U.getLongUnaligned(  STABLE_LONG_ARRAY,  ARRAY_LONG_BASE_OFFSET + 1); }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   192
    }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   193
36349
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   194
    static void run(Callable<?> c) throws Exception {
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   195
        run(c, null, null);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   196
    }
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   197
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   198
    static void run(Callable<?> c, Runnable sameResultAction, Runnable changeResultAction) throws Exception {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   199
        Object first = c.call();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   200
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   201
        // Trigger compilation.
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   202
        for (int i = 0; i < 20_000; i++) {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   203
            // Don't compare results here, since most of Test::testL_* results vary across iterations (due to GC).
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   204
            c.call();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   205
        }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   206
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   207
        if (sameResultAction != null) {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   208
            sameResultAction.run();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   209
            assertEQ(first, c.call());
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   210
        }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   211
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   212
        if (changeResultAction != null) {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   213
            changeResultAction.run();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   214
            assertNE(first, c.call());
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   215
            assertEQ(c.call(), c.call());
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   216
        }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   217
    }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   218
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   219
    static void testMatched(Callable<?> c, Runnable setDefaultAction) throws Exception {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   220
        run(c, setDefaultAction, null);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   221
        Setter.reset();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   222
    }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   223
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   224
    static void testMismatched(Callable<?> c, Runnable setDefaultAction) throws Exception {
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   225
        run(c, null, setDefaultAction);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   226
        Setter.reset();
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   227
    }
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   228
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   229
    static void testUnsafeAccess() throws Exception {
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   230
        // boolean[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   231
        testMatched(   Test::testZ_Z, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   232
        testMismatched(Test::testZ_B, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   233
        testMismatched(Test::testZ_S, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   234
        testMismatched(Test::testZ_C, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   235
        testMismatched(Test::testZ_I, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   236
        testMismatched(Test::testZ_J, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   237
        testMismatched(Test::testZ_F, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   238
        testMismatched(Test::testZ_D, Test::changeZ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   239
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   240
        // byte[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   241
        testMismatched(Test::testB_Z, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   242
        testMatched(   Test::testB_B, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   243
        testMismatched(Test::testB_S, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   244
        testMismatched(Test::testB_C, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   245
        testMismatched(Test::testB_I, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   246
        testMismatched(Test::testB_J, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   247
        testMismatched(Test::testB_F, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   248
        testMismatched(Test::testB_D, Test::changeB);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   249
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   250
        // short[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   251
        testMismatched(Test::testS_Z, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   252
        testMismatched(Test::testS_B, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   253
        testMatched(   Test::testS_S, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   254
        testMismatched(Test::testS_C, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   255
        testMismatched(Test::testS_I, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   256
        testMismatched(Test::testS_J, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   257
        testMismatched(Test::testS_F, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   258
        testMismatched(Test::testS_D, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   259
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   260
        // char[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   261
        testMismatched(Test::testC_Z, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   262
        testMismatched(Test::testC_B, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   263
        testMismatched(Test::testC_S, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   264
        testMatched(   Test::testC_C, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   265
        testMismatched(Test::testC_I, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   266
        testMismatched(Test::testC_J, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   267
        testMismatched(Test::testC_F, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   268
        testMismatched(Test::testC_D, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   269
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   270
        // int[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   271
        testMismatched(Test::testI_Z, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   272
        testMismatched(Test::testI_B, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   273
        testMismatched(Test::testI_S, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   274
        testMismatched(Test::testI_C, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   275
        testMatched(   Test::testI_I, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   276
        testMismatched(Test::testI_J, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   277
        testMismatched(Test::testI_F, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   278
        testMismatched(Test::testI_D, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   279
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   280
        // long[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   281
        testMismatched(Test::testJ_Z, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   282
        testMismatched(Test::testJ_B, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   283
        testMismatched(Test::testJ_S, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   284
        testMismatched(Test::testJ_C, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   285
        testMismatched(Test::testJ_I, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   286
        testMatched(   Test::testJ_J, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   287
        testMismatched(Test::testJ_F, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   288
        testMismatched(Test::testJ_D, Test::changeJ);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   289
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   290
        // float[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   291
        testMismatched(Test::testF_Z, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   292
        testMismatched(Test::testF_B, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   293
        testMismatched(Test::testF_S, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   294
        testMismatched(Test::testF_C, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   295
        testMismatched(Test::testF_I, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   296
        testMismatched(Test::testF_J, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   297
        testMatched(   Test::testF_F, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   298
        testMismatched(Test::testF_D, Test::changeF);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   299
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   300
        // double[], aligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   301
        testMismatched(Test::testD_Z, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   302
        testMismatched(Test::testD_B, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   303
        testMismatched(Test::testD_S, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   304
        testMismatched(Test::testD_C, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   305
        testMismatched(Test::testD_I, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   306
        testMismatched(Test::testD_J, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   307
        testMismatched(Test::testD_F, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   308
        testMatched(   Test::testD_D, Test::changeD);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   309
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   310
        // Object[], aligned accesses
36349
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   311
        testMismatched(Test::testL_J, Test::changeL); // long & double are always as large as an OOP
36337
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   312
        testMismatched(Test::testL_D, Test::changeL);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   313
        testMatched(   Test::testL_L, Test::changeL);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   314
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   315
        // Unaligned accesses
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   316
        testMismatched(Test::testS_U, Test::changeS);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   317
        testMismatched(Test::testC_U, Test::changeC);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   318
        testMismatched(Test::testI_U, Test::changeI);
d4b2f60ff5a9 8150543: Mismatched access detection is inaccurate
vlivanov
parents: 36330
diff changeset
   319
        testMismatched(Test::testJ_U, Test::changeJ);
36349
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   320
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   321
        // No way to reliably check the expected behavior:
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   322
        //   (1) OOPs change during GC;
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   323
        //   (2) there's no way to reliably change some part of an OOP (e.g., when reading a byte from it).
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   324
        //
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   325
        // Just trigger the compilation hoping to catch any problems with asserts.
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   326
        run(Test::testL_B);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   327
        run(Test::testL_Z);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   328
        run(Test::testL_S);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   329
        run(Test::testL_C);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   330
        run(Test::testL_I);
6cc8e6f596b2 8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
vlivanov
parents: 36337
diff changeset
   331
        run(Test::testL_F);
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
   332
    }
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   333
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   334
    public static void main(String[] args) throws Exception {
43455
96560cffef4d 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 40631
diff changeset
   335
        if (!Platform.isServer() || Platform.isEmulatedClient()) {
96560cffef4d 8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents: 40631
diff changeset
   336
            throw new Error("TESTBUG: Not server mode");
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   337
        }
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
   338
        testUnsafeAccess();
38030
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   339
        System.out.println("TEST PASSED");
93f24e7b3c43 8152590: C2: @Stable support doesn't always work w/ incremental inlining
vlivanov
parents: 36617
diff changeset
   340
    }
36330
37a0f096251b 8150186: Folding mismatched accesses with @Stable is incorrect
vlivanov
parents:
diff changeset
   341
}