Mon, 03 Jun 2019 16:14:54 +0100
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
Summary: Includes compile_id addition from JDK-8054492
Reviewed-by: andrew
1 /*
2 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
24 import com.sun.management.HotSpotDiagnosticMXBean;
25 import com.sun.management.VMOption;
26 import sun.hotspot.WhiteBox;
27 import sun.hotspot.code.NMethod;
28 import sun.management.ManagementFactoryHelper;
30 import java.lang.reflect.Constructor;
31 import java.lang.reflect.Executable;
32 import java.lang.reflect.Method;
33 import java.util.Objects;
34 import java.util.concurrent.Callable;
35 import java.util.function.Function;
37 /**
38 * Abstract class for WhiteBox testing of JIT.
39 *
40 * @author igor.ignatyev@oracle.com
41 */
42 public abstract class CompilerWhiteBoxTest {
43 /** {@code CompLevel::CompLevel_none} -- Interpreter */
44 protected static final int COMP_LEVEL_NONE = 0;
45 /** {@code CompLevel::CompLevel_any}, {@code CompLevel::CompLevel_all} */
46 protected static final int COMP_LEVEL_ANY = -1;
47 /** {@code CompLevel::CompLevel_simple} -- C1 */
48 protected static final int COMP_LEVEL_SIMPLE = 1;
49 /** {@code CompLevel::CompLevel_limited_profile} -- C1, invocation & backedge counters */
50 protected static final int COMP_LEVEL_LIMITED_PROFILE = 2;
51 /** {@code CompLevel::CompLevel_full_profile} -- C1, invocation & backedge counters + mdo */
52 protected static final int COMP_LEVEL_FULL_PROFILE = 3;
53 /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
54 protected static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
55 /** Maximal value for CompLevel */
56 protected static final int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
58 /** Instance of WhiteBox */
59 protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
60 /** Value of {@code -XX:CompileThreshold} */
61 protected static final int COMPILE_THRESHOLD
62 = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
63 /** Value of {@code -XX:BackgroundCompilation} */
64 protected static final boolean BACKGROUND_COMPILATION
65 = Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
66 /** Value of {@code -XX:TieredCompilation} */
67 protected static final boolean TIERED_COMPILATION
68 = Boolean.valueOf(getVMOption("TieredCompilation", "false"));
69 /** Value of {@code -XX:TieredStopAtLevel} */
70 protected static final int TIERED_STOP_AT_LEVEL
71 = Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));
72 /** Flag for verbose output, true if {@code -Dverbose} specified */
73 protected static final boolean IS_VERBOSE
74 = System.getProperty("verbose") != null;
75 /** invocation count to trigger compilation */
76 protected static final int THRESHOLD;
77 /** invocation count to trigger OSR compilation */
78 protected static final long BACKEDGE_THRESHOLD;
79 /** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
80 protected static final String MODE = System.getProperty("java.vm.info");
82 static {
83 if (TIERED_COMPILATION) {
84 BACKEDGE_THRESHOLD = THRESHOLD = 150000;
85 } else {
86 THRESHOLD = COMPILE_THRESHOLD;
87 BACKEDGE_THRESHOLD = Math.max(10000, COMPILE_THRESHOLD *
88 Long.parseLong(getVMOption("OnStackReplacePercentage")));
89 }
90 }
92 /**
93 * Returns value of VM option.
94 *
95 * @param name option's name
96 * @return value of option or {@code null}, if option doesn't exist
97 * @throws NullPointerException if name is null
98 */
99 protected static String getVMOption(String name) {
100 Objects.requireNonNull(name);
101 HotSpotDiagnosticMXBean diagnostic
102 = ManagementFactoryHelper.getDiagnosticMXBean();
103 VMOption tmp;
104 try {
105 tmp = diagnostic.getVMOption(name);
106 } catch (IllegalArgumentException e) {
107 tmp = null;
108 }
109 return (tmp == null ? null : tmp.getValue());
110 }
112 /**
113 * Returns value of VM option or default value.
114 *
115 * @param name option's name
116 * @param defaultValue default value
117 * @return value of option or {@code defaultValue}, if option doesn't exist
118 * @throws NullPointerException if name is null
119 * @see #getVMOption(String)
120 */
121 protected static String getVMOption(String name, String defaultValue) {
122 String result = getVMOption(name);
123 return result == null ? defaultValue : result;
124 }
126 /** copy of is_c1_compile(int) from utilities/globalDefinitions.hpp */
127 protected static boolean isC1Compile(int compLevel) {
128 return (compLevel > COMP_LEVEL_NONE)
129 && (compLevel < COMP_LEVEL_FULL_OPTIMIZATION);
130 }
132 /** copy of is_c2_compile(int) from utilities/globalDefinitions.hpp */
133 protected static boolean isC2Compile(int compLevel) {
134 return compLevel == COMP_LEVEL_FULL_OPTIMIZATION;
135 }
137 protected static void main(
138 Function<TestCase, CompilerWhiteBoxTest> constructor,
139 String[] args) {
140 if (args.length == 0) {
141 for (TestCase test : SimpleTestCase.values()) {
142 constructor.apply(test).runTest();
143 }
144 } else {
145 for (String name : args) {
146 constructor.apply(SimpleTestCase.valueOf(name)).runTest();
147 }
148 }
149 }
151 /** tested method */
152 protected final Executable method;
153 protected final TestCase testCase;
155 /**
156 * Constructor.
157 *
158 * @param testCase object, that contains tested method and way to invoke it.
159 */
160 protected CompilerWhiteBoxTest(TestCase testCase) {
161 Objects.requireNonNull(testCase);
162 System.out.println("TEST CASE:" + testCase.name());
163 method = testCase.getExecutable();
164 this.testCase = testCase;
165 }
167 /**
168 * Template method for testing. Prints tested method's info before
169 * {@linkplain #test()} and after {@linkplain #test()} or on thrown
170 * exception.
171 *
172 * @throws RuntimeException if method {@linkplain #test()} throws any
173 * exception
174 * @see #test()
175 */
176 protected final void runTest() {
177 if (ManagementFactoryHelper.getCompilationMXBean() == null) {
178 System.err.println(
179 "Warning: test is not applicable in interpreted mode");
180 return;
181 }
182 System.out.println("at test's start:");
183 printInfo();
184 try {
185 test();
186 } catch (Exception e) {
187 System.out.printf("on exception '%s':", e.getMessage());
188 printInfo();
189 e.printStackTrace();
190 if (e instanceof RuntimeException) {
191 throw (RuntimeException) e;
192 }
193 throw new RuntimeException(e);
194 }
195 System.out.println("at test's end:");
196 printInfo();
197 }
199 /**
200 * Checks, that {@linkplain #method} is not compiled at the given compilation
201 * level or above.
202 *
203 * @param compLevel
204 *
205 * @throws RuntimeException if {@linkplain #method} is in compiler queue or
206 * is compiled, or if {@linkplain #method} has zero
207 * compilation level.
208 */
209 protected final void checkNotCompiled(int compLevel) {
210 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
211 throw new RuntimeException(method + " must not be in queue");
212 }
213 if (WHITE_BOX.getMethodCompilationLevel(method, false) >= compLevel) {
214 throw new RuntimeException(method + " comp_level must be >= maxCompLevel");
215 }
216 if (WHITE_BOX.getMethodCompilationLevel(method, true) >= compLevel) {
217 throw new RuntimeException(method + " osr_comp_level must be >= maxCompLevel");
218 }
219 }
221 /**
222 * Checks, that {@linkplain #method} is not compiled.
223 *
224 * @throws RuntimeException if {@linkplain #method} is in compiler queue or
225 * is compiled, or if {@linkplain #method} has zero
226 * compilation level.
227 */
228 protected final void checkNotCompiled() {
229 checkNotCompiled(true);
230 checkNotCompiled(false);
231 }
233 /**
234 * Checks, that {@linkplain #method} is not (OSR-)compiled.
235 *
236 * @param isOsr Check for OSR compilation if true
237 * @throws RuntimeException if {@linkplain #method} is in compiler queue or
238 * is compiled, or if {@linkplain #method} has zero
239 * compilation level.
240 */
241 protected final void checkNotCompiled(boolean isOsr) {
242 waitBackgroundCompilation();
243 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
244 throw new RuntimeException(method + " must not be in queue");
245 }
246 if (WHITE_BOX.isMethodCompiled(method, isOsr)) {
247 throw new RuntimeException(method + " must not be " +
248 (isOsr ? "osr_" : "") + "compiled");
249 }
250 if (WHITE_BOX.getMethodCompilationLevel(method, isOsr) != 0) {
251 throw new RuntimeException(method + (isOsr ? " osr_" : " ") +
252 "comp_level must be == 0");
253 }
254 }
256 /**
257 * Checks, that {@linkplain #method} is compiled.
258 *
259 * @throws RuntimeException if {@linkplain #method} isn't in compiler queue
260 * and isn't compiled, or if {@linkplain #method}
261 * has nonzero compilation level
262 */
263 protected final void checkCompiled() {
264 final long start = System.currentTimeMillis();
265 waitBackgroundCompilation();
266 if (WHITE_BOX.isMethodQueuedForCompilation(method)) {
267 System.err.printf("Warning: %s is still in queue after %dms%n",
268 method, System.currentTimeMillis() - start);
269 return;
270 }
271 if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
272 throw new RuntimeException(method + " must be "
273 + (testCase.isOsr() ? "osr_" : "") + "compiled");
274 }
275 if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr())
276 == 0) {
277 throw new RuntimeException(method
278 + (testCase.isOsr() ? " osr_" : " ")
279 + "comp_level must be != 0");
280 }
281 }
283 protected final void deoptimize() {
284 WHITE_BOX.deoptimizeMethod(method, testCase.isOsr());
285 if (testCase.isOsr()) {
286 WHITE_BOX.deoptimizeMethod(method, false);
287 }
288 }
290 protected final int getCompLevel() {
291 NMethod nm = NMethod.get(method, testCase.isOsr());
292 return nm == null ? COMP_LEVEL_NONE : nm.comp_level;
293 }
295 protected final boolean isCompilable() {
296 return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY,
297 testCase.isOsr());
298 }
300 protected final boolean isCompilable(int compLevel) {
301 return WHITE_BOX
302 .isMethodCompilable(method, compLevel, testCase.isOsr());
303 }
305 protected final void makeNotCompilable() {
306 WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY,
307 testCase.isOsr());
308 }
310 protected final void makeNotCompilable(int compLevel) {
311 WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr());
312 }
314 /**
315 * Waits for completion of background compilation of {@linkplain #method}.
316 */
317 protected final void waitBackgroundCompilation() {
318 waitBackgroundCompilation(method);
319 }
321 /**
322 * Waits for completion of background compilation of the given executable.
323 *
324 * @param executable Executable
325 */
326 protected static final void waitBackgroundCompilation(Executable executable) {
327 if (!BACKGROUND_COMPILATION) {
328 return;
329 }
330 final Object obj = new Object();
331 for (int i = 0; i < 10
332 && WHITE_BOX.isMethodQueuedForCompilation(executable); ++i) {
333 synchronized (obj) {
334 try {
335 obj.wait(1000);
336 } catch (InterruptedException e) {
337 Thread.currentThread().interrupt();
338 }
339 }
340 }
341 }
343 /**
344 * Prints information about {@linkplain #method}.
345 */
346 protected final void printInfo() {
347 System.out.printf("%n%s:%n", method);
348 System.out.printf("\tcompilable:\t%b%n",
349 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, false));
350 boolean isCompiled = WHITE_BOX.isMethodCompiled(method, false);
351 System.out.printf("\tcompiled:\t%b%n", isCompiled);
352 if (isCompiled) {
353 System.out.printf("\tcompile_id:\t%d%n",
354 NMethod.get(method, false).compile_id);
355 }
356 System.out.printf("\tcomp_level:\t%d%n",
357 WHITE_BOX.getMethodCompilationLevel(method, false));
358 System.out.printf("\tosr_compilable:\t%b%n",
359 WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, true));
360 isCompiled = WHITE_BOX.isMethodCompiled(method, true);
361 System.out.printf("\tosr_compiled:\t%b%n", isCompiled);
362 if (isCompiled) {
363 System.out.printf("\tosr_compile_id:\t%d%n",
364 NMethod.get(method, true).compile_id);
365 }
366 System.out.printf("\tosr_comp_level:\t%d%n",
367 WHITE_BOX.getMethodCompilationLevel(method, true));
368 System.out.printf("\tin_queue:\t%b%n",
369 WHITE_BOX.isMethodQueuedForCompilation(method));
370 System.out.printf("compile_queues_size:\t%d%n%n",
371 WHITE_BOX.getCompileQueuesSize());
372 }
374 /**
375 * Executes testing.
376 */
377 protected abstract void test() throws Exception;
379 /**
380 * Tries to trigger compilation of {@linkplain #method} by call
381 * {@linkplain TestCase#getCallable()} enough times.
382 *
383 * @return accumulated result
384 * @see #compile(int)
385 */
386 protected final int compile() {
387 if (testCase.isOsr()) {
388 return compile(1);
389 } else {
390 return compile(THRESHOLD);
391 }
392 }
394 /**
395 * Tries to trigger compilation of {@linkplain #method} by call
396 * {@linkplain TestCase#getCallable()} specified times.
397 *
398 * @param count invocation count
399 * @return accumulated result
400 */
401 protected final int compile(int count) {
402 int result = 0;
403 Integer tmp;
404 for (int i = 0; i < count; ++i) {
405 try {
406 tmp = testCase.getCallable().call();
407 } catch (Exception e) {
408 tmp = null;
409 }
410 result += tmp == null ? 0 : tmp;
411 }
412 if (IS_VERBOSE) {
413 System.out.println("method was invoked " + count + " times");
414 }
415 return result;
416 }
418 /**
419 * Utility interface provides tested method and object to invoke it.
420 */
421 public interface TestCase {
422 /** the name of test case */
423 String name();
425 /** tested method */
426 Executable getExecutable();
428 /** object to invoke {@linkplain #getExecutable()} */
429 Callable<Integer> getCallable();
431 /** flag for OSR test case */
432 boolean isOsr();
433 }
435 /**
436 * @return {@code true} if the current test case is OSR and the mode is
437 * Xcomp, otherwise {@code false}
438 */
439 protected boolean skipXcompOSR() {
440 boolean result = testCase.isOsr()
441 && CompilerWhiteBoxTest.MODE.startsWith("compiled ");
442 if (result && IS_VERBOSE) {
443 System.err.printf("Warning: %s is not applicable in %s%n",
444 testCase.name(), CompilerWhiteBoxTest.MODE);
445 }
446 return result;
447 }
449 /**
450 * Skip the test for the specified value of Tiered Compilation
451 * @param value of TieredCompilation the test should not run with
452 * @return {@code true} if the test should be skipped,
453 * {@code false} otherwise
454 */
455 protected static boolean skipOnTieredCompilation(boolean value) {
456 if (value == CompilerWhiteBoxTest.TIERED_COMPILATION) {
457 System.err.println("Test isn't applicable w/ "
458 + (value ? "enabled" : "disabled")
459 + "TieredCompilation. Skip test.");
460 return true;
461 }
462 return false;
463 }
464 }
466 enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
467 /** constructor test case */
468 CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false),
469 /** method test case */
470 METHOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false),
471 /** static method test case */
472 STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false),
473 /** OSR constructor test case */
474 OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR,
475 Helper.OSR_CONSTRUCTOR_CALLABLE, true),
476 /** OSR method test case */
477 OSR_METHOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true),
478 /** OSR static method test case */
479 OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true);
481 private final Executable executable;
482 private final Callable<Integer> callable;
483 private final boolean isOsr;
485 private SimpleTestCase(Executable executable, Callable<Integer> callable,
486 boolean isOsr) {
487 this.executable = executable;
488 this.callable = callable;
489 this.isOsr = isOsr;
490 }
492 @Override
493 public Executable getExecutable() {
494 return executable;
495 }
497 @Override
498 public Callable<Integer> getCallable() {
499 return callable;
500 }
502 @Override
503 public boolean isOsr() {
504 return isOsr;
505 }
507 private static class Helper {
509 private static final Callable<Integer> CONSTRUCTOR_CALLABLE
510 = new Callable<Integer>() {
511 @Override
512 public Integer call() throws Exception {
513 return new Helper(1337).hashCode();
514 }
515 };
517 private static final Callable<Integer> METHOD_CALLABLE
518 = new Callable<Integer>() {
519 private final Helper helper = new Helper();
521 @Override
522 public Integer call() throws Exception {
523 return helper.method();
524 }
525 };
527 private static final Callable<Integer> STATIC_CALLABLE
528 = new Callable<Integer>() {
529 @Override
530 public Integer call() throws Exception {
531 return staticMethod();
532 }
533 };
535 private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE
536 = new Callable<Integer>() {
537 @Override
538 public Integer call() throws Exception {
539 return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
540 }
541 };
543 private static final Callable<Integer> OSR_METHOD_CALLABLE
544 = new Callable<Integer>() {
545 private final Helper helper = new Helper();
547 @Override
548 public Integer call() throws Exception {
549 return helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
550 }
551 };
553 private static final Callable<Integer> OSR_STATIC_CALLABLE
554 = new Callable<Integer>() {
555 @Override
556 public Integer call() throws Exception {
557 return osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
558 }
559 };
561 private static final Constructor CONSTRUCTOR;
562 private static final Constructor OSR_CONSTRUCTOR;
563 private static final Method METHOD;
564 private static final Method STATIC;
565 private static final Method OSR_METHOD;
566 private static final Method OSR_STATIC;
568 static {
569 try {
570 CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
571 } catch (NoSuchMethodException | SecurityException e) {
572 throw new RuntimeException(
573 "exception on getting method Helper.<init>(int)", e);
574 }
575 try {
576 OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor(
577 Object.class, long.class);
578 } catch (NoSuchMethodException | SecurityException e) {
579 throw new RuntimeException(
580 "exception on getting method Helper.<init>(Object, long)", e);
581 }
582 METHOD = getMethod("method");
583 STATIC = getMethod("staticMethod");
584 OSR_METHOD = getMethod("osrMethod", long.class);
585 OSR_STATIC = getMethod("osrStaticMethod", long.class);
586 }
588 private static Method getMethod(String name, Class<?>... parameterTypes) {
589 try {
590 return Helper.class.getDeclaredMethod(name, parameterTypes);
591 } catch (NoSuchMethodException | SecurityException e) {
592 throw new RuntimeException(
593 "exception on getting method Helper." + name, e);
594 }
595 }
597 private static int staticMethod() {
598 return 1138;
599 }
601 private int method() {
602 return 42;
603 }
605 /**
606 * Deoptimizes all non-osr versions of the given executable after
607 * compilation finished.
608 *
609 * @param e Executable
610 * @throws Exception
611 */
612 private static void waitAndDeoptimize(Executable e) {
613 CompilerWhiteBoxTest.waitBackgroundCompilation(e);
614 if (WhiteBox.getWhiteBox().isMethodQueuedForCompilation(e)) {
615 throw new RuntimeException(e + " must not be in queue");
616 }
617 // Deoptimize non-osr versions of executable
618 WhiteBox.getWhiteBox().deoptimizeMethod(e, false);
619 }
621 /**
622 * Executes the method multiple times to make sure we have
623 * enough profiling information before triggering an OSR
624 * compilation. Otherwise the C2 compiler may add uncommon traps.
625 *
626 * @param m Method to be executed
627 * @return Number of times the method was executed
628 * @throws Exception
629 */
630 private static int warmup(Method m) throws Exception {
631 waitAndDeoptimize(m);
632 Helper helper = new Helper();
633 int result = 0;
634 for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) {
635 result += (int)m.invoke(helper, 1);
636 }
637 // Wait to make sure OSR compilation is not blocked by
638 // non-OSR compilation in the compile queue
639 CompilerWhiteBoxTest.waitBackgroundCompilation(m);
640 return result;
641 }
643 /**
644 * Executes the constructor multiple times to make sure we
645 * have enough profiling information before triggering an OSR
646 * compilation. Otherwise the C2 compiler may add uncommon traps.
647 *
648 * @param c Constructor to be executed
649 * @return Number of times the constructor was executed
650 * @throws Exception
651 */
652 private static int warmup(Constructor c) throws Exception {
653 waitAndDeoptimize(c);
654 int result = 0;
655 for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) {
656 result += c.newInstance(null, 1).hashCode();
657 }
658 // Wait to make sure OSR compilation is not blocked by
659 // non-OSR compilation in the compile queue
660 CompilerWhiteBoxTest.waitBackgroundCompilation(c);
661 return result;
662 }
664 private static int osrStaticMethod(long limit) throws Exception {
665 int result = 0;
666 if (limit != 1) {
667 result = warmup(OSR_STATIC);
668 }
669 // Trigger osr compilation
670 for (long i = 0; i < limit; ++i) {
671 result += staticMethod();
672 }
673 return result;
674 }
676 private int osrMethod(long limit) throws Exception {
677 int result = 0;
678 if (limit != 1) {
679 result = warmup(OSR_METHOD);
680 }
681 // Trigger osr compilation
682 for (long i = 0; i < limit; ++i) {
683 result += method();
684 }
685 return result;
686 }
688 private final int x;
690 // for method and OSR method test case
691 public Helper() {
692 x = 0;
693 }
695 // for OSR constructor test case
696 private Helper(Object o, long limit) throws Exception {
697 int result = 0;
698 if (limit != 1) {
699 result = warmup(OSR_CONSTRUCTOR);
700 }
701 // Trigger osr compilation
702 for (long i = 0; i < limit; ++i) {
703 result += method();
704 }
705 x = result;
706 }
708 // for constructor test case
709 private Helper(int x) {
710 this.x = x;
711 }
713 @Override
714 public int hashCode() {
715 return x;
716 }
717 }
718 }