comparison test/compiler/6589834/Test_ia32.java @ 730:9c6be3edf0dc

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