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