1 /* 2 * Copyright (c) 2016, 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 8159016 27 * @summary Tests correct dominator information after over-unrolling a loop. 28 * @requires vm.gc == "Parallel" | vm.gc == "null" 29 * 30 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-TieredCompilation 31 * -XX:-UseG1GC -XX:+UseParallelGC 32 * compiler.loopopts.TestOverunrolling 33 */ 34 35 package compiler.loopopts; 36 37 public class TestOverunrolling { 38 39 public static Object test(int arg) { 40 Object arr[] = new Object[3]; 41 int lim = (arg & 3); 42 // The pre loop is executed for one iteration, initializing p[0]. 43 // The main loop is unrolled twice, initializing p[1], p[2], p[3] and p[4]. 44 // The p[3] and p[4] stores are always out of bounds and removed. However, 45 // C2 is unable to remove the "over-unrolled", dead main loop. As a result, 46 // there is a control path from the main loop to the post loop without a 47 // memory path (because the last store was replaced by TOP). We crash 48 // because we use a memory edge from a non-dominating region. 49 for (int i = 0; i < lim; ++i) { 50 arr[i] = new Object(); 51 } 52 // Avoid EA 53 return arr; 54 } 55 56 public static void main(String args[]) { 57 for (int i = 0; i < 42; ++i) { 58 test(i); 59 } 60 } 61 } 62