changeset 21904:c0781796c8bc

made getSubstitutionMethod part of Replacements API
author Doug Simon <doug.simon@oracle.com>
date Thu, 11 Jun 2015 01:15:26 +0200
parents 5ebd0a25abe4
children 3187b704b4d1
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.
      *
--- 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);
     }