< prev index next >

test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java

Print this page
rev 7559 : imported patch bengt-review


   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  * @test TestEagerReclaimHumongousRegions2
  26  * @bug 8051973
  27  * @summary Test to make sure that eager reclaim of humongous objects correctly clears
  28  * mark bitmaps at reclaim.
  29  * @key gc
  30  * @library /testlibrary
  31  */
  32 
  33 import java.util.ArrayList;
  34 import java.util.LinkedList;
  35 import java.util.Random;
  36 
  37 import com.oracle.java.testlibrary.OutputAnalyzer;
  38 import com.oracle.java.testlibrary.ProcessTools;
  39 
  40 // An object that has a few references to other instances to slow down marking.
  41 class ObjectWithSomeRefs {
  42     public ObjectWithSomeRefs other1;
  43     public ObjectWithSomeRefs other2;
  44     public ObjectWithSomeRefs other3;
  45     public ObjectWithSomeRefs other4;


  92             if ((current_millis - start_millis) > MAX_MILLIS_FOR_RUN) {
  93               System.out.println("Finishing test because maximum runtime exceeded");
  94               break;
  95             }
  96             // A set of large objects that will be reclaimed eagerly - and hopefully marked.
  97             large1 = new int[M - 20];
  98             large2 = new int[M - 20];
  99             large3 = new int[M - 20];
 100             large4 = new int[M - 20];
 101             genGarbage(large1);
 102             // Make sure that the compiler cannot completely remove
 103             // the allocation of the large object until here.
 104             System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
 105         }
 106 
 107         // Keep the reference to the first object alive.
 108         System.out.println(ref_from_stack);
 109     }
 110 }
 111 
 112 public class TestEagerReclaimHumongousRegions2 {
 113     public static void main(String[] args) throws Exception {
 114         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 115             "-XX:+UseG1GC",
 116             "-Xms128M",
 117             "-Xmx128M",
 118             "-Xmn2M",
 119             "-XX:G1HeapRegionSize=1M",
 120             "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
 121             "-XX:+PrintGC",
 122             "-XX:+VerifyAfterGC",
 123             "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
 124             "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
 125             "-XX:+G1VerifyBitmaps",
 126             ReclaimRegionFast.class.getName());
 127         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 128         output.shouldHaveExitValue(0);
 129     }
 130 }
 131 


   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  * @test TestEagerReclaimHumongousRegionsClearMarkBits
  26  * @bug 8051973
  27  * @summary Test to make sure that eager reclaim of humongous objects correctly clears
  28  * mark bitmaps at reclaim.
  29  * @key gc
  30  * @library /testlibrary
  31  */
  32 
  33 import java.util.ArrayList;
  34 import java.util.LinkedList;
  35 import java.util.Random;
  36 
  37 import com.oracle.java.testlibrary.OutputAnalyzer;
  38 import com.oracle.java.testlibrary.ProcessTools;
  39 
  40 // An object that has a few references to other instances to slow down marking.
  41 class ObjectWithSomeRefs {
  42     public ObjectWithSomeRefs other1;
  43     public ObjectWithSomeRefs other2;
  44     public ObjectWithSomeRefs other3;
  45     public ObjectWithSomeRefs other4;


  92             if ((current_millis - start_millis) > MAX_MILLIS_FOR_RUN) {
  93               System.out.println("Finishing test because maximum runtime exceeded");
  94               break;
  95             }
  96             // A set of large objects that will be reclaimed eagerly - and hopefully marked.
  97             large1 = new int[M - 20];
  98             large2 = new int[M - 20];
  99             large3 = new int[M - 20];
 100             large4 = new int[M - 20];
 101             genGarbage(large1);
 102             // Make sure that the compiler cannot completely remove
 103             // the allocation of the large object until here.
 104             System.out.println(large1 + " " + large2 + " " + large3 + " " + large4);
 105         }
 106 
 107         // Keep the reference to the first object alive.
 108         System.out.println(ref_from_stack);
 109     }
 110 }
 111 
 112 public class TestEagerReclaimHumongousRegionsClearMarkBits {
 113     public static void main(String[] args) throws Exception {
 114         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
 115             "-XX:+UseG1GC",
 116             "-Xms128M",
 117             "-Xmx128M",
 118             "-Xmn2M",
 119             "-XX:G1HeapRegionSize=1M",
 120             "-XX:InitiatingHeapOccupancyPercent=0", // Want to have as much as possible initial marks.
 121             "-XX:+PrintGC",
 122             "-XX:+VerifyAfterGC",
 123             "-XX:ConcGCThreads=1", // Want to make marking as slow as possible.
 124             "-XX:+IgnoreUnrecognizedVMOptions", // G1VerifyBitmaps is develop only.
 125             "-XX:+G1VerifyBitmaps",
 126             ReclaimRegionFast.class.getName());
 127         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 128         output.shouldHaveExitValue(0);
 129     }
 130 }
 131 
< prev index next >