hotspot/test/compiler/stable/TestStableInt.java
author vlivanov
Mon, 14 Jul 2014 03:25:40 -0700
changeset 25641 d99065e4572b
parent 23192 f6a1c8866065
child 26916 8a1deee4f9b4
permissions -rw-r--r--
8043546: C1 optimizes @Stable instance fields with default values Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     1
/*
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     4
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    10
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    15
 * accompanied this code).
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    16
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    20
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    23
 * questions.
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    24
 */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    25
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    26
/*
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    27
 * @test TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    28
 * @summary tests on stable fields and arrays
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    29
 * @library /testlibrary /testlibrary/whitebox
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    30
 * @build TestStableInt StableConfiguration sun.hotspot.WhiteBox
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    31
 * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    32
 * @run main ClassFileInstaller
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    33
 *           java/lang/invoke/StableConfiguration
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    34
 *           java/lang/invoke/TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    35
 *           java/lang/invoke/TestStableInt$IntStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    36
 *           java/lang/invoke/TestStableInt$StaticIntStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    37
 *           java/lang/invoke/TestStableInt$VolatileIntStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    38
 *           java/lang/invoke/TestStableInt$IntArrayDim1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    39
 *           java/lang/invoke/TestStableInt$IntArrayDim2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    40
 *           java/lang/invoke/TestStableInt$IntArrayDim3
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    41
 *           java/lang/invoke/TestStableInt$IntArrayDim4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    42
 *           java/lang/invoke/TestStableInt$ObjectArrayLowerDim0
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    43
 *           java/lang/invoke/TestStableInt$ObjectArrayLowerDim1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    44
 *           java/lang/invoke/TestStableInt$NestedStableField
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    45
 *           java/lang/invoke/TestStableInt$NestedStableField$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    46
 *           java/lang/invoke/TestStableInt$NestedStableField1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    47
 *           java/lang/invoke/TestStableInt$NestedStableField1$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    48
 *           java/lang/invoke/TestStableInt$NestedStableField2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    49
 *           java/lang/invoke/TestStableInt$NestedStableField2$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    50
 *           java/lang/invoke/TestStableInt$NestedStableField3
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    51
 *           java/lang/invoke/TestStableInt$NestedStableField3$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    52
 *           java/lang/invoke/TestStableInt$DefaultValue
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    53
 *           java/lang/invoke/TestStableInt$DefaultStaticValue
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    54
 *           java/lang/invoke/TestStableInt$ObjectArrayLowerDim2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    55
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    56
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    57
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    58
 *                   -server -XX:-TieredCompilation
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    59
 *                   -XX:+FoldStableValues
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    60
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    61
 *                   java.lang.invoke.TestStableInt
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    62
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    63
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    64
 *                   -server -XX:-TieredCompilation
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    65
 *                   -XX:-FoldStableValues
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    66
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    67
 *                   java.lang.invoke.TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    68
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    69
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    70
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    71
 *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    72
 *                   -XX:+FoldStableValues
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    73
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    74
 *                   java.lang.invoke.TestStableInt
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    75
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    76
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    77
 *                   -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    78
 *                   -XX:-FoldStableValues
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    79
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    80
 *                   java.lang.invoke.TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    81
 *
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    82
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    83
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    84
 *                   -client -XX:-TieredCompilation
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    85
 *                   -XX:+FoldStableValues
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    86
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    87
 *                   java.lang.invoke.TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    88
 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    89
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    90
 *                   -client -XX:-TieredCompilation
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    91
 *                   -XX:-FoldStableValues
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    92
 *                   -XX:CompileOnly=::get,::get1,::get2,::get3,::get4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    93
 *                   java.lang.invoke.TestStableInt
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    94
 */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    95
