Path: blob/master/test/hotspot/jtreg/compiler/c1/CanonicalizeArrayLength.java
41152 views
/*1* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 8150102 8150514 8150534 817143526* @summary C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-815010227*28* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions29* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=130* -XX:-BackgroundCompilation31* compiler.c1.CanonicalizeArrayLength32* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions33* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=334* -XX:-BackgroundCompilation35* -XX:+PatchALot36* compiler.c1.CanonicalizeArrayLength37* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions38* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=139* -XX:-BackgroundCompilation40* -XX:ScavengeRootsInCode=041* compiler.c1.CanonicalizeArrayLength42* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions43* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=144* -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=145* compiler.c1.CanonicalizeArrayLength46*/4748package compiler.c1;4950public class CanonicalizeArrayLength {51int[] arr = new int[42];52int[] arrNull = null;5354final int[] finalArr = new int[42];55final int[] finalArrNull = null;5657static int[] staticArr = new int[42];58static int[] staticArrNull = null;5960static final int[] staticFinalArr = new int[42];61static final int[] staticFinalArrNull = null;6263public static void main(String... args) {64CanonicalizeArrayLength t = new CanonicalizeArrayLength();65for (int i = 0; i < 20000; i++) {66if (t.testLocal() != 42)67throw new IllegalStateException();68if (t.testLocalNull() != 42)69throw new IllegalStateException();70if (t.testField() != 42)71throw new IllegalStateException();72if (t.testFieldNull() != 42)73throw new IllegalStateException();74if (t.testFinalField() != 42)75throw new IllegalStateException();76if (t.testFinalFieldNull() != 42)77throw new IllegalStateException();78if (t.testStaticField() != 42)79throw new IllegalStateException();80if (t.testStaticFieldNull() != 42)81throw new IllegalStateException();82if (t.testStaticFinalField() != 42)83throw new IllegalStateException();84if (t.testStaticFinalFieldNull() != 42)85throw new IllegalStateException();86}87}8889int testField() {90try {91return arr.length;92} catch (Throwable t) {93return -1;94}95}9697int testFieldNull() {98try {99return arrNull.length;100} catch (Throwable t) {101return 42;102}103}104105int testFinalField() {106try {107return finalArr.length;108} catch (Throwable t) {109return -1;110}111}112113int testFinalFieldNull() {114try {115return finalArrNull.length;116} catch (Throwable t) {117return 42;118}119}120121int testStaticField() {122try {123return staticArr.length;124} catch (Throwable t) {125return -1;126}127}128129int testStaticFieldNull() {130try {131return staticArrNull.length;132} catch (Throwable t) {133return 42;134}135}136137int testStaticFinalField() {138try {139return staticFinalArr.length;140} catch (Throwable t) {141return -1;142}143}144145int testStaticFinalFieldNull() {146try {147return staticFinalArrNull.length;148} catch (Throwable t) {149return 42;150}151}152153int testLocal() {154int[] arr = new int[42];155try {156return arr.length;157} catch (Throwable t) {158return -1;159}160}161162int testLocalNull() {163int[] arrNull = null;164try {165return arrNull.length;166} catch (Throwable t) {167return 42;168}169}170171172}173174175