# HG changeset patch # User Doug Simon # Date 1433978126 -7200 # Node ID c0781796c8bc584c5176eddeb645f6b7d02eae5c # Parent 5ebd0a25abe4637ce9d2738f5c4d2897f5c429df made getSubstitutionMethod part of Replacements API diff -r 5ebd0a25abe4 -r c0781796c8bc graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Wed Jun 10 20:19:30 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java Thu Jun 11 01:15:26 2015 +0200 @@ -80,6 +80,13 @@ StructuredGraph getSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly, int invokeBci); /** + * Gets a method that is a substitution for a given method. + * + * @return the method, if any, whose bytecode are a substitution for {@code method} + */ + ResolvedJavaMethod getSubstitutionMethod(ResolvedJavaMethod method); + + /** * Determines if there is a {@linkplain #getSubstitution(ResolvedJavaMethod, int) substitution * graph} for a given method. * diff -r 5ebd0a25abe4 -r c0781796c8bc graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Wed Jun 10 20:19:30 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Jun 11 01:15:26 2015 +0200 @@ -327,8 +327,8 @@ if (plugin != null) { if (!plugin.inlineOnly() || invokeBci >= 0) { if (plugin instanceof MethodSubstitutionPlugin) { - MethodSubstitutionPlugin msplugin = (MethodSubstitutionPlugin) plugin; - substitute = msplugin.getSubstitute(providers.getMetaAccess()); + MethodSubstitutionPlugin msPlugin = (MethodSubstitutionPlugin) plugin; + substitute = msPlugin.getSubstitute(providers.getMetaAccess()); } else { StructuredGraph graph = new IntrinsicGraphBuilder(providers.getMetaAccess(), providers.getConstantReflection(), providers.getStampProvider(), original, invokeBci).buildGraph(plugin); if (graph != null) { @@ -682,6 +682,11 @@ } public ResolvedJavaMethod getSubstitutionMethod(ResolvedJavaMethod original) { + InvocationPlugin plugin = graphBuilderPlugins.getInvocationPlugins().lookupInvocation(original); + if (plugin instanceof MethodSubstitutionPlugin) { + MethodSubstitutionPlugin msPlugin = (MethodSubstitutionPlugin) plugin; + return msPlugin.getSubstitute(providers.getMetaAccess()); + } ClassReplacements cr = getClassReplacements(original.getDeclaringClass().getName()); return cr == null ? null : cr.methodSubstitutions.get(original); }