annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java @ 19884:87736c089259

refactored graph builder plugins to be top level interfaces
author Doug Simon <doug.simon@oracle.com>
date Sun, 15 Mar 2015 11:48:14 +0100
parents 4d33cd6e0c8f
children 87c62a38f843
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
23 package com.oracle.graal.hotspot.meta;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19882
diff changeset
25 import static com.oracle.graal.graphbuilderconf.GraphBuilderContext.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
26 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
19155
ac9ad302e12f added utility to GraphBuilderContext for generating a receiver null check from within an InvocationPlugin for a non-static method
Doug Simon <doug.simon@oracle.com>
parents: 19150
diff changeset
27
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
28 import com.oracle.graal.api.code.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.meta.*;
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
30 import com.oracle.graal.api.replacements.*;
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
31 import com.oracle.graal.compiler.common.type.*;
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19882
diff changeset
32 import com.oracle.graal.graphbuilderconf.*;
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19882
diff changeset
33 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.*;
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19882
diff changeset
34 import com.oracle.graal.graphbuilderconf.InvocationPlugins.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
35 import com.oracle.graal.hotspot.*;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
36 import com.oracle.graal.hotspot.nodes.*;
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
37 import com.oracle.graal.hotspot.replacements.*;
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
38 import com.oracle.graal.hotspot.word.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.nodes.*;
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
40 import com.oracle.graal.nodes.HeapAccess.BarrierType;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.nodes.extended.*;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.nodes.spi.*;
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
43 import com.oracle.graal.options.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
44 import com.oracle.graal.replacements.*;
19801
2e6e20ac56b4 moved WordTypes from c.o.g.word.phases to c.o.g.word
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
45 import com.oracle.graal.word.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
47 /**
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
48 * Defines the {@link Plugins} used when running on HotSpot.
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
49 */
19243
006e321d592b removed use of ServiceLoader for graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19198
diff changeset
50 public class HotSpotGraphBuilderPlugins {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
51
19882
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
52 private static final int PLUGIN_COUNT_ESTIMATE = 160;
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
53
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
54 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
55 * Creates a {@link Plugins} object that should be used when running on HotSpot.
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
56 *
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
57 * @param constantReflection
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
58 * @param snippetReflection
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
59 * @param foreignCalls
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
60 * @param stampProvider
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
61 */
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
62 public static Plugins create(HotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection,
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
63 SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, StampProvider stampProvider, ReplacementsImpl replacements, Architecture arch) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
64
19882
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
65 InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, metaAccess, PLUGIN_COUNT_ESTIMATE);
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
66
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
67 Plugins plugins = new Plugins(invocationPlugins);
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
68 NodeIntrinsificationPhase nodeIntrinsification = new NodeIntrinsificationPhase(metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider);
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
69 HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
70
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
71 plugins.setParameterPlugin(new HotSpotParameterPlugin(wordTypes));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
72 plugins.setLoadFieldPlugin(new HotSpotLoadFieldPlugin(metaAccess, constantReflection));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
73 plugins.setLoadIndexedPlugin(new HotSpotLoadIndexedPlugin(wordTypes));
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
74 plugins.setInlineInvokePlugin(new HotSpotInlineInvokePlugin(nodeIntrinsification, replacements));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
75 plugins.setGenericInvocationPlugin(new DefaultGenericInvocationPlugin(nodeIntrinsification, wordOperationPlugin));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
76
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
77 registerObjectPlugins(invocationPlugins);
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
78 registerSystemPlugins(invocationPlugins, foreignCalls);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
79 registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config);
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
80 registerStableOptionPlugins(invocationPlugins);
19881
6a684aeb1590 NodeIntrinsificationPhase is given only the providers it needs instead of a Providers object
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
81 StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, arch, invocationPlugins, !config.useHeapProfiler);
19882
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
82
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
83 int size = invocationPlugins.size();
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
84 assert PLUGIN_COUNT_ESTIMATE >= size : String.format("adjust %s.PLUGIN_COUNT_ESTIMATE to be above or equal to %d", HotSpotGraphBuilderPlugins.class.getSimpleName(), size);
0c29075aeafe graph builder plugins are created before GraphBuilderConfigurations and the process for deriving plugins from an existing configuration is simplified
Doug Simon <doug.simon@oracle.com>
parents: 19881
diff changeset
85 assert PLUGIN_COUNT_ESTIMATE - size < 20 : String.format("adjust %s.PLUGIN_COUNT_ESTIMATE to be closer to %d", HotSpotGraphBuilderPlugins.class.getSimpleName(), size);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
86 return plugins;
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
87 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
88
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
89 private static void registerObjectPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
90 Registration r = new Registration(plugins, Object.class);
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19070
diff changeset
91 r.register1("getClass", Receiver.class, new InvocationPlugin() {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
92 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, ValueNode rcvr) {
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
93 ObjectStamp objectStamp = (ObjectStamp) rcvr.stamp();
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
94 ValueNode mirror;
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
95 if (objectStamp.isExactType() && objectStamp.nonNull()) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
96 mirror = b.append(ConstantNode.forConstant(objectStamp.type().getJavaClass(), b.getMetaAccess()));
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
97 } else {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
98 StampProvider stampProvider = b.getStampProvider();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
99 LoadHubNode hub = b.append(new LoadHubNode(stampProvider, nullCheckedValue(b, rcvr)));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
100 mirror = b.append(new HubGetClassNode(b.getMetaAccess(), hub));
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
101 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
102 b.push(Kind.Object, mirror);
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 return true;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19070
diff changeset
105 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
106 }
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
107
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
108 private static void registerSystemPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
109 Registration r = new Registration(plugins, System.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
110 r.register0("currentTimeMillis", new InvocationPlugin() {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
111 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
112 b.push(Kind.Long, b.append(new ForeignCallNode(foreignCalls, SystemSubstitutions.JAVA_TIME_MILLIS, StampFactory.forKind(Kind.Long))));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
113 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
114 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
115 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
116 r.register0("nanoTime", new InvocationPlugin() {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
117 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
118 b.push(Kind.Long, b.append(new ForeignCallNode(foreignCalls, SystemSubstitutions.JAVA_TIME_NANOS, StampFactory.forKind(Kind.Long))));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
119 return true;
19198
5b75ec42c975 added graph builder plugin for Class.cast()
Doug Simon <doug.simon@oracle.com>
parents: 19197
diff changeset
120 }
5b75ec42c975 added graph builder plugin for Class.cast()
Doug Simon <doug.simon@oracle.com>
parents: 19197
diff changeset
121 });
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
122 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
123
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
124 private static void registerThreadPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, WordTypes wordTypes, HotSpotVMConfig config) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
125 Registration r = new Registration(plugins, Thread.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
126 r.register0("currentThread", new InvocationPlugin() {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
127 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
128 CurrentJavaThreadNode thread = b.append(new CurrentJavaThreadNode(wordTypes.getWordKind()));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
129 ConstantLocationNode location = b.append(new ConstantLocationNode(JAVA_THREAD_THREAD_OBJECT_LOCATION, config.threadObjectOffset));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
130 boolean compressible = false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
131 ValueNode javaThread = WordOperationPlugin.readOp(b, Kind.Object, thread, location, BarrierType.NONE, compressible);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
132 boolean exactType = compressible;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
133 boolean nonNull = true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
134 b.push(Kind.Object, b.append(new PiNode(javaThread, metaAccess.lookupJavaType(Thread.class), exactType, nonNull)));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
135 return true;
19325
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
136 }
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
137 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
138 }
19325
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
139
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
140 private static void registerStableOptionPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
141 Registration r = new Registration(plugins, StableOptionValue.class);
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
142 r.register1("getValue", Receiver.class, new InvocationPlugin() {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
143 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, ValueNode rcvr) {
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
144 if (rcvr.isConstant() && !rcvr.isNullConstant()) {
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
145 Object object = ((HotSpotObjectConstantImpl) rcvr.asConstant()).object();
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
146 StableOptionValue<?> option = (StableOptionValue<?>) object;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
147 ConstantNode value = b.append(ConstantNode.forConstant(HotSpotObjectConstantImpl.forObject(option.getValue()), b.getMetaAccess()));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
148 b.push(Kind.Object, value);
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
149 return true;
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
150 }
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
151 return false;
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
152 }
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
153 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
154 }
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 }