test/gc/logging/TestGCId.java

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

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6909
418bb2c2b55a
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

brutisso@6904 1 /*
brutisso@6904 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
brutisso@6904 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
brutisso@6904 4 *
brutisso@6904 5 * This code is free software; you can redistribute it and/or modify it
brutisso@6904 6 * under the terms of the GNU General Public License version 2 only, as
brutisso@6904 7 * published by the Free Software Foundation.
brutisso@6904 8 *
brutisso@6904 9 * This code is distributed in the hope that it will be useful, but WITHOUT
brutisso@6904 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
brutisso@6904 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
brutisso@6904 12 * version 2 for more details (a copy is included in the LICENSE file that
brutisso@6904 13 * accompanied this code).
brutisso@6904 14 *
brutisso@6904 15 * You should have received a copy of the GNU General Public License version
brutisso@6904 16 * 2 along with this work; if not, write to the Free Software Foundation,
brutisso@6904 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
brutisso@6904 18 *
brutisso@6904 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
brutisso@6904 20 * or visit www.oracle.com if you need additional information or have any
brutisso@6904 21 * questions.
brutisso@6904 22 */
brutisso@6904 23
brutisso@6904 24 /*
brutisso@6904 25 * @test TestGCId
brutisso@6904 26 * @bug 8043607
brutisso@6904 27 * @summary Ensure that the GCId is logged
brutisso@6904 28 * @key gc
brutisso@6904 29 * @library /testlibrary
brutisso@6904 30 */
brutisso@6904 31
brutisso@6904 32 import com.oracle.java.testlibrary.ProcessTools;
brutisso@6904 33 import com.oracle.java.testlibrary.OutputAnalyzer;
brutisso@6904 34
brutisso@6904 35 public class TestGCId {
brutisso@6904 36 public static void main(String[] args) throws Exception {
brutisso@6904 37 testGCId("UseParallelGC", "PrintGC");
brutisso@6904 38 testGCId("UseParallelGC", "PrintGCDetails");
brutisso@6904 39
brutisso@6904 40 testGCId("UseG1GC", "PrintGC");
brutisso@6904 41 testGCId("UseG1GC", "PrintGCDetails");
brutisso@6904 42
brutisso@6904 43 testGCId("UseConcMarkSweepGC", "PrintGC");
brutisso@6904 44 testGCId("UseConcMarkSweepGC", "PrintGCDetails");
brutisso@6904 45
brutisso@6904 46 testGCId("UseSerialGC", "PrintGC");
brutisso@6904 47 testGCId("UseSerialGC", "PrintGCDetails");
brutisso@6904 48 }
brutisso@6904 49
brutisso@6904 50 private static void verifyContainsGCIDs(OutputAnalyzer output) {
brutisso@6904 51 output.shouldMatch("^#0: \\[");
brutisso@6904 52 output.shouldMatch("^#1: \\[");
brutisso@6904 53 output.shouldHaveExitValue(0);
brutisso@6904 54 }
brutisso@6904 55
brutisso@6904 56 private static void verifyContainsNoGCIDs(OutputAnalyzer output) {
brutisso@6904 57 output.shouldNotMatch("^#[0-9]+: \\[");
brutisso@6904 58 output.shouldHaveExitValue(0);
brutisso@6904 59 }
brutisso@6904 60
brutisso@6904 61 private static void testGCId(String gcFlag, String logFlag) throws Exception {
brutisso@6904 62 // GCID logging enabled
brutisso@6904 63 ProcessBuilder pb_enabled =
brutisso@6904 64 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName());
brutisso@6904 65 verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start()));
brutisso@6904 66
brutisso@6904 67 // GCID logging disabled
brutisso@6904 68 ProcessBuilder pb_disabled =
brutisso@6904 69 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName());
brutisso@6904 70 verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start()));
brutisso@6904 71
brutisso@6904 72 // GCID logging default
brutisso@6904 73 ProcessBuilder pb_default =
brutisso@6904 74 ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName());
brutisso@6909 75 verifyContainsNoGCIDs(new OutputAnalyzer(pb_default.start()));
brutisso@6904 76 }
brutisso@6904 77
brutisso@6904 78 static class GCTest {
brutisso@6904 79 private static byte[] garbage;
brutisso@6904 80 public static void main(String [] args) {
brutisso@6904 81 System.out.println("Creating garbage");
brutisso@6904 82 // create 128MB of garbage. This should result in at least one GC
brutisso@6904 83 for (int i = 0; i < 1024; i++) {
brutisso@6904 84 garbage = new byte[128 * 1024];
brutisso@6904 85 }
brutisso@6904 86 // do a system gc to get one more gc
brutisso@6904 87 System.gc();
brutisso@6904 88 System.out.println("Done");
brutisso@6904 89 }
brutisso@6904 90 }
brutisso@6904 91 }

mercurial