annotate test/compiler/whitebox/CompilerWhiteBoxTest.java @ 14094:3f27e57439ed

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