Mercurial > hg > truffle
annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 12273:fff4842215d1
Added tag jdk8-b109 for changeset c81dd5393a5e
author | cl |
---|---|
date | Thu, 26 Sep 2013 10:43:15 -0700 |
parents | f99558245e5c |
children | 303826f477c6 |
rev | line source |
---|---|
8051 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
24 import com.sun.management.HotSpotDiagnosticMXBean; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
25 import com.sun.management.VMOption; |
8051 | 26 import sun.hotspot.WhiteBox; |
27 import sun.management.ManagementFactoryHelper; | |
28 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
29 import java.lang.reflect.Constructor; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
30 import java.lang.reflect.Executable; |
8051 | 31 import java.lang.reflect.Method; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
32 import java.util.Objects; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
33 import java.util.concurrent.Callable; |
8051 | 34 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
35 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
36 * Abstract class for WhiteBox testing of JIT. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
37 * |
8051 | 38 * @author igor.ignatyev@oracle.com |
39 */ | |
40 public abstract class CompilerWhiteBoxTest { | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
41 /** {@code CompLevel::CompLevel_none} -- Interpreter */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
42 protected static int COMP_LEVEL_NONE = 0; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
43 /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
44 protected static int COMP_LEVEL_ANY = -1; |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
45 /** {@code CompLevel::CompLevel_simple} -- C1 */ |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
46 protected static int COMP_LEVEL_SIMPLE = 1; |
12073 | 47 /** {@code CompLevel::CompLevel_limited_profile} -- C1, invocation & backedge counters */ |
48 protected static int COMP_LEVEL_LIMITED_PROFILE = 2; | |
49 /** {@code CompLevel::CompLevel_full_profile} -- C1, invocation & backedge counters + mdo */ | |
50 protected static int COMP_LEVEL_FULL_PROFILE = 3; | |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
51 /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */ |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
52 protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4; |
12073 | 53 /** Maximal value for CompLeveL */ |
54 protected static int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION; | |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
55 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
56 /** Instance of WhiteBox */ |
8051 | 57 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
58 /** Value of {@code -XX:CompileThreshold} */ |
8051 | 59 protected static final int COMPILE_THRESHOLD |
60 = Integer.parseInt(getVMOption("CompileThreshold", "10000")); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
61 /** Value of {@code -XX:BackgroundCompilation} */ |
8766 | 62 protected static final boolean BACKGROUND_COMPILATION |
63 = Boolean.valueOf(getVMOption("BackgroundCompilation", "true")); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
64 /** Value of {@code -XX:TieredCompilation} */ |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
65 protected static final boolean TIERED_COMPILATION |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
66 = Boolean.valueOf(getVMOption("TieredCompilation", "false")); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
67 /** Value of {@code -XX:TieredStopAtLevel} */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
68 protected static final int TIERED_STOP_AT_LEVEL |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
69 = Integer.parseInt(getVMOption("TieredStopAtLevel", "0")); |
12026
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
70 /** Flag for verbose output, true if {@code -Dverbose} specified */ |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
71 protected static final boolean IS_VERBOSE |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
72 = System.getProperty("verbose") != null; |
12073 | 73 /** count of invocation to triger compilation */ |
74 protected static final int THRESHOLD; | |
75 /** count of invocation to triger OSR compilation */ | |
76 protected static final long BACKEDGE_THRESHOLD; | |
77 | |
78 static { | |
79 if (TIERED_COMPILATION) { | |
80 THRESHOLD = 150000; | |
81 BACKEDGE_THRESHOLD = 0xFFFFFFFFL; | |
82 } else { | |
83 THRESHOLD = COMPILE_THRESHOLD; | |
84 BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption( | |
85 "OnStackReplacePercentage")); | |
86 } | |
87 } | |
8051 | 88 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
89 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
90 * Returns value of VM option. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
91 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
92 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
93 * @return value of option or {@code null}, if option doesn't exist |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
94 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
95 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
96 protected static String getVMOption(String name) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
97 Objects.requireNonNull(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
98 HotSpotDiagnosticMXBean diagnostic |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
99 = ManagementFactoryHelper.getDiagnosticMXBean(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
100 VMOption tmp; |
8051 | 101 try { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
102 tmp = diagnostic.getVMOption(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
103 } catch (IllegalArgumentException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
104 tmp = null; |
8051 | 105 } |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
106 return (tmp == null ? null : tmp.getValue()); |
8051 | 107 } |
108 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
109 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
110 * Returns value of VM option or default value. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
111 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
112 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
113 * @param defaultValue default value |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
114 * @return value of option or {@code defaultValue}, if option doesn't exist |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
115 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
116 * @see #getVMOption(String) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
117 */ |
8766 | 118 protected static String getVMOption(String name, String defaultValue) { |
119 String result = getVMOption(name); | |
8051 | 120 return result == null ? defaultValue : result; |
121 } | |
122 | |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
123 /** copy of is_c1_compile(int) from utilities/globalDefinitions.hpp */ |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
124 protected static boolean isC1Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
125 return (compLevel > COMP_LEVEL_NONE) |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
126 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION); |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
127 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
128 |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
129 /** copy of is_c2_compile(int) from utilities/globalDefinitions.hpp */ |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
130 protected static boolean isC2Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
131 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION; |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
132 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
133 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
134 /** tested method */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
135 protected final Executable method; |
12073 | 136 protected final TestCase testCase; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
137 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
138 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
139 * Constructor. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
140 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
141 * @param testCase object, that contains tested method and way to invoke it. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
142 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
143 protected CompilerWhiteBoxTest(TestCase testCase) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
144 Objects.requireNonNull(testCase); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
145 System.out.println("TEST CASE:" + testCase.name()); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
146 method = testCase.executable; |
12073 | 147 this.testCase = testCase; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
148 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
149 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
150 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
151 * Template method for testing. Prints tested method's info before |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
152 * {@linkplain #test()} and after {@linkplain #test()} or on thrown |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
153 * exception. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
154 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
155 * @throws RuntimeException if method {@linkplain #test()} throws any |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
156 * exception |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
157 * @see #test() |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
158 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
159 protected final void runTest() { |
8051 | 160 if (ManagementFactoryHelper.getCompilationMXBean() == null) { |
161 System.err.println( | |
162 "Warning: test is not applicable in interpreted mode"); | |
163 return; | |
164 } | |
165 System.out.println("at test's start:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
166 printInfo(); |
8051 | 167 try { |
168 test(); | |
169 } catch (Exception e) { | |
170 System.out.printf("on exception '%s':", e.getMessage()); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
171 printInfo(); |
8766 | 172 e.printStackTrace(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
173 if (e instanceof RuntimeException) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
174 throw (RuntimeException) e; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
175 } |
8051 | 176 throw new RuntimeException(e); |
177 } | |
178 System.out.println("at test's end:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
179 printInfo(); |
8051 | 180 } |
181 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
182 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
183 * Checks, that {@linkplain #method} is not compiled. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
184 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
185 * @throws RuntimeException if {@linkplain #method} is in compiler queue or |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
186 * is compiled, or if {@linkplain #method} has zero |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
187 * compilation level. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
188 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
189 protected final void checkNotCompiled() { |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
190 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
191 throw new RuntimeException(method + " must not be in queue"); |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
192 } |
12073 | 193 if (WHITE_BOX.isMethodCompiled(method, false)) { |
8051 | 194 throw new RuntimeException(method + " must be not compiled"); |
195 } | |
12073 | 196 if (WHITE_BOX.getMethodCompilationLevel(method, false) != 0) { |
8051 | 197 throw new RuntimeException(method + " comp_level must be == 0"); |
198 } | |
12073 | 199 if (WHITE_BOX.isMethodCompiled(method, true)) { |
200 throw new RuntimeException(method + " must be not osr_compiled"); | |
201 } | |
202 if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) { | |
203 throw new RuntimeException(method + " osr_comp_level must be == 0"); | |
204 } | |
8051 | 205 } |
206 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
207 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
208 * Checks, that {@linkplain #method} is compiled. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
209 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
210 * @throws RuntimeException if {@linkplain #method} isn't in compiler queue |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
211 * and isn't compiled, or if {@linkplain #method} |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
212 * has nonzero compilation level |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
213 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
214 protected final void checkCompiled() { |
8051 | 215 final long start = System.currentTimeMillis(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
216 waitBackgroundCompilation(); |
8051 | 217 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
218 System.err.printf("Warning: %s is still in queue after %dms%n", | |
219 method, System.currentTimeMillis() - start); | |
220 return; | |
221 } | |
12073 | 222 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr)) { |
223 throw new RuntimeException(method + " must be " | |
224 + (testCase.isOsr ? "osr_" : "") + "compiled"); | |
225 } | |
226 if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr) == 0) { | |
227 throw new RuntimeException(method | |
228 + (testCase.isOsr ? " osr_" : " ") | |
229 + "comp_level must be != 0"); | |
230 } | |
231 } | |
232 | |
233 protected final void deoptimize() { | |
234 WHITE_BOX.deoptimizeMethod(method, testCase.isOsr); | |
235 if (testCase.isOsr) { | |
236 WHITE_BOX.deoptimizeMethod(method, false); | |
8051 | 237 } |
12073 | 238 } |
239 | |
240 protected final int getCompLevel() { | |
241 return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr); | |
242 } | |
243 | |
244 protected final boolean isCompilable() { | |
245 return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, | |
246 testCase.isOsr); | |
247 } | |
248 | |
249 protected final boolean isCompilable(int compLevel) { | |
250 return WHITE_BOX.isMethodCompilable(method, compLevel, testCase.isOsr); | |
251 } | |
252 | |
253 protected final void makeNotCompilable() { | |
254 WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY, | |
255 testCase.isOsr); | |
256 } | |
257 | |
258 protected final void makeNotCompilable(int compLevel) { | |
259 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr); | |
8051 | 260 } |
261 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
262 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
263 * Waits for completion of background compilation of {@linkplain #method}. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
264 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
265 protected final void waitBackgroundCompilation() { |
8766 | 266 if (!BACKGROUND_COMPILATION) { |
267 return; | |
268 } | |
8051 | 269 final Object obj = new Object(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
270 for (int i = 0; i < 10 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
271 && WHITE_BOX.isMethodQueuedForCompilation(method); ++i) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
272 synchronized (obj) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
273 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
274 obj.wait(1000); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
275 } catch (InterruptedException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
276 Thread.currentThread().interrupt(); |
8051 | 277 } |
278 } | |
279 } | |
280 } | |
281 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
282 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
283 * Prints information about {@linkplain #method}. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
284 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
285 protected final void printInfo() { |
8051 | 286 System.out.printf("%n%s:%n", method); |
287 System.out.printf("\tcompilable:\t%b%n", | |
12073 | 288 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); |
8051 | 289 System.out.printf("\tcompiled:\t%b%n", |
12073 | 290 WHITE_BOX.isMethodCompiled(method, false)); |
8051 | 291 System.out.printf("\tcomp_level:\t%d%n", |
12073 | 292 WHITE_BOX.getMethodCompilationLevel(method, false)); |
293 System.out.printf("\tosr_compilable:\t%b%n", | |
294 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); | |
295 System.out.printf("\tosr_compiled:\t%b%n", | |
296 WHITE_BOX.isMethodCompiled(method, true)); | |
297 System.out.printf("\tosr_comp_level:\t%d%n", | |
298 WHITE_BOX.getMethodCompilationLevel(method, true)); | |
299 System.out.printf("\tin_queue:\t%b%n", | |
8051 | 300 WHITE_BOX.isMethodQueuedForCompilation(method)); |
301 System.out.printf("compile_queues_size:\t%d%n%n", | |
302 WHITE_BOX.getCompileQueuesSize()); | |
303 } | |
304 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
305 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
306 * Executes testing. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
307 */ |
8051 | 308 protected abstract void test() throws Exception; |
309 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
310 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
311 * Tries to trigger compilation of {@linkplain #method} by call |
12073 | 312 * {@linkplain #testCase.callable} enough times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
313 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
314 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
315 * @see #compile(int) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
316 */ |
8051 | 317 protected final int compile() { |
12073 | 318 if (testCase.isOsr) { |
319 return compile(1); | |
320 } else { | |
321 return compile(THRESHOLD); | |
322 } | |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
323 } |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
324 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
325 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
326 * Tries to trigger compilation of {@linkplain #method} by call |
12073 | 327 * {@linkplain #testCase.callable} specified times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
328 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
329 * @param count invocation count |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
330 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
331 */ |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
332 protected final int compile(int count) { |
8051 | 333 int result = 0; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
334 Integer tmp; |
8766 | 335 for (int i = 0; i < count; ++i) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
336 try { |
12073 | 337 tmp = testCase.callable.call(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
338 } catch (Exception e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
339 tmp = null; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
340 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
341 result += tmp == null ? 0 : tmp; |
8051 | 342 } |
12026
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
343 if (IS_VERBOSE) { |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
344 System.out.println("method was invoked " + count + " times"); |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
345 } |
8051 | 346 return result; |
347 } | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
348 } |
8051 | 349 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
350 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
351 * Utility structure containing tested method and object to invoke it. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
352 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
353 enum TestCase { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
354 /** constructor test case */ |
12073 | 355 CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false), |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
356 /** method test case */ |
12073 | 357 METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false), |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
358 /** static method test case */ |
12073 | 359 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), |
360 | |
361 /** OSR constructor test case */ | |
362 OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, | |
363 Helper.OSR_CONSTRUCTOR_CALLABLE, true), | |
364 /** OSR method test case */ | |
365 OSR_METOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), | |
366 /** OSR static method test case */ | |
367 OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
368 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
369 /** tested method */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
370 final Executable executable; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
371 /** object to invoke {@linkplain #executable} */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
372 final Callable<Integer> callable; |
12073 | 373 /** flag for OSR test case */ |
374 final boolean isOsr; | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
375 |
12073 | 376 private TestCase(Executable executable, Callable<Integer> callable, |
377 boolean isOsr) { | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
378 this.executable = executable; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
379 this.callable = callable; |
12073 | 380 this.isOsr = isOsr; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
381 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
382 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
383 private static class Helper { |
12073 | 384 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
385 private static final Callable<Integer> CONSTRUCTOR_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
386 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
387 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
388 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
389 return new Helper(1337).hashCode(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
390 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
391 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
392 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
393 private static final Callable<Integer> METHOD_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
394 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
395 private final Helper helper = new Helper(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
396 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
397 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
398 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
399 return helper.method(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
400 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
401 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
402 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
403 private static final Callable<Integer> STATIC_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
404 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
405 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
406 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
407 return staticMethod(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
408 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
409 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
410 |
12073 | 411 private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE |
412 = new Callable<Integer>() { | |
413 @Override | |
414 public Integer call() throws Exception { | |
415 return new Helper(null).hashCode(); | |
416 } | |
417 }; | |
418 | |
419 private static final Callable<Integer> OSR_METHOD_CALLABLE | |
420 = new Callable<Integer>() { | |
421 private final Helper helper = new Helper(); | |
422 | |
423 @Override | |
424 public Integer call() throws Exception { | |
425 return helper.osrMethod(); | |
426 } | |
427 }; | |
428 | |
429 private static final Callable<Integer> OSR_STATIC_CALLABLE | |
430 = new Callable<Integer>() { | |
431 @Override | |
432 public Integer call() throws Exception { | |
433 return osrStaticMethod(); | |
434 } | |
435 }; | |
436 | |
437 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
438 private static final Constructor CONSTRUCTOR; |
12073 | 439 private static final Constructor OSR_CONSTRUCTOR; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
440 private static final Method METHOD; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
441 private static final Method STATIC; |
12073 | 442 private static final Method OSR_METHOD; |
443 private static final Method OSR_STATIC; | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
444 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
445 static { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
446 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
447 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
448 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
449 throw new RuntimeException( |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
450 "exception on getting method Helper.<init>(int)", e); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
451 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
452 try { |
12073 | 453 OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( |
454 Object.class); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
455 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
456 throw new RuntimeException( |
12073 | 457 "exception on getting method Helper.<init>(Object)", e); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
458 } |
12073 | 459 METHOD = getMethod("method"); |
460 STATIC = getMethod("staticMethod"); | |
461 OSR_METHOD = getMethod("osrMethod"); | |
462 OSR_STATIC = getMethod("osrStaticMethod"); | |
463 } | |
464 | |
465 private static Method getMethod(String name) { | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
466 try { |
12073 | 467 return Helper.class.getDeclaredMethod(name); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
468 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
469 throw new RuntimeException( |
12073 | 470 "exception on getting method Helper." + name, e); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
471 } |
12073 | 472 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
473 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
474 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
475 private static int staticMethod() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
476 return 1138; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
477 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
478 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
479 private int method() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
480 return 42; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
481 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
482 |
12073 | 483 private static int osrStaticMethod() { |
484 int result = 0; | |
485 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
486 result += staticMethod(); | |
487 } | |
488 return result; | |
489 } | |
490 | |
491 private int osrMethod() { | |
492 int result = 0; | |
493 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
494 result += method(); | |
495 } | |
496 return result; | |
497 } | |
498 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
499 private final int x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
500 |
12073 | 501 // for method and OSR method test case |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
502 public Helper() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
503 x = 0; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
504 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
505 |
12073 | 506 // for OSR constructor test case |
507 private Helper(Object o) { | |
508 int result = 0; | |
509 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
510 result += method(); | |
511 } | |
512 x = result; | |
513 } | |
514 | |
515 // for constructor test case | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
516 private Helper(int x) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
517 this.x = x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
518 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
519 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
520 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
521 public int hashCode() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
522 return x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
523 } |
8051 | 524 } |
525 } |