hotspot/test/compiler/intrinsics/unsafe/AllocateUninitializedArray.java
author vdeshpande
Fri, 26 Aug 2016 12:20:09 -0700
changeset 41362 e09e871860a7
parent 40059 c2304140ed64
child 41705 332239c052cc
permissions -rw-r--r--
8154122: Intrinsify fused mac operations Summary: added FMA intrinsics on x86 Reviewed-by: kvn, aph, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36553
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     1
/*
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     4
 *
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     7
 * published by the Free Software Foundation.
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     8
 *
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    13
 * accompanied this code).
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    14
 *
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    18
 *
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    21
 * questions.
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    22
 *
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    23
 */
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    24
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    25
/*
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    26
 * @test
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    27
 * @bug 8150465
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    28
 * @summary Unsafe methods to produce uninitialized arrays
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    29
 * @modules java.base/jdk.internal.misc
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    30
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    31
 * @run main/othervm -ea -Diters=200   -Xint
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    32
 *      compiler.intrinsics.unsafe.AllocateUninitializedArray
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    33
 * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=1
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    34
 *      compiler.intrinsics.unsafe.AllocateUninitializedArray
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    35
 * @run main/othervm -ea -Diters=30000 -XX:TieredStopAtLevel=4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    36
 *      compiler.intrinsics.unsafe.AllocateUninitializedArray
36553
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    37
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    38
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    39
package compiler.intrinsics.unsafe;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    40
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36553
diff changeset
    41
import java.lang.reflect.Array;
36553
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    42
import java.lang.reflect.Field;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    43
import java.util.concurrent.Callable;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    44
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    45
public class AllocateUninitializedArray {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    46
    static final int ITERS = Integer.getInteger("iters", 1);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    47
    static final jdk.internal.misc.Unsafe UNSAFE;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    48
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    49
    static {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    50
        try {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    51
            Field f = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe");
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    52
            f.setAccessible(true);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    53
            UNSAFE = (jdk.internal.misc.Unsafe) f.get(null);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    54
        } catch (Exception e) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    55
            throw new RuntimeException("Unable to get Unsafe instance.", e);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    56
        }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    57
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    58
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    59
    public static void main(String... args) throws Exception {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    60
        testIAE(AllConstants::testObject);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    61
        testIAE(LengthIsConstant::testObject);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    62
        testIAE(ClassIsConstant::testObject);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    63
        testIAE(NothingIsConstant::testObject);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    64
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    65
        testIAE(AllConstants::testArray);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    66
        testIAE(LengthIsConstant::testArray);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    67
        testIAE(ClassIsConstant::testArray);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    68
        testIAE(NothingIsConstant::testArray);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    69
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    70
        testIAE(AllConstants::testNull);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    71
        testIAE(LengthIsConstant::testNull);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    72
        testIAE(ClassIsConstant::testNull);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    73
        testIAE(NothingIsConstant::testNull);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    74
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    75
        testOK(boolean[].class, 10, AllConstants::testBoolean);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    76
        testOK(byte[].class,    10, AllConstants::testByte);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    77
        testOK(short[].class,   10, AllConstants::testShort);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    78
        testOK(char[].class,    10, AllConstants::testChar);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    79
        testOK(int[].class,     10, AllConstants::testInt);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    80
        testOK(float[].class,   10, AllConstants::testFloat);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    81
        testOK(long[].class,    10, AllConstants::testLong);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    82
        testOK(double[].class,  10, AllConstants::testDouble);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    83
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    84
        testOK(boolean[].class, 10, LengthIsConstant::testBoolean);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    85
        testOK(byte[].class,    10, LengthIsConstant::testByte);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    86
        testOK(short[].class,   10, LengthIsConstant::testShort);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    87
        testOK(char[].class,    10, LengthIsConstant::testChar);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    88
        testOK(int[].class,     10, LengthIsConstant::testInt);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    89
        testOK(float[].class,   10, LengthIsConstant::testFloat);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    90
        testOK(long[].class,    10, LengthIsConstant::testLong);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    91
        testOK(double[].class,  10, LengthIsConstant::testDouble);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    92
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    93
        testOK(boolean[].class, 10, ClassIsConstant::testBoolean);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    94
        testOK(byte[].class,    10, ClassIsConstant::testByte);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    95
        testOK(short[].class,   10, ClassIsConstant::testShort);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    96
        testOK(char[].class,    10, ClassIsConstant::testChar);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    97
        testOK(int[].class,     10, ClassIsConstant::testInt);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    98
        testOK(float[].class,   10, ClassIsConstant::testFloat);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
    99
        testOK(long[].class,    10, ClassIsConstant::testLong);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   100
        testOK(double[].class,  10, ClassIsConstant::testDouble);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   101
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   102
        testOK(boolean[].class, 10, NothingIsConstant::testBoolean);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   103
        testOK(byte[].class,    10, NothingIsConstant::testByte);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   104
        testOK(short[].class,   10, NothingIsConstant::testShort);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   105
        testOK(char[].class,    10, NothingIsConstant::testChar);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   106
        testOK(int[].class,     10, NothingIsConstant::testInt);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   107
        testOK(float[].class,   10, NothingIsConstant::testFloat);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   108
        testOK(long[].class,    10, NothingIsConstant::testLong);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   109
        testOK(double[].class,  10, NothingIsConstant::testDouble);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   110
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   111
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   112
    public static void testOK(Class<?> expectClass, int expectLen, Callable<Object> test) throws Exception {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   113
        for (int c = 0; c < ITERS; c++) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   114
            Object res = test.call();
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   115
            Class<?> actualClass = res.getClass();
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   116
            if (!actualClass.equals(expectClass)) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   117
                throw new IllegalStateException("Wrong class: expected = " + expectClass + ", but got " + actualClass);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   118
            }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   119
            int actualLen = Array.getLength(res);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   120
            if (actualLen != expectLen) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   121
                throw new IllegalStateException("Wrong length: expected = " + expectLen + ", but got " + actualLen);
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   122
            }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   123
        }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   124
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   125
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   126
    static volatile Object sink;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   127
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   128
    public static void testIAE(Callable<Object> test) throws Exception {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   129
        for (int c = 0; c < ITERS; c++) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   130
            try {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   131
               sink = test.call();
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   132
               throw new IllegalStateException("Expected IAE");
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   133
            } catch (IllegalArgumentException iae) {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   134
               // expected
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   135
            }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   136
        }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   137
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   138
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   139
    static volatile int sampleLenNeg  = -1;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   140
    static volatile int sampleLenZero = 0;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   141
    static volatile int sampleLen     = 10;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   142
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   143
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   144
    static volatile Class<?> classBoolean = boolean.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   145
    static volatile Class<?> classByte    = byte.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   146
    static volatile Class<?> classShort   = short.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   147
    static volatile Class<?> classChar    = char.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   148
    static volatile Class<?> classInt     = int.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   149
    static volatile Class<?> classFloat   = float.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   150
    static volatile Class<?> classLong    = long.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   151
    static volatile Class<?> classDouble  = double.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   152
    static volatile Class<?> classObject  = Object.class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   153
    static volatile Class<?> classArray   = Object[].class;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   154
    static volatile Class<?> classNull    = null;
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   155
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   156
    static class AllConstants {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   157
        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(boolean.class,  10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   158
        static Object testByte()    { return UNSAFE.allocateUninitializedArray(byte.class,     10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   159
        static Object testShort()   { return UNSAFE.allocateUninitializedArray(short.class,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   160
        static Object testChar()    { return UNSAFE.allocateUninitializedArray(char.class,     10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   161
        static Object testInt()     { return UNSAFE.allocateUninitializedArray(int.class,      10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   162
        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(float.class,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   163
        static Object testLong()    { return UNSAFE.allocateUninitializedArray(long.class,     10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   164
        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(double.class,   10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   165
        static Object testObject()  { return UNSAFE.allocateUninitializedArray(Object.class,   10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   166
        static Object testArray()   { return UNSAFE.allocateUninitializedArray(Object[].class, 10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   167
        static Object testNull()    { return UNSAFE.allocateUninitializedArray(null,           10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   168
        static Object testZero()    { return UNSAFE.allocateUninitializedArray(int.class,      0);  }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   169
        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(int.class,      -1); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   170
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   171
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   172
    static class ClassIsConstant {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   173
        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(boolean.class,  sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   174
        static Object testByte()    { return UNSAFE.allocateUninitializedArray(byte.class,     sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   175
        static Object testShort()   { return UNSAFE.allocateUninitializedArray(short.class,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   176
        static Object testChar()    { return UNSAFE.allocateUninitializedArray(char.class,     sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   177
        static Object testInt()     { return UNSAFE.allocateUninitializedArray(int.class,      sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   178
        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(float.class,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   179
        static Object testLong()    { return UNSAFE.allocateUninitializedArray(long.class,     sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   180
        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(double.class,   sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   181
        static Object testObject()  { return UNSAFE.allocateUninitializedArray(Object.class,   sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   182
        static Object testArray()   { return UNSAFE.allocateUninitializedArray(Object[].class, sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   183
        static Object testNull()    { return UNSAFE.allocateUninitializedArray(null,           sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   184
        static Object testZero()    { return UNSAFE.allocateUninitializedArray(int.class,      sampleLenZero); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   185
        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(int.class,      sampleLenNeg); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   186
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   187
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   188
    static class LengthIsConstant {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   189
        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(classBoolean, 10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   190
        static Object testByte()    { return UNSAFE.allocateUninitializedArray(classByte,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   191
        static Object testShort()   { return UNSAFE.allocateUninitializedArray(classShort,   10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   192
        static Object testChar()    { return UNSAFE.allocateUninitializedArray(classChar,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   193
        static Object testInt()     { return UNSAFE.allocateUninitializedArray(classInt,     10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   194
        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(classFloat,   10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   195
        static Object testLong()    { return UNSAFE.allocateUninitializedArray(classLong,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   196
        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(classDouble,  10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   197
        static Object testObject()  { return UNSAFE.allocateUninitializedArray(classObject,  10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   198
        static Object testArray()   { return UNSAFE.allocateUninitializedArray(classArray,   10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   199
        static Object testNull()    { return UNSAFE.allocateUninitializedArray(classNull,    10); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   200
        static Object testZero()    { return UNSAFE.allocateUninitializedArray(classInt,     0);  }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   201
        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(classInt,     -1); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   202
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   203
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   204
    static class NothingIsConstant {
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   205
        static Object testBoolean() { return UNSAFE.allocateUninitializedArray(classBoolean, sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   206
        static Object testByte()    { return UNSAFE.allocateUninitializedArray(classByte,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   207
        static Object testShort()   { return UNSAFE.allocateUninitializedArray(classShort,   sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   208
        static Object testChar()    { return UNSAFE.allocateUninitializedArray(classChar,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   209
        static Object testInt()     { return UNSAFE.allocateUninitializedArray(classInt,     sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   210
        static Object testFloat()   { return UNSAFE.allocateUninitializedArray(classFloat,   sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   211
        static Object testLong()    { return UNSAFE.allocateUninitializedArray(classLong,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   212
        static Object testDouble()  { return UNSAFE.allocateUninitializedArray(classDouble,  sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   213
        static Object testObject()  { return UNSAFE.allocateUninitializedArray(classObject,  sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   214
        static Object testArray()   { return UNSAFE.allocateUninitializedArray(classArray,   sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   215
        static Object testNull()    { return UNSAFE.allocateUninitializedArray(classNull,    sampleLen); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   216
        static Object testZero()    { return UNSAFE.allocateUninitializedArray(classInt,     sampleLenZero); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   217
        static Object testNeg()     { return UNSAFE.allocateUninitializedArray(classInt,     sampleLenNeg); }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   218
    }
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   219
}
203b2b5d149b 8150465: Unsafe methods to produce uninitialized arrays
shade
parents:
diff changeset
   220