Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/TestSieveObjects.java
32284 views
/*1* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223/*24* @test TestSieveObjects25* @summary Acceptance tests: collector can deal with retained objects26* @key gc27*28* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions29* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive30* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify31* TestSieveObjects32*33* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions34* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive35* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify36* TestSieveObjects37*38* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions39* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive40* -XX:+ShenandoahDegeneratedGC41* TestSieveObjects42*43* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions44* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive45* -XX:-ShenandoahDegeneratedGC46* TestSieveObjects47*/4849/*50* @test TestSieveObjects51* @summary Acceptance tests: collector can deal with retained objects52* @key gc53*54* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions55* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive56* -XX:+ShenandoahOOMDuringEvacALot57* TestSieveObjects58*59* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions60* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive61* -XX:+ShenandoahAllocFailureALot62* TestSieveObjects63*64* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions65* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive66* TestSieveObjects67*/6869/*70* @test TestSieveObjects71* @summary Acceptance tests: collector can deal with retained objects72* @key gc73*74* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions75* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive76* -XX:+ShenandoahVerify77* TestSieveObjects78*79* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions80* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive81* TestSieveObjects82*83*/8485/*86* @test TestSieveObjects87* @summary Acceptance tests: collector can deal with retained objects88* @key gc89*90* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions91* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static92* TestSieveObjects93*/9495/*96* @test TestSieveObjects97* @summary Acceptance tests: collector can deal with retained objects98* @key gc99*100* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions101* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact102* TestSieveObjects103*/104105/*106* @test TestSieveObjects107* @summary Acceptance tests: collector can deal with retained objects108* @key gc109*110* @run main/othervm/timeout=240 -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions111* -XX:+UseShenandoahGC112* -XX:-UseTLAB -XX:+ShenandoahVerify113* TestSieveObjects114*/115116/*117* @test TestSieveObjects118* @summary Acceptance tests: collector can deal with retained objects119* @key gc120*121* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions122* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive123* -XX:+ShenandoahOOMDuringEvacALot124* TestSieveObjects125*126* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions127* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive128* -XX:+ShenandoahAllocFailureALot129* TestSieveObjects130*131* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions132* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive133* TestSieveObjects134*/135136/*137* @test TestSieveObjects138* @summary Acceptance tests: collector can deal with retained objects139* @key gc140*141* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions142* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu143* -XX:+ShenandoahVerify144* TestSieveObjects145*146* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions147* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu148* TestSieveObjects149*/150151import java.util.concurrent.ThreadLocalRandom;152153public class TestSieveObjects {154155static final int COUNT = 100_000_000;156static final int WINDOW = 1_000_000;157static final int PAYLOAD = 100;158159static final MyObject[] arr = new MyObject[WINDOW];160161public static void main(String[] args) throws Exception {162int rIdx = 0;163for (int c = 0; c < COUNT; c++) {164MyObject v = arr[rIdx];165if (v != null) {166if (v.x != rIdx) {167throw new IllegalStateException("Illegal value at index " + rIdx + ": " + v.x);168}169if (ThreadLocalRandom.current().nextInt(1000) > 100) {170arr[rIdx] = null;171}172} else {173if (ThreadLocalRandom.current().nextInt(1000) > 500) {174arr[rIdx] = new MyObject(rIdx);175}176}177rIdx++;178if (rIdx >= WINDOW) {179rIdx = 0;180}181}182}183184public static class MyObject {185public int x;186public byte[] payload;187188public MyObject(int x) {189this.x = x;190this.payload = new byte[PAYLOAD];191}192}193194}195196197