hotspot/test/compiler/stable/TestStableDouble.java
author thartmann
Fri, 12 Dec 2014 09:37:38 +0100
changeset 28190 5a6b07edeb21
parent 26916 8a1deee4f9b4
child 33730 30e064828045
permissions -rw-r--r--
8066433: Move Whitebox test library to top level repository Summary: Moved Whitebox test library to top level repository. Reviewed-by: iignatyev, sla, mr
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 TestStableDouble
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    28
 * @summary tests on stable fields and arrays
28190
5a6b07edeb21 8066433: Move Whitebox test library to top level repository
thartmann
parents: 26916
diff changeset
    29
 * @library /testlibrary /../../test/lib
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    30
 * @build TestStableDouble 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/TestStableDouble
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    35
 *           java/lang/invoke/TestStableDouble$DoubleStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    36
 *           java/lang/invoke/TestStableDouble$StaticDoubleStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    37
 *           java/lang/invoke/TestStableDouble$VolatileDoubleStable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    38
 *           java/lang/invoke/TestStableDouble$DoubleArrayDim1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    39
 *           java/lang/invoke/TestStableDouble$DoubleArrayDim2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    40
 *           java/lang/invoke/TestStableDouble$DoubleArrayDim3
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    41
 *           java/lang/invoke/TestStableDouble$DoubleArrayDim4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    42
 *           java/lang/invoke/TestStableDouble$ObjectArrayLowerDim0
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    43
 *           java/lang/invoke/TestStableDouble$ObjectArrayLowerDim1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    44
 *           java/lang/invoke/TestStableDouble$NestedStableField
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    45
 *           java/lang/invoke/TestStableDouble$NestedStableField$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    46
 *           java/lang/invoke/TestStableDouble$NestedStableField1
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    47
 *           java/lang/invoke/TestStableDouble$NestedStableField1$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    48
 *           java/lang/invoke/TestStableDouble$NestedStableField2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    49
 *           java/lang/invoke/TestStableDouble$NestedStableField2$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    50
 *           java/lang/invoke/TestStableDouble$NestedStableField3
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    51
 *           java/lang/invoke/TestStableDouble$NestedStableField3$A
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    52
 *           java/lang/invoke/TestStableDouble$DefaultValue
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    53
 *           java/lang/invoke/TestStableDouble$DefaultStaticValue
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    54
 *           java/lang/invoke/TestStableDouble$ObjectArrayLowerDim2
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    55
 *
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    56
 * @run main/othervm -Xbootclasspath/a:.
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    57
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    58
 *                   -XX:-TieredCompilation
25641
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.TestStableDouble
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    62
 * @run main/othervm -Xbootclasspath/a:.
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    63
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    64
 *                   -XX:-TieredCompilation
25641
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.TestStableDouble
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    68
 *
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    69
 * @run main/othervm -Xbootclasspath/a:.
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    70
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    71
 *                   -XX:+TieredCompilation -XX:TieredStopAtLevel=1
25641
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.TestStableDouble
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    75
 * @run main/othervm -Xbootclasspath/a:.
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    76
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp
26916
8a1deee4f9b4 8038098: [TESTBUG] remove explicit set build flavor from hotspot/test/compiler/* tests
vlivanov
parents: 25641
diff changeset
    77
 *                   -XX:+TieredCompilation -XX:TieredStopAtLevel=1
25641
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.TestStableDouble
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
 */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    83
