author | iignatyev |
Fri, 16 Oct 2015 02:05:54 +0300 | |
changeset 33191 | e155b02f22fc |
parent 33160 | c59f1676d27e |
child 33730 | 30e064828045 |
child 33632 | 038347770a9e |
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" |
|
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 |
||
44 |
import jdk.vm.ci.code.InstalledCode; |
|
45 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
46 |
import jdk.test.lib.Asserts; |
|
47 |
import sun.hotspot.code.NMethod; |
|
48 |
||
49 |
import java.util.List; |
|
50 |
||
51 |
public class InvalidateInstalledCodeTest { |
|
52 |
public static void main(String[] args) { |
|
53 |
InvalidateInstalledCodeTest test |
|
54 |
= new InvalidateInstalledCodeTest(); |
|
55 |
List<CompileCodeTestCase> testCases |
|
56 |
= CompileCodeTestCase.generate(/* bci = */ 0); |
|
57 |
testCases.addAll(CompileCodeTestCase.generate(/* bci = */ -1)); |
|
58 |
testCases.forEach(test::check); |
|
59 |
test.checkNull(); |
|
60 |
} |
|
61 |
||
62 |
private void checkNull() { |
|
63 |
InstalledCode installedCode = new InstalledCode("<null>"); |
|
64 |
installedCode.setAddress(0); |
|
65 |
CompilerToVMHelper.invalidateInstalledCode(installedCode); |
|
66 |
} |
|
67 |
||
68 |
private void check(CompileCodeTestCase testCase) { |
|
69 |
System.out.println(testCase); |
|
70 |
// to have a clean state |
|
71 |
NMethod beforeInvalidation = testCase.deoptimizeAndCompile(); |
|
72 |
if (beforeInvalidation == null) { |
|
73 |
throw new Error("method is not compiled, testCase " + testCase); |
|
74 |
} |
|
75 |
||
76 |
// run twice to verify how it works if method is already invalidated |
|
77 |
for (int i = 0; i < 2; ++i) { |
|
78 |
InstalledCode installedCode = new InstalledCode( |
|
79 |
testCase.executable.getName()); |
|
80 |
installedCode.setAddress(beforeInvalidation.address); |
|
81 |
||
82 |
CompilerToVMHelper.invalidateInstalledCode(installedCode); |
|
83 |
NMethod afterInvalidation = testCase.toNMethod(); |
|
84 |
if (afterInvalidation != null) { |
|
85 |
System.err.println("before: " + beforeInvalidation); |
|
86 |
System.err.println("after: " + afterInvalidation); |
|
87 |
throw new AssertionError(testCase |
|
88 |
+ " : method hasn't been invalidated, i = " + i); |
|
89 |
} |
|
90 |
Asserts.assertFalse(installedCode.isValid(), testCase |
|
91 |
+ " : code is valid after invalidation, i = " + i); |
|
92 |
} |
|
93 |
} |
|
94 |
} |