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 package org.graalvm.compiler.nodes.spi;
26
27 import org.graalvm.compiler.api.replacements.MethodSubstitution;
28 import org.graalvm.compiler.api.replacements.SnippetTemplateCache;
29 import org.graalvm.compiler.bytecode.Bytecode;
30 import org.graalvm.compiler.bytecode.BytecodeProvider;
31 import org.graalvm.compiler.graph.NodeSourcePosition;
32 import org.graalvm.compiler.nodes.StructuredGraph;
33 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
34 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
35 import org.graalvm.compiler.options.OptionValues;
36
37 import jdk.vm.ci.meta.ResolvedJavaMethod;
38
39 /**
40 * Interface for managing replacements.
41 */
42 public interface Replacements {
43
44 OptionValues getOptions();
45
46 /**
47 * Gets the object managing the various graph builder plugins used by this object when parsing
48 * bytecode into a graph.
49 */
50 GraphBuilderConfiguration.Plugins getGraphBuilderPlugins();
75 */
76 void registerSnippet(ResolvedJavaMethod method, boolean trackNodeSourcePosition);
77
78 /**
79 * Gets a graph that is a substitution for a given method.
80 *
81 * @param invokeBci the call site BCI if this request is made for inlining a substitute
82 * otherwise {@code -1}
83 * @param trackNodeSourcePosition
84 * @return the graph, if any, that is a substitution for {@code method}
85 */
86 StructuredGraph getSubstitution(ResolvedJavaMethod method, int invokeBci, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition);
87
88 /**
89 * Gets the substitute bytecode for a given method.
90 *
91 * @return the bytecode to substitute for {@code method} or {@code null} if there is no
92 * substitute bytecode for {@code method}
93 */
94 Bytecode getSubstitutionBytecode(ResolvedJavaMethod method);
95
96 /**
97 * Determines if there may be a
98 * {@linkplain #getSubstitution(ResolvedJavaMethod, int, boolean, NodeSourcePosition)
99 * substitution graph} for a given method.
100 *
101 * A call to {@link #getSubstitution} may still return {@code null} for {@code method} and
102 * {@code invokeBci}. A substitution may be based on an {@link InvocationPlugin} that returns
103 * {@code false} for {@link InvocationPlugin#execute} making it impossible to create a
104 * substitute graph.
105 *
106 * @param invokeBci the call site BCI if this request is made for inlining a substitute
107 * otherwise {@code -1}
108 * @return true iff there may be a substitution graph available for {@code method}
109 */
110 boolean hasSubstitution(ResolvedJavaMethod method, int invokeBci);
111
112 /**
113 * Gets the provider for accessing the bytecode of a substitution method if no other provider is
114 * associated with the substitution method.
|
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 package org.graalvm.compiler.nodes.spi;
26
27 import org.graalvm.compiler.api.replacements.MethodSubstitution;
28 import org.graalvm.compiler.api.replacements.SnippetTemplateCache;
29 import org.graalvm.compiler.bytecode.Bytecode;
30 import org.graalvm.compiler.bytecode.BytecodeProvider;
31 import org.graalvm.compiler.core.common.CompilationIdentifier;
32 import org.graalvm.compiler.debug.DebugContext;
33 import org.graalvm.compiler.graph.NodeSourcePosition;
34 import org.graalvm.compiler.nodes.StructuredGraph;
35 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
36 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
37 import org.graalvm.compiler.options.OptionValues;
38
39 import jdk.vm.ci.meta.ResolvedJavaMethod;
40
41 /**
42 * Interface for managing replacements.
43 */
44 public interface Replacements {
45
46 OptionValues getOptions();
47
48 /**
49 * Gets the object managing the various graph builder plugins used by this object when parsing
50 * bytecode into a graph.
51 */
52 GraphBuilderConfiguration.Plugins getGraphBuilderPlugins();
77 */
78 void registerSnippet(ResolvedJavaMethod method, boolean trackNodeSourcePosition);
79
80 /**
81 * Gets a graph that is a substitution for a given method.
82 *
83 * @param invokeBci the call site BCI if this request is made for inlining a substitute
84 * otherwise {@code -1}
85 * @param trackNodeSourcePosition
86 * @return the graph, if any, that is a substitution for {@code method}
87 */
88 StructuredGraph getSubstitution(ResolvedJavaMethod method, int invokeBci, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition);
89
90 /**
91 * Gets the substitute bytecode for a given method.
92 *
93 * @return the bytecode to substitute for {@code method} or {@code null} if there is no
94 * substitute bytecode for {@code method}
95 */
96 Bytecode getSubstitutionBytecode(ResolvedJavaMethod method);
97
98 /**
99 * Gets a graph produced from the intrinsic for a given method that can be compiled and
100 * installed for the method.
101 *
102 * @param method
103 * @param compilationId
104 * @param debug
105 * @return an intrinsic graph that can be compiled and installed for {@code method} or null
106 */
107 StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, CompilationIdentifier compilationId, DebugContext debug);
108
109 /**
110 * Determines if there may be a
111 * {@linkplain #getSubstitution(ResolvedJavaMethod, int, boolean, NodeSourcePosition)
112 * substitution graph} for a given method.
113 *
114 * A call to {@link #getSubstitution} may still return {@code null} for {@code method} and
115 * {@code invokeBci}. A substitution may be based on an {@link InvocationPlugin} that returns
116 * {@code false} for {@link InvocationPlugin#execute} making it impossible to create a
117 * substitute graph.
118 *
119 * @param invokeBci the call site BCI if this request is made for inlining a substitute
120 * otherwise {@code -1}
121 * @return true iff there may be a substitution graph available for {@code method}
122 */
123 boolean hasSubstitution(ResolvedJavaMethod method, int invokeBci);
124
125 /**
126 * Gets the provider for accessing the bytecode of a substitution method if no other provider is
127 * associated with the substitution method.
|