test/gc/g1/TestDeferredRSUpdate.java

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

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6939
cd43876f692e
child 7013
e8ba50da0de0
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

tschatzl@6939 1 /*
tschatzl@6939 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
tschatzl@6939 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tschatzl@6939 4 *
tschatzl@6939 5 * This code is free software; you can redistribute it and/or modify it
tschatzl@6939 6 * under the terms of the GNU General Public License version 2 only, as
tschatzl@6939 7 * published by the Free Software Foundation.
tschatzl@6939 8 *
tschatzl@6939 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tschatzl@6939 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tschatzl@6939 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tschatzl@6939 12 * version 2 for more details (a copy is included in the LICENSE file that
tschatzl@6939 13 * accompanied this code).
tschatzl@6939 14 *
tschatzl@6939 15 * You should have received a copy of the GNU General Public License version
tschatzl@6939 16 * 2 along with this work; if not, write to the Free Software Foundation,
tschatzl@6939 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tschatzl@6939 18 *
tschatzl@6939 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tschatzl@6939 20 * or visit www.oracle.com if you need additional information or have any
tschatzl@6939 21 * questions.
tschatzl@6939 22 */
tschatzl@6939 23
tschatzl@6939 24 /*
tschatzl@6939 25 * @test TestDeferredRSUpdate
tschatzl@6939 26 * @bug 8040977
tschatzl@6939 27 * @summary Ensure that running with -XX:-G1DeferredRSUpdate does not crash the VM
tschatzl@6939 28 * @key gc
tschatzl@6939 29 * @library /testlibrary
tschatzl@6939 30 */
tschatzl@6939 31
tschatzl@6939 32 import com.oracle.java.testlibrary.ProcessTools;
tschatzl@6939 33 import com.oracle.java.testlibrary.OutputAnalyzer;
tschatzl@6939 34
tschatzl@6939 35 public class TestDeferredRSUpdate {
tschatzl@6939 36 public static void main(String[] args) throws Exception {
tschatzl@6939 37 GCTest.main(args);
tschatzl@6939 38
tschatzl@6939 39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
tschatzl@6939 40 "-Xmx10M",
tschatzl@6939 41 // G1DeferredRSUpdate is a develop option, but we cannot limit execution of this test to only debug VMs.
tschatzl@6939 42 "-XX:+IgnoreUnrecognizedVMOptions",
tschatzl@6939 43 "-XX:-G1DeferredRSUpdate",
tschatzl@6939 44 GCTest.class.getName());
tschatzl@6939 45
tschatzl@6939 46 OutputAnalyzer output = new OutputAnalyzer(pb.start());
tschatzl@6939 47 output.shouldHaveExitValue(0);
tschatzl@6939 48 }
tschatzl@6939 49
tschatzl@6939 50 static class GCTest {
tschatzl@6939 51 private static Object[] garbage = new Object[32];
tschatzl@6939 52
tschatzl@6939 53 public static void main(String [] args) {
tschatzl@6939 54 System.out.println("Creating garbage");
tschatzl@6939 55 // Create 128MB of garbage. This should result in at least one minor GC, with
tschatzl@6939 56 // some objects copied to old gen. As references from old to young are installed,
tschatzl@6939 57 // the crash due to the use before initialize occurs.
tschatzl@6939 58 Object prev = null;
tschatzl@6939 59 Object prevPrev = null;
tschatzl@6939 60 for (int i = 0; i < 1024; i++) {
tschatzl@6939 61 Object[] next = new Object[32 * 1024];
tschatzl@6939 62 next[0] = prev;
tschatzl@6939 63 next[1] = prevPrev;
tschatzl@6939 64
tschatzl@6939 65 Object[] cur = (Object[]) garbage[i % garbage.length];
tschatzl@6939 66 if (cur != null) {
tschatzl@6939 67 cur[0] = null;
tschatzl@6939 68 cur[1] = null;
tschatzl@6939 69 }
tschatzl@6939 70 garbage[i % garbage.length] = next;
tschatzl@6939 71
tschatzl@6939 72 prevPrev = prev;
tschatzl@6939 73 prev = next;
tschatzl@6939 74 }
tschatzl@6939 75 System.out.println("Done");
tschatzl@6939 76 }
tschatzl@6939 77 }
tschatzl@6939 78 }

mercurial