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 8150102 8150514 8150534 27 * @summary C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-8150102 28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation CanonicalizeArrayLength 29 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:+PatchALot CanonicalizeArrayLength 30 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=0 CanonicalizeArrayLength 31 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=1 CanonicalizeArrayLength 32 */ 33 public class CanonicalizeArrayLength { 34 int[] arr = new int[42]; 35 int[] arrNull = null; 36 37 final int[] finalArr = new int[42]; 38 final int[] finalArrNull = null; 39 40 static int[] staticArr = new int[42]; 41 static int[] staticArrNull = null; 42 43 static final int[] staticFinalArr = new int[42]; 44 static final int[] staticFinalArrNull = null; 45 46 public static void main(String... args) { 47 CanonicalizeArrayLength t = new CanonicalizeArrayLength(); 48 for (int i = 0; i < 20000; i++) { 49 if (t.testLocal() != 42) 50 throw new IllegalStateException(); 51 if (t.testLocalNull() != 42) 52 throw new IllegalStateException(); 53 if (t.testField() != 42) 54 throw new IllegalStateException(); 55 if (t.testFieldNull() != 42) 56 throw new IllegalStateException(); 57 if (t.testFinalField() != 42) 58 throw new IllegalStateException(); 59 if (t.testFinalFieldNull() != 42) 60 throw new IllegalStateException(); 61 if (t.testStaticField() != 42) 62 throw new IllegalStateException(); 63 if (t.testStaticFieldNull() != 42) 64 throw new IllegalStateException(); 65 if (t.testStaticFinalField() != 42) 66 throw new IllegalStateException(); 67 if (t.testStaticFinalFieldNull() != 42) 68 throw new IllegalStateException(); 69 } 70 } 71 72 int testField() { 73 try { 74 return arr.length; 75 } catch (Throwable t) { 76 return -1; 77 } 78 } 79 80 int testFieldNull() { 81 try { 82 return arrNull.length; 83 } catch (Throwable t) { 84 return 42; 85 } 86 } 87 88 int testFinalField() { 89 try { 90 return finalArr.length; 91 } catch (Throwable t) { 92 return -1; 93 } 94 } 95 96 int testFinalFieldNull() { 97 try { 98 return finalArrNull.length; 99 } catch (Throwable t) { 100 return 42; 101 } 102 } 103 104 int testStaticField() { 105 try { 106 return staticArr.length; 107 } catch (Throwable t) { 108 return -1; 109 } 110 } 111 112 int testStaticFieldNull() { 113 try { 114 return staticArrNull.length; 115 } catch (Throwable t) { 116 return 42; 117 } 118 } 119 120 int testStaticFinalField() { 121 try { 122 return staticFinalArr.length; 123 } catch (Throwable t) { 124 return -1; 125 } 126 } 127 128 int testStaticFinalFieldNull() { 129 try { 130 return staticFinalArrNull.length; 131 } catch (Throwable t) { 132 return 42; 133 } 134 } 135 136 int testLocal() { 137 int[] arr = new int[42]; 138 try { 139 return arr.length; 140 } catch (Throwable t) { 141 return -1; 142 } 143 } 144 145 int testLocalNull() { 146 int[] arrNull = null; 147 try { 148 return arrNull.length; 149 } catch (Throwable t) { 150 return 42; 151 } 152 } 153 154 155 }