author | never |
Tue, 28 Jun 2016 17:22:56 +0000 | |
changeset 40034 | 4a288aaf8511 |
parent 39291 | a4efe145313d |
child 40053 | b3617982544e |
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 |
|
39291
a4efe145313d
8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents:
38152
diff
changeset
|
27 |
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") |
33160 | 28 |
* @library / /testlibrary |
36508 | 29 |
* @library ../common/patches |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
37285
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
36508 | 31 |
* @modules java.base/jdk.internal.org.objectweb.asm |
32 |
* java.base/jdk.internal.org.objectweb.asm.tree |
|
33 |
* jdk.vm.ci/jdk.vm.ci.hotspot |
|
34 |
* jdk.vm.ci/jdk.vm.ci.code |
|
35 |
* jdk.vm.ci/jdk.vm.ci.meta |
|
36 |
* jdk.vm.ci/jdk.vm.ci.runtime |
|
37 |
* @ignore 8144964 |
|
38 |
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper |
|
33160 | 39 |
* @build compiler.jvmci.common.JVMCIHelpers |
40 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
|
41 |
* @run main jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ |
|
42 |
* @run main jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config |
|
43 |
* ./META-INF/services/jdk.vm.ci.hotspot.HotSpotVMEventListener |
|
44 |
* @run main ClassFileInstaller |
|
45 |
* compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler |
|
46 |
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory |
|
40034
4a288aaf8511
8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents:
39291
diff
changeset
|
47 |
* compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult |
4a288aaf8511
8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents:
39291
diff
changeset
|
48 |
* compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener |
33160 | 49 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
50 |
* compiler.jvmci.common.CTVMUtilities |
|
51 |
* compiler.jvmci.common.testcases.SimpleClass |
|
52 |
* jdk.test.lib.Asserts |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
53 |
* jdk.test.lib.Utils |
33160 | 54 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
55 |
* -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed |
|
56 |
* -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
57 |
* -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=false |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
58 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
59 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
60 |
* -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
61 |
* -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI -XX:JVMCINMethodSizeLimit=0 |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
62 |
* -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=false |
33160 | 63 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
64 |
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-EnableJVMCI |
|
65 |
* -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
66 |
* -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=true |
33160 | 67 |
* compiler.jvmci.events.JvmciNotifyInstallEventTest |
68 |
*/ |
|
69 |
||
70 |
package compiler.jvmci.events; |
|
71 |
||
72 |
import compiler.jvmci.common.CTVMUtilities; |
|
73 |
import compiler.jvmci.common.testcases.SimpleClass; |
|
74 |
import jdk.test.lib.Asserts; |
|
75 |
import java.lang.reflect.Method; |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
76 |
import jdk.test.lib.Utils; |
33160 | 77 |
import jdk.vm.ci.hotspot.HotSpotVMEventListener; |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
78 |
import jdk.vm.ci.code.CompiledCode; |
33160 | 79 |
import jdk.vm.ci.code.InstalledCode; |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
80 |
import jdk.vm.ci.code.site.DataPatch; |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
81 |
import jdk.vm.ci.code.site.Site; |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
82 |
import jdk.vm.ci.meta.Assumptions.Assumption; |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
83 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
33160 | 84 |
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
85 |
import jdk.vm.ci.hotspot.HotSpotCompiledCode; |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
86 |
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment; |
33160 | 87 |
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
33632 | 88 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
33160 | 89 |
|
90 |
public class JvmciNotifyInstallEventTest implements HotSpotVMEventListener { |
|
91 |
private static final String METHOD_NAME = "testMethod"; |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
92 |
private static final boolean FAIL_ON_INIT = !Boolean.getBoolean( |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
93 |
"compiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit"); |
33160 | 94 |
private static volatile int gotInstallNotification = 0; |
95 |
||
96 |
public static void main(String args[]) { |
|
97 |
new JvmciNotifyInstallEventTest().runTest(); |
|
98 |
} |
|
99 |
||
100 |
private void runTest() { |
|
101 |
if (gotInstallNotification != 0) { |
|
102 |
throw new Error("Got install notification before test actions"); |
|
103 |
} |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
104 |
HotSpotCodeCacheProvider codeCache; |
33160 | 105 |
try { |
106 |
codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime() |
|
107 |
.getHostJVMCIBackend().getCodeCache(); |
|
108 |
} catch (InternalError ie) { |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
109 |
if (FAIL_ON_INIT) { |
33160 | 110 |
throw new AssertionError( |
111 |
"Got unexpected InternalError trying to get code cache", |
|
112 |
ie); |
|
113 |
} |
|
114 |
// passed |
|
115 |
return; |
|
116 |
} |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
117 |
Asserts.assertTrue(FAIL_ON_INIT, |
33160 | 118 |
"Haven't caught InternalError in negative case"); |
119 |
Method testMethod; |
|
120 |
try { |
|
121 |
testMethod = SimpleClass.class.getDeclaredMethod(METHOD_NAME); |
|
122 |
} catch (NoSuchMethodException e) { |
|
123 |
throw new Error("TEST BUG: Can't find " + METHOD_NAME, e); |
|
124 |
} |
|
33632 | 125 |
HotSpotResolvedJavaMethod method = CTVMUtilities |
33160 | 126 |
.getResolvedMethod(SimpleClass.class, testMethod); |
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
127 |
HotSpotCompiledCode compiledCode = new HotSpotCompiledCode(METHOD_NAME, |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
128 |
new byte[0], 0, new Site[0], new Assumption[0], |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
129 |
new ResolvedJavaMethod[]{method}, new Comment[0], new byte[0], |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
130 |
16, new DataPatch[0], false, 0, null); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
131 |
codeCache.installCode(method, compiledCode, /* installedCode = */ null, |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
132 |
/* speculationLog = */ null, /* isDefault = */ false); |
33160 | 133 |
Asserts.assertEQ(gotInstallNotification, 1, |
134 |
"Got unexpected event count after 1st install attempt"); |
|
135 |
// since "empty" compilation result is ok, a second attempt should be ok |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
136 |
codeCache.installCode(method, compiledCode, /* installedCode = */ null, |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
137 |
/* speculationLog = */ null, /* isDefault = */ false); |
33160 | 138 |
Asserts.assertEQ(gotInstallNotification, 2, |
139 |
"Got unexpected event count after 2nd install attempt"); |
|
37285
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
140 |
// and an incorrect cases |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
141 |
Utils.runAndCheckException(() -> { |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
142 |
codeCache.installCode(method, null, null, null, true); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
143 |
}, NullPointerException.class); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
144 |
Asserts.assertEQ(gotInstallNotification, 2, |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
145 |
"Got unexpected event count after 3rd install attempt"); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
146 |
Utils.runAndCheckException(() -> { |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
147 |
codeCache.installCode(null, null, null, null, true); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
148 |
}, NullPointerException.class); |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
149 |
Asserts.assertEQ(gotInstallNotification, 2, |
0473a5a36212
8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents:
36508
diff
changeset
|
150 |
"Got unexpected event count after 4th install attempt"); |
33160 | 151 |
} |
152 |
||
153 |
@Override |
|
154 |
public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, |
|
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
35148
diff
changeset
|
155 |
InstalledCode installedCode, CompiledCode compiledCode) { |
33160 | 156 |
gotInstallNotification++; |
157 |
} |
|
158 |
} |