author | neliasso |
Fri, 13 Nov 2015 13:31:48 +0100 | |
changeset 34185 | ee71c590a456 |
parent 33813 | 4f376e851453 |
parent 34172 | 19299c8b7c81 |
child 35148 | 5cfafc99d791 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 |
* |
|
23 |
*/ |
|
24 |
||
25 |
/** |
|
26 |
* @test |
|
27 |
* @bug 8136421 |
|
28 |
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64" |
|
33730
30e064828045
8140189: [TESTBUG] Get rid of "@library /../../test/lib" in jtreg tests
cjplummer
parents:
33160
diff
changeset
|
29 |
* @library /testlibrary /test/lib / |
33160 | 30 |
* @compile ../common/CompilerToVMHelper.java |
31 |
* @build sun.hotspot.WhiteBox |
|
32 |
* @run main ClassFileInstaller |
|
33 |
* sun.hotspot.WhiteBox |
|
34 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
35 |
* jdk.vm.ci.hotspot.CompilerToVMHelper |
|
36 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
37 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
|
38 |
* -Xmixed |
|
39 |
* compiler.jvmci.compilerToVM.ReprofileTest |
|
40 |
*/ |
|
41 |
||
42 |
package compiler.jvmci.compilerToVM; |
|
43 |
||
44 |
import compiler.jvmci.common.CTVMUtilities; |
|
45 |
import java.lang.reflect.Method; |
|
46 |
import java.util.ArrayList; |
|
47 |
import java.util.List; |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
48 |
|
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
49 |
import compiler.whitebox.CompilerWhiteBoxTest; |
33632 | 50 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
33160 | 51 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
52 |
import jdk.vm.ci.meta.ProfilingInfo; |
|
53 |
import jdk.test.lib.Asserts; |
|
54 |
||
55 |
public class ReprofileTest { |
|
56 |
||
57 |
public static void main(String[] args) { |
|
58 |
List<Method> testCases = createTestCases(); |
|
59 |
testCases.forEach(ReprofileTest::runSanityTest); |
|
60 |
} |
|
61 |
||
62 |
private static List<Method> createTestCases() { |
|
63 |
List<Method> testCases = new ArrayList<>(); |
|
64 |
try { |
|
65 |
||
66 |
Class<?> aClass = DummyClass.class; |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
67 |
testCases.add(aClass.getMethod("dummyInstanceFunction")); |
33160 | 68 |
|
69 |
aClass = DummyClass.class; |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
70 |
testCases.add(aClass.getMethod("dummyFunction")); |
33160 | 71 |
} catch (NoSuchMethodException e) { |
72 |
throw new Error("TEST BUG " + e.getMessage(), e); |
|
73 |
} |
|
74 |
return testCases; |
|
75 |
} |
|
76 |
||
77 |
private static void runSanityTest(Method aMethod) { |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
78 |
System.out.println(aMethod); |
33632 | 79 |
HotSpotResolvedJavaMethod method = CTVMUtilities |
33160 | 80 |
.getResolvedMethod(aMethod); |
81 |
ProfilingInfo startProfile = method.getProfilingInfo(); |
|
82 |
Asserts.assertFalse(startProfile.isMature(), aMethod |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
83 |
+ " : profiling info is mature in the beginning"); |
33160 | 84 |
|
85 |
// make interpreter to profile this method |
|
86 |
try { |
|
87 |
Object obj = aMethod.getDeclaringClass().newInstance(); |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
88 |
for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { |
33160 | 89 |
aMethod.invoke(obj); |
90 |
} |
|
91 |
} catch (ReflectiveOperationException e) { |
|
92 |
throw new Error("TEST BUG : " + e.getMessage(), e); |
|
93 |
} |
|
94 |
ProfilingInfo compProfile = method.getProfilingInfo(); |
|
95 |
||
96 |
Asserts.assertNE(startProfile.toString(), compProfile.toString(), |
|
97 |
String.format("%s : profiling info wasn't changed after " |
|
98 |
+ "%d invocations", |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
99 |
aMethod, CompilerWhiteBoxTest.THRESHOLD)); |
33160 | 100 |
Asserts.assertTrue(compProfile.isMature(), |
101 |
String.format("%s is not mature after %d invocations", |
|
34172
19299c8b7c81
8139388: [TESTBUG] JVMCI test failed with RuntimeException profiling info wasn't changed after 100 invocations (assert failed: BaseProfilingInfo<> != BaseProfilingInfo<>)
tpivovarova
parents:
33632
diff
changeset
|
102 |
aMethod, CompilerWhiteBoxTest.THRESHOLD)); |
33160 | 103 |
|
104 |
CompilerToVMHelper.reprofile(method); |
|
105 |
ProfilingInfo reprofiledProfile = method.getProfilingInfo(); |
|
106 |
||
107 |
Asserts.assertNE(startProfile.toString(), reprofiledProfile.toString(), |
|
108 |
aMethod + " : profiling info wasn't changed after reprofiling"); |
|
109 |
Asserts.assertNE(compProfile.toString(), reprofiledProfile.toString(), |
|
110 |
aMethod + " : profiling info didn't change after reprofile"); |
|
111 |
Asserts.assertFalse(reprofiledProfile.isMature(), aMethod |
|
112 |
+ " : profiling info is mature after reprofiling"); |
|
113 |
} |
|
114 |
} |