< prev index next >

test/hotspot/jtreg/gc/shenandoah/compiler/TestClone.java

Print this page

  1 /*
  2  * Copyright (c) 2019, 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  */

188  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
189  *                   -Xint
190  *                   TestClone
191  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
192  *                   -XX:-UseCompressedOops
193  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
194  *                   -XX:-TieredCompilation
195  *                   TestClone
196  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
197  *                   -XX:-UseCompressedOops
198  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
199  *                   -XX:TieredStopAtLevel=1
200  *                   TestClone
201  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
202  *                   -XX:-UseCompressedOops
203  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
204  *                   -XX:TieredStopAtLevel=4
205  *                   TestClone
206  */
207 


















































































































208 




































209 public class TestClone {
210 
211     public static void main(String[] args) throws Exception {
212         for (int i = 0; i < 10000; i++) {
213             Object[] src = new Object[i];
214             for (int c = 0; c < src.length; c++) {
215                 src[c] = new Object();
216             }
217             testWith(src);
218         }
219     }
220 
221     static void testWith(Object[] src) {
222         Object[] dst = src.clone();
223         int srcLen = src.length;
224         int dstLen = dst.length;
225         if (srcLen != dstLen) {
226             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
227         }
228         for (int c = 0; c < src.length; c++) {

  1 /*
  2  * Copyright (c) 2019, 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  */

189  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
190  *                   -Xint
191  *                   TestClone
192  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
193  *                   -XX:-UseCompressedOops
194  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
195  *                   -XX:-TieredCompilation
196  *                   TestClone
197  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
198  *                   -XX:-UseCompressedOops
199  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
200  *                   -XX:TieredStopAtLevel=1
201  *                   TestClone
202  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
203  *                   -XX:-UseCompressedOops
204  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
205  *                   -XX:TieredStopAtLevel=4
206  *                   TestClone
207  */
208 
209 /*
210  * @test id=generational
211  * @summary Test clone barriers work correctly
212  * @requires vm.gc.Shenandoah
213  *
214  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
215  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
216  *                   TestClone
217  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
218  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
219  *                   -Xint
220  *                   TestClone
221  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
222  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
223  *                   -XX:-TieredCompilation
224  *                   TestClone
225  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
226  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
227  *                   -XX:TieredStopAtLevel=1
228  *                   TestClone
229  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
230  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
231  *                   -XX:TieredStopAtLevel=4
232  *                   TestClone
233  */
234 
235 /*
236  * @test id=generational-small-card-size
237  * @summary Test clone barriers work correctly
238  * @requires vm.gc.Shenandoah
239  *
240  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
241  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
242  *                   TestClone
243  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
244  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
245  *                   -Xint
246  *                   TestClone
247  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
248  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
249  *                   -XX:-TieredCompilation
250  *                   TestClone
251  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
252  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
253  *                   -XX:TieredStopAtLevel=1
254  *                   TestClone
255  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
256  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational -XX:GCCardSizeInBytes=128
257  *                   -XX:TieredStopAtLevel=4
258  *                   TestClone
259  */
260 
261 /*
262  * @test id=generational-verify
263  * @summary Test clone barriers work correctly
264  * @requires vm.gc.Shenandoah
265  *
266  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
267  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
268  *                   -XX:+ShenandoahVerify
269  *                   TestClone
270  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
271  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
272  *                   -XX:+ShenandoahVerify
273  *                   -Xint
274  *                   TestClone
275  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
276  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
277  *                   -XX:+ShenandoahVerify
278  *                   -XX:-TieredCompilation
279  *                   TestClone
280  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
281  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
282  *                   -XX:+ShenandoahVerify
283  *                   -XX:TieredStopAtLevel=1
284  *                   TestClone
285  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
286  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
287  *                   -XX:+ShenandoahVerify
288  *                   -XX:TieredStopAtLevel=4
289  *                   TestClone
290  */
291 
292  /*
293   * @test id=generational-no-coops
294   * @summary Test clone barriers work correctly
295   * @requires vm.gc.Shenandoah
296   * @requires vm.bits == "64"
297   *
298   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
299   *                   -XX:-UseCompressedOops
300   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
301   *                   TestClone
302   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
303   *                   -XX:-UseCompressedOops
304   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
305   *                   -Xint
306   *                   TestClone
307   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
308   *                   -XX:-UseCompressedOops
309   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
310   *                   -XX:-TieredCompilation
311   *                   TestClone
312   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
313   *                   -XX:-UseCompressedOops
314   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
315   *                   -XX:TieredStopAtLevel=1
316   *                   TestClone
317   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
318   *                   -XX:-UseCompressedOops
319   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
320   *                   -XX:TieredStopAtLevel=4
321   *                   TestClone
322   */
323 
324  /*
325   * @test id=generational-no-coops-verify
326   * @summary Test clone barriers work correctly
327   * @requires vm.gc.Shenandoah
328   * @requires vm.bits == "64"
329   *
330   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
331   *                   -XX:-UseCompressedOops
332   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
333   *                   -XX:+ShenandoahVerify
334   *                   TestClone
335   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
336   *                   -XX:-UseCompressedOops
337   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
338   *                   -XX:+ShenandoahVerify
339   *                   -Xint
340   *                   TestClone
341   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
342   *                   -XX:-UseCompressedOops
343   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
344   *                   -XX:+ShenandoahVerify
345   *                   -XX:-TieredCompilation
346   *                   TestClone
347   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
348   *                   -XX:-UseCompressedOops
349   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
350   *                   -XX:+ShenandoahVerify
351   *                   -XX:TieredStopAtLevel=1
352   *                   TestClone
353   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
354   *                   -XX:-UseCompressedOops
355   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
356   *                   -XX:+ShenandoahVerify
357   *                   -XX:TieredStopAtLevel=4
358   *                   TestClone
359   */
360 public class TestClone {
361 
362     public static void main(String[] args) throws Exception {
363         for (int i = 0; i < 10000; i++) {
364             Object[] src = new Object[i];
365             for (int c = 0; c < src.length; c++) {
366                 src[c] = new Object();
367             }
368             testWith(src);
369         }
370     }
371 
372     static void testWith(Object[] src) {
373         Object[] dst = src.clone();
374         int srcLen = src.length;
375         int dstLen = dst.length;
376         if (srcLen != dstLen) {
377             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
378         }
379         for (int c = 0; c < src.length; c++) {
< prev index next >