Path: blob/master/test/hotspot/jtreg/gc/shenandoah/TestSieveObjects.java
40942 views
/*1* Copyright (c) 2017, 2018, 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*22*/2324/*25* @test TestSieveObjects26* @summary Acceptance tests: collector can deal with retained objects27* @key randomness28* @requires vm.gc.Shenandoah29* @library /test/lib30*31* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions32* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive33* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify34* TestSieveObjects35*36* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions37* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive38* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify39* TestSieveObjects40*41* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions42* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive43* -XX:+ShenandoahDegeneratedGC44* TestSieveObjects45*46* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions47* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive48* -XX:-ShenandoahDegeneratedGC49* TestSieveObjects50*/5152/*53* @test TestSieveObjects54* @summary Acceptance tests: collector can deal with retained objects55* @key randomness56* @requires vm.gc.Shenandoah57* @library /test/lib58*59* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions60* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive61* -XX:+ShenandoahOOMDuringEvacALot62* TestSieveObjects63*64* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions65* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive66* -XX:+ShenandoahAllocFailureALot67* TestSieveObjects68*69* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions70* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive71* TestSieveObjects72*/7374/*75* @test TestSieveObjects76* @summary Acceptance tests: collector can deal with retained objects77* @key randomness78* @requires vm.gc.Shenandoah79* @library /test/lib80*81* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions82* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive83* -XX:+ShenandoahVerify84* TestSieveObjects85*86* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions87* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive88* TestSieveObjects89*90*/9192/*93* @test TestSieveObjects94* @summary Acceptance tests: collector can deal with retained objects95* @key randomness96* @requires vm.gc.Shenandoah97* @library /test/lib98*99* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions100* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static101* TestSieveObjects102*/103104/*105* @test TestSieveObjects106* @summary Acceptance tests: collector can deal with retained objects107* @key randomness108* @requires vm.gc.Shenandoah109* @library /test/lib110*111* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions112* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact113* TestSieveObjects114*/115116/*117* @test TestSieveObjects118* @summary Acceptance tests: collector can deal with retained objects119* @key randomness120* @requires vm.gc.Shenandoah121* @library /test/lib122*123* @run main/othervm/timeout=240 -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions124* -XX:+UseShenandoahGC125* -XX:-UseTLAB -XX:+ShenandoahVerify126* TestSieveObjects127*/128129/*130* @test TestSieveObjects131* @summary Acceptance tests: collector can deal with retained objects132* @key randomness133* @requires vm.gc.Shenandoah134* @library /test/lib135*136* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions137* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive138* -XX:+ShenandoahOOMDuringEvacALot139* TestSieveObjects140*141* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions142* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive143* -XX:+ShenandoahAllocFailureALot144* TestSieveObjects145*146* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions147* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive148* TestSieveObjects149*/150151/*152* @test TestSieveObjects153* @summary Acceptance tests: collector can deal with retained objects154* @key randomness155* @requires vm.gc.Shenandoah156* @library /test/lib157*158* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions159* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu160* -XX:+ShenandoahVerify161* TestSieveObjects162*163* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions164* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu165* TestSieveObjects166*/167168import java.util.Random;169import jdk.test.lib.Utils;170171public class TestSieveObjects {172173static final int COUNT = 100_000_000;174static final int WINDOW = 1_000_000;175static final int PAYLOAD = 100;176177static final MyObject[] arr = new MyObject[WINDOW];178179public static void main(String[] args) throws Exception {180int rIdx = 0;181Random rng = Utils.getRandomInstance();182for (int c = 0; c < COUNT; c++) {183MyObject v = arr[rIdx];184if (v != null) {185if (v.x != rIdx) {186throw new IllegalStateException("Illegal value at index " + rIdx + ": " + v.x);187}188if (rng.nextInt(1000) > 100) {189arr[rIdx] = null;190}191} else {192if (rng.nextInt(1000) > 500) {193arr[rIdx] = new MyObject(rIdx);194}195}196rIdx++;197if (rIdx >= WINDOW) {198rIdx = 0;199}200}201}202203public static class MyObject {204public int x;205public byte[] payload;206207public MyObject(int x) {208this.x = x;209this.payload = new byte[PAYLOAD];210}211}212213}214215216