package java.lang.invoke;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    84
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    85
import java.lang.reflect.InvocationTargetException;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    86
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    87
public class TestStableDouble {
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    88
    static final boolean isStableEnabled    = StableConfiguration.isStableEnabled;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    89
    static final boolean isServerWithStable = StableConfiguration.isServerWithStable;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    90
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    91
    public static void main(String[] args) throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    92
        run(DefaultValue.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    93
        run(DoubleStable.class);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
    94
        run(DefaultStaticValue.class);
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    95
        run(StaticDoubleStable.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    96
        run(VolatileDoubleStable.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    97
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    98
        // @Stable arrays: Dim 1-4
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
    99
        run(DoubleArrayDim1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   100
        run(DoubleArrayDim2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   101
        run(DoubleArrayDim3.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   102
        run(DoubleArrayDim4.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   103
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   104
        // @Stable Object field: dynamic arrays
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   105
        run(ObjectArrayLowerDim0.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   106
        run(ObjectArrayLowerDim1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   107
        run(ObjectArrayLowerDim2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   108
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   109
        // Nested @Stable fields
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   110
        run(NestedStableField.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   111
        run(NestedStableField1.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   112
        run(NestedStableField2.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   113
        run(NestedStableField3.class);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   114
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   115
        if (failed) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   116
            throw new Error("TEST FAILED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   117
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   118
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   119
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   122
    static class DefaultValue {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   123
        public @Stable double v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   124
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   125
        public static final DefaultValue c = new DefaultValue();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   126
        public static double get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   127
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   128
                       double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   129
            c.v = 1.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   130
            assertEquals(val1, 0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   131
            assertEquals(val2, 1.0);
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   135
    /* ==================================================== */
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
    static class DoubleStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   138
        public @Stable double v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   139
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   140
        public static final DoubleStable c = new DoubleStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   141
        public static double get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   142
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   143
            c.v = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   144
            c.v = Double.MAX_VALUE; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   145
            assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   146
            assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   150
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   151
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   152
    static class DefaultStaticValue {
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   153
        public static @Stable double v;
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   154
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   155
        public static final DefaultStaticValue c = new DefaultStaticValue();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   156
        public static double get() { return c.v; }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   157
        public static void test() throws Exception {
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   158
                       double val1 = get();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   159
            c.v = 1.0; double val2 = get();
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   160
            assertEquals(val1, 0);
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   161
            assertEquals(val2, 1.0);
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   162
        }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   163
    }
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   164
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   165
    /* ==================================================== */
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   166
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   167
    static class StaticDoubleStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   168
        public static @Stable double v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   169
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   170
        public static final StaticDoubleStable c = new StaticDoubleStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   171
        public static double get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   172
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   173
            c.v = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   174
            c.v = Double.MAX_VALUE; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   175
            assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   176
            assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   177
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   178
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   179
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   180
    /* ==================================================== */
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
    static class VolatileDoubleStable {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   183
        public @Stable double v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   184
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   185
        public static final VolatileDoubleStable c = new VolatileDoubleStable();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   186
        public static double get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   187
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   188
            c.v = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   189
            c.v = Double.MAX_VALUE; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   190
            assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   191
            assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   195
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   196
    // @Stable array == field && all components are stable
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   197
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   198
    static class DoubleArrayDim1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   199
        public @Stable double[] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   200
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   201
        public static final DoubleArrayDim1 c = new DoubleArrayDim1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   202
        public static double get() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   203
        public static double get1() { return c.v[10]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   204
        public static double[] get2() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   205
        public static void test() throws Exception {
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
                c.v = new double[1]; c.v[0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   208
                                     c.v[0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   209
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   210
                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   211
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   212
                c.v = new double[1]; c.v[0] = 3.0; double val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   213
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   214
                                                    : 3.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   215
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   216
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   217
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   218
                c.v = new double[20]; c.v[10] = 1.0; double val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   219
                                      c.v[10] = 2.0; double val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   220
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   221
                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   222
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   223
                c.v = new double[20]; c.v[10] = 3.0; double val3 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   224
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   225
                                                    : 3.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   226
            }
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
                c.v = new double[1]; double[] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   230
                c.v = new double[1]; double[] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   231
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   232
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   233
        }
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   236
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   237
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   238
    static class DoubleArrayDim2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   239
        public @Stable double[][] v;
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
        public static final DoubleArrayDim2 c = new DoubleArrayDim2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   242
        public static double get() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   243
        public static double[] get1() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   244
        public static double[][] get2() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   245
        public static void test() throws Exception {
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
                c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   248
                                        c.v[0][0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   249
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   250
                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   251
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   252
                c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   253
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   254
                                                    : 3.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   255
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   256
                c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   257
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   258
                                                    : 4.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   259
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   260
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   261
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   262
                c.v = new double[1][1]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   263
                c.v[0] = new double[1]; double[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   264
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   265
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   266
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 = new double[1][1]; double[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   269
                c.v = new double[1][1]; double[][] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   270
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   275
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   276
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   277
    static class DoubleArrayDim3 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   278
        public @Stable double[][][] v;
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
        public static final DoubleArrayDim3 c = new DoubleArrayDim3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   281
        public static double get() { return c.v[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   282
        public static double[] get1() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   283
        public static double[][] get2() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   284
        public static double[][][] get3() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   285
        public static void test() throws Exception {
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
                c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   288
                                           c.v[0][0][0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   289
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   290
                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
23192
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
                c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   293
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   294
                                                    : 3.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   295
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   296
                c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   297
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   298
                                                    : 4.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   299
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   300
                c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   301
                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   302
                                                    : 5.0));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   305
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   306
                c.v = new double[1][1][1]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   307
                c.v[0][0] = new double[1]; double[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   308
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   309
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   310
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 = new double[1][1][1]; double[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   313
                c.v[0] = new double[1][1]; double[][] val2 = get2();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   314
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
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 double[1][1][1]; double[][][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   319
                c.v = new double[1][1][1]; double[][][] val2 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   320
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   325
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   326
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   327
    static class DoubleArrayDim4 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   328
        public @Stable double[][][][] v;
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
        public static final DoubleArrayDim4 c = new DoubleArrayDim4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   331
        public static double get() { return c.v[0][0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   332
        public static double[] get1() { return c.v[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   333
        public static double[][] get2() { return c.v[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   334
        public static double[][][] get3() { return c.v[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   335
        public static double[][][][] get4() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   336
        public static void test() throws Exception {
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
                c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   339
                                              c.v[0][0][0][0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   340
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   341
                assertEquals(val2, (isServerWithStable ? 1.0 : 2.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   342
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   343
                c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   344
                assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   345
                                                    : 3.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   346
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   347
                c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   348
                assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   349
                                                    : 4.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   350
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   351
                c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   352
                assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   353
                                                    : 5.0));
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[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   356
                assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0)
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   357
                                                    : 6.0));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   360
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   361
                c.v = new double[1][1][1][1]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   362
                c.v[0][0][0] = new double[1]; double[] val2 = get1();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   363
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   364
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   365
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 = new double[1][1][1][1]; double[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   368
                c.v[0][0] = new double[1][1]; double[][] val2 = get2();
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   369
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
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 double[1][1][1][1]; double[][][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   374
                c.v[0] = new double[1][1][1]; double[][][] val2 = get3();
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 double[1][1][1][1]; double[][][][] val1 = get4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   380
                c.v = new double[1][1][1][1]; double[][][][] val2 = get4();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   381
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   386
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   387
    // Dynamic Dim is higher than static
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   388
    static class ObjectArrayLowerDim0 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   389
        public @Stable Object v;
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
        public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   392
        public static double get() { return ((double[])c.v)[0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   393
        public static double[] get1() { return (double[])c.v; }
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
        public static void test() throws Exception {
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
                c.v = new double[1]; ((double[])c.v)[0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   398
                                     ((double[])c.v)[0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   399
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   400
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   401
                assertEquals(val2, 2.0);
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   404
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   405
                c.v = new double[1]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   406
                c.v = new double[1]; double[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   407
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   410
    }
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
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   413
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   414
    static class ObjectArrayLowerDim1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   415
        public @Stable Object[] v;
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
        public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   418
        public static double get() { return ((double[][])c.v)[0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   419
        public static double[] get1() { return (double[])(c.v[0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   420
        public static Object[] get2() { return c.v; }
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
        public static void test() throws Exception {
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
                c.v = new double[1][1]; ((double[][])c.v)[0][0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   425
                                        ((double[][])c.v)[0][0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   426
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   427
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   428
                assertEquals(val2, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   429
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   430
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   431
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   432
                c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   433
                                        c.v[0] = new double[0]; double[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   434
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   435
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   436
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   437
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
                c.v = new double[0][0]; Object[] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   440
                c.v = new double[0][0]; Object[] val2 = get2();
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
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   445
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   446
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   447
    /* ==================================================== */
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
    static class ObjectArrayLowerDim2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   450
        public @Stable Object[][] v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   451
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   452
        public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   453
        public static double get() { return ((double[][][])c.v)[0][0][0]; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   454
        public static double[] get1() { return (double[])(c.v[0][0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   455
        public static double[][] get2() { return (double[][])(c.v[0]); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   456
        public static Object[][] get3() { return c.v; }
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
        public static void test() throws Exception {
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
                c.v = new double[1][1][1]; ((double[][][])c.v)[0][0][0] = 1.0; double val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   461
                                           ((double[][][])c.v)[0][0][0] = 2.0; double val2 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   462
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   463
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   464
                assertEquals(val2, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   465
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   466
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   467
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   468
                c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   469
                                           c.v[0][0] = new double[0]; double[] val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   470
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   471
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   472
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   473
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
                c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   476
                                           c.v[0] = new double[0][0]; double[][] val2 = get2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   477
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   478
                assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2)));
23192
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   481
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   482
                c.v = new double[0][0][0]; Object[][] val1 = get3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   483
                c.v = new double[0][0][0]; Object[][] val2 = get3();
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
                assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2)));
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
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   488
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   489
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   490
    /* ==================================================== */
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
    static class NestedStableField {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   493
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   494
            public @Stable double a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   495
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
        public @Stable A v;
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
        public static final NestedStableField c = new NestedStableField();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   500
        public static A get() { return c.v; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   501
        public static double get1() { return get().a; }
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
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   504
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   505
                c.v = new A(); c.v.a = 1.0; A val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   506
                               c.v.a = 2.0; A val2 = get();
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
                assertEquals(val1.a, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   509
                assertEquals(val2.a, 2.0);
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   512
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   513
                c.v = new A(); c.v.a = 1.0; double val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   514
                               c.v.a = 2.0; double val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   515
                c.v = new A(); c.v.a = 3.0; double val3 = get1();
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
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   518
                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   519
                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   520
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   521
        }
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   526
    static class NestedStableField1 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   527
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   528
            public @Stable double a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   529
            public @Stable A next;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   530
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   531
        public @Stable A v;
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
        public static final NestedStableField1 c = new NestedStableField1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   534
        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
   535
        public static double get1() { return get().a; }
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
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   538
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   539
                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
   540
                               c.v.a = 1.0; c.v.next.a = 1.0; A val1 = get();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   541
                               c.v.a = 2.0; c.v.next.a = 2.0; A val2 = get();
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
                assertEquals(val1.a, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   544
                assertEquals(val2.a, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   545
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   546
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   547
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   548
                c.v = new A(); c.v.next = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   549
                               c.v.a = 1.0; double val1 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   550
                               c.v.a = 2.0; double val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   551
                c.v = new A(); c.v.next = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   552
                               c.v.a = 3.0; double val3 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   553
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   554
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   555
                assertEquals(val2, (isStableEnabled ? 1.0 : 2.0));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   556
                assertEquals(val3, (isStableEnabled ? 1.0 : 3.0));
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
   /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   561
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   562
    static class NestedStableField2 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   563
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   564
            public @Stable double a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   565
            public @Stable A left;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   566
            public         A right;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   567
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   568
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   569
        public @Stable A v;
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
        public static final NestedStableField2 c = new NestedStableField2();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   572
        public static double get() { return c.v.left.left.left.a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   573
        public static double get1() { return c.v.left.left.right.left.a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   574
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   575
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   576
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   577
                c.v = new A(); c.v.left = c.v.right = c.v;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   578
                               c.v.a = 1.0; double val1 = get(); double val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   579
                               c.v.a = 2.0; double val3 = get(); double val4 = get1();
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
                assertEquals(val1, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   582
                assertEquals(val3, (isStableEnabled ? 1.0 : 2.0));
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   583
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   584
                assertEquals(val2, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   585
                assertEquals(val4, 2.0);
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
        }
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
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   590
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   591
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   592
    static class NestedStableField3 {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   593
        static class A {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   594
            public @Stable double a;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   595
            public @Stable A[] left;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   596
            public         A[] right;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   597
        }
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
        public @Stable A[] v;
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
        public static final NestedStableField3 c = new NestedStableField3();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   602
        public static double get() { return c.v[0].left[1].left[0].left[1].a; }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   603
        public static double 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
   604
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   605
        public static void test() throws Exception {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   606
            {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   607
                A elem = new A();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   608
                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
   609
                               elem.a = 1.0; double val1 = get(); double val2 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   610
                               elem.a = 2.0; double val3 = get(); double val4 = get1();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   611
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   612
                assertEquals(val1, 1.0);
25641
d99065e4572b 8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents: 23192
diff changeset
   613
                assertEquals(val3, (isServerWithStable ? 1.0 : 2.0));
23192
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   614
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   615
                assertEquals(val2, 1.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   616
                assertEquals(val4, 2.0);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   617
            }
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
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   620
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   621
    /* ==================================================== */
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   622
    // Auxiliary methods
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   623
    static void assertEquals(double i, double j) { if (i != j)  throw new AssertionError(i + " != " + j); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   624
    static void assertTrue(boolean b) { if (!b)  throw new AssertionError(); }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   625
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   626
    static boolean failed = false;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   627
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   628
    public static void run(Class<?> test) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   629
        Throwable ex = null;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   630
        System.out.print(test.getName()+": ");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   631
        try {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   632
            test.getMethod("test").invoke(null);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   633
        } catch (InvocationTargetException e) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   634
            ex = e.getCause();
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   635
        } catch (Throwable e) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   636
            ex = e;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   637
        } finally {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   638
            if (ex == null) {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   639
                System.out.println("PASSED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   640
            } else {
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   641
                failed = true;
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   642
                System.out.println("FAILED");
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   643
                ex.printStackTrace(System.out);
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   644
            }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   645
        }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   646
    }
f6a1c8866065 8035828: Turn on @Stable support in VM
vlivanov
parents:
diff changeset
   647
}