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