Mercurial > hg > truffle
annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 17445:8cc283ce4bd1
Truffle: fix TraceTruffleCompilationAST.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Oct 2014 20:02:44 +0200 |
parents | 4ca6dc0799b6 |
children | 52b4284cb496 |
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; |
14909 | 53 /** Maximal value for CompLeveL */ |
12073 | 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; | |
12328
303826f477c6
8023452: TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
12073
diff
changeset
|
77 /** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */ |
14909 | 78 protected static final String MODE |
79 = System.getProperty("java.vm.info"); | |
12073 | 80 |
81 static { | |
82 if (TIERED_COMPILATION) { | |
12958
600c83f8e6a5
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
12328
diff
changeset
|
83 BACKEDGE_THRESHOLD = THRESHOLD = 150000; |
12073 | 84 } else { |
85 THRESHOLD = COMPILE_THRESHOLD; | |
86 BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption( | |
87 "OnStackReplacePercentage")); | |
88 } | |
89 } | |
8051 | 90 |
10113
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 * Returns value of VM option. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
93 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
94 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
95 * @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
|
96 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
97 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
98 protected static String getVMOption(String name) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
99 Objects.requireNonNull(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
100 HotSpotDiagnosticMXBean diagnostic |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
101 = ManagementFactoryHelper.getDiagnosticMXBean(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
102 VMOption tmp; |
8051 | 103 try { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
104 tmp = diagnostic.getVMOption(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
105 } catch (IllegalArgumentException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
106 tmp = null; |
8051 | 107 } |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
108 return (tmp == null ? null : tmp.getValue()); |
8051 | 109 } |
110 | |
10113
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 * Returns value of VM option or default value. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
113 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
114 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
115 * @param defaultValue default value |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
116 * @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
|
117 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
118 * @see #getVMOption(String) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
119 */ |
8766 | 120 protected static String getVMOption(String name, String defaultValue) { |
121 String result = getVMOption(name); | |
8051 | 122 return result == null ? defaultValue : result; |
123 } | |
124 | |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
125 /** 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
|
126 protected static boolean isC1Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
127 return (compLevel > COMP_LEVEL_NONE) |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
128 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION); |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
129 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
130 |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
131 /** 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
|
132 protected static boolean isC2Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
133 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION; |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
134 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
135 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
136 /** tested method */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
137 protected final Executable method; |
12073 | 138 protected final TestCase testCase; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
139 |
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 * Constructor. |
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 * @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
|
144 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
145 protected CompilerWhiteBoxTest(TestCase testCase) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
146 Objects.requireNonNull(testCase); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
147 System.out.println("TEST CASE:" + testCase.name()); |
14909 | 148 method = testCase.executable; |
12073 | 149 this.testCase = testCase; |
10113
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 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
152 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
153 * 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
|
154 * {@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
|
155 * exception. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
156 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
157 * @throws RuntimeException if method {@linkplain #test()} throws any |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
158 * exception |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
159 * @see #test() |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
160 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
161 protected final void runTest() { |
8051 | 162 if (ManagementFactoryHelper.getCompilationMXBean() == null) { |
163 System.err.println( | |
164 "Warning: test is not applicable in interpreted mode"); | |
165 return; | |
166 } | |
167 System.out.println("at test's start:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
168 printInfo(); |
8051 | 169 try { |
170 test(); | |
171 } catch (Exception e) { | |
172 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
|
173 printInfo(); |
8766 | 174 e.printStackTrace(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
175 if (e instanceof RuntimeException) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
176 throw (RuntimeException) e; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
177 } |
8051 | 178 throw new RuntimeException(e); |
179 } | |
180 System.out.println("at test's end:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
181 printInfo(); |
8051 | 182 } |
183 | |
10113
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 * Checks, that {@linkplain #method} is not compiled. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
186 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
187 * @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
|
188 * is compiled, or if {@linkplain #method} has zero |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
189 * compilation level. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
190 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
191 protected final void checkNotCompiled() { |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
192 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
193 throw new RuntimeException(method + " must not be in queue"); |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
194 } |
12073 | 195 if (WHITE_BOX.isMethodCompiled(method, false)) { |
8051 | 196 throw new RuntimeException(method + " must be not compiled"); |
197 } | |
12073 | 198 if (WHITE_BOX.getMethodCompilationLevel(method, false) != 0) { |
8051 | 199 throw new RuntimeException(method + " comp_level must be == 0"); |
200 } | |
12073 | 201 if (WHITE_BOX.isMethodCompiled(method, true)) { |
202 throw new RuntimeException(method + " must be not osr_compiled"); | |
203 } | |
204 if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) { | |
205 throw new RuntimeException(method + " osr_comp_level must be == 0"); | |
206 } | |
14909 | 207 } |
8051 | 208 |
10113
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 * Checks, that {@linkplain #method} is compiled. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
211 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
212 * @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
|
213 * and isn't compiled, or if {@linkplain #method} |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
214 * has nonzero compilation level |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
215 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
216 protected final void checkCompiled() { |
8051 | 217 final long start = System.currentTimeMillis(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
218 waitBackgroundCompilation(); |
8051 | 219 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
220 System.err.printf("Warning: %s is still in queue after %dms%n", | |
221 method, System.currentTimeMillis() - start); | |
222 return; | |
223 } | |
14909 | 224 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr)) { |
12073 | 225 throw new RuntimeException(method + " must be " |
14909 | 226 + (testCase.isOsr ? "osr_" : "") + "compiled"); |
12073 | 227 } |
14909 | 228 if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr) == 0) { |
12073 | 229 throw new RuntimeException(method |
14909 | 230 + (testCase.isOsr ? " osr_" : " ") |
12073 | 231 + "comp_level must be != 0"); |
232 } | |
233 } | |
234 | |
235 protected final void deoptimize() { | |
14909 | 236 WHITE_BOX.deoptimizeMethod(method, testCase.isOsr); |
237 if (testCase.isOsr) { | |
12073 | 238 WHITE_BOX.deoptimizeMethod(method, false); |
8051 | 239 } |
12073 | 240 } |
241 | |
242 protected final int getCompLevel() { | |
14909 | 243 return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr); |
12073 | 244 } |
245 | |
246 protected final boolean isCompilable() { | |
247 return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, | |
14909 | 248 testCase.isOsr); |
12073 | 249 } |
250 | |
251 protected final boolean isCompilable(int compLevel) { | |
14909 | 252 return WHITE_BOX.isMethodCompilable(method, compLevel, testCase.isOsr); |
12073 | 253 } |
254 | |
255 protected final void makeNotCompilable() { | |
256 WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY, | |
14909 | 257 testCase.isOsr); |
12073 | 258 } |
259 | |
260 protected final void makeNotCompilable(int compLevel) { | |
14909 | 261 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr); |
8051 | 262 } |
263 | |
10113
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 * 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
|
266 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
267 protected final void waitBackgroundCompilation() { |
8766 | 268 if (!BACKGROUND_COMPILATION) { |
269 return; | |
270 } | |
8051 | 271 final Object obj = new Object(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
272 for (int i = 0; i < 10 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
273 && WHITE_BOX.isMethodQueuedForCompilation(method); ++i) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
274 synchronized (obj) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
275 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
276 obj.wait(1000); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
277 } catch (InterruptedException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
278 Thread.currentThread().interrupt(); |
8051 | 279 } |
280 } | |
281 } | |
282 } | |
283 | |
10113
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 * Prints information about {@linkplain #method}. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
286 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
287 protected final void printInfo() { |
8051 | 288 System.out.printf("%n%s:%n", method); |
289 System.out.printf("\tcompilable:\t%b%n", | |
12073 | 290 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); |
8051 | 291 System.out.printf("\tcompiled:\t%b%n", |
12073 | 292 WHITE_BOX.isMethodCompiled(method, false)); |
8051 | 293 System.out.printf("\tcomp_level:\t%d%n", |
12073 | 294 WHITE_BOX.getMethodCompilationLevel(method, false)); |
295 System.out.printf("\tosr_compilable:\t%b%n", | |
296 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); | |
297 System.out.printf("\tosr_compiled:\t%b%n", | |
298 WHITE_BOX.isMethodCompiled(method, true)); | |
299 System.out.printf("\tosr_comp_level:\t%d%n", | |
300 WHITE_BOX.getMethodCompilationLevel(method, true)); | |
14909 | 301 System.out.printf("\tin_queue:\t%b%n", |
8051 | 302 WHITE_BOX.isMethodQueuedForCompilation(method)); |
303 System.out.printf("compile_queues_size:\t%d%n%n", | |
304 WHITE_BOX.getCompileQueuesSize()); | |
305 } | |
306 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
307 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
308 * Executes testing. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
309 */ |
8051 | 310 protected abstract void test() throws Exception; |
311 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
312 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
313 * Tries to trigger compilation of {@linkplain #method} by call |
14909 | 314 * {@linkplain #testCase.callable} enough times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
315 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
316 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
317 * @see #compile(int) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
318 */ |
8051 | 319 protected final int compile() { |
14909 | 320 if (testCase.isOsr) { |
12073 | 321 return compile(1); |
322 } else { | |
323 return compile(THRESHOLD); | |
324 } | |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
325 } |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
326 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
327 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
328 * Tries to trigger compilation of {@linkplain #method} by call |
14909 | 329 * {@linkplain #testCase.callable} specified times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
330 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
331 * @param count invocation count |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
332 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
333 */ |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
334 protected final int compile(int count) { |
8051 | 335 int result = 0; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
336 Integer tmp; |
8766 | 337 for (int i = 0; i < count; ++i) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
338 try { |
14909 | 339 tmp = testCase.callable.call(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
340 } catch (Exception e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
341 tmp = null; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
342 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
343 result += tmp == null ? 0 : tmp; |
8051 | 344 } |
12026
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
345 if (IS_VERBOSE) { |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
346 System.out.println("method was invoked " + count + " times"); |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
347 } |
8051 | 348 return result; |
349 } | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
350 } |
8051 | 351 |
14909 | 352 /** |
353 * Utility structure containing tested method and object to invoke it. | |
354 */ | |
355 enum TestCase { | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
356 /** constructor test case */ |
12073 | 357 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
|
358 /** method test case */ |
12073 | 359 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
|
360 /** static method test case */ |
12073 | 361 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), |
14909 | 362 |
12073 | 363 /** OSR constructor test case */ |
364 OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, | |
365 Helper.OSR_CONSTRUCTOR_CALLABLE, true), | |
12958
600c83f8e6a5
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
12328
diff
changeset
|
366 /** OSR method test case */ |
12073 | 367 OSR_METOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), |
368 /** OSR static method test case */ | |
369 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
|
370 |
14909 | 371 /** tested method */ |
372 final Executable executable; | |
373 /** object to invoke {@linkplain #executable} */ | |
374 final Callable<Integer> callable; | |
375 /** flag for OSR test case */ | |
376 final boolean isOsr; | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
377 |
14909 | 378 private TestCase(Executable executable, Callable<Integer> callable, |
12073 | 379 boolean isOsr) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
380 this.executable = executable; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
381 this.callable = callable; |
12073 | 382 this.isOsr = isOsr; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
383 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
384 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
385 private static class Helper { |
12073 | 386 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
387 private static final Callable<Integer> CONSTRUCTOR_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
388 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
389 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
390 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
391 return new Helper(1337).hashCode(); |
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 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
394 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
395 private static final Callable<Integer> METHOD_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
396 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
397 private final Helper helper = new Helper(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
398 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
399 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
400 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
401 return helper.method(); |
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 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
404 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
405 private static final Callable<Integer> STATIC_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
406 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
407 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
408 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
409 return staticMethod(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
410 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
411 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
412 |
12073 | 413 private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE |
414 = new Callable<Integer>() { | |
415 @Override | |
416 public Integer call() throws Exception { | |
417 return new Helper(null).hashCode(); | |
418 } | |
419 }; | |
420 | |
421 private static final Callable<Integer> OSR_METHOD_CALLABLE | |
422 = new Callable<Integer>() { | |
423 private final Helper helper = new Helper(); | |
424 | |
425 @Override | |
426 public Integer call() throws Exception { | |
427 return helper.osrMethod(); | |
428 } | |
429 }; | |
430 | |
431 private static final Callable<Integer> OSR_STATIC_CALLABLE | |
432 = new Callable<Integer>() { | |
433 @Override | |
434 public Integer call() throws Exception { | |
435 return osrStaticMethod(); | |
436 } | |
437 }; | |
438 | |
14909 | 439 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
440 private static final Constructor CONSTRUCTOR; |
12073 | 441 private static final Constructor OSR_CONSTRUCTOR; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
442 private static final Method METHOD; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
443 private static final Method STATIC; |
12073 | 444 private static final Method OSR_METHOD; |
445 private static final Method OSR_STATIC; | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
446 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
447 static { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
448 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
449 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
450 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
451 throw new RuntimeException( |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
452 "exception on getting method Helper.<init>(int)", e); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
453 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
454 try { |
12073 | 455 OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( |
456 Object.class); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
457 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
458 throw new RuntimeException( |
12073 | 459 "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
|
460 } |
12073 | 461 METHOD = getMethod("method"); |
462 STATIC = getMethod("staticMethod"); | |
463 OSR_METHOD = getMethod("osrMethod"); | |
464 OSR_STATIC = getMethod("osrStaticMethod"); | |
465 } | |
466 | |
467 private static Method getMethod(String name) { | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
468 try { |
12073 | 469 return Helper.class.getDeclaredMethod(name); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
470 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
471 throw new RuntimeException( |
12073 | 472 "exception on getting method Helper." + name, e); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
473 } |
12073 | 474 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
475 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
476 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
477 private static int staticMethod() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
478 return 1138; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
479 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
480 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
481 private int method() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
482 return 42; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
483 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
484 |
12073 | 485 private static int osrStaticMethod() { |
486 int result = 0; | |
487 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
488 result += staticMethod(); | |
489 } | |
490 return result; | |
491 } | |
492 | |
493 private int osrMethod() { | |
494 int result = 0; | |
495 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
496 result += method(); | |
497 } | |
498 return result; | |
499 } | |
500 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
501 private final int x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
502 |
12073 | 503 // for method and OSR method test case |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
504 public Helper() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
505 x = 0; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
506 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
507 |
12073 | 508 // for OSR constructor test case |
509 private Helper(Object o) { | |
510 int result = 0; | |
511 for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { | |
512 result += method(); | |
513 } | |
514 x = result; | |
515 } | |
516 | |
517 // for constructor test case | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
518 private Helper(int x) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
519 this.x = x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
520 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
521 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
522 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
523 public int hashCode() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
524 return x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
525 } |
8051 | 526 } |
527 } |