test/compiler/6589834/Test_ia32.java

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 */
aoqi@0 23
aoqi@0 24 /**
aoqi@0 25 * @test
aoqi@0 26 * @bug 6589834
aoqi@0 27 * @summary deoptimization problem with -XX:+DeoptimizeALot
aoqi@0 28 *
aoqi@0 29 * @run main Test_ia32
aoqi@0 30 */
aoqi@0 31
aoqi@0 32 /***************************************************************************************
aoqi@0 33 NOTE: The bug shows up (with several "Bug!" message) even without the
aoqi@0 34 flag -XX:+DeoptimizeALot. In a debug build, you may want to try
aoqi@0 35 the flags -XX:+VerifyStack and -XX:+DeoptimizeALot to get more information.
aoqi@0 36 ****************************************************************************************/
aoqi@0 37 import java.lang.reflect.Constructor;
aoqi@0 38
aoqi@0 39 public class Test_ia32 {
aoqi@0 40
aoqi@0 41 public static int NUM_THREADS = 100;
aoqi@0 42
aoqi@0 43 public static int CLONE_LENGTH = 1000;
aoqi@0 44
aoqi@0 45 public static void main(String[] args) throws InterruptedException, ClassNotFoundException {
aoqi@0 46
aoqi@0 47 Reflector[] threads = new Reflector[NUM_THREADS];
aoqi@0 48 for (int i = 0; i < threads.length; i++) {
aoqi@0 49 threads[i] = new Reflector();
aoqi@0 50 threads[i].start();
aoqi@0 51 }
aoqi@0 52
aoqi@0 53 System.out.println("Give Reflector.run() some time to compile...");
aoqi@0 54 Thread.sleep(5000);
aoqi@0 55
aoqi@0 56 System.out.println("Load RMISecurityException causing run() deoptimization");
aoqi@0 57 ClassLoader.getSystemClassLoader().loadClass("java.rmi.RMISecurityException");
aoqi@0 58
aoqi@0 59 for (Reflector thread : threads)
aoqi@0 60 thread.requestStop();
aoqi@0 61
aoqi@0 62 for (Reflector thread : threads)
aoqi@0 63 try {
aoqi@0 64 thread.join();
aoqi@0 65 } catch (InterruptedException e) {
aoqi@0 66 System.out.println(e);
aoqi@0 67 }
aoqi@0 68
aoqi@0 69 }
aoqi@0 70
aoqi@0 71 }
aoqi@0 72
aoqi@0 73 class Reflector extends Thread {
aoqi@0 74
aoqi@0 75 volatile boolean _doSpin = true;
aoqi@0 76
aoqi@0 77 Test_ia32[] _tests;
aoqi@0 78
aoqi@0 79 Reflector() {
aoqi@0 80 _tests = new Test_ia32[Test_ia32.CLONE_LENGTH];
aoqi@0 81 for (int i = 0; i < _tests.length; i++) {
aoqi@0 82 _tests[i] = new Test_ia32();
aoqi@0 83 }
aoqi@0 84 }
aoqi@0 85
aoqi@0 86 static int g(int i1, int i2, Test_ia32[] arr, int i3, int i4) {
aoqi@0 87
aoqi@0 88 if (!(i1==1 && i2==2 && i3==3 && i4==4)) {
aoqi@0 89 System.out.println("Bug!");
aoqi@0 90 }
aoqi@0 91
aoqi@0 92 return arr.length;
aoqi@0 93 }
aoqi@0 94
aoqi@0 95 static int f(Test_ia32[] arr) {
aoqi@0 96 return g(1, 2, arr.clone(), 3, 4);
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 @Override
aoqi@0 100 public void run() {
aoqi@0 101 Constructor[] ctrs = null;
aoqi@0 102 Class<Test_ia32> klass = Test_ia32.class;
aoqi@0 103 try {
aoqi@0 104 ctrs = klass.getConstructors();
aoqi@0 105 } catch (SecurityException e) {
aoqi@0 106 System.out.println(e);
aoqi@0 107 }
aoqi@0 108
aoqi@0 109 try {
aoqi@0 110 while (_doSpin) {
aoqi@0 111 if (f(_tests) < 0)
aoqi@0 112 System.out.println("return value usage");
aoqi@0 113 }
aoqi@0 114 } catch (NullPointerException e) {
aoqi@0 115 e.printStackTrace();
aoqi@0 116 }
aoqi@0 117
aoqi@0 118 System.out.println(this + " - stopped.");
aoqi@0 119 }
aoqi@0 120
aoqi@0 121 public void requestStop() {
aoqi@0 122 System.out.println(this + " - stop requested.");
aoqi@0 123 _doSpin = false;
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 }

mercurial