author | iignatyev |
Thu, 27 Mar 2014 11:17:26 +0400 | |
changeset 23499 | 9d5b7480c9f4 |
parent 23207 | fc39038d37dc |
child 25736 | 6f35dbe32581 |
permissions | -rw-r--r-- |
15621 | 1 |
/* |
23207
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
2 |
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
15621 | 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 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
24 |
import com.sun.management.HotSpotDiagnosticMXBean; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
25 |
import com.sun.management.VMOption; |
15621 | 26 |
import sun.hotspot.WhiteBox; |
23499 | 27 |
import sun.hotspot.code.NMethod; |
15621 | 28 |
import sun.management.ManagementFactoryHelper; |
29 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
30 |
import java.lang.reflect.Constructor; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
31 |
import java.lang.reflect.Executable; |
15621 | 32 |
import java.lang.reflect.Method; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
33 |
import java.util.Objects; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
34 |
import java.util.concurrent.Callable; |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
35 |
import java.util.function.Function; |
15621 | 36 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
37 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
38 |
* Abstract class for WhiteBox testing of JIT. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
39 |
* |
15621 | 40 |
* @author igor.ignatyev@oracle.com |
41 |
*/ |
|
42 |
public abstract class CompilerWhiteBoxTest { |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
43 |
/** {@code CompLevel::CompLevel_none} -- Interpreter */ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
44 |
protected static int COMP_LEVEL_NONE = 0; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
45 |
/** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
46 |
protected static int COMP_LEVEL_ANY = -1; |
17126
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
47 |
/** {@code CompLevel::CompLevel_simple} -- C1 */ |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
48 |
protected static int COMP_LEVEL_SIMPLE = 1; |
19332 | 49 |
/** {@code CompLevel::CompLevel_limited_profile} -- C1, invocation & backedge counters */ |
50 |
protected static int COMP_LEVEL_LIMITED_PROFILE = 2; |
|
51 |
/** {@code CompLevel::CompLevel_full_profile} -- C1, invocation & backedge counters + mdo */ |
|
52 |
protected static int COMP_LEVEL_FULL_PROFILE = 3; |
|
17126
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
53 |
/** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */ |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
54 |
protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4; |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
55 |
/** Maximal value for CompLevel */ |
19332 | 56 |
protected static int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION; |
17126
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
57 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
58 |
/** Instance of WhiteBox */ |
15621 | 59 |
protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
60 |
/** Value of {@code -XX:CompileThreshold} */ |
15621 | 61 |
protected static final int COMPILE_THRESHOLD |
62 |
= Integer.parseInt(getVMOption("CompileThreshold", "10000")); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
63 |
/** Value of {@code -XX:BackgroundCompilation} */ |
16367 | 64 |
protected static final boolean BACKGROUND_COMPILATION |
65 |
= Boolean.valueOf(getVMOption("BackgroundCompilation", "true")); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
66 |
/** Value of {@code -XX:TieredCompilation} */ |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
67 |
protected static final boolean TIERED_COMPILATION |
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
68 |
= Boolean.valueOf(getVMOption("TieredCompilation", "false")); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
69 |
/** Value of {@code -XX:TieredStopAtLevel} */ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
70 |
protected static final int TIERED_STOP_AT_LEVEL |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
71 |
= Integer.parseInt(getVMOption("TieredStopAtLevel", "0")); |
19282
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
72 |
/** Flag for verbose output, true if {@code -Dverbose} specified */ |
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
73 |
protected static final boolean IS_VERBOSE |
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
74 |
= System.getProperty("verbose") != null; |
19332 | 75 |
/** count of invocation to triger compilation */ |
76 |
protected static final int THRESHOLD; |
|
77 |
/** count of invocation to triger OSR compilation */ |
|
78 |
protected static final long BACKEDGE_THRESHOLD; |
|
20294
af95d17f2e04
8023452: TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
19332
diff
changeset
|
79 |
/** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */ |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
80 |
protected static final String MODE = System.getProperty("java.vm.info"); |
19332 | 81 |
|
82 |
static { |
|
83 |
if (TIERED_COMPILATION) { |
|
21091
588413a8426e
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
20294
diff
changeset
|
84 |
BACKEDGE_THRESHOLD = THRESHOLD = 150000; |
19332 | 85 |
} else { |
86 |
THRESHOLD = COMPILE_THRESHOLD; |
|
87 |
BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption( |
|
88 |
"OnStackReplacePercentage")); |
|
89 |
} |
|
90 |
} |
|
15621 | 91 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
92 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
93 |
* Returns value of VM option. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
94 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
95 |
* @param name option's name |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
96 |
* @return value of option or {@code null}, if option doesn't exist |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
97 |
* @throws NullPointerException if name is null |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
98 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
99 |
protected static String getVMOption(String name) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
100 |
Objects.requireNonNull(name); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
101 |
HotSpotDiagnosticMXBean diagnostic |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
102 |
= ManagementFactoryHelper.getDiagnosticMXBean(); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
103 |
VMOption tmp; |
15621 | 104 |
try { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
105 |
tmp = diagnostic.getVMOption(name); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
106 |
} catch (IllegalArgumentException e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
107 |
tmp = null; |
15621 | 108 |
} |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
109 |
return (tmp == null ? null : tmp.getValue()); |
15621 | 110 |
} |
111 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
112 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
113 |
* Returns value of VM option or default value. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
114 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
115 |
* @param name option's name |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
116 |
* @param defaultValue default value |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
117 |
* @return value of option or {@code defaultValue}, if option doesn't exist |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
118 |
* @throws NullPointerException if name is null |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
119 |
* @see #getVMOption(String) |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
120 |
*/ |
16367 | 121 |
protected static String getVMOption(String name, String defaultValue) { |
122 |
String result = getVMOption(name); |
|
15621 | 123 |
return result == null ? defaultValue : result; |
124 |
} |
|
125 |
||
17126
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
126 |
/** copy of is_c1_compile(int) from utilities/globalDefinitions.hpp */ |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
127 |
protected static boolean isC1Compile(int compLevel) { |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
128 |
return (compLevel > COMP_LEVEL_NONE) |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
129 |
&& (compLevel < COMP_LEVEL_FULL_OPTIMIZATION); |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
130 |
} |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
131 |
|
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
132 |
/** copy of is_c2_compile(int) from utilities/globalDefinitions.hpp */ |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
133 |
protected static boolean isC2Compile(int compLevel) { |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
134 |
return compLevel == COMP_LEVEL_FULL_OPTIMIZATION; |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
135 |
} |
42a942feeea2
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
17015
diff
changeset
|
136 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
137 |
protected static void main( |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
138 |
Function<TestCase, CompilerWhiteBoxTest> constructor, |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
139 |
String[] args) { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
140 |
if (args.length == 0) { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
141 |
for (TestCase test : SimpleTestCase.values()) { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
142 |
constructor.apply(test).runTest(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
143 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
144 |
} else { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
145 |
for (String name : args) { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
146 |
constructor.apply(SimpleTestCase.valueOf(name)).runTest(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
147 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
148 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
149 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
150 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
151 |
/** tested method */ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
152 |
protected final Executable method; |
19332 | 153 |
protected final TestCase testCase; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
154 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
155 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
156 |
* Constructor. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
157 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
158 |
* @param testCase object, that contains tested method and way to invoke it. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
159 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
160 |
protected CompilerWhiteBoxTest(TestCase testCase) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
161 |
Objects.requireNonNull(testCase); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
162 |
System.out.println("TEST CASE:" + testCase.name()); |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
163 |
method = testCase.getExecutable(); |
19332 | 164 |
this.testCase = testCase; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
165 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
166 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
167 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
168 |
* Template method for testing. Prints tested method's info before |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
169 |
* {@linkplain #test()} and after {@linkplain #test()} or on thrown |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
170 |
* exception. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
171 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
172 |
* @throws RuntimeException if method {@linkplain #test()} throws any |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
173 |
* exception |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
174 |
* @see #test() |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
175 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
176 |
protected final void runTest() { |
15621 | 177 |
if (ManagementFactoryHelper.getCompilationMXBean() == null) { |
178 |
System.err.println( |
|
179 |
"Warning: test is not applicable in interpreted mode"); |
|
180 |
return; |
|
181 |
} |
|
182 |
System.out.println("at test's start:"); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
183 |
printInfo(); |
15621 | 184 |
try { |
185 |
test(); |
|
186 |
} catch (Exception e) { |
|
187 |
System.out.printf("on exception '%s':", e.getMessage()); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
188 |
printInfo(); |
16367 | 189 |
e.printStackTrace(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
190 |
if (e instanceof RuntimeException) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
191 |
throw (RuntimeException) e; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
192 |
} |
15621 | 193 |
throw new RuntimeException(e); |
194 |
} |
|
195 |
System.out.println("at test's end:"); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
196 |
printInfo(); |
15621 | 197 |
} |
198 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
199 |
/** |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
200 |
* Checks, that {@linkplain #method} is not compiled at the given compilation |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
201 |
* level or above. |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
202 |
* |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
203 |
* @param compLevel |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
204 |
* |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
205 |
* @throws RuntimeException if {@linkplain #method} is in compiler queue or |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
206 |
* is compiled, or if {@linkplain #method} has zero |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
207 |
* compilation level. |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
208 |
*/ |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
209 |
|
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
210 |
protected final void checkNotCompiled(int compLevel) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
211 |
if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
212 |
throw new RuntimeException(method + " must not be in queue"); |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
213 |
} |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
214 |
if (WHITE_BOX.getMethodCompilationLevel(method, false) >= compLevel) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
215 |
throw new RuntimeException(method + " comp_level must be >= maxCompLevel"); |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
216 |
} |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
217 |
if (WHITE_BOX.getMethodCompilationLevel(method, true) >= compLevel) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
218 |
throw new RuntimeException(method + " osr_comp_level must be >= maxCompLevel"); |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
219 |
} |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
220 |
} |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
221 |
|
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
222 |
/** |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
223 |
* Checks, that {@linkplain #method} is not compiled. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
224 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
225 |
* @throws RuntimeException if {@linkplain #method} is in compiler queue or |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
226 |
* is compiled, or if {@linkplain #method} has zero |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
227 |
* compilation level. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
228 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
229 |
protected final void checkNotCompiled() { |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
230 |
if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
231 |
throw new RuntimeException(method + " must not be in queue"); |
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
232 |
} |
19332 | 233 |
if (WHITE_BOX.isMethodCompiled(method, false)) { |
15621 | 234 |
throw new RuntimeException(method + " must be not compiled"); |
235 |
} |
|
19332 | 236 |
if (WHITE_BOX.getMethodCompilationLevel(method, false) != 0) { |
15621 | 237 |
throw new RuntimeException(method + " comp_level must be == 0"); |
238 |
} |
|
19332 | 239 |
if (WHITE_BOX.isMethodCompiled(method, true)) { |
240 |
throw new RuntimeException(method + " must be not osr_compiled"); |
|
241 |
} |
|
242 |
if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) { |
|
243 |
throw new RuntimeException(method + " osr_comp_level must be == 0"); |
|
244 |
} |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
245 |
} |
15621 | 246 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
247 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
248 |
* Checks, that {@linkplain #method} is compiled. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
249 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
250 |
* @throws RuntimeException if {@linkplain #method} isn't in compiler queue |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
251 |
* and isn't compiled, or if {@linkplain #method} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
252 |
* has nonzero compilation level |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
253 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
254 |
protected final void checkCompiled() { |
15621 | 255 |
final long start = System.currentTimeMillis(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
256 |
waitBackgroundCompilation(); |
15621 | 257 |
if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
258 |
System.err.printf("Warning: %s is still in queue after %dms%n", |
|
259 |
method, System.currentTimeMillis() - start); |
|
260 |
return; |
|
261 |
} |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
262 |
if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) { |
19332 | 263 |
throw new RuntimeException(method + " must be " |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
264 |
+ (testCase.isOsr() ? "osr_" : "") + "compiled"); |
19332 | 265 |
} |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
266 |
if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr()) |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
267 |
== 0) { |
19332 | 268 |
throw new RuntimeException(method |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
269 |
+ (testCase.isOsr() ? " osr_" : " ") |
19332 | 270 |
+ "comp_level must be != 0"); |
271 |
} |
|
272 |
} |
|
273 |
||
274 |
protected final void deoptimize() { |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
275 |
WHITE_BOX.deoptimizeMethod(method, testCase.isOsr()); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
276 |
if (testCase.isOsr()) { |
19332 | 277 |
WHITE_BOX.deoptimizeMethod(method, false); |
15621 | 278 |
} |
19332 | 279 |
} |
280 |
||
281 |
protected final int getCompLevel() { |
|
23499 | 282 |
NMethod nm = NMethod.get(method, testCase.isOsr()); |
283 |
return nm == null ? COMP_LEVEL_NONE : nm.comp_level; |
|
19332 | 284 |
} |
285 |
||
286 |
protected final boolean isCompilable() { |
|
287 |
return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
288 |
testCase.isOsr()); |
19332 | 289 |
} |
290 |
||
291 |
protected final boolean isCompilable(int compLevel) { |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
292 |
return WHITE_BOX |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
293 |
.isMethodCompilable(method, compLevel, testCase.isOsr()); |
19332 | 294 |
} |
295 |
||
296 |
protected final void makeNotCompilable() { |
|
297 |
WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY, |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
298 |
testCase.isOsr()); |
19332 | 299 |
} |
300 |
||
301 |
protected final void makeNotCompilable(int compLevel) { |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
302 |
WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr()); |
15621 | 303 |
} |
304 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
305 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
306 |
* Waits for completion of background compilation of {@linkplain #method}. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
307 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
308 |
protected final void waitBackgroundCompilation() { |
16367 | 309 |
if (!BACKGROUND_COMPILATION) { |
310 |
return; |
|
311 |
} |
|
15621 | 312 |
final Object obj = new Object(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
313 |
for (int i = 0; i < 10 |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
314 |
&& WHITE_BOX.isMethodQueuedForCompilation(method); ++i) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
315 |
synchronized (obj) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
316 |
try { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
317 |
obj.wait(1000); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
318 |
} catch (InterruptedException e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
319 |
Thread.currentThread().interrupt(); |
15621 | 320 |
} |
321 |
} |
|
322 |
} |
|
323 |
} |
|
324 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
325 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
326 |
* Prints information about {@linkplain #method}. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
327 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
328 |
protected final void printInfo() { |
15621 | 329 |
System.out.printf("%n%s:%n", method); |
330 |
System.out.printf("\tcompilable:\t%b%n", |
|
19332 | 331 |
WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); |
15621 | 332 |
System.out.printf("\tcompiled:\t%b%n", |
19332 | 333 |
WHITE_BOX.isMethodCompiled(method, false)); |
15621 | 334 |
System.out.printf("\tcomp_level:\t%d%n", |
19332 | 335 |
WHITE_BOX.getMethodCompilationLevel(method, false)); |
336 |
System.out.printf("\tosr_compilable:\t%b%n", |
|
337 |
WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); |
|
338 |
System.out.printf("\tosr_compiled:\t%b%n", |
|
339 |
WHITE_BOX.isMethodCompiled(method, true)); |
|
340 |
System.out.printf("\tosr_comp_level:\t%d%n", |
|
341 |
WHITE_BOX.getMethodCompilationLevel(method, true)); |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
342 |
System.out.printf("\tin_queue:\t%b%n", |
15621 | 343 |
WHITE_BOX.isMethodQueuedForCompilation(method)); |
344 |
System.out.printf("compile_queues_size:\t%d%n%n", |
|
345 |
WHITE_BOX.getCompileQueuesSize()); |
|
346 |
} |
|
347 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
348 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
349 |
* Executes testing. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
350 |
*/ |
15621 | 351 |
protected abstract void test() throws Exception; |
352 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
353 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
354 |
* Tries to trigger compilation of {@linkplain #method} by call |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
355 |
* {@linkplain TestCase#getCallable()} enough times. |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
356 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
357 |
* @return accumulated result |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
358 |
* @see #compile(int) |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
359 |
*/ |
15621 | 360 |
protected final int compile() { |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
361 |
if (testCase.isOsr()) { |
19332 | 362 |
return compile(1); |
363 |
} else { |
|
364 |
return compile(THRESHOLD); |
|
365 |
} |
|
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
366 |
} |
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
367 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
368 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
369 |
* Tries to trigger compilation of {@linkplain #method} by call |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
370 |
* {@linkplain TestCase#getCallable()} specified times. |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
371 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
372 |
* @param count invocation count |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
373 |
* @return accumulated result |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
374 |
*/ |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
375 |
protected final int compile(int count) { |
15621 | 376 |
int result = 0; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
377 |
Integer tmp; |
16367 | 378 |
for (int i = 0; i < count; ++i) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
379 |
try { |
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
380 |
tmp = testCase.getCallable().call(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
381 |
} catch (Exception e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
382 |
tmp = null; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
383 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
384 |
result += tmp == null ? 0 : tmp; |
15621 | 385 |
} |
19282
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
386 |
if (IS_VERBOSE) { |
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
387 |
System.out.println("method was invoked " + count + " times"); |
9764b5a041b6
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
17126
diff
changeset
|
388 |
} |
15621 | 389 |
return result; |
390 |
} |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
391 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
392 |
/** |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
393 |
* Utility interface provides tested method and object to invoke it. |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
394 |
*/ |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
395 |
public interface TestCase { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
396 |
/** the name of test case */ |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
397 |
String name(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
398 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
399 |
/** tested method */ |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
400 |
Executable getExecutable(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
401 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
402 |
/** object to invoke {@linkplain #getExecutable()} */ |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
403 |
Callable<Integer> getCallable(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
404 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
405 |
/** flag for OSR test case */ |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
406 |
boolean isOsr(); |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
407 |
} |
23207
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
408 |
|
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
409 |
/** |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
410 |
* @return {@code true} if the current test case is OSR and the mode is |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
411 |
* Xcomp, otherwise {@code false} |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
412 |
*/ |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
413 |
protected boolean skipXcompOSR() { |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
414 |
boolean result = testCase.isOsr() |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
415 |
&& CompilerWhiteBoxTest.MODE.startsWith("compiled "); |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
416 |
if (result && IS_VERBOSE) { |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
417 |
System.err.printf("Warning: %s is not applicable in %s%n", |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
418 |
testCase.name(), CompilerWhiteBoxTest.MODE); |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
419 |
} |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
420 |
return result; |
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
421 |
} |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
422 |
} |
15621 | 423 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
424 |
enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
425 |
/** constructor test case */ |
19332 | 426 |
CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false), |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
427 |
/** method test case */ |
19332 | 428 |
METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false), |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
429 |
/** static method test case */ |
19332 | 430 |
STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), |
431 |
/** OSR constructor test case */ |
|
432 |
OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, |
|
433 |
Helper.OSR_CONSTRUCTOR_CALLABLE, true), |
|
21091
588413a8426e
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
20294
diff
changeset
|
434 |
/** OSR method test case */ |
19332 | 435 |
OSR_METOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), |
436 |
/** OSR static method test case */ |
|
437 |
OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
438 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
439 |
private final Executable executable; |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
440 |
private final Callable<Integer> callable; |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
441 |
private final boolean isOsr; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
442 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
443 |
private SimpleTestCase(Executable executable, Callable<Integer> callable, |
19332 | 444 |
boolean isOsr) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
445 |
this.executable = executable; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
446 |
this.callable = callable; |
19332 | 447 |
this.isOsr = isOsr; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
448 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
449 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
450 |
@Override |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
451 |
public Executable getExecutable() { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
452 |
return executable; |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
453 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
454 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
455 |
@Override |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
456 |
public Callable<Integer> getCallable() { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
457 |
return callable; |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
458 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
459 |
|
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
460 |
@Override |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
461 |
public boolean isOsr() { |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
462 |
return isOsr; |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
463 |
} |
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
21091
diff
changeset
|
464 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
465 |
private static class Helper { |
19332 | 466 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
467 |
private static final Callable<Integer> CONSTRUCTOR_CALLABLE |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
468 |
= new Callable<Integer>() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
469 |
@Override |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
470 |
public Integer call() throws Exception { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
471 |
return new Helper(1337).hashCode(); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
472 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
473 |
}; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
474 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
475 |
private static final Callable<Integer> METHOD_CALLABLE |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
476 |
= new Callable<Integer>() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
477 |
private final Helper helper = new Helper(); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
478 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
479 |
@Override |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
480 |
public Integer call() throws Exception { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
481 |
return helper.method(); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
482 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
483 |
}; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
484 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
485 |
private static final Callable<Integer> STATIC_CALLABLE |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
486 |
= new Callable<Integer>() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
487 |
@Override |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
488 |
public Integer call() throws Exception { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
489 |
return staticMethod(); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
490 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
491 |
}; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
492 |
|
19332 | 493 |
private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE |
494 |
= new Callable<Integer>() { |
|
495 |
@Override |
|
496 |
public Integer call() throws Exception { |
|
497 |
return new Helper(null).hashCode(); |
|
498 |
} |
|
499 |
}; |
|
500 |
||
501 |
private static final Callable<Integer> OSR_METHOD_CALLABLE |
|
502 |
= new Callable<Integer>() { |
|
503 |
private final Helper helper = new Helper(); |
|
504 |
||
505 |
@Override |
|
506 |
public Integer call() throws Exception { |
|
507 |
return helper.osrMethod(); |
|
508 |
} |
|
509 |
}; |
|
510 |
||
511 |
private static final Callable<Integer> OSR_STATIC_CALLABLE |
|
512 |
= new Callable<Integer>() { |
|
513 |
@Override |
|
514 |
public Integer call() throws Exception { |
|
515 |
return osrStaticMethod(); |
|
516 |
} |
|
517 |
}; |
|
518 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
519 |
private static final Constructor CONSTRUCTOR; |
19332 | 520 |
private static final Constructor OSR_CONSTRUCTOR; |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
521 |
private static final Method METHOD; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
522 |
private static final Method STATIC; |
19332 | 523 |
private static final Method OSR_METHOD; |
524 |
private static final Method OSR_STATIC; |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
525 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
526 |
static { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
527 |
try { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
528 |
CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
529 |
} catch (NoSuchMethodException | SecurityException e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
530 |
throw new RuntimeException( |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
531 |
"exception on getting method Helper.<init>(int)", e); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
532 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
533 |
try { |
19332 | 534 |
OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( |
535 |
Object.class); |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
536 |
} catch (NoSuchMethodException | SecurityException e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
537 |
throw new RuntimeException( |
19332 | 538 |
"exception on getting method Helper.<init>(Object)", e); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
539 |
} |
19332 | 540 |
METHOD = getMethod("method"); |
541 |
STATIC = getMethod("staticMethod"); |
|
542 |
OSR_METHOD = getMethod("osrMethod"); |
|
543 |
OSR_STATIC = getMethod("osrStaticMethod"); |
|
544 |
} |
|
545 |
||
546 |
private static Method getMethod(String name) { |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
547 |
try { |
19332 | 548 |
return Helper.class.getDeclaredMethod(name); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
549 |
} catch (NoSuchMethodException | SecurityException e) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
550 |
throw new RuntimeException( |
19332 | 551 |
"exception on getting method Helper." + name, e); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
552 |
} |
19332 | 553 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
554 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
555 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
556 |
private static int staticMethod() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
557 |
return 1138; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
558 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
559 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
560 |
private int method() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
561 |
return 42; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
562 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
563 |
|
19332 | 564 |
private static int osrStaticMethod() { |
565 |
int result = 0; |
|
566 |
for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { |
|
567 |
result += staticMethod(); |
|
568 |
} |
|
569 |
return result; |
|
570 |
} |
|
571 |
||
572 |
private int osrMethod() { |
|
573 |
int result = 0; |
|
574 |
for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { |
|
575 |
result += method(); |
|
576 |
} |
|
577 |
return result; |
|
578 |
} |
|
579 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
580 |
private final int x; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
581 |
|
19332 | 582 |
// for method and OSR method test case |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
583 |
public Helper() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
584 |
x = 0; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
585 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
586 |
|
19332 | 587 |
// for OSR constructor test case |
588 |
private Helper(Object o) { |
|
589 |
int result = 0; |
|
590 |
for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) { |
|
591 |
result += method(); |
|
592 |
} |
|
593 |
x = result; |
|
594 |
} |
|
595 |
||
596 |
// for constructor test case |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
597 |
private Helper(int x) { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
598 |
this.x = x; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
599 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
600 |
|
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
601 |
@Override |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
602 |
public int hashCode() { |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
603 |
return x; |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
604 |
} |
15621 | 605 |
} |
606 |
} |