1 /*
2  * Copyright (c) 2009, 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  */
23 
24 /**
25  * @test
26  * @bug 6826736
27  * @summary CMS: core dump with -XX:+UseCompressedOops
28  *
29  * @run main/othervm/timeout=600 -XX:+IgnoreUnrecognizedVMOptions -Xbatch
30  *      -XX:+ScavengeALot -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g
31  *      -XX:CompileThreshold=100 -XX:-BlockLayoutRotateLoops
32  *      -XX:LoopUnrollLimit=0 -Xmx256m -XX:ParallelGCThreads=4
33  *      -XX:CompileCommand=compileonly,compiler.runtime.Test6826736::test
34  *      compiler.runtime.Test6826736
35  */
36 
37 package compiler.runtime;
38 
39 public class Test6826736 {
40     int[] arr;
41     int[] arr2;
test(int r)42     int test(int r) {
43         for (int i = 0; i < 100; i++) {
44             for (int j = i; j < 100; j++) {
45                int a = 0;
46                for (long k = 0; k < 100; k++) {
47                   a += k;
48                }
49                if (arr != null)
50                    a = arr[j];
51                r += a;
52             }
53         }
54         return r;
55     }
56 
main(String[] args)57     public static void main(String[] args) {
58         int r = 0;
59         Test6826736 t = new Test6826736();
60         for (int i = 0; i < 100; i++) {
61             t.arr = new int[100];
62             r = t.test(r);
63         }
64         System.out.println("Warmup 1 is done.");
65         for (int i = 0; i < 100; i++) {
66             t.arr = null;
67             r = t.test(r);
68         }
69         System.out.println("Warmup 2 is done.");
70         for (int i = 0; i < 100; i++) {
71             t.arr = new int[100];
72             r = t.test(r);
73         }
74         System.out.println("Warmup is done.");
75         for (int i = 0; i < 100; i++) {
76             t.arr = new int[1000000];
77             t.arr = null;
78             r = t.test(r);
79         }
80     }
81 }
82