author | twisti |
Wed, 23 Dec 2015 20:19:42 -1000 | |
changeset 35148 | 5cfafc99d791 |
parent 34511 | 307de49e6b2a |
child 35582 | c32a0cc19877 |
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 |
* @test |
|
26 |
* @bug 8136421 |
|
35148 | 27 |
* @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") |
33160 | 28 |
* @library / /testlibrary |
29 |
* @compile ../common/CompilerToVMHelper.java |
|
30 |
* @build compiler.jvmci.common.JVMCIHelpers |
|
31 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
|
32 |
* @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ |
|
33 |
* @run main jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config |
|
34 |
* ./META-INF/services/jdk.vm.ci.hotspot.HotSpotVMEventListener |
|
35 |
* @run main ClassFileInstaller |
|
36 |
* compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler |
|
37 |
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory |
|
38 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
|
39 |
* compiler.jvmci.common.CTVMUtilities |
|
40 |
* compiler.jvmci.common.testcases.SimpleClass |
|
41 |
* jdk.vm.ci.hotspot.CompilerToVMHelper |
|
42 |
* jdk.test.lib.Asserts |
|
43 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
|
44 |
* -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed |
|
45 |
* -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI |
|
46 |
* -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.noevent=false |
|
47 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
|
48 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-EnableJVMCI |
|
49 |
* -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed |
|
50 |
* -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.noevent=true |
|
51 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
|
52 |
*/ |
|
53 |
||
54 |
package compiler.jvmci.events; |
|
55 |
||
56 |
import compiler.jvmci.common.CTVMUtilities; |
|
57 |
import compiler.jvmci.common.testcases.SimpleClass; |
|
58 |
import jdk.test.lib.Asserts; |
|
59 |
import java.lang.reflect.Method; |
|
60 |
import jdk.vm.ci.hotspot.HotSpotVMEventListener; |
|
61 |
import jdk.vm.ci.code.CompilationResult; |
|
62 |
import jdk.vm.ci.code.InstalledCode; |
|
63 |
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; |
|
33632 | 64 |
import jdk.vm.ci.hotspot.HotSpotCompilationRequest; |
33160 | 65 |
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
33632 | 66 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
33160 | 67 |
|
68 |
public class JvmciNotifyInstallEventTest implements HotSpotVMEventListener { |
|
69 |
private static final String METHOD_NAME = "testMethod"; |
|
70 |
private static final boolean IS_POSITIVE = !Boolean.getBoolean( |
|
71 |
"compiler.jvmci.events.JvmciNotifyInstallEventTest.noevent"); |
|
72 |
private static volatile int gotInstallNotification = 0; |
|
73 |
||
74 |
public static void main(String args[]) { |
|
75 |
new JvmciNotifyInstallEventTest().runTest(); |
|
76 |
} |
|
77 |
||
78 |
private void runTest() { |
|
79 |
if (gotInstallNotification != 0) { |
|
80 |
throw new Error("Got install notification before test actions"); |
|
81 |
} |
|
82 |
HotSpotCodeCacheProvider codeCache = null; |
|
83 |
try { |
|
84 |
codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime() |
|
85 |
.getHostJVMCIBackend().getCodeCache(); |
|
86 |
} catch (InternalError ie) { |
|
87 |
if (IS_POSITIVE) { |
|
88 |
throw new AssertionError( |
|
89 |
"Got unexpected InternalError trying to get code cache", |
|
90 |
ie); |
|
91 |
} |
|
92 |
// passed |
|
93 |
return; |
|
94 |
} |
|
95 |
Asserts.assertTrue(IS_POSITIVE, |
|
96 |
"Haven't caught InternalError in negative case"); |
|
97 |
Method testMethod; |
|
98 |
try { |
|
99 |
testMethod = SimpleClass.class.getDeclaredMethod(METHOD_NAME); |
|
100 |
} catch (NoSuchMethodException e) { |
|
101 |
throw new Error("TEST BUG: Can't find " + METHOD_NAME, e); |
|
102 |
} |
|
33632 | 103 |
HotSpotResolvedJavaMethod method = CTVMUtilities |
33160 | 104 |
.getResolvedMethod(SimpleClass.class, testMethod); |
105 |
CompilationResult compResult = new CompilationResult(METHOD_NAME); |
|
33632 | 106 |
HotSpotCompilationRequest compRequest = new HotSpotCompilationRequest(method, -1, 0L); |
33160 | 107 |
// to pass sanity check of default -1 |
108 |
compResult.setTotalFrameSize(0); |
|
34511
307de49e6b2a
8144529: [JVMCI] compiler/jvmci/errors/TestInvalidCompilationResult.java fails to compile after JDK-8143730
twisti
parents:
34156
diff
changeset
|
109 |
compResult.close(); |
33632 | 110 |
codeCache.installCode(compRequest, compResult, /* installedCode = */ null, /* speculationLog = */ null, |
33160 | 111 |
/* isDefault = */ false); |
112 |
Asserts.assertEQ(gotInstallNotification, 1, |
|
113 |
"Got unexpected event count after 1st install attempt"); |
|
114 |
// since "empty" compilation result is ok, a second attempt should be ok |
|
33632 | 115 |
codeCache.installCode(compRequest, compResult, /* installedCode = */ null, /* speculationLog = */ null, |
33160 | 116 |
/* isDefault = */ false); |
117 |
Asserts.assertEQ(gotInstallNotification, 2, |
|
118 |
"Got unexpected event count after 2nd install attempt"); |
|
119 |
} |
|
120 |
||
121 |
@Override |
|
122 |
public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, |
|
123 |
InstalledCode installedCode, CompilationResult compResult) { |
|
124 |
gotInstallNotification++; |
|
125 |
} |
|
126 |
} |