< prev index next >

test/hotspot/jtreg/gc/shenandoah/TestRefprocSanity.java

Print this page

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

 24 
 25 /*
 26  * @test id=default
 27  * @summary Test that null references/referents work fine
 28  * @requires vm.gc.Shenandoah
 29  *
 30  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 31  *      -XX:+UseShenandoahGC
 32  *      -XX:+ShenandoahVerify
 33  *      TestRefprocSanity
 34  *
 35  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 36  *      -XX:+UseShenandoahGC
 37  *      TestRefprocSanity
 38  *
 39  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 40  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 41  *      TestRefprocSanity
 42  */
 43 















 44 import java.lang.ref.*;
 45 
 46 public class TestRefprocSanity {
 47 
 48     static final long TARGET_MB = Long.getLong("target", 1_000); // 1 Gb allocation
 49     static final int WINDOW = 1_000;
 50 
 51     static final Reference<MyObject>[] refs = new Reference[WINDOW];
 52 
 53     static Object sink;
 54 
 55     public static void main(String[] args) throws Exception {
 56         long count = TARGET_MB * 1024 * 1024 / 128;
 57         int rIdx = 0;
 58 
 59         ReferenceQueue rq = new ReferenceQueue();
 60 
 61         for (int c = 0; c < WINDOW; c++) {
 62             refs[c] = select(c, new MyObject(c), rq);
 63         }

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

 25 
 26 /*
 27  * @test id=default
 28  * @summary Test that null references/referents work fine
 29  * @requires vm.gc.Shenandoah
 30  *
 31  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 32  *      -XX:+UseShenandoahGC
 33  *      -XX:+ShenandoahVerify
 34  *      TestRefprocSanity
 35  *
 36  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 37  *      -XX:+UseShenandoahGC
 38  *      TestRefprocSanity
 39  *
 40  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 41  *      -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
 42  *      TestRefprocSanity
 43  */
 44 
 45 /*
 46  * @test id=generational
 47  * @summary Test that null references/referents work fine
 48  * @requires vm.gc.Shenandoah
 49  *
 50  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 51  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
 52  *      -XX:+ShenandoahVerify
 53  *      TestRefprocSanity
 54  *
 55  * @run main/othervm -Xmx128m -Xms128m -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
 56  *      -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational
 57  *      TestRefprocSanity
 58  */
 59 
 60 import java.lang.ref.*;
 61 
 62 public class TestRefprocSanity {
 63 
 64     static final long TARGET_MB = Long.getLong("target", 1_000); // 1 Gb allocation
 65     static final int WINDOW = 1_000;
 66 
 67     static final Reference<MyObject>[] refs = new Reference[WINDOW];
 68 
 69     static Object sink;
 70 
 71     public static void main(String[] args) throws Exception {
 72         long count = TARGET_MB * 1024 * 1024 / 128;
 73         int rIdx = 0;
 74 
 75         ReferenceQueue rq = new ReferenceQueue();
 76 
 77         for (int c = 0; c < WINDOW; c++) {
 78             refs[c] = select(c, new MyObject(c), rq);
 79         }
< prev index next >