1 /* 2 * Copyright (c) 2020, Red Hat, Inc. All rights reserved. 3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 /* 27 * @test id=passive 28 * @key randomness 29 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 30 * @requires vm.gc.Shenandoah 31 * @library /test/lib 32 * 33 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 34 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 35 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 36 * -XX:+ShenandoahVerify 37 * -XX:+ResizeTLAB 38 * TestResizeTLAB 39 * 40 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 41 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 42 * -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify 43 * -XX:+ShenandoahVerify 44 * -XX:-ResizeTLAB 45 * TestResizeTLAB 46 * 47 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 48 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 49 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 50 * -XX:+ShenandoahVerify 51 * -XX:+ResizeTLAB 52 * TestResizeTLAB 53 * 54 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 55 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive 56 * -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify 57 * -XX:+ShenandoahVerify 58 * -XX:-ResizeTLAB 59 * TestResizeTLAB 60 */ 61 62 /* 63 * @test id=aggressive 64 * @key randomness 65 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 66 * @requires vm.gc.Shenandoah 67 * @library /test/lib 68 * 69 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 70 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 71 * -XX:+ShenandoahVerify 72 * -XX:+ResizeTLAB 73 * TestResizeTLAB 74 * 75 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 76 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive 77 * -XX:+ShenandoahVerify 78 * -XX:-ResizeTLAB 79 * TestResizeTLAB 80 */ 81 82 /* 83 * @test id=adaptive 84 * @key randomness 85 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 86 * @requires vm.gc.Shenandoah 87 * @library /test/lib 88 * 89 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 90 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 91 * -XX:+ShenandoahVerify 92 * -XX:+ResizeTLAB 93 * TestResizeTLAB 94 * 95 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 96 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive 97 * -XX:+ShenandoahVerify 98 * -XX:-ResizeTLAB 99 * TestResizeTLAB 100 */ 101 102 /* 103 * @test id=generational 104 * @key randomness 105 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 106 * @requires vm.gc.Shenandoah 107 * @library /test/lib 108 * 109 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 110 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 111 * -XX:+ShenandoahVerify 112 * -XX:+ResizeTLAB 113 * TestResizeTLAB 114 * 115 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 116 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive -XX:ShenandoahGCMode=generational 117 * -XX:+ShenandoahVerify 118 * -XX:-ResizeTLAB 119 * TestResizeTLAB 120 */ 121 122 /* 123 * @test id=static 124 * @key randomness 125 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 126 * @requires vm.gc.Shenandoah 127 * @library /test/lib 128 * 129 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 130 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 131 * -XX:+ShenandoahVerify 132 * -XX:+ResizeTLAB 133 * TestResizeTLAB 134 * 135 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 136 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static 137 * -XX:+ShenandoahVerify 138 * -XX:-ResizeTLAB 139 * TestResizeTLAB 140 */ 141 142 /* 143 * @test id=compact 144 * @key randomness 145 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 146 * @requires vm.gc.Shenandoah 147 * @library /test/lib 148 * 149 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 150 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 151 * -XX:+ShenandoahVerify 152 * -XX:+ResizeTLAB 153 * TestResizeTLAB 154 * 155 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 156 * -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact 157 * -XX:+ShenandoahVerify 158 * -XX:-ResizeTLAB 159 * TestResizeTLAB 160 */ 161 162 /* 163 * @test id=iu-aggressive 164 * @key randomness 165 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 166 * @requires vm.gc.Shenandoah 167 * @library /test/lib 168 * 169 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 170 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 171 * -XX:+ShenandoahVerify 172 * -XX:+ResizeTLAB 173 * TestResizeTLAB 174 * 175 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 176 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive 177 * -XX:+ShenandoahVerify 178 * -XX:-ResizeTLAB 179 * TestResizeTLAB 180 */ 181 182 /* 183 * @test id=iu 184 * @key randomness 185 * @summary Test that Shenandoah is able to work with(out) resizeable TLABs 186 * @requires vm.gc.Shenandoah 187 * @library /test/lib 188 * 189 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 190 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 191 * -XX:+ShenandoahVerify 192 * -XX:+ResizeTLAB 193 * TestResizeTLAB 194 * 195 * @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions 196 * -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu 197 * -XX:+ShenandoahVerify 198 * -XX:-ResizeTLAB 199 * TestResizeTLAB 200 */ 201 202 import java.util.Random; 203 import jdk.test.lib.Utils; 204 205 public class TestResizeTLAB { 206 207 static final long TARGET_MB = Long.getLong("target", 10_000); // 10 Gb allocation 208 209 static volatile Object sink; 210 211 public static void main(String[] args) throws Exception { 212 final int min = 0; 213 final int max = 384 * 1024; 214 long count = TARGET_MB * 1024 * 1024 / (16 + 4 * (min + (max - min) / 2)); 215 216 Random r = Utils.getRandomInstance(); 217 for (long c = 0; c < count; c++) { 218 sink = new int[min + r.nextInt(max - min)]; 219 } 220 } 221 222 }