changeset 20166:28a85fa57b27

renamed getMethodSubstitution to getSubstitution in Replacements API and removed getMethodSubstitutionMethod
author Doug Simon <doug.simon@oracle.com>
date Sat, 04 Apr 2015 21:57:19 +0200
parents a100c22edc32
children 6b119b6362de
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineMethodSubstitutionsPolicy.java graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/ReplaceIntrinsicsPhase.java
diffstat 12 files changed, 37 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Sat Apr 04 21:57:19 2015 +0200
@@ -125,7 +125,8 @@
             Method method = lookup(className, methodName);
             if (method != null) {
                 ResolvedJavaMethod installedCodeOwner = getMetaAccess().lookupJavaMethod(method);
-                ResolvedJavaMethod substMethod = getReplacements().getMethodSubstitutionMethod(installedCodeOwner);
+                StructuredGraph subst = getReplacements().getSubstitution(installedCodeOwner, true);
+                ResolvedJavaMethod substMethod = subst == null ? null : subst.method();
                 if (substMethod != null) {
                     StructuredGraph graph = new StructuredGraph(substMethod, AllowAssumptions.YES);
                     Plugins plugins = new Plugins(((HotSpotProviders) getProviders()).getGraphBuilderPlugins());
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java	Sat Apr 04 21:57:19 2015 +0200
@@ -88,7 +88,7 @@
                 }
                 if (BootstrapReplacements.getValue()) {
                     for (ResolvedJavaMethod method : replacements.getAllReplacements()) {
-                        replacements.getMethodSubstitution(method);
+                        replacements.getSubstitution(method);
                     }
                 }
             } catch (Throwable e) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Sat Apr 04 21:57:19 2015 +0200
@@ -72,8 +72,8 @@
      *
      * @return the graph, if any, that is a substitution for {@code method}
      */
-    default StructuredGraph getMethodSubstitution(ResolvedJavaMethod method) {
-        return getMethodSubstitution(method, false);
+    default StructuredGraph getSubstitution(ResolvedJavaMethod method) {
+        return getSubstitution(method, false);
     }
 
     /**
@@ -82,22 +82,27 @@
      * @param fromBytecodeOnly only return a graph created by parsing the bytecode of another method
      * @return the graph, if any, that is a substitution for {@code method}
      */
-    StructuredGraph getMethodSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly);
+    StructuredGraph getSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly);
 
     /**
-     * Determines if there is a {@linkplain #getMethodSubstitution(ResolvedJavaMethod) substitution
-     * graph} for a given method.
+     * Determines if there is a {@linkplain #getSubstitution(ResolvedJavaMethod) substitution graph}
+     * for a given method.
      *
      * @return true iff there is a substitution graph available for {@code method}
      */
-    boolean hasMethodSubstitution(ResolvedJavaMethod method);
+    default boolean hasSubstitution(ResolvedJavaMethod method) {
+        return hasSubstitution(method, false);
+    }
 
     /**
-     * Gets the method that is a substitution for a given method.
+     * Determines if there is a {@linkplain #getSubstitution(ResolvedJavaMethod) substitution graph}
+     * for a given method.
      *
-     * @return the method, if any, that is a substitution for {@code method}
+     * @param fromBytecodeOnly only consider graphs created by parsing the bytecode of another
+     *            method
+     * @return true iff there is a substitution graph available for {@code method}
      */
