Mercurial > hg > truffle
annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 20604:c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
Summary: Added code to 'warm up' the methods before triggering OSR compilation by executing them a limited number of times. Like this, the profile information marks the loop exit as taken and we don't add an uncommon trap.
Reviewed-by: kvn, dlong, iignatyev
author | thartmann |
---|---|
date | Mon, 13 Oct 2014 12:30:37 +0200 |
parents | 5e6f84e7a942 |
children | 564d97997064 |
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; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
75 /** invocation count to trigger compilation */ |
12073 | 76 protected static final int THRESHOLD; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
77 /** invocation count to trigger OSR compilation */ |
12073 | 78 protected static final long BACKEDGE_THRESHOLD; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
79 /** invocation count to warm up method before triggering OSR compilation */ |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
80 protected static final long OSR_WARMUP = 2000; |
12328
303826f477c6
8023452: TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
12073
diff
changeset
|
81 /** 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
|
82 protected static final String MODE = System.getProperty("java.vm.info"); |
12073 | 83 |
84 static { | |
85 if (TIERED_COMPILATION) { | |
12958
600c83f8e6a5
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
12328
diff
changeset
|
86 BACKEDGE_THRESHOLD = THRESHOLD = 150000; |
12073 | 87 } else { |
88 THRESHOLD = COMPILE_THRESHOLD; | |
89 BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption( | |
90 "OnStackReplacePercentage")); | |
91 } | |
92 } | |
8051 | 93 |
10113
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 * Returns value of VM option. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
96 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
97 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
98 * @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
|
99 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
100 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
101 protected static String getVMOption(String name) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
102 Objects.requireNonNull(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
103 HotSpotDiagnosticMXBean diagnostic |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
104 = ManagementFactoryHelper.getDiagnosticMXBean(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
105 VMOption tmp; |
8051 | 106 try { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
107 tmp = diagnostic.getVMOption(name); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
108 } catch (IllegalArgumentException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
109 tmp = null; |
8051 | 110 } |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
111 return (tmp == null ? null : tmp.getValue()); |
8051 | 112 } |
113 | |
10113
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 * Returns value of VM option or default value. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
116 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
117 * @param name option's name |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
118 * @param defaultValue default value |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
119 * @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
|
120 * @throws NullPointerException if name is null |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
121 * @see #getVMOption(String) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
122 */ |
8766 | 123 protected static String getVMOption(String name, String defaultValue) { |
124 String result = getVMOption(name); | |
8051 | 125 return result == null ? defaultValue : result; |
126 } | |
127 | |
10200
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
128 /** 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
|
129 protected static boolean isC1Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
130 return (compLevel > COMP_LEVEL_NONE) |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
131 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION); |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
132 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
133 |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
134 /** 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
|
135 protected static boolean isC2Compile(int compLevel) { |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
136 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION; |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
137 } |
d1c9384eecb4
8012322: Tiered: CompilationPolicy::can_be_compiled(CompLevel_all) mistakenly return false
iignatyev
parents:
10113
diff
changeset
|
138 |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
139 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
|
140 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
|
141 String[] args) { |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
142 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
|
143 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
|
144 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
|
145 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
146 } else { |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
147 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
|
148 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
|
149 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
150 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
151 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
152 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
153 /** tested method */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
154 protected final Executable method; |
12073 | 155 protected final TestCase testCase; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
156 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
157 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
158 * Constructor. |
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 * @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
|
161 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
162 protected CompilerWhiteBoxTest(TestCase testCase) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
163 Objects.requireNonNull(testCase); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
164 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
|
165 method = testCase.getExecutable(); |
12073 | 166 this.testCase = testCase; |
10113
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 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
169 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
170 * 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
|
171 * {@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
|
172 * exception. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
173 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
174 * @throws RuntimeException if method {@linkplain #test()} throws any |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
175 * exception |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
176 * @see #test() |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
177 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
178 protected final void runTest() { |
8051 | 179 if (ManagementFactoryHelper.getCompilationMXBean() == null) { |
180 System.err.println( | |
181 "Warning: test is not applicable in interpreted mode"); | |
182 return; | |
183 } | |
184 System.out.println("at test's start:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
185 printInfo(); |
8051 | 186 try { |
187 test(); | |
188 } catch (Exception e) { | |
189 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
|
190 printInfo(); |
8766 | 191 e.printStackTrace(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
192 if (e instanceof RuntimeException) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
193 throw (RuntimeException) e; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
194 } |
8051 | 195 throw new RuntimeException(e); |
196 } | |
197 System.out.println("at test's end:"); | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
198 printInfo(); |
8051 | 199 } |
200 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
201 /** |
17869
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
202 * Checks, that {@linkplain #method} is not compiled at the given compilation |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
203 * level or above. |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
204 * |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
205 * @param compLevel |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
206 * |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
207 * @throws RuntimeException if {@linkplain #method} is in compiler queue or |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
208 * is compiled, or if {@linkplain #method} has zero |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
209 * compilation level. |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
210 */ |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
211 |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
212 protected final void checkNotCompiled(int compLevel) { |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
213 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
214 throw new RuntimeException(method + " must not be in queue"); |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
215 } |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
216 if (WHITE_BOX.getMethodCompilationLevel(method, false) >= compLevel) { |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
217 throw new RuntimeException(method + " comp_level must be >= maxCompLevel"); |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
218 } |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
219 if (WHITE_BOX.getMethodCompilationLevel(method, true) >= compLevel) { |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
220 throw new RuntimeException(method + " osr_comp_level must be >= maxCompLevel"); |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
221 } |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
222 } |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
223 |
5e6f84e7a942
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
17817
diff
changeset
|
224 /** |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
225 * Checks, that {@linkplain #method} is not 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} is in compiler queue or |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
228 * is compiled, or if {@linkplain #method} has zero |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
229 * 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 checkNotCompiled() { |
12073 | 232 if (WHITE_BOX.isMethodCompiled(method, false)) { |
8051 | 233 throw new RuntimeException(method + " must be not compiled"); |
234 } | |
12073 | 235 if (WHITE_BOX.getMethodCompilationLevel(method, false) != 0) { |
8051 | 236 throw new RuntimeException(method + " comp_level must be == 0"); |
237 } | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
238 checkNotOsrCompiled(); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
239 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
240 |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
241 protected final void checkNotOsrCompiled() { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
242 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
243 throw new RuntimeException(method + " must not be in queue"); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
244 } |
12073 | 245 if (WHITE_BOX.isMethodCompiled(method, true)) { |
246 throw new RuntimeException(method + " must be not osr_compiled"); | |
247 } | |
248 if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) { | |
249 throw new RuntimeException(method + " osr_comp_level must be == 0"); | |
250 } | |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
251 } |
8051 | 252 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
253 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
254 * Checks, that {@linkplain #method} is compiled. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
255 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
256 * @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
|
257 * and isn't compiled, or if {@linkplain #method} |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
258 * has nonzero compilation level |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
259 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
260 protected final void checkCompiled() { |
8051 | 261 final long start = System.currentTimeMillis(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
262 waitBackgroundCompilation(); |
8051 | 263 if (WHITE_BOX.isMethodQueuedForCompilation(method)) { |
264 System.err.printf("Warning: %s is still in queue after %dms%n", | |
265 method, System.currentTimeMillis() - start); | |
266 return; | |
267 } | |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
268 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) { |
12073 | 269 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
|
270 + (testCase.isOsr() ? "osr_" : "") + "compiled"); |
12073 | 271 } |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
272 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
|
273 == 0) { |
12073 | 274 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
|
275 + (testCase.isOsr() ? " osr_" : " ") |
12073 | 276 + "comp_level must be != 0"); |
277 } | |
278 } | |
279 | |
280 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
|
281 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
|
282 if (testCase.isOsr()) { |
12073 | 283 WHITE_BOX.deoptimizeMethod(method, false); |
8051 | 284 } |
12073 | 285 } |
286 | |
287 protected final int getCompLevel() { | |
17817 | 288 NMethod nm = NMethod.get(method, testCase.isOsr()); |
289 return nm == null ? COMP_LEVEL_NONE : nm.comp_level; | |
12073 | 290 } |
291 | |
292 protected final boolean isCompilable() { | |
293 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
|
294 testCase.isOsr()); |
12073 | 295 } |
296 | |
297 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
|
298 return WHITE_BOX |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
299 .isMethodCompilable(method, compLevel, testCase.isOsr()); |
12073 | 300 } |
301 | |
302 protected final void makeNotCompilable() { | |
303 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
|
304 testCase.isOsr()); |
12073 | 305 } |
306 | |
307 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
|
308 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr()); |
8051 | 309 } |
310 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
311 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
312 * 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
|
313 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
314 protected final void waitBackgroundCompilation() { |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
315 waitBackgroundCompilation(method); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
316 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
317 |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
318 /** |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
319 * Waits for completion of background compilation of the given executable. |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
320 * |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
321 * @param executable Executable |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
322 */ |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
323 protected static final void waitBackgroundCompilation(Executable executable) { |
8766 | 324 if (!BACKGROUND_COMPILATION) { |
325 return; | |
326 } | |
8051 | 327 final Object obj = new Object(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
328 for (int i = 0; i < 10 |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
329 && WHITE_BOX.isMethodQueuedForCompilation(executable); ++i) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
330 synchronized (obj) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
331 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
332 obj.wait(1000); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
333 } catch (InterruptedException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
334 Thread.currentThread().interrupt(); |
8051 | 335 } |
336 } | |
337 } | |
338 } | |
339 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
340 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
341 * Prints information about {@linkplain #method}. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
342 */ |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
343 protected final void printInfo() { |
8051 | 344 System.out.printf("%n%s:%n", method); |
345 System.out.printf("\tcompilable:\t%b%n", | |
12073 | 346 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false)); |
8051 | 347 System.out.printf("\tcompiled:\t%b%n", |
12073 | 348 WHITE_BOX.isMethodCompiled(method, false)); |
8051 | 349 System.out.printf("\tcomp_level:\t%d%n", |
12073 | 350 WHITE_BOX.getMethodCompilationLevel(method, false)); |
351 System.out.printf("\tosr_compilable:\t%b%n", | |
352 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true)); | |
353 System.out.printf("\tosr_compiled:\t%b%n", | |
354 WHITE_BOX.isMethodCompiled(method, true)); | |
355 System.out.printf("\tosr_comp_level:\t%d%n", | |
356 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
|
357 System.out.printf("\tin_queue:\t%b%n", |
8051 | 358 WHITE_BOX.isMethodQueuedForCompilation(method)); |
359 System.out.printf("compile_queues_size:\t%d%n%n", | |
360 WHITE_BOX.getCompileQueuesSize()); | |
361 } | |
362 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
363 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
364 * Executes testing. |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
365 */ |
8051 | 366 protected abstract void test() throws Exception; |
367 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
368 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
369 * 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
|
370 * {@linkplain TestCase#getCallable()} enough times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
371 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
372 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
373 * @see #compile(int) |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
374 */ |
8051 | 375 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
|
376 if (testCase.isOsr()) { |
12073 | 377 return compile(1); |
378 } else { | |
379 return compile(THRESHOLD); | |
380 } | |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
381 } |
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
382 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
383 /** |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
384 * 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
|
385 * {@linkplain TestCase#getCallable()} specified times. |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
386 * |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
387 * @param count invocation count |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
388 * @return accumulated result |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
389 */ |
9080
b84fd7d73702
8007288: Additional WB API for compiler's testing
iignatyev
parents:
8766
diff
changeset
|
390 protected final int compile(int count) { |
8051 | 391 int result = 0; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
392 Integer tmp; |
8766 | 393 for (int i = 0; i < count; ++i) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
394 try { |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
395 tmp = testCase.getCallable().call(); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
396 } catch (Exception e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
397 tmp = null; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
398 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
399 result += tmp == null ? 0 : tmp; |
8051 | 400 } |
12026
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
401 if (IS_VERBOSE) { |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
402 System.out.println("method was invoked " + count + " times"); |
11237ee74aae
8019915: whitebox testClearMethodStateTest fails with tiered on sparc
iignatyev
parents:
10200
diff
changeset
|
403 } |
8051 | 404 return result; |
405 } | |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
406 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
407 /** |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
408 * 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
|
409 */ |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
410 public interface TestCase { |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
411 /** 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
|
412 String name(); |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
413 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
414 /** tested method */ |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
415 Executable getExecutable(); |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
416 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
417 /** 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
|
418 Callable<Integer> getCallable(); |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
419 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
420 /** 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
|
421 boolean isOsr(); |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
422 } |
17711
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
423 |
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
424 /** |
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
425 * @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
|
426 * 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
|
427 */ |
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
428 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
|
429 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
|
430 && 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
|
431 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
|
432 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
|
433 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
|
434 } |
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
435 return result; |
d559dbbded7a
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
17616
diff
changeset
|
436 } |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
437 } |
8051 | 438 |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
439 enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
440 /** constructor test case */ |
12073 | 441 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
|
442 /** method test case */ |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
443 METHOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false), |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
444 /** static method test case */ |
12073 | 445 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), |
446 /** OSR constructor test case */ | |
447 OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, | |
448 Helper.OSR_CONSTRUCTOR_CALLABLE, true), | |
12958
600c83f8e6a5
8023318: compiler/whitebox tests timeout with enabled TieredCompilation
iignatyev
parents:
12328
diff
changeset
|
449 /** OSR method test case */ |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
450 OSR_METHOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), |
12073 | 451 /** OSR static method test case */ |
452 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
|
453 |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
454 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
|
455 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
|
456 private final boolean isOsr; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
457 |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
458 private SimpleTestCase(Executable executable, Callable<Integer> callable, |
12073 | 459 boolean isOsr) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
460 this.executable = executable; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
461 this.callable = callable; |
12073 | 462 this.isOsr = isOsr; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
463 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
464 |
17616
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
465 @Override |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
466 public Executable getExecutable() { |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
467 return executable; |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
468 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
469 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
470 @Override |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
471 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
|
472 return callable; |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
473 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
474 |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
475 @Override |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
476 public boolean isOsr() { |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
477 return isOsr; |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
478 } |
d1760952ebdd
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
12958
diff
changeset
|
479 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
480 private static class Helper { |
12073 | 481 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
482 private static final Callable<Integer> CONSTRUCTOR_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
483 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
484 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
485 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
486 return new Helper(1337).hashCode(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
487 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
488 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
489 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
490 private static final Callable<Integer> METHOD_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
491 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
492 private final Helper helper = new Helper(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
493 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
494 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
495 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
496 return helper.method(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
497 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
498 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
499 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
500 private static final Callable<Integer> STATIC_CALLABLE |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
501 = new Callable<Integer>() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
502 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
503 public Integer call() throws Exception { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
504 return staticMethod(); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
505 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
506 }; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
507 |
12073 | 508 private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE |
509 = new Callable<Integer>() { | |
510 @Override | |
511 public Integer call() throws Exception { | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
512 int result = warmup(OSR_CONSTRUCTOR); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
513 return result + new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode(); |
12073 | 514 } |
515 }; | |
516 | |
517 private static final Callable<Integer> OSR_METHOD_CALLABLE | |
518 = new Callable<Integer>() { | |
519 private final Helper helper = new Helper(); | |
520 | |
521 @Override | |
522 public Integer call() throws Exception { | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
523 int result = warmup(OSR_METHOD); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
524 return result + helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); |
12073 | 525 } |
526 }; | |
527 | |
528 private static final Callable<Integer> OSR_STATIC_CALLABLE | |
529 = new Callable<Integer>() { | |
530 @Override | |
531 public Integer call() throws Exception { | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
532 int result = warmup(OSR_STATIC); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
533 return result + osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD); |
12073 | 534 } |
535 }; | |
536 | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
537 /** |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
538 * Deoptimizes all non-osr versions of the given executable after |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
539 * compilation finished. |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
540 * |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
541 * @param e Executable |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
542 * @throws Exception |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
543 */ |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
544 private static void waitAndDeoptimize(Executable e) throws Exception { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
545 CompilerWhiteBoxTest.waitBackgroundCompilation(e); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
546 if (WhiteBox.getWhiteBox().isMethodQueuedForCompilation(e)) { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
547 throw new RuntimeException(e + " must not be in queue"); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
548 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
549 // Deoptimize non-osr versions of executable |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
550 WhiteBox.getWhiteBox().deoptimizeMethod(e, false); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
551 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
552 |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
553 /** |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
554 * Executes the method multiple times to make sure we have |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
555 * enough profiling information before triggering an OSR |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
556 * compilation. Otherwise the C2 compiler may add uncommon traps. |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
557 * |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
558 * @param m Method to be executed |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
559 * @return Number of times the method was executed |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
560 * @throws Exception |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
561 */ |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
562 private static int warmup(Method m) throws Exception { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
563 Helper helper = new Helper(); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
564 int result = 0; |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
565 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
566 result += (int)m.invoke(helper, 1); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
567 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
568 // Deoptimize non-osr versions |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
569 waitAndDeoptimize(m); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
570 return result; |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
571 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
572 |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
573 /** |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
574 * Executes the constructor multiple times to make sure we |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
575 * have enough profiling information before triggering an OSR |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
576 * compilation. Otherwise the C2 compiler may add uncommon traps. |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
577 * |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
578 * @param c Constructor to be executed |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
579 * @return Number of times the constructor was executed |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
580 * @throws Exception |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
581 */ |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
582 private static int warmup(Constructor c) throws Exception { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
583 int result = 0; |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
584 for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
585 result += c.newInstance(null, 1).hashCode(); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
586 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
587 // Deoptimize non-osr versions |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
588 waitAndDeoptimize(c); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
589 return result; |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
590 } |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
591 |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
592 private static final Constructor CONSTRUCTOR; |
12073 | 593 private static final Constructor OSR_CONSTRUCTOR; |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
594 private static final Method METHOD; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
595 private static final Method STATIC; |
12073 | 596 private static final Method OSR_METHOD; |
597 private static final Method OSR_STATIC; | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
598 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
599 static { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
600 try { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
601 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
602 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
603 throw new RuntimeException( |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
604 "exception on getting method Helper.<init>(int)", e); |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
605 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
606 try { |
12073 | 607 OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
608 Object.class, long.class); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
609 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
610 throw new RuntimeException( |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
611 "exception on getting method Helper.<init>(Object, long)", e); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
612 } |
12073 | 613 METHOD = getMethod("method"); |
614 STATIC = getMethod("staticMethod"); | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
615 OSR_METHOD = getMethod("osrMethod", long.class); |
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
616 OSR_STATIC = getMethod("osrStaticMethod", long.class); |
12073 | 617 } |
618 | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
619 private static Method getMethod(String name, Class<?>... parameterTypes) { |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
620 try { |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
621 return Helper.class.getDeclaredMethod(name, parameterTypes); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
622 } catch (NoSuchMethodException | SecurityException e) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
623 throw new RuntimeException( |
12073 | 624 "exception on getting method Helper." + name, e); |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
625 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
626 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
627 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
628 private static int staticMethod() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
629 return 1138; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
630 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
631 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
632 private int method() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
633 return 42; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
634 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
635 |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
636 private static int osrStaticMethod(long limit) { |
12073 | 637 int result = 0; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
638 for (long i = 0; i < limit; ++i) { |
12073 | 639 result += staticMethod(); |
640 } | |
641 return result; | |
642 } | |
643 | |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
644 private int osrMethod(long limit) { |
12073 | 645 int result = 0; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
646 for (long i = 0; i < limit; ++i) { |
12073 | 647 result += method(); |
648 } | |
649 return result; | |
650 } | |
651 | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
652 private final int x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
653 |
12073 | 654 // for method and OSR method test case |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
655 public Helper() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
656 x = 0; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
657 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
658 |
12073 | 659 // for OSR constructor test case |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
660 private Helper(Object o, long limit) { |
12073 | 661 int result = 0; |
20604
c88a4554854c
8046268: compiler/whitebox/ tests fail : must be osr_compiled
thartmann
parents:
17869
diff
changeset
|
662 for (long i = 0; i < limit; ++i) { |
12073 | 663 result += method(); |
664 } | |
665 x = result; | |
666 } | |
667 | |
668 // for constructor test case | |
10113
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
669 private Helper(int x) { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
670 this.x = x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
671 } |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
672 |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
673 @Override |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
674 public int hashCode() { |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
675 return x; |
4b2eebe03f93
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
9080
diff
changeset
|
676 } |
8051 | 677 } |
678 } |