Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6800154.java
41149 views
/*1* Copyright (c) 2009, 2016, 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 680015426* @summary Add comments to long_by_long_mulhi() for better understandability27* @modules java.base/jdk.internal.misc28* @library /test/lib29*30* @run main/othervm -Xcomp31* -XX:CompileCommand=compileonly,compiler.c2.Test6800154::divcomp32* compiler.c2.Test680015433*/343536package compiler.c2;3738import jdk.test.lib.Utils;3940public class Test6800154 implements Runnable {41static final long[] DIVIDENDS = {420,431,442,451423487,464444441,474918923241323L,48-1,49-24351,500x3333,510x0000000080000000L,520x7fffffffffffffffL,530x8000000000000000L54};5556static final long[] DIVISORS = {571,582,5917,6012342,6124123,62143444,63123444442344L,64-1,65-2,66-4423423234231423L,670x0000000080000000L,680x7fffffffffffffffL,690x8000000000000000L70};7172// Initialize DIVISOR so that it is final in this class.73static final long DIVISOR;7475static {76long value = 0;77try {78value = Long.decode(System.getProperty("divisor"));79} catch (Throwable e) {80}81DIVISOR = value;82}8384public static void main(String[] args) throws Exception85{86Class cl = Test6800154.class;87ClassLoader apploader = cl.getClassLoader();8889// Iterate over all divisors.90for (int i = 0; i < DIVISORS.length; i++) {91System.setProperty("divisor", "" + DIVISORS[i]);92ClassLoader loader93= Utils.getTestClassPathURLClassLoader(apploader.getParent());94Class c = loader.loadClass(Test6800154.class.getName());95Runnable r = (Runnable) c.newInstance();96r.run();97}98}99100public void run()101{102// Iterate over all dividends.103for (int i = 0; i < DIVIDENDS.length; i++) {104long dividend = DIVIDENDS[i];105106long expected = divint(dividend);107long result = divcomp(dividend);108109if (result != expected)110throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected);111}112}113114static long divint(long a) { return a / DIVISOR; }115static long divcomp(long a) { return a / DIVISOR; }116}117118119