Mon, 28 Jul 2014 15:06:38 -0700
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
mgerdin@4902 | 1 | /* |
mikael@6198 | 2 | * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
mgerdin@4902 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
mgerdin@4902 | 4 | * |
mgerdin@4902 | 5 | * This code is free software; you can redistribute it and/or modify it |
mgerdin@4902 | 6 | * under the terms of the GNU General Public License version 2 only, as |
mgerdin@4902 | 7 | * published by the Free Software Foundation. |
mgerdin@4902 | 8 | * |
mgerdin@4902 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
mgerdin@4902 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
mgerdin@4902 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
mgerdin@4902 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
mgerdin@4902 | 13 | * accompanied this code). |
mgerdin@4902 | 14 | * |
mgerdin@4902 | 15 | * You should have received a copy of the GNU General Public License version |
mgerdin@4902 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
mgerdin@4902 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
mgerdin@4902 | 18 | * |
mgerdin@4902 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
mgerdin@4902 | 20 | * or visit www.oracle.com if you need additional information or have any |
mgerdin@4902 | 21 | * questions. |
mgerdin@4902 | 22 | */ |
mgerdin@4902 | 23 | |
mgerdin@4902 | 24 | /* |
mgerdin@4902 | 25 | * @test Test6941923.java |
mgerdin@4902 | 26 | * @bug 6941923 |
mgerdin@4902 | 27 | * @summary test flags for gc log rotation |
mgerdin@4902 | 28 | * @library /testlibrary |
mgerdin@4902 | 29 | * @run main/othervm/timeout=600 Test6941923 |
mgerdin@4902 | 30 | * |
mgerdin@4902 | 31 | */ |
mgerdin@4902 | 32 | import com.oracle.java.testlibrary.*; |
mgerdin@4902 | 33 | import java.io.File; |
mgerdin@4902 | 34 | import java.io.FilenameFilter; |
mgerdin@4902 | 35 | import java.util.ArrayList; |
mgerdin@4902 | 36 | import java.util.Arrays; |
mgerdin@4902 | 37 | |
mgerdin@4902 | 38 | class GCLoggingGenerator { |
mgerdin@4902 | 39 | |
mgerdin@4902 | 40 | public static void main(String[] args) throws Exception { |
mgerdin@4902 | 41 | |
mgerdin@4902 | 42 | long sizeOfLog = Long.parseLong(args[0]); |
mgerdin@4902 | 43 | long lines = sizeOfLog / 80; |
mgerdin@4902 | 44 | // full.GC generates ad least 1-line which is not shorter then 80 chars |
mgerdin@4902 | 45 | // for some GC 2 shorter lines are generated |
mgerdin@4902 | 46 | for (long i = 0; i < lines; i++) { |
mgerdin@4902 | 47 | System.gc(); |
mgerdin@4902 | 48 | } |
mgerdin@4902 | 49 | } |
mgerdin@4902 | 50 | } |
mgerdin@4902 | 51 | |
mgerdin@4902 | 52 | public class Test6941923 { |
mgerdin@4902 | 53 | |
mgerdin@4902 | 54 | static final File currentDirectory = new File("."); |
mgerdin@4902 | 55 | static final String logFileName = "test.log"; |
mgerdin@4902 | 56 | static final int logFileSizeK = 16; |
mgerdin@4902 | 57 | static FilenameFilter logFilter = new FilenameFilter() { |
mgerdin@4902 | 58 | @Override |
mgerdin@4902 | 59 | public boolean accept(File dir, String name) { |
mgerdin@4902 | 60 | return name.startsWith(logFileName); |
mgerdin@4902 | 61 | } |
mgerdin@4902 | 62 | }; |
mgerdin@4902 | 63 | |
mgerdin@4902 | 64 | public static void cleanLogs() { |
mgerdin@4902 | 65 | for (File log : currentDirectory.listFiles(logFilter)) { |
mgerdin@4902 | 66 | if (!log.delete()) { |
mgerdin@4902 | 67 | throw new Error("Unable to delete " + log.getAbsolutePath()); |
mgerdin@4902 | 68 | } |
mgerdin@4902 | 69 | } |
mgerdin@4902 | 70 | } |
mgerdin@4902 | 71 | |
mgerdin@4902 | 72 | public static void runTest(int numberOfFiles) throws Exception { |
mgerdin@4902 | 73 | |
mgerdin@4902 | 74 | ArrayList<String> args = new ArrayList(); |
mgerdin@4902 | 75 | String[] logOpts = new String[]{ |
mgerdin@4902 | 76 | "-cp", System.getProperty("java.class.path"), |
mgerdin@4902 | 77 | "-Xloggc:" + logFileName, |
mgerdin@4902 | 78 | "-XX:-DisableExplicitGC", // to sure that System.gc() works |
mgerdin@4902 | 79 | "-XX:+PrintGC", "-XX:+PrintGCDetails", "-XX:+UseGCLogFileRotation", |
mgerdin@4902 | 80 | "-XX:NumberOfGCLogFiles=" + numberOfFiles, |
mgerdin@4902 | 81 | "-XX:GCLogFileSize=" + logFileSizeK + "K", "-Xmx128M"}; |
mgerdin@4902 | 82 | // System.getProperty("test.java.opts") is '' if no options is set |
mgerdin@4902 | 83 | // need to skip such empty |
mgerdin@4902 | 84 | String[] externalVMopts = System.getProperty("test.java.opts").length() == 0 |
mgerdin@4902 | 85 | ? new String[0] |
mgerdin@4902 | 86 | : System.getProperty("test.java.opts").split(" "); |
mgerdin@4902 | 87 | args.addAll(Arrays.asList(externalVMopts)); |
mgerdin@4902 | 88 | args.addAll(Arrays.asList(logOpts)); |
mgerdin@4902 | 89 | args.add(GCLoggingGenerator.class.getName()); |
mgerdin@4902 | 90 | args.add(String.valueOf(numberOfFiles * logFileSizeK * 1024)); |
mgerdin@4902 | 91 | ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0])); |
mgerdin@4902 | 92 | pb.redirectErrorStream(true); |
mgerdin@4902 | 93 | pb.redirectOutput(new File(GCLoggingGenerator.class.getName() + ".log")); |
mgerdin@4902 | 94 | Process process = pb.start(); |
mgerdin@4902 | 95 | int result = process.waitFor(); |
mgerdin@4902 | 96 | if (result != 0) { |
mgerdin@4902 | 97 | throw new Error("Unexpected exit code = " + result); |
mgerdin@4902 | 98 | } |
mgerdin@4902 | 99 | File[] logs = currentDirectory.listFiles(logFilter); |
mgerdin@4902 | 100 | int smallFilesNumber = 0; |
mgerdin@4902 | 101 | for (File log : logs) { |
mgerdin@4902 | 102 | if (log.length() < logFileSizeK * 1024) { |
mgerdin@4902 | 103 | smallFilesNumber++; |
mgerdin@4902 | 104 | } |
mgerdin@4902 | 105 | } |
mgerdin@4902 | 106 | if (logs.length != numberOfFiles) { |
mgerdin@4902 | 107 | throw new Error("There are only " + logs.length + " logs instead " + numberOfFiles); |
mgerdin@4902 | 108 | } |
mgerdin@4902 | 109 | if (smallFilesNumber > 1) { |
mgerdin@4902 | 110 | throw new Error("There should maximum one log with size < " + logFileSizeK + "K"); |
mgerdin@4902 | 111 | } |
mgerdin@4902 | 112 | } |
mgerdin@4902 | 113 | |
mgerdin@4902 | 114 | public static void main(String[] args) throws Exception { |
mgerdin@4902 | 115 | cleanLogs(); |
mgerdin@4902 | 116 | runTest(1); |
mgerdin@4902 | 117 | cleanLogs(); |
mgerdin@4902 | 118 | runTest(3); |
mgerdin@4902 | 119 | cleanLogs(); |
mgerdin@4902 | 120 | } |
mgerdin@4902 | 121 | } |