hotspot/test/runtime/contended/OopMapsSameGroup.java
author fzhinkin
Tue, 20 Jan 2015 11:26:20 +0300
changeset 28722 51fe60d9e30c
parent 27616 6a63de6a8276
child 29678 dd2f3932c21e
permissions -rw-r--r--
8069126: compiler/rtm/locking/TestRTMTotalCountIncrRate.java nightly failure Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27616
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     1
/*
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     4
 *
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     8
 *
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    13
 * accompanied this code).
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    14
 *
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    18
 *
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    21
 * questions.
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    22
 */
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    23
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    24
import java.io.BufferedReader;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    25
import java.io.InputStreamReader;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    26
import java.lang.Class;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    27
import java.lang.String;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    28
import java.lang.System;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    29
import java.lang.management.ManagementFactory;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    30
import java.lang.management.RuntimeMXBean;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    31
import java.util.ArrayList;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    32
import java.util.List;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    33
import java.util.concurrent.CyclicBarrier;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    34
import java.util.regex.Matcher;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    35
import java.util.regex.Pattern;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    36
import java.lang.reflect.Field;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    37
import java.lang.reflect.Modifier;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    38
import sun.misc.Unsafe;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    39
import sun.misc.Contended;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    40
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    41
/*
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    42
 * @test
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    43
 * @bug     8015272
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    44
 * @summary \@Contended within the same group to use the same oop map
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    45
 *
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    46
 * @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsSameGroup
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    47
 */
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    48
public class OopMapsSameGroup {
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    49
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    50
    public static final int COUNT = 10000;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    51
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    52
    public static void main(String[] args) throws Exception {
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    53
        Object o01 = new Object();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    54
        Object o02 = new Object();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    55
        Object o03 = new Object();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    56
        Object o04 = new Object();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    57
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    58
        R[] rs = new R[COUNT];
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    59
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    60
        for (int i = 0; i < COUNT; i++) {
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    61
           R r = new R();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    62
           r.o01 = o01;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    63
           r.o02 = o02;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    64
           r.o03 = o03;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    65
           r.o04 = o04;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    66
           rs[i] = r;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    67
        }
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    68
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    69
        System.gc();
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    70
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    71
        for (int i = 0; i < COUNT; i++) {
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    72
           R r = rs[i];
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    73
           if (r.o01 != o01) throw new Error("Test Error: o01");
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    74
           if (r.o02 != o02) throw new Error("Test Error: o02");
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    75
           if (r.o03 != o03) throw new Error("Test Error: o03");
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    76
           if (r.o04 != o04) throw new Error("Test Error: o04");
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    77
        }
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    78
    }
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    79
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    80
    public static class R {
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    81
        @Contended("group1")
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    82
        Object o01;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    83
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    84
        @Contended("group1")
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    85
        Object o02;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    86
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    87
        @Contended("group2")
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    88
        Object o03;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    89
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    90
        @Contended("group2")
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    91
        Object o04;
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    92
    }
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    93
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    94
}
6a63de6a8276 8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff changeset
    95