Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6805724/Test6805724.java
32285 views
/*1* Copyright (c) 2009, 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 680572426* @summary ModLNode::Ideal() generates functionally incorrect graph when divisor is any (2^k-1) constant.27*28* @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test680572429*/3031import java.net.URLClassLoader;3233public class Test6805724 implements Runnable {34// Initialize DIVISOR so that it is final in this class.35static final long DIVISOR; // 2^k-1 constant3637static {38long value = 0;39try {40value = Long.decode(System.getProperty("divisor"));41} catch (Throwable t) {42// This one is required for the Class.forName() in main.43}44DIVISOR = value;45}4647static long fint(long x) {48return x % DIVISOR;49}5051static long fcomp(long x) {52return x % DIVISOR;53}5455public void run() {56long a = 0x617981E1L;5758long expected = fint(a);59long result = fcomp(a);6061if (result != expected)62throw new InternalError(result + " != " + expected);63}6465public static void main(String args[]) throws Exception {66Class cl = Class.forName("Test6805724");67URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();6869// Iterate over all 2^k-1 divisors.70for (int k = 1; k < Long.SIZE; k++) {71long divisor = (1L << k) - 1;72System.setProperty("divisor", "" + divisor);73ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());74Class c = loader.loadClass("Test6805724");75Runnable r = (Runnable) c.newInstance();76r.run();77}78}79}808182