1 /* 2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 /* 26 * @test TestSieveObjects 27 * @summary Acceptance tests: collector can deal with retained objects 28 * @key randomness 29 * @requires vm.gc.Shenandoah 30 * @library /test/lib 31 * 32 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 33 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 34 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 35 * TestSieveObjects 36 * 37 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 38 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 39 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 40 * TestSieveObjects 41 * 42 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 43 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 44 * -XX:+ShenandoahDegeneratedGC 45 * TestSieveObjects 46 * 47 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 48 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 49 * -XX:-ShenandoahDegeneratedGC 50 * TestSieveObjects 51 */ 52 53 /* 54 * @test TestSieveObjects 55 * @summary Acceptance tests: collector can deal with retained objects 56 * @key randomness 57 * @requires vm.gc.Shenandoah 58 * @library /test/lib 59 * 60 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 61 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 62 * -XX:+ShenandoahOOMDuringEvacALot 63 * TestSieveObjects 64 * 65 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 66 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 67 * -XX:+ShenandoahAllocFailureALot 68 * TestSieveObjects 69 * 70 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 71 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 72 * TestSieveObjects 73 * 74 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 75 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 76 * -XX:+ShenandoahVerify 77 * TestSieveObjects 78 * 79 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 80 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 81 * TestSieveObjects 82 * 83 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 84 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 85 * TestSieveObjects 86 * 87 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 88 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 89 * TestSieveObjects 90 * 91 * @run main/othervm/timeout=240 -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 92 * -XX:+UseShenandoahGC 93 * -XX:-UseTLAB -XX:+ShenandoahVerify 94 * TestSieveObjects 95 */ 96 97 /* 98 * @test TestSieveObjects 99 * @summary Acceptance tests: collector can deal with retained objects 100 * @key randomness 101 * @requires vm.gc.Shenandoah 102 * @library /test/lib 103 * 104 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 105 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 106 * -XX:+ShenandoahOOMDuringEvacALot 107 * TestSieveObjects 108 * 109 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 110 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 111 * -XX:+ShenandoahAllocFailureALot 112 * TestSieveObjects 113 * 114 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 115 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 116 * TestSieveObjects 117 * 118 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 119 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 120 * -XX:+ShenandoahVerify 121 * TestSieveObjects 122 * 123 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 124 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 125 * TestSieveObjects 126 */ 127 128 import java.util.Random; 129 import jdk.test.lib.Utils; 130 131 public class TestSieveObjects { 132 133 static final int COUNT = 100_000_000; 134 static final int WINDOW = 1_000_000; 135 static final int PAYLOAD = 100; 136 137 static final MyObject[] arr = new MyObject[WINDOW]; 138 139 public static void main(String[] args) throws Exception { 140 int rIdx = 0; 141 Random rng = Utils.getRandomInstance(); 142 for (int c = 0; c < COUNT; c++) { 143 MyObject v = arr[rIdx]; 144 if (v != null) { 145 if (v.x != rIdx) { 146 throw new IllegalStateException("Illegal value at index " + rIdx + ": " + v.x); 147 } 148 if (rng.nextInt(1000) > 100) { 149 arr[rIdx] = null; 150 } 151 } else { 152 if (rng.nextInt(1000) > 500) { 153 arr[rIdx] = new MyObject(rIdx); 154 } 155 } 156 rIdx++; 157 if (rIdx >= WINDOW) { 158 rIdx = 0; 159 } 160 } 161 } 162 163 public static class MyObject { 164 public int x; 165 public byte[] payload; 166 167 public MyObject(int x) { 168 this.x = x; 169 this.payload = new byte[PAYLOAD]; 170 } 171 } 172 173 }