Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/contended/OopMaps.java
32284 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.BufferedReader;24import java.io.InputStreamReader;25import java.lang.Class;26import java.lang.String;27import java.lang.System;28import java.lang.management.ManagementFactory;29import java.lang.management.RuntimeMXBean;30import java.util.ArrayList;31import java.util.List;32import java.util.concurrent.CyclicBarrier;33import java.util.regex.Matcher;34import java.util.regex.Pattern;35import java.lang.reflect.Field;36import java.lang.reflect.Modifier;37import sun.misc.Unsafe;38import sun.misc.Contended;3940/*41* @test42* @bug 801527043* @bug 801549344* @summary \@Contended: fix multiple issues in the layout code45*46* @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMaps47*/48public class OopMaps {4950public static final int COUNT = 10000;5152public static void main(String[] args) throws Exception {53Object o01 = new Object();54Object o02 = new Object();55Object o03 = new Object();56Object o04 = new Object();57Object o05 = new Object();58Object o06 = new Object();59Object o07 = new Object();60Object o08 = new Object();61Object o09 = new Object();62Object o10 = new Object();63Object o11 = new Object();64Object o12 = new Object();65Object o13 = new Object();66Object o14 = new Object();6768R1[] rs = new R1[COUNT];6970for (int i = 0; i < COUNT; i++) {71R1 r1 = new R1();72r1.o01 = o01;73r1.o02 = o02;74r1.o03 = o03;75r1.o04 = o04;76r1.o05 = o05;77r1.o06 = o06;78r1.o07 = o07;79r1.o08 = o08;80r1.o09 = o09;81r1.o10 = o10;82r1.o11 = o11;83r1.o12 = o12;84r1.o13 = o13;85r1.o14 = o14;86r1.i1 = 1;87r1.i2 = 2;88r1.i3 = 3;89r1.i4 = 4;90rs[i] = r1;91}9293System.gc();9495for (int i = 0; i < COUNT; i++) {96R1 r1 = rs[i];97if (r1.o01 != o01) throw new Error("Test Error: o01");98if (r1.o02 != o02) throw new Error("Test Error: o02");99if (r1.o03 != o03) throw new Error("Test Error: o03");100if (r1.o04 != o04) throw new Error("Test Error: o04");101if (r1.o05 != o05) throw new Error("Test Error: o05");102if (r1.o06 != o06) throw new Error("Test Error: o06");103if (r1.o07 != o07) throw new Error("Test Error: o07");104if (r1.o08 != o08) throw new Error("Test Error: o08");105if (r1.o09 != o09) throw new Error("Test Error: o09");106if (r1.o10 != o10) throw new Error("Test Error: o10");107if (r1.o11 != o11) throw new Error("Test Error: o11");108if (r1.o12 != o12) throw new Error("Test Error: o12");109if (r1.o13 != o13) throw new Error("Test Error: o13");110if (r1.o14 != o14) throw new Error("Test Error: o14");111if (r1.i1 != 1) throw new Error("Test Error: i1");112if (r1.i2 != 2) throw new Error("Test Error: i2");113if (r1.i3 != 3) throw new Error("Test Error: i3");114if (r1.i4 != 4) throw new Error("Test Error: i4");115}116}117118public static class R0 {119int i1;120int i2;121122Object o01;123Object o02;124125@Contended126Object o03;127128@Contended129Object o04;130131@Contended132Object o05;133134@Contended135Object o06;136137@Contended138Object o07;139}140141public static class R1 extends R0 {142int i3;143int i4;144145Object o08;146Object o09;147148@Contended149Object o10;150151@Contended152Object o11;153154@Contended155Object o12;156157@Contended158Object o13;159160@Contended161Object o14;162}163164}165166167168