1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/compiler/6800154/Test6800154.java Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,109 @@ 1.4 +/* 1.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +/** 1.28 + * @test 1.29 + * @bug 6800154 1.30 + * @summary Add comments to long_by_long_mulhi() for better understandability 1.31 + * 1.32 + * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154 1.33 + */ 1.34 + 1.35 +import java.net.URLClassLoader; 1.36 + 1.37 +public class Test6800154 implements Runnable { 1.38 + static final long[] DIVIDENDS = { 1.39 + 0, 1.40 + 1, 1.41 + 2, 1.42 + 1423487, 1.43 + 4444441, 1.44 + 4918923241323L, 1.45 + -1, 1.46 + -24351, 1.47 + 0x3333, 1.48 + 0x0000000080000000L, 1.49 + 0x7fffffffffffffffL, 1.50 + 0x8000000000000000L 1.51 + }; 1.52 + 1.53 + static final long[] DIVISORS = { 1.54 + 1, 1.55 + 2, 1.56 + 17, 1.57 + 12342, 1.58 + 24123, 1.59 + 143444, 1.60 + 123444442344L, 1.61 + -1, 1.62 + -2, 1.63 + -4423423234231423L, 1.64 + 0x0000000080000000L, 1.65 + 0x7fffffffffffffffL, 1.66 + 0x8000000000000000L 1.67 + }; 1.68 + 1.69 + // Initialize DIVISOR so that it is final in this class. 1.70 + static final long DIVISOR; 1.71 + 1.72 + static { 1.73 + long value = 0; 1.74 + try { 1.75 + value = Long.decode(System.getProperty("divisor")); 1.76 + } catch (Throwable e) { 1.77 + } 1.78 + DIVISOR = value; 1.79 + } 1.80 + 1.81 + public static void main(String[] args) throws Exception 1.82 + { 1.83 + Class cl = Class.forName("Test6800154"); 1.84 + URLClassLoader apploader = (URLClassLoader) cl.getClassLoader(); 1.85 + 1.86 + // Iterate over all divisors. 1.87 + for (int i = 0; i < DIVISORS.length; i++) { 1.88 + System.setProperty("divisor", "" + DIVISORS[i]); 1.89 + ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent()); 1.90 + Class c = loader.loadClass("Test6800154"); 1.91 + Runnable r = (Runnable) c.newInstance(); 1.92 + r.run(); 1.93 + } 1.94 + } 1.95 + 1.96 + public void run() 1.97 + { 1.98 + // Iterate over all dividends. 1.99 + for (int i = 0; i < DIVIDENDS.length; i++) { 1.100 + long dividend = DIVIDENDS[i]; 1.101 + 1.102 + long expected = divint(dividend); 1.103 + long result = divcomp(dividend); 1.104 + 1.105 + if (result != expected) 1.106 + throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected); 1.107 + } 1.108 + } 1.109 + 1.110 + static long divint(long a) { return a / DIVISOR; } 1.111 + static long divcomp(long a) { return a / DIVISOR; } 1.112 +}