test/gc/g1/TestHumongousAllocInitialMark.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6198
55fb97c4c58d
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. 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  * @test TestHumongousAllocInitialMark
    26  * @bug 7168848
    27  * @summary G1: humongous object allocations should initiate marking cycles when necessary
    28  * @library /testlibrary
    29  */
    31 import com.oracle.java.testlibrary.*;
    33 public class TestHumongousAllocInitialMark {
    34     private static final int heapSize                       = 200; // MB
    35     private static final int heapRegionSize                 = 1;   // MB
    36     private static final int initiatingHeapOccupancyPercent = 50;  // %
    38     public static void main(String[] args) throws Exception {
    39         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    40             "-XX:+UseG1GC",
    41             "-Xms" + heapSize + "m",
    42             "-Xmx" + heapSize + "m",
    43             "-XX:G1HeapRegionSize=" + heapRegionSize + "m",
    44             "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,
    45             "-XX:+PrintGC",
    46             HumongousObjectAllocator.class.getName());
    48         OutputAnalyzer output = new OutputAnalyzer(pb.start());
    49         output.shouldContain("GC pause (G1 Humongous Allocation) (young) (initial-mark)");
    50         output.shouldNotContain("Full GC");
    51         output.shouldHaveExitValue(0);
    52     }
    54     static class HumongousObjectAllocator {
    55         private static byte[] dummy;
    57         public static void main(String [] args) throws Exception {
    58             // Make object size 75% of region size
    59             final int humongousObjectSize =
    60                 (int)(heapRegionSize * 1024 * 1024 * 0.75);
    62             // Number of objects to allocate to go above IHOP
    63             final int humongousObjectAllocations =
    64                 (int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1;
    66             // Allocate
    67             for (int i = 1; i <= humongousObjectAllocations; i++) {
    68                 System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations +
    69                                    " of size " + humongousObjectSize + " bytes");
    70                 dummy = new byte[humongousObjectSize];
    71             }
    72         }
    73     }
    74 }

mercurial