author | kshefov |
Thu, 11 Dec 2014 15:10:35 +0300 | |
changeset 27958 | 51c87937ff0c |
parent 27803 | d04ca9d519ce |
child 28405 | 53e900131e21 |
permissions | -rw-r--r-- |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
1 |
/* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
4 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
8 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
13 |
* accompanied this code). |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
14 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
18 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
21 |
* questions. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
22 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
23 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
24 |
import com.oracle.testlibrary.jsr292.Helper; |
27030
4e989f27c905
8058733: [TESTBUG] java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java and LFMultiThreadCachingTest.java failed on some platforms due to java.lang.VirtualMachineError
kshefov
parents:
26600
diff
changeset
|
25 |
import com.sun.management.HotSpotDiagnosticMXBean; |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
26 |
|
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
27 |
import java.lang.management.GarbageCollectorMXBean; |
27030
4e989f27c905
8058733: [TESTBUG] java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java and LFMultiThreadCachingTest.java failed on some platforms due to java.lang.VirtualMachineError
kshefov
parents:
26600
diff
changeset
|
28 |
import java.lang.management.ManagementFactory; |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
29 |
import java.lang.reflect.Method; |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
30 |
import java.util.Collection; |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
31 |
import java.util.List; |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
32 |
import java.util.function.Function; |
27758
dfba484228ed
8059070: [TESTBUG] java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java failed - timeout
kshefov
parents:
27030
diff
changeset
|
33 |
import jdk.testlibrary.Utils; |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
34 |
import jdk.testlibrary.TimeLimitedRunner; |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
35 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
36 |
/** |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
37 |
* Lambda forms caching test case class. Contains all necessary test routines to |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
38 |
* test lambda forms caching in method handles returned by methods of |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
39 |
* MethodHandles class. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
40 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
41 |
* @author kshefov |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
42 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
43 |
public abstract class LambdaFormTestCase { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
44 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
45 |
private final static String METHOD_HANDLE_CLASS_NAME = "java.lang.invoke.MethodHandle"; |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
46 |
private final static String INTERNAL_FORM_METHOD_NAME = "internalForm"; |
27030
4e989f27c905
8058733: [TESTBUG] java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java and LFMultiThreadCachingTest.java failed on some platforms due to java.lang.VirtualMachineError
kshefov
parents:
26600
diff
changeset
|
47 |
private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO |
4e989f27c905
8058733: [TESTBUG] java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java and LFMultiThreadCachingTest.java failed on some platforms due to java.lang.VirtualMachineError
kshefov
parents:
26600
diff
changeset
|
48 |
= 45 / (128.0 * 1024 * 1024); |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
49 |
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9); |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
50 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
51 |
/** |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
52 |
* Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
53 |
* used to get a lambda form from a method handle. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
54 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
55 |
protected final static Method INTERNAL_FORM; |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
56 |
private static final List<GarbageCollectorMXBean> gcInfo; |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
57 |
|
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
58 |
private static long gcCount() { |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
59 |
return gcInfo.stream().mapToLong(GarbageCollectorMXBean::getCollectionCount).sum(); |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
60 |
} |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
61 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
62 |
static { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
63 |
try { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
64 |
Class mhClass = Class.forName(METHOD_HANDLE_CLASS_NAME); |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
65 |
INTERNAL_FORM = mhClass.getDeclaredMethod(INTERNAL_FORM_METHOD_NAME); |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
66 |
INTERNAL_FORM.setAccessible(true); |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
67 |
} catch (Exception ex) { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
68 |
throw new Error("Unexpected exception: ", ex); |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
69 |
} |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
70 |
|
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
71 |
gcInfo = ManagementFactory.getGarbageCollectorMXBeans(); |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
72 |
if (gcInfo.size() == 0) { |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
73 |
throw new Error("No GarbageCollectorMXBeans found."); |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
74 |
} |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
75 |
} |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
76 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
77 |
private final TestMethods testMethod; |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
78 |
private long gcCountAtStart; |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
79 |
|
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
80 |
private static class TestRun { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
81 |
|
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
82 |
final Function<TestMethods, LambdaFormTestCase> ctor; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
83 |
final Collection<TestMethods> testMethods; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
84 |
final long totalIterations; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
85 |
long doneIterations; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
86 |
long testCounter; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
87 |
long failCounter; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
88 |
boolean passed; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
89 |
|
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
90 |
TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
91 |
this.ctor = ctor; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
92 |
this.testMethods = testMethods; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
93 |
long testCaseNum = testMethods.size(); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
94 |
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
95 |
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
96 |
iterations, iterations * testCaseNum); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
97 |
HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
98 |
long codeCacheSize = Long.parseLong( |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
99 |
hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue()); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
100 |
System.out.printf("Code cache size is %d bytes%n", codeCacheSize); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
101 |
long iterationsByCodeCacheSize = (long) (codeCacheSize |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
102 |
* ITERATIONS_TO_CODE_CACHE_SIZE_RATIO); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
103 |
long nonProfiledCodeCacheSize = Long.parseLong( |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
104 |
hsDiagBean.getVMOption("NonProfiledCodeHeapSize").getValue()); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
105 |
System.out.printf("Non-profiled code cache size is %d bytes%n", nonProfiledCodeCacheSize); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
106 |
long iterationsByNonProfiledCodeCacheSize = (long) (nonProfiledCodeCacheSize |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
107 |
* ITERATIONS_TO_CODE_CACHE_SIZE_RATIO); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
108 |
System.out.printf("Number of iterations limited by code cache size is %d (%d cases)%n", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
109 |
iterationsByCodeCacheSize, iterationsByCodeCacheSize * testCaseNum); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
110 |
System.out.printf("Number of iterations limited by non-profiled code cache size is %d (%d cases)%n", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
111 |
iterationsByNonProfiledCodeCacheSize, iterationsByNonProfiledCodeCacheSize * testCaseNum); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
112 |
iterations = Math.min(iterationsByCodeCacheSize, |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
113 |
Math.min(iterations, iterationsByNonProfiledCodeCacheSize)); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
114 |
if (iterations == 0) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
115 |
System.out.println("Warning: code cache size is too small to provide at" |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
116 |
+ " least one iteration! Test will try to do one iteration."); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
117 |
iterations = 1; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
118 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
119 |
System.out.printf("Number of iterations is set to %d (%d cases)%n", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
120 |
iterations, iterations * testCaseNum); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
121 |
System.out.flush(); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
122 |
totalIterations = iterations; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
123 |
doneIterations = 0L; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
124 |
testCounter = 0L; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
125 |
failCounter = 0L; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
126 |
passed = true; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
127 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
128 |
|
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
129 |
Boolean doIteration() { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
130 |
if (doneIterations >= totalIterations) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
131 |
return false; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
132 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
133 |
System.err.println(String.format("Iteration %d:", doneIterations)); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
134 |
for (TestMethods testMethod : testMethods) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
135 |
LambdaFormTestCase testCase = ctor.apply(testMethod); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
136 |
try { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
137 |
System.err.printf("Tested LF caching feature with MethodHandles.%s method.%n", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
138 |
testCase.getTestMethod().name); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
139 |
testCase.doTest(); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
140 |
System.err.println("PASSED"); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
141 |
} catch (Throwable t) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
142 |
t.printStackTrace(); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
143 |
System.err.printf("FAILED. Caused by %s%n", t.getMessage()); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
144 |
passed = false; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
145 |
failCounter++; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
146 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
147 |
testCounter++; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
148 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
149 |
doneIterations++; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
150 |
return true; |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
151 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
152 |
|
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
153 |
void checkPassed() { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
154 |
if (!passed) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
155 |
throw new Error(String.format("%d of %d test cases FAILED! %n" |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
156 |
+ "Rerun the test with the same \"-Dseed=\" option as in the log file!", |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
157 |
failCounter, testCounter)); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
158 |
} else { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
159 |
System.err.printf("All %d test cases PASSED!%n", testCounter); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
160 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
161 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
162 |
} |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
163 |
|
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
164 |
/** |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
165 |
* Test case constructor. Generates test cases with random method types for |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
166 |
* given methods form {@code j.l.i.MethodHandles} class. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
167 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
168 |
* @param testMethod A method from {@code j.l.i.MethodHandles} class which |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
169 |
* returns a {@code j.l.i.MethodHandle}. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
170 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
171 |
protected LambdaFormTestCase(TestMethods testMethod) { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
172 |
this.testMethod = testMethod; |
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
173 |
this.gcCountAtStart = gcCount(); |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
174 |
} |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
175 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
176 |
public TestMethods getTestMethod() { |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
177 |
return testMethod; |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
178 |
} |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
179 |
|
27803
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
180 |
protected boolean noGCHappened() { |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
181 |
return gcCount() == gcCountAtStart; |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
182 |
} |
d04ca9d519ce
8057020: LambdaForm caches should support eviction
vlivanov
parents:
27758
diff
changeset
|
183 |
|
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
184 |
/** |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
185 |
* Routine that executes a test case. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
186 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
187 |
public abstract void doTest(); |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
188 |
|
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
189 |
/** |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
190 |
* Runs a number of test cases defined by the size of testCases list. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
191 |
* |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
192 |
* @param ctor constructor of LambdaFormCachingTest or its child classes |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
193 |
* object. |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
194 |
* @param testMethods list of test methods |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
195 |
*/ |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
196 |
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) { |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
197 |
LambdaFormTestCase.TestRun run = |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
198 |
new LambdaFormTestCase.TestRun(ctor, testMethods); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
199 |
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
200 |
try { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
201 |
runner.call(); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
202 |
} catch (Exception ex) { |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
203 |
System.err.println("FAILED"); |
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
204 |
throw new Error("Unexpected error!", ex); |
27030
4e989f27c905
8058733: [TESTBUG] java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java and LFMultiThreadCachingTest.java failed on some platforms due to java.lang.VirtualMachineError
kshefov
parents:
26600
diff
changeset
|
205 |
} |
27958
51c87937ff0c
8066798: [TEST] Make java/lang/invoke/LFCaching tests use lib/testlibrary/jdk/testlibrary/TimeLimitedRunner.java to define their number of iterations
kshefov
parents:
27803
diff
changeset
|
206 |
run.checkPassed(); |
26600
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
207 |
} |
27b115fe8b3c
8057719: Develop new tests for LambdaForm Reduction and Caching feature
kshefov
parents:
diff
changeset
|
208 |
} |