Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestDivZeroDominatedBy.java
41149 views
/*1* Copyright (c) 2021, 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*22*/2324/*25* @test26* @key stress randomness27* @bug 825922728* @summary Verify that zero check is executed before division/modulo operation.29* @requires vm.compiler2.enabled30* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test31* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=917280111 compiler.loopopts.TestDivZeroDominatedBy32* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroDominatedBy::test33* -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM compiler.loopopts.TestDivZeroDominatedBy34*/3536package compiler.loopopts;3738public class TestDivZeroDominatedBy {3940public static int iFld = 1;41public static int iFld1 = 2;42public static int iFld2 = 3;43public static int iArrFld[] = new int[10];44public static double dFld = 1.0;4546public static void test() {47int x = 1;48int y = 2;49int z = 3;5051iFld = y;52iArrFld[5] += iFld1;53int i = 1;54do {55for (int j = 0; j < 10; j++) {56iFld2 += iFld2;57iFld1 = iFld2;58int k = 1;59do {60iArrFld[k] = y;61z = iFld2;62dFld = x;63try {64y = iArrFld[k];65iArrFld[8] = 5;66iFld = (100 / z);67} catch (ArithmeticException a_e) {}68} while (++k < 2);69}70} while (++i < 10);71}7273public static void main(String[] strArr) {74test();75}76}77787980