annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java @ 20045:8470e81631f8

converted all @MacroSubstitution uses to InvocationPlugins
author Doug Simon <doug.simon@oracle.com>
date Fri, 27 Mar 2015 13:29:08 +0100
parents 39c0ccfcd070
children 178814b064a7
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
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
25 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
26
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
27 import java.lang.invoke.*;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
28
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
29 import sun.reflect.*;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
30
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
31 import com.oracle.graal.api.code.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 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
33 import com.oracle.graal.api.replacements.*;
19954
c39d8bafd342 Guard constant folding with !ImmutableCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19947
diff changeset
34 import com.oracle.graal.compiler.common.*;
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
35 import com.oracle.graal.compiler.common.type.*;
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
36 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19882
diff changeset
37 import com.oracle.graal.graphbuilderconf.*;
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
38 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Receiver;
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
39 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
40 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
41 import com.oracle.graal.hotspot.nodes.*;
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
42 import com.oracle.graal.hotspot.nodes.ClassQueryNode.Query;
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
43 import com.oracle.graal.hotspot.replacements.*;
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
44 import com.oracle.graal.hotspot.replacements.arraycopy.*;
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
45 import com.oracle.graal.hotspot.word.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 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
47 import com.oracle.graal.nodes.HeapAccess.BarrierType;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 import com.oracle.graal.nodes.extended.*;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 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
50 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
51 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
52 import com.oracle.graal.word.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
54 /**
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
55 * Defines the {@link Plugins} used when running on HotSpot.
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
56 */
19243
006e321d592b removed use of ServiceLoader for graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19198
diff changeset
57 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
58
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
59 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
60 * 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
61 *
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 * @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
63 * @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
64 * @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
65 * @param stampProvider
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
66 */
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
67 public static Plugins create(HotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection,
19947
b94503d3840c removed logic for estimating invocation plugin count
Doug Simon <doug.simon@oracle.com>
parents: 19935
diff changeset
68 SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, StampProvider stampProvider, ReplacementsImpl replacements, Architecture arch) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
69 InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, metaAccess, constantReflection.getMethodHandleAccess());
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
70
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
71 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
72 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
73 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
74
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
75 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
76 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
77 plugins.setLoadIndexedPlugin(new HotSpotLoadIndexedPlugin(wordTypes));
19999
43661c648060 moved non-HotSpot specific inlining functionality into non-HotSpot specific location
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
78 plugins.setInlineInvokePlugin(new DefaultInlineInvokePlugin(replacements));
20033
39c0ccfcd070 Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents: 20006
diff changeset
79 plugins.setGenericInvocationPlugin(new DefaultGenericInvocationPlugin(metaAccess, nodeIntrinsification, wordOperationPlugin));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
80
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
81 registerObjectPlugins(invocationPlugins);
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
82 registerClassPlugins(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
83 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
84 registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config);
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
85 registerCallSitePlugins(invocationPlugins);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
86 registerReflectionPlugins(invocationPlugins);
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
87 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
88 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
89
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
90 return plugins;
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
91 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
92
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
93 private static void registerObjectPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
94 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
95 r.register1("getClass", Receiver.class, new InvocationPlugin() {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
96 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
97 ValueNode rcvr = receiver.get();
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
98 ObjectStamp objectStamp = (ObjectStamp) rcvr.stamp();
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
99 ValueNode mirror;
19954
c39d8bafd342 Guard constant folding with !ImmutableCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19947
diff changeset
100 if (objectStamp.isExactType() && objectStamp.nonNull() && !GraalOptions.ImmutableCode.getValue()) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
101 mirror = 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
102 } else {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
103 StampProvider stampProvider = b.getStampProvider();
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
104 LoadHubNode hub = b.add(new LoadHubNode(stampProvider, rcvr));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
105 mirror = new HubGetClassNode(b.getMetaAccess(), hub);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
106 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
107 b.addPush(Kind.Object, mirror);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
108 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
109 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
110 });
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
111 r.register1("clone", Receiver.class, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
112 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
113 ValueNode object = receiver.get();
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
114 b.addPush(Kind.Object, new ObjectCloneNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), object));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
115 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
116 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
117 });
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
118 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
119
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
120 private static void registerClassPlugins(InvocationPlugins plugins) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
121 Registration r = new Registration(plugins, Class.class);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
122
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
123 for (Query query : Query.values()) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
124 r.register1(query.name(), Receiver.class, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
125 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
126 ValueNode javaClass = receiver.get();
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
127 ValueNode folded = ClassQueryNode.tryFold(javaClass, query, b.getMetaAccess(), b.getConstantReflection());
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
128 if (folded != null) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
129 b.addPush(query.returnKind, folded);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
130 } else {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
131 b.addPush(query.returnKind, new ClassQueryNode(b.getInvokeKind(), targetMethod, query, b.bci(), b.getInvokeReturnType(), javaClass));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
132 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
133 return true;
19150
bb25b153433c Add constant folding for getClass graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
134 }
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
135 });
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
136 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
137 r.register2("cast", Receiver.class, Object.class, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
138 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
139 ValueNode javaClass = receiver.get();
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
140 ValueNode folded = ClassCastNode.tryFold(javaClass, object, b.getConstantReflection(), b.getAssumptions());
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
141 if (folded != null) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
142 b.addPush(Kind.Object, folded);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
143 } else {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
144 b.addPush(Kind.Object, new ClassCastNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), javaClass, object));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
145 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
146 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
147 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
148 });
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
149 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
150
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
151 private static void registerCallSitePlugins(InvocationPlugins plugins) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
152 InvocationPlugin plugin = new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
153 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
154 ValueNode callSite = receiver.get();
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
155 ValueNode folded = CallSiteTargetNode.tryFold(callSite, b.getMetaAccess(), b.getAssumptions());
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
156 if (folded != null) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
157 b.addPush(Kind.Object, folded);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
158 } else {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
159 b.addPush(Kind.Object, new CallSiteTargetNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), callSite));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
160 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
161 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
162 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
163 };
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
164 plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
165 plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
166 plugins.register(plugin, VolatileCallSite.class, "getTarget", Receiver.class);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
167 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
168
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
169 private static void registerReflectionPlugins(InvocationPlugins plugins) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
170 Registration r = new Registration(plugins, Reflection.class);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
171 r.register0("getCallerClass", new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
172 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
173 b.addPush(new ReflectionGetCallerClassNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType()));
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 return true;
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 }
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
176 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
177 }
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
178
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
179 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
180 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
181 r.register0("currentTimeMillis", new InvocationPlugin() {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
182 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19999
diff changeset
183 b.addPush(Kind.Long, new ForeignCallNode(foreignCalls, SystemSubstitutions.JAVA_TIME_MILLIS, StampFactory.forKind(Kind.Long)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
184 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
185 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
186 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
187 r.register0("nanoTime", new InvocationPlugin() {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
188 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19999
diff changeset
189 b.addPush(Kind.Long, new ForeignCallNode(foreignCalls, SystemSubstitutions.JAVA_TIME_NANOS, StampFactory.forKind(Kind.Long)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
190 return true;
19198
5b75ec42c975 added graph builder plugin for Class.cast()
Doug Simon <doug.simon@oracle.com>
parents: 19197
diff changeset
191 }
5b75ec42c975 added graph builder plugin for Class.cast()
Doug Simon <doug.simon@oracle.com>
parents: 19197
diff changeset
192 });
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
193 r.register1("identityHashCode", Object.class, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
194 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
195 b.addPush(new SystemIdentityHashCodeNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), object));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
196 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
197 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
198 });
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
199 r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
200 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
201 b.add(new ArrayCopyNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), src, srcPos, dst, dstPos, length));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
202 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
203 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
204 });
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
205 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
206
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
207 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
208 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
209 r.register0("currentThread", new InvocationPlugin() {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
210 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
211 CurrentJavaThreadNode thread = b.add(new CurrentJavaThreadNode(wordTypes.getWordKind()));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20033
diff changeset
212 ConstantLocationNode location = b.add(new ConstantLocationNode(JAVA_THREAD_THREAD_OBJECT_LOCATION, config.threadObjectOffset));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
213 boolean compressible = false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
214 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
215 boolean exactType = compressible;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
216 boolean nonNull = true;
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19999
diff changeset
217 b.addPush(Kind.Object, new PiNode(javaThread, metaAccess.lookupJavaType(Thread.class), exactType, nonNull));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19504
diff changeset
218 return true;
19325
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
219 }
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
220 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
221 }
19325
1b51524ff1c9 Graph builder plugin for isInstance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19198
diff changeset
222
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
223 private static void registerStableOptionPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19801
diff changeset
224 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
225 r.register1("getValue", Receiver.class, new InvocationPlugin() {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
226 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
19970
30ad420c16fd removed Receiver.isNullConstant() since InvocationPlugins will never be applied if the receiver is the null constant
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
227 if (receiver.isConstant()) {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19954
diff changeset
228 Object object = ((HotSpotObjectConstantImpl) receiver.get().asConstant()).object();
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
229 StableOptionValue<?> option = (StableOptionValue<?>) object;
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19999
diff changeset
230 b.addPush(Kind.Object, ConstantNode.forConstant(HotSpotObjectConstantImpl.forObject(option.getValue()), b.getMetaAccess()));
19197
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
231 return true;
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
232 }
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
233 return false;
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
234 }
c75f5c9c8b6b added graph builder plugin for StableOptionValue.getValue()
Doug Simon <doug.simon@oracle.com>
parents: 19167
diff changeset
235 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
236 }
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
237 }