package java.lang.invoke;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    96
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    97
import java.lang.reflect.InvocationTargetException;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    98
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    99
public class TestStableInt {
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   100
    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   101
    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   102
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   103
    public static void main(String[] args) throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   104
        run(DefaultValue.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   105
        run(IntStable.class);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   106
        run(DefaultStaticValue.class);
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   107
        run(StaticIntStable.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   108
        run(VolatileIntStable.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   109
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   110
        // @Stable arrays: Dim 1-4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   111
        run(IntArrayDim1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   112
        run(IntArrayDim2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   113
        run(IntArrayDim3.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   114
        run(IntArrayDim4.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   115
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   116
        // @Stable Object field: dynamic arrays
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   117
        run(ObjectArrayLowerDim0.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   118
        run(ObjectArrayLowerDim1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   119
        run(ObjectArrayLowerDim2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   120
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   121
        // Nested @Stable fields
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   122
        run(NestedStableField.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   123
        run(NestedStableField1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   124
        run(NestedStableField2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   125
        run(NestedStableField3.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   126
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   127
        if (failed) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   128
            throw new Error("TEST FAILED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   129
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   130
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   131
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   132
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   133
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   134
    static class DefaultValue {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   135
        public @Stable int v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   136
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   137
        public static final DefaultValue c = new DefaultValue();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   138
        public static int get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   139
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   140
                        int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   141
            c.v = 1; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   142
            assertEquals(val1, 0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   143
            assertEquals(val2, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   144
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   145
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   146
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   147
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   148
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   149
    static class IntStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   150
        public @Stable int v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   151
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   152
        public static final IntStable c = new IntStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   153
        public static int get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   154
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   155
            c.v = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   156
            c.v = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   157
            assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   158
            assertEquals(val2, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   159
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   160
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   161
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   162
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   163
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   164
    static class DefaultStaticValue {
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   165
        public static @Stable int v;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   166
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   167
        public static final DefaultStaticValue c = new DefaultStaticValue();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   168
        public static int get() { return c.v; }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   169
        public static void test() throws Exception {
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   170
                        int val1 = get();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   171
            c.v = 1; int val2 = get();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   172
            assertEquals(val1, 0);
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   173
            assertEquals(val2, 1);
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   174
        }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   175
    }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   176
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   177
    /* ==================================================== */
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   178
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   179
    static class StaticIntStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   180
        public static @Stable int v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   181
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   182
        public static final StaticIntStable c = new StaticIntStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   183
        public static int get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   184
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   185
            c.v = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   186
            c.v = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   187
            assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   188
            assertEquals(val2, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   189
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   190
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   191
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   192
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   193
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   194
    static class VolatileIntStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   195
        public @Stable volatile int v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   196
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   197
        public static final VolatileIntStable c = new VolatileIntStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   198
        public static int get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   199
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   200
            c.v = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   201
            c.v = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   202
            assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   203
            assertEquals(val2, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   204
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   205
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   206
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   207
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   208
    // @Stable array == field && all components are stable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   209
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   210
    static class IntArrayDim1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   211
        public @Stable int[] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   212
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   213
        public static final IntArrayDim1 c = new IntArrayDim1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   214
        public static int get() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   215
        public static int get1() { return c.v[10]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   216
        public static int[] get2() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   217
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   218
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   219
                c.v = new int[1]; c.v[0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   220
                                  c.v[0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   221
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   222
                assertEquals(val2, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   223
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   224
                c.v = new int[1]; c.v[0] = 3; int val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   225
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   226
                                                    : 3));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   227
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   228
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   229
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   230
                c.v = new int[20]; c.v[10] = 1; int val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   231
                                   c.v[10] = 2; int val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   232
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   233
                assertEquals(val2, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   234
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   235
                c.v = new int[20]; c.v[10] = 3; int val3 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   236
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   237
                                                    : 3));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   238
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   239
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   240
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   241
                c.v = new int[1]; int[] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   242
                c.v = new int[1]; int[] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   243
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   244
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   245
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   246
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   247
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   248
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   249
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   250
    static class IntArrayDim2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   251
        public @Stable int[][] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   252
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   253
        public static final IntArrayDim2 c = new IntArrayDim2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   254
        public static int get() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   255
        public static int[] get1() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   256
        public static int[][] get2() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   257
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   258
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   259
                c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   260
                                     c.v[0][0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   261
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   262
                assertEquals(val2, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   263
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   264
                c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   265
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   266
                                                    : 3));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   267
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   268
                c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   269
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   270
                                                    : 4));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   271
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   272
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   273
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   274
                c.v = new int[1][1]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   275
                c.v[0] = new int[1]; int[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   276
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   277
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   278
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   279
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   280
                c.v = new int[1][1]; int[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   281
                c.v = new int[1][1]; int[][] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   282
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   283
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   284
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   285
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   286
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   287
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   288
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   289
    static class IntArrayDim3 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   290
        public @Stable int[][][] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   291
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   292
        public static final IntArrayDim3 c = new IntArrayDim3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   293
        public static int get() { return c.v[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   294
        public static int[] get1() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   295
        public static int[][] get2() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   296
        public static int[][][] get3() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   297
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   298
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   299
                c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   300
                                        c.v[0][0][0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   301
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   302
                assertEquals(val2, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   303
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   304
                c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   305
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   306
                                                    : 3));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   307
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   308
                c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   309
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   310
                                                    : 4));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   311
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   312
                c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   313
                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   314
                                                    : 5));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   315
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   316
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   317
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   318
                c.v = new int[1][1][1]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   319
                c.v[0][0] = new int[1]; int[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   320
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   321
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   322
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   323
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   324
                c.v = new int[1][1][1]; int[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   325
                c.v[0] = new int[1][1]; int[][] val2 = get2();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   326
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   327
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   328
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   329
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   330
                c.v = new int[1][1][1]; int[][][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   331
                c.v = new int[1][1][1]; int[][][] val2 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   332
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   333
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   334
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   335
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   336
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   337
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   338
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   339
    static class IntArrayDim4 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   340
        public @Stable int[][][][] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   341
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   342
        public static final IntArrayDim4 c = new IntArrayDim4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   343
        public static int get() { return c.v[0][0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   344
        public static int[] get1() { return c.v[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   345
        public static int[][] get2() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   346
        public static int[][][] get3() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   347
        public static int[][][][] get4() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   348
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   349
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   350
                c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   351
                                           c.v[0][0][0][0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   352
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   353
                assertEquals(val2, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   354
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   355
                c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   356
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   357
                                                    : 3));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   358
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   359
                c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   360
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   361
                                                    : 4));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   362
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   363
                c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   364
                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   365
                                                    : 5));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   366
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   367
                c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   368
                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   369
                                                    : 6));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   370
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   371
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   372
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   373
                c.v = new int[1][1][1][1]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   374
                c.v[0][0][0] = new int[1]; int[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   375
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   376
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   377
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   378
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   379
                c.v = new int[1][1][1][1]; int[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   380
                c.v[0][0] = new int[1][1]; int[][] val2 = get2();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   381
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   382
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   383
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   384
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   385
                c.v = new int[1][1][1][1]; int[][][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   386
                c.v[0] = new int[1][1][1]; int[][][] val2 = get3();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   387
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   388
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   389
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   390
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   391
                c.v = new int[1][1][1][1]; int[][][][] val1 = get4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   392
                c.v = new int[1][1][1][1]; int[][][][] val2 = get4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   393
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   394
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   395
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   396
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   397
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   398
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   399
    // Dynamic Dim is higher than static
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   400
    static class ObjectArrayLowerDim0 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   401
        public @Stable Object v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   402
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   403
        public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   404
        public static int get() { return ((int[])c.v)[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   405
        public static int[] get1() { return (int[])c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   406
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   407
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   408
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   409
                c.v = new int[1]; ((int[])c.v)[0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   410
                                  ((int[])c.v)[0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   411
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   412
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   413
                assertEquals(val2, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   414
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   415
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   416
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   417
                c.v = new int[1]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   418
                c.v = new int[1]; int[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   419
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   420
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   421
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   422
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   423
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   424
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   425
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   426
    static class ObjectArrayLowerDim1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   427
        public @Stable Object[] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   428
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   429
        public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   430
        public static int get() { return ((int[][])c.v)[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   431
        public static int[] get1() { return (int[])(c.v[0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   432
        public static Object[] get2() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   433
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   434
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   435
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   436
                c.v = new int[1][1]; ((int[][])c.v)[0][0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   437
                                     ((int[][])c.v)[0][0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   438
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   439
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   440
                assertEquals(val2, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   441
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   442
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   443
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   444
                c.v = new int[1][1]; c.v[0] = new int[0]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   445
                                     c.v[0] = new int[0]; int[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   446
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   447
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   448
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   449
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   450
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   451
                c.v = new int[0][0]; Object[] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   452
                c.v = new int[0][0]; Object[] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   453
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   454
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   455
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   456
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   457
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   458
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   459
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   460
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   461
    static class ObjectArrayLowerDim2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   462
        public @Stable Object[][] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   463
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   464
        public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   465
        public static int get() { return ((int[][][])c.v)[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   466
        public static int[] get1() { return (int[])(c.v[0][0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   467
        public static int[][] get2() { return (int[][])(c.v[0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   468
        public static Object[][] get3() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   469
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   470
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   471
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   472
                c.v = new int[1][1][1]; ((int[][][])c.v)[0][0][0] = 1; int val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   473
                                        ((int[][][])c.v)[0][0][0] = 2; int val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   474
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   475
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   476
                assertEquals(val2, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   477
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   478
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   479
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   480
                c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   481
                                        c.v[0][0] = new int[0]; int[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   482
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   483
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   484
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   485
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   486
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   487
                c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   488
                                        c.v[0] = new int[0][0]; int[][] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   489
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   490
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   491
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   492
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   493
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   494
                c.v = new int[0][0][0]; Object[][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   495
                c.v = new int[0][0][0]; Object[][] val2 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   496
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   497
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   498
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   499
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   500
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   501
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   502
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   503
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   504
    static class NestedStableField {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   505
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   506
            public @Stable int a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   507
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   508
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   509
        public @Stable A v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   510
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   511
        public static final NestedStableField c = new NestedStableField();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   512
        public static A get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   513
        public static int get1() { return get().a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   514
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   515
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   516
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   517
                c.v = new A(); c.v.a = 1; A val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   518
                               c.v.a = 2; A val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   519
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   520
                assertEquals(val1.a, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   521
                assertEquals(val2.a, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   522
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   523
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   524
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   525
                c.v = new A(); c.v.a = 1; int val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   526
                               c.v.a = 2; int val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   527
                c.v = new A(); c.v.a = 3; int val3 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   528
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   529
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   530
                assertEquals(val2, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   531
                assertEquals(val3, (isStableEnabled ? 1 : 3));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   532
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   533
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   534
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   535
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   536
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   537
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   538
    static class NestedStableField1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   539
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   540
            public @Stable int a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   541
            public @Stable A next;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   542
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   543
        public @Stable A v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   544
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   545
        public static final NestedStableField1 c = new NestedStableField1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   546
        public static A get() { return c.v.next.next.next.next.next.next.next; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   547
        public static int get1() { return get().a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   548
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   549
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   550
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   551
                c.v = new A(); c.v.next = new A();   c.v.next.next  = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   552
                               c.v.a = 1; c.v.next.a = 1; A val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   553
                               c.v.a = 2; c.v.next.a = 2; A val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   554
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   555
                assertEquals(val1.a, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   556
                assertEquals(val2.a, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   557
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   558
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   559
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   560
                c.v = new A(); c.v.next = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   561
                               c.v.a = 1; int val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   562
                               c.v.a = 2; int val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   563
                c.v = new A(); c.v.next = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   564
                               c.v.a = 3; int val3 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   565
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   566
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   567
                assertEquals(val2, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   568
                assertEquals(val3, (isStableEnabled ? 1 : 3));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   569
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   570
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   571
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   572
   /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   573
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   574
    static class NestedStableField2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   575
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   576
            public @Stable int a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   577
            public @Stable A left;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   578
            public         A right;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   579
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   580
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   581
        public @Stable A v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   582
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   583
        public static final NestedStableField2 c = new NestedStableField2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   584
        public static int get() { return c.v.left.left.left.a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   585
        public static int get1() { return c.v.left.left.right.left.a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   586
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   587
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   588
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   589
                c.v = new A(); c.v.left = c.v.right = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   590
                               c.v.a = 1; int val1 = get(); int val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   591
                               c.v.a = 2; int val3 = get(); int val4 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   592
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   593
                assertEquals(val1, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   594
                assertEquals(val3, (isStableEnabled ? 1 : 2));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   595
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   596
                assertEquals(val2, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   597
                assertEquals(val4, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   598
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   599
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   600
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   601
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   602
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   603
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   604
    static class NestedStableField3 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   605
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   606
            public @Stable int a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   607
            public @Stable A[] left;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   608
            public         A[] right;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   609
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   610
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   611
        public @Stable A[] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   612
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   613
        public static final NestedStableField3 c = new NestedStableField3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   614
        public static int get() { return c.v[0].left[1].left[0].left[1].a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   615
        public static int get1() { return c.v[1].left[0].left[1].right[0].left[1].a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   616
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   617
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   618
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   619
                A elem = new A();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   620
                c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   621
                               elem.a = 1; int val1 = get(); int val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   622
                               elem.a = 2; int val3 = get(); int val4 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   623
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   624
                assertEquals(val1, 1);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   625
                assertEquals(val3, (isServerWithStable ? 1 : 2));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   626
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   627
                assertEquals(val2, 1);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   628
                assertEquals(val4, 2);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   629
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   630
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   631
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   632
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   633
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   634
    // Auxiliary methods
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   635
    static void assertEquals(int i, int j) { if (i != j)  throw new AssertionError(i + " != " + j); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   636
    static void assertTrue(boolean b) { if (!b)  throw new AssertionError(); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   637
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   638
    static boolean failed = false;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   639
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   640
    public static void run(Class<?> test) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   641
        Throwable ex = null;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   642
        System.out.print(test.getName()+": ");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   643
        try {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   644
            test.getMethod("test").invoke(null);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   645
        } catch (InvocationTargetException e) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   646
            ex = e.getCause();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   647
        } catch (Throwable e) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   648
            ex = e;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   649
        } finally {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   650
            if (ex == null) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   651
                System.out.println("PASSED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   652
            } else {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   653
                failed = true;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   654
                System.out.println("FAILED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   655
                ex.printStackTrace(System.out);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   656
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   657
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   658
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   659
}