1 /* 2 * Copyright (c) 2015, 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 /** 26 * @test 27 * @bug 8069191 28 * @summary predicate moved out of loops and CastPP removal causes dependency to be lost 29 * 30 * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+StressGCM 31 * -XX:CompileCommand=compileonly,compiler.loopopts.TestPredicateLostDependency::m1 32 * compiler.loopopts.TestPredicateLostDependency 33 * 34 */ 35 36 package compiler.loopopts; 37 38 public class TestPredicateLostDependency { 39 static class A { 40 int i; 41 } 42 43 static class B extends A { 44 } 45 46 static boolean crash = false; 47 48 static boolean m2() { 49 return crash; 50 } 51 52 static int m3(float[] arr) { 53 return 0; 54 } 55 56 static float m1(A aa) { 57 float res = 0; 58 float[] arr = new float[10]; 59 for (int i = 0; i < 10; i++) { 60 if (m2()) { 61 arr = null; 62 } 63 m3(arr); 64 int j = arr.length; 65 int k = 0; 66 for (k = 9; k < j; k++) { 67 } 68 if (k == 10) { 69 if (aa instanceof B) { 70 } 71 } 72 res += arr[0]; 73 res += arr[1]; 74 } 75 return res; 76 } 77 78 static public void main(String args[]) { 79 A a = new A(); 80 B b = new B(); 81 for (int i = 0; i < 20000; i++) { 82 m1(a); 83 } 84 crash = true; 85 try { 86 m1(a); 87 } catch (NullPointerException npe) {} 88 } 89 }