Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/compiler/TestClone.java
32285 views
/*1* Copyright (c) 2019, Red Hat, Inc. 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*/2223/*24* @test TestClone25* @summary Test clone barriers work correctly26* @key gc27*28* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g29* -XX:+UseShenandoahGC30* TestClone31* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g32* -XX:+UseShenandoahGC33* -Xint34* TestClone35* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g36* -XX:+UseShenandoahGC37* -XX:-TieredCompilation38* TestClone39* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g40* -XX:+UseShenandoahGC41* -XX:TieredStopAtLevel=142* TestClone43* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g44* -XX:+UseShenandoahGC45* -XX:TieredStopAtLevel=446* TestClone47*/4849/*50* @test TestClone51* @summary Test clone barriers work correctly52* @key gc53*54* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g55* -XX:+UseShenandoahGC56* -XX:+ShenandoahVerify57* TestClone58* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g59* -XX:+UseShenandoahGC60* -XX:+ShenandoahVerify61* -Xint62* TestClone63* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g64* -XX:+UseShenandoahGC65* -XX:+ShenandoahVerify66* -XX:-TieredCompilation67* TestClone68* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g69* -XX:+UseShenandoahGC70* -XX:+ShenandoahVerify71* -XX:TieredStopAtLevel=172* TestClone73* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g74* -XX:+UseShenandoahGC75* -XX:+ShenandoahVerify76* -XX:TieredStopAtLevel=477* TestClone78*/7980/*81* @test TestClone82* @summary Test clone barriers work correctly83* @key gc84*85* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g86* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive87* TestClone88* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g89* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive90* -Xint91* TestClone92* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g93* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive94* -XX:-TieredCompilation95* TestClone96* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g97* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive98* -XX:TieredStopAtLevel=199* TestClone100* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g101* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive102* -XX:TieredStopAtLevel=4103* TestClone104*/105106/*107* @test TestClone108* @summary Test clone barriers work correctly109* @key gc110* @requires (vm.bits == "64")111*112* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g113* -XX:-UseCompressedOops114* -XX:+UseShenandoahGC115* TestClone116* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g117* -XX:-UseCompressedOops118* -XX:+UseShenandoahGC119* -Xint120* TestClone121* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g122* -XX:-UseCompressedOops123* -XX:+UseShenandoahGC124* -XX:-TieredCompilation125* TestClone126* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g127* -XX:-UseCompressedOops128* -XX:+UseShenandoahGC129* -XX:TieredStopAtLevel=1130* TestClone131* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g132* -XX:-UseCompressedOops133* -XX:+UseShenandoahGC134* -XX:TieredStopAtLevel=4135* TestClone136*/137138/*139* @test TestClone140* @summary Test clone barriers work correctly141* @key gc142* @requires (vm.bits == "64")143*144* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g145* -XX:-UseCompressedOops146* -XX:+UseShenandoahGC147* -XX:+ShenandoahVerify148* TestClone149* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g150* -XX:-UseCompressedOops151* -XX:+UseShenandoahGC152* -XX:+ShenandoahVerify153* -Xint154* TestClone155* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g156* -XX:-UseCompressedOops157* -XX:+UseShenandoahGC158* -XX:+ShenandoahVerify159* -XX:-TieredCompilation160* TestClone161* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g162* -XX:-UseCompressedOops163* -XX:+UseShenandoahGC164* -XX:+ShenandoahVerify165* -XX:TieredStopAtLevel=1166* TestClone167* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g168* -XX:-UseCompressedOops169* -XX:+UseShenandoahGC170* -XX:+ShenandoahVerify171* -XX:TieredStopAtLevel=4172* TestClone173*/174175/*176* @test TestClone177* @summary Test clone barriers work correctly178* @key gc179* @requires (vm.bits == "64")180*181* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g182* -XX:-UseCompressedOops183* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive184* TestClone185* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g186* -XX:-UseCompressedOops187* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive188* -Xint189* TestClone190* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g191* -XX:-UseCompressedOops192* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive193* -XX:-TieredCompilation194* TestClone195* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g196* -XX:-UseCompressedOops197* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive198* -XX:TieredStopAtLevel=1199* TestClone200* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g201* -XX:-UseCompressedOops202* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive203* -XX:TieredStopAtLevel=4204* TestClone205*/206207208public class TestClone {209210public static void main(String[] args) throws Exception {211for (int i = 0; i < 10000; i++) {212Object[] src = new Object[i];213for (int c = 0; c < src.length; c++) {214src[c] = new Object();215}216testWith(src);217}218}219220static void testWith(Object[] src) {221Object[] dst = src.clone();222int srcLen = src.length;223int dstLen = dst.length;224if (srcLen != dstLen) {225throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);226}227for (int c = 0; c < src.length; c++) {228Object s = src[c];229Object d = dst[c];230if (s != d) {231throw new IllegalStateException("Elements do not match at " + c + ": " + s + " vs " + d);232}233}234}235}236237238