43972
|
1 |
/*
|
58299
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
43972
|
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 |
*/
|
50858
|
23 |
|
|
24 |
|
43972
|
25 |
package org.graalvm.compiler.hotspot.test;
|
|
26 |
|
44836
|
27 |
import static org.graalvm.compiler.core.common.CompilationIdentifier.INVALID_COMPILATION_ID;
|
48861
|
28 |
|
43972
|
29 |
import java.util.List;
|
|
30 |
|
49873
|
31 |
import jdk.internal.vm.compiler.collections.EconomicMap;
|
43972
|
32 |
import org.graalvm.compiler.api.test.Graal;
|
|
33 |
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
46640
|
34 |
import org.graalvm.compiler.debug.DebugContext;
|
43972
|
35 |
import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
|
|
36 |
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
|
37 |
import org.graalvm.compiler.nodes.StructuredGraph;
|
|
38 |
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
|
39 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
|
40 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
46459
|
41 |
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Binding;
|
48861
|
42 |
import org.graalvm.compiler.nodes.graphbuilderconf.MethodSubstitutionPlugin;
|
46640
|
43 |
import org.graalvm.compiler.options.OptionValues;
|
43972
|
44 |
import org.graalvm.compiler.runtime.RuntimeProvider;
|
44836
|
45 |
import org.junit.Test;
|
43972
|
46 |
|
|
47 |
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
|
|
48 |
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
|
|
49 |
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Exercise the compilation of intrinsic method substitutions.
|
|
53 |
*/
|
|
54 |
public class TestIntrinsicCompiles extends GraalCompilerTest {
|
|
55 |
|
|
56 |
@Test
|
|
57 |
@SuppressWarnings("try")
|
46459
|
58 |
public void test() throws ClassNotFoundException {
|
43972
|
59 |
HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
|
|
60 |
HotSpotProviders providers = rt.getHostBackend().getProviders();
|
|
61 |
Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
|
|
62 |
InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
|
|
63 |
|
46459
|
64 |
EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
|
43972
|
65 |
HotSpotVMConfigStore store = rt.getVMConfig().getStore();
|
|
66 |
List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
|
46640
|
67 |
OptionValues options = getInitialOptions();
|
|
68 |
DebugContext debug = getDebugContext(options);
|
43972
|
69 |
for (VMIntrinsicMethod intrinsic : intrinsics) {
|
46459
|
70 |
InvocationPlugin plugin = CheckGraalIntrinsics.findPlugin(bindings, intrinsic);
|
|
71 |
if (plugin != null) {
|
|
72 |
if (plugin instanceof MethodSubstitutionPlugin) {
|
|
73 |
ResolvedJavaMethod method = CheckGraalIntrinsics.resolveIntrinsic(getMetaAccess(), intrinsic);
|
|
74 |
if (!method.isNative()) {
|
55509
|
75 |
StructuredGraph graph = providers.getReplacements().getIntrinsicGraph(method, INVALID_COMPILATION_ID, debug, null);
|
46459
|
76 |
getCode(method, graph);
|
|
77 |
}
|
43972
|
78 |
}
|
|
79 |
}
|
|
80 |
}
|
|
81 |
}
|
|
82 |
}
|