author | jprovino |
Wed, 11 Nov 2015 23:47:41 +0000 | |
changeset 33813 | 4f376e851453 |
parent 33632 | 038347770a9e |
parent 33730 | 30e064828045 |
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:
33191
diff
changeset
|
29 |
* @library /testlibrary /test/lib / |
33191
e155b02f22fc
8139707: [TESTBUG] Quarantine unstable compiler/jvmci tests
iignatyev
parents:
33160
diff
changeset
|
30 |
* @ignore 8139700 |
33160 | 31 |
* @compile ../common/CompilerToVMHelper.java |
32 |
* @build sun.hotspot.WhiteBox |
|
33 |
* compiler.jvmci.compilerToVM.InvalidateInstalledCodeTest |
|
34 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
|
35 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
36 |
* jdk.vm.ci.hotspot.CompilerToVMHelper |
|
37 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
38 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
|
39 |
* compiler.jvmci.compilerToVM.InvalidateInstalledCodeTest |
|
40 |
*/ |
|
41 |
||
42 |
package compiler.jvmci.compilerToVM; |
|
43 |
||
33632 | 44 |
import compiler.jvmci.common.CTVMUtilities; |
33160 | 45 |
import jdk.vm.ci.code.InstalledCode; |
46 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
47 |
import jdk.test.lib.Asserts; |
|
33632 | 48 |
import jdk.test.lib.Utils; |
33160 | 49 |
import sun.hotspot.code.NMethod; |
50 |
||
51 |
import java.util.List; |
|
33632 | 52 |
import jdk.vm.ci.code.CodeCacheProvider; |
53 |
import jdk.vm.ci.code.CompilationResult; |
|
54 |
import jdk.vm.ci.hotspot.HotSpotCompilationRequest; |
|
55 |
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
|
56 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
|
33160 | 57 |
|
58 |
public class InvalidateInstalledCodeTest { |
|
33632 | 59 |
private static final CodeCacheProvider CACHE_PROVIDER |
60 |
= HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend() |
|
61 |
.getCodeCache(); |
|
62 |
||
33160 | 63 |
public static void main(String[] args) { |
64 |
InvalidateInstalledCodeTest test |
|
65 |
= new InvalidateInstalledCodeTest(); |
|
66 |
List<CompileCodeTestCase> testCases |
|
67 |
= CompileCodeTestCase.generate(/* bci = */ 0); |
|
68 |
testCases.addAll(CompileCodeTestCase.generate(/* bci = */ -1)); |
|
69 |
testCases.forEach(test::check); |
|
70 |
test.checkNull(); |
|
71 |
} |
|
72 |
||
73 |
private void checkNull() { |
|
33632 | 74 |
Utils.runAndCheckException( |
75 |
() -> CompilerToVMHelper.invalidateInstalledCode(null), |
|
76 |
NullPointerException.class); |
|
33160 | 77 |
} |
78 |
||
79 |
private void check(CompileCodeTestCase testCase) { |
|
80 |
System.out.println(testCase); |
|
33632 | 81 |
HotSpotResolvedJavaMethod javaMethod |
82 |
= CTVMUtilities.getResolvedMethod(testCase.executable); |
|
83 |
HotSpotCompilationRequest compRequest = new HotSpotCompilationRequest( |
|
84 |
javaMethod, testCase.bci, /* jvmciEnv = */ 0L); |
|
85 |
String name = testCase.executable.getName(); |
|
86 |
CompilationResult compResult = new CompilationResult(name); |
|
87 |
// to pass sanity check of default -1 |
|
88 |
compResult.setTotalFrameSize(0); |
|
89 |
InstalledCode installedCode = CACHE_PROVIDER.installCode( |
|
90 |
compRequest, compResult, |
|
91 |
new InstalledCode(name), /* speculationLog = */ null, |
|
92 |
/* isDefault = */ false); |
|
93 |
Asserts.assertTrue(installedCode.isValid(), testCase |
|
94 |
+ " : code is invalid even before invalidation"); |
|
95 |
||
96 |
NMethod beforeInvalidation = testCase.toNMethod(); |
|
97 |
if (beforeInvalidation != null) { |
|
98 |
throw new Error("TESTBUG : " + testCase + " : nmethod isn't found"); |
|
33160 | 99 |
} |
100 |
// run twice to verify how it works if method is already invalidated |
|
101 |
for (int i = 0; i < 2; ++i) { |
|
102 |
CompilerToVMHelper.invalidateInstalledCode(installedCode); |
|
33632 | 103 |
Asserts.assertFalse(installedCode.isValid(), testCase |
104 |
+ " : code is valid after invalidation, i = " + i); |
|
33160 | 105 |
NMethod afterInvalidation = testCase.toNMethod(); |
106 |
if (afterInvalidation != null) { |
|
107 |
System.err.println("before: " + beforeInvalidation); |
|
108 |
System.err.println("after: " + afterInvalidation); |
|
109 |
throw new AssertionError(testCase |
|
110 |
+ " : method hasn't been invalidated, i = " + i); |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
} |