Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6589834/Test_ia32.java
32285 views
/*1* Copyright (c) 2009, 2013, 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 658983426* @summary deoptimization problem with -XX:+DeoptimizeALot27*28* @run main Test_ia3229*/3031/***************************************************************************************32NOTE: The bug shows up (with several "Bug!" message) even without the33flag -XX:+DeoptimizeALot. In a debug build, you may want to try34the flags -XX:+VerifyStack and -XX:+DeoptimizeALot to get more information.35****************************************************************************************/36import java.lang.reflect.Constructor;3738public class Test_ia32 {3940public static int NUM_THREADS = 100;4142public static int CLONE_LENGTH = 1000;4344public static void main(String[] args) throws InterruptedException, ClassNotFoundException {4546Reflector[] threads = new Reflector[NUM_THREADS];47for (int i = 0; i < threads.length; i++) {48threads[i] = new Reflector();49threads[i].start();50}5152System.out.println("Give Reflector.run() some time to compile...");53Thread.sleep(5000);5455System.out.println("Load RMISecurityException causing run() deoptimization");56ClassLoader.getSystemClassLoader().loadClass("java.rmi.RMISecurityException");5758for (Reflector thread : threads)59thread.requestStop();6061for (Reflector thread : threads)62try {63thread.join();64} catch (InterruptedException e) {65System.out.println(e);66}6768}6970}7172class Reflector extends Thread {7374volatile boolean _doSpin = true;7576Test_ia32[] _tests;7778Reflector() {79_tests = new Test_ia32[Test_ia32.CLONE_LENGTH];80for (int i = 0; i < _tests.length; i++) {81_tests[i] = new Test_ia32();82}83}8485static int g(int i1, int i2, Test_ia32[] arr, int i3, int i4) {8687if (!(i1==1 && i2==2 && i3==3 && i4==4)) {88System.out.println("Bug!");89}9091return arr.length;92}9394static int f(Test_ia32[] arr) {95return g(1, 2, arr.clone(), 3, 4);96}9798@Override99public void run() {100Constructor[] ctrs = null;101Class<Test_ia32> klass = Test_ia32.class;102try {103ctrs = klass.getConstructors();104} catch (SecurityException e) {105System.out.println(e);106}107108try {109while (_doSpin) {110if (f(_tests) < 0)111System.out.println("return value usage");112}113} catch (NullPointerException e) {114e.printStackTrace();115}116117System.out.println(this + " - stopped.");118}119120public void requestStop() {121System.out.println(this + " - stop requested.");122_doSpin = false;123}124125}126127128