-    ResolvedJavaMethod getMethodSubstitutionMethod(ResolvedJavaMethod method);
+    boolean hasSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly);
 
     /**
      * Registers all the {@linkplain MethodSubstitution method} substitutions defined by a given
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java	Sat Apr 04 21:57:19 2015 +0200
@@ -574,11 +574,11 @@
     }
 
     public static boolean canIntrinsify(Replacements replacements, ResolvedJavaMethod target) {
-        return replacements.hasMethodSubstitution(target);
+        return replacements.hasSubstitution(target, false);
     }
 
     public static StructuredGraph getIntrinsicGraph(Replacements replacements, ResolvedJavaMethod target) {
-        return replacements.getMethodSubstitution(target);
+        return replacements.getSubstitution(target);
     }
 
     public static FixedWithNextNode inlineMacroNode(Invoke invoke, ResolvedJavaMethod concrete, Class<? extends FixedWithNextNode> macroNodeClass) throws GraalInternalError {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineMethodSubstitutionsPolicy.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/policy/InlineMethodSubstitutionsPolicy.java	Sat Apr 04 21:57:19 2015 +0200
@@ -38,7 +38,7 @@
         CallTargetNode callTarget = invocation.callee().invoke().callTarget();
         if (callTarget instanceof MethodCallTargetNode) {
             ResolvedJavaMethod calleeMethod = ((MethodCallTargetNode) callTarget).targetMethod();
-            if (replacements.getMethodSubstitution(calleeMethod) != null) {
+            if (replacements.getSubstitution(calleeMethod) != null) {
                 return true;
             }
         }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java	Sat Apr 04 21:57:19 2015 +0200
@@ -76,7 +76,7 @@
         StructuredGraph graph = testGraph(testMethodName);
 
         // Check to see if the resulting graph contains the expected node
-        StructuredGraph replacement = getReplacements().getMethodSubstitution(realMethod);
+        StructuredGraph replacement = getReplacements().getSubstitution(realMethod);
         if (replacement == null && !optional) {
             assertInGraph(graph, intrinsicClass);
         }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java	Sat Apr 04 21:57:19 2015 +0200
@@ -131,7 +131,7 @@
         StructuredGraph graph = testGraph(testMethodName);
 
         // Check to see if the resulting graph contains the expected node
-        StructuredGraph replacement = getReplacements().getMethodSubstitution(realJavaMethod);
+        StructuredGraph replacement = getReplacements().getSubstitution(realJavaMethod);
         if (replacement == null && !optional) {
             assertInGraph(graph, intrinsicClass);
         }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java	Sat Apr 04 21:57:19 2015 +0200
@@ -41,7 +41,7 @@
         StructuredGraph graph = testGraph(testMethodName);
 
         // Check to see if the resulting graph contains the expected node
-        StructuredGraph replacement = getReplacements().getMethodSubstitution(realMethod);
+        StructuredGraph replacement = getReplacements().getSubstitution(realMethod);
         if (replacement == null && !optional) {
             assertInGraph(graph, intrinsicClass);
         }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Sat Apr 04 21:57:19 2015 +0200
@@ -93,7 +93,7 @@
      *         inlined based on substitution related criteria
      */
     public InlineInfo getInlineInfo(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType) {
-        ResolvedJavaMethod subst = getMethodSubstitutionMethod(method);
+        ResolvedJavaMethod subst = getSubstitutionMethod(method);
         if (subst != null) {
             if (b.parsingReplacement() || InlineDuringParsing.getValue() || InlineIntrinsicsDuringParsing.getValue()) {
                 // Forced inlining of intrinsics
@@ -336,7 +336,7 @@
     }
 
     @Override
-    public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original, boolean fromBytecodeOnly) {
+    public StructuredGraph getSubstitution(ResolvedJavaMethod original, boolean fromBytecodeOnly) {
         if (!fromBytecodeOnly) {
             InvocationPlugin plugin = graphBuilderPlugins.getInvocationPlugins().lookupInvocation(original);
             if (plugin != null) {
@@ -800,12 +800,16 @@
         return cr != null && cr.forcedSubstitutions.contains(method);
     }
 
-    public boolean hasMethodSubstitution(ResolvedJavaMethod method) {
-        return graphBuilderPlugins.getInvocationPlugins().lookupInvocation(method) != null || getMethodSubstitutionMethod(method) != null;
+    public boolean hasSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly) {
+        if (!fromBytecodeOnly) {
+            if (graphBuilderPlugins.getInvocationPlugins().lookupInvocation(method) != null) {
+                return true;
+            }
+        }
+        return getSubstitutionMethod(method) != null;
     }
 
-    @Override
-    public ResolvedJavaMethod getMethodSubstitutionMethod(ResolvedJavaMethod original) {
+    public ResolvedJavaMethod getSubstitutionMethod(ResolvedJavaMethod original) {
         ClassReplacements cr = getClassReplacements(original.getDeclaringClass().getName());
         return cr == null ? null : cr.methodSubstitutions.get(original);
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Sat Apr 04 21:57:19 2015 +0200
@@ -108,7 +108,7 @@
      * lowered}.
      */
     protected StructuredGraph getLoweredSubstitutionGraph(LoweringTool tool) {
-        StructuredGraph methodSubstitution = tool.getReplacements().getMethodSubstitution(getTargetMethod(), true);
+        StructuredGraph methodSubstitution = tool.getReplacements().getSubstitution(getTargetMethod(), true);
         if (methodSubstitution != null) {
             methodSubstitution = methodSubstitution.copy();
             if (stateAfter() == null || stateAfter().bci == BytecodeFrame.AFTER_BCI) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Sat Apr 04 21:57:19 2015 +0200
@@ -170,7 +170,7 @@
             if (original.getAnnotation(TruffleBoundary.class) != null) {
                 return null;
             }
-            if (replacements != null && replacements.getMethodSubstitutionMethod(original) != null) {
+            if (replacements != null && replacements.hasSubstitution(original)) {
                 return null;
             }
             assert !builder.parsingReplacement();
@@ -248,7 +248,7 @@
         new ConvertDeoptimizeToGuardPhase().apply(graph, tierContext);
 
         for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.TYPE)) {
-            StructuredGraph inlineGraph = providers.getReplacements().getMethodSubstitution(methodCallTargetNode.targetMethod());
+            StructuredGraph inlineGraph = providers.getReplacements().getSubstitution(methodCallTargetNode.targetMethod());
             if (inlineGraph != null) {
                 InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, true, null);
             }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/ReplaceIntrinsicsPhase.java	Sat Apr 04 21:43:21 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/ReplaceIntrinsicsPhase.java	Sat Apr 04 21:57:19 2015 +0200
@@ -47,7 +47,7 @@
             if (methodCallTarget.isAlive()) {
                 InvokeKind invokeKind = methodCallTarget.invokeKind();
                 if (invokeKind.isDirect()) {
-                    StructuredGraph inlineGraph = replacements.getMethodSubstitution(methodCallTarget.targetMethod());
+                    StructuredGraph inlineGraph = replacements.getSubstitution(methodCallTarget.targetMethod());
                     if (inlineGraph != null) {
                         InliningUtil.inline(methodCallTarget.invoke(), inlineGraph, true, null);
                         Debug.dump(graph, "After inlining %s", methodCallTarget.targetMethod().toString());