test/compiler/6589834/Test_ia32.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 6198
55fb97c4c58d
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

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

mercurial