< 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-verify
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
242  *                   -XX:+ShenandoahVerify
243  *                   TestClone
244  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
245  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
246  *                   -XX:+ShenandoahVerify
247  *                   -Xint
248  *                   TestClone
249  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
250  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
251  *                   -XX:+ShenandoahVerify
252  *                   -XX:-TieredCompilation
253  *                   TestClone
254  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
255  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
256  *                   -XX:+ShenandoahVerify
257  *                   -XX:TieredStopAtLevel=1
258  *                   TestClone
259  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
260  *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
261  *                   -XX:+ShenandoahVerify
262  *                   -XX:TieredStopAtLevel=4
263  *                   TestClone
264  */
265 
266  /*
267   * @test id=generational-no-coops
268   * @summary Test clone barriers work correctly
269   * @requires vm.gc.Shenandoah
270   * @requires vm.bits == "64"
271   *
272   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
273   *                   -XX:-UseCompressedOops
274   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
275   *                   TestClone
276   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
277   *                   -XX:-UseCompressedOops
278   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
279   *                   -Xint
280   *                   TestClone
281   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
282   *                   -XX:-UseCompressedOops
283   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
284   *                   -XX:-TieredCompilation
285   *                   TestClone
286   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
287   *                   -XX:-UseCompressedOops
288   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
289   *                   -XX:TieredStopAtLevel=1
290   *                   TestClone
291   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
292   *                   -XX:-UseCompressedOops
293   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
294   *                   -XX:TieredStopAtLevel=4
295   *                   TestClone
296   */
297 
298  /*
299   * @test id=generational-no-coops-verify
300   * @summary Test clone barriers work correctly
301   * @requires vm.gc.Shenandoah
302   * @requires vm.bits == "64"
303   *
304   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
305   *                   -XX:-UseCompressedOops
306   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
307   *                   -XX:+ShenandoahVerify
308   *                   TestClone
309   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
310   *                   -XX:-UseCompressedOops
311   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
312   *                   -XX:+ShenandoahVerify
313   *                   -Xint
314   *                   TestClone
315   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
316   *                   -XX:-UseCompressedOops
317   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
318   *                   -XX:+ShenandoahVerify
319   *                   -XX:-TieredCompilation
320   *                   TestClone
321   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
322   *                   -XX:-UseCompressedOops
323   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
324   *                   -XX:+ShenandoahVerify
325   *                   -XX:TieredStopAtLevel=1
326   *                   TestClone
327   * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xms1g -Xmx1g
328   *                   -XX:-UseCompressedOops
329   *                   -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
330   *                   -XX:+ShenandoahVerify
331   *                   -XX:TieredStopAtLevel=4
332   *                   TestClone
333   */
334 public class TestClone {
335 
336     public static void main(String[] args) throws Exception {
337         for (int i = 0; i < 10000; i++) {
338             Object[] src = new Object[i];
339             for (int c = 0; c < src.length; c++) {
340                 src[c] = new Object();
341             }
342             testWith(src);
343         }
344     }
345 
346     static void testWith(Object[] src) {
347         Object[] dst = src.clone();
348         int srcLen = src.length;
349         int dstLen = dst.length;
350         if (srcLen != dstLen) {
351             throw new IllegalStateException("Lengths do not match: " + srcLen + " vs " + dstLen);
352         }
353         for (int c = 0; c < src.length; c++) {
< prev index next >