changeset 22129:769e2e74e4f3

added support for inlining intrinsics to PEGraphDecoder (GRAAL-1170)
author Doug Simon <doug.simon@oracle.com>
date Tue, 30 Jun 2015 12:39:18 +0200
parents 3b8028e55761
children 3f01bf8c02eb
files graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java	Mon Jun 29 20:06:19 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java	Tue Jun 30 12:39:18 2015 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.replacements;
 
+import static com.oracle.graal.graphbuilderconf.IntrinsicContext.CompilationContext.*;
+
 import java.util.*;
 
 import jdk.internal.jvmci.code.*;
@@ -59,11 +61,12 @@
         this.graphCache = new HashMap<>();
     }
 
-    private EncodedGraph createGraph(ResolvedJavaMethod method) {
+    private EncodedGraph createGraph(ResolvedJavaMethod method, boolean isIntrinsic) {
         StructuredGraph graph = new StructuredGraph(method, allowAssumptions);
         try (Debug.Scope scope = Debug.scope("createGraph", graph)) {
 
-            new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), graphBuilderConfig, optimisticOpts, null).apply(graph);
+            IntrinsicContext initialIntrinsicContext = isIntrinsic ? new IntrinsicContext(method, method, INLINE_AFTER_PARSING) : null;
+            new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), graphBuilderConfig, optimisticOpts, initialIntrinsicContext).apply(graph);
 
             PhaseContext context = new PhaseContext(providers);
             new CanonicalizerPhase().apply(graph, context);
@@ -78,10 +81,10 @@
     }
 
     @Override
-    protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod method) {
+    protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod method, boolean isIntrinsic) {
         EncodedGraph result = graphCache.get(method);
         if (result == null && method.hasBytecodes()) {
-            result = createGraph(method);
+            result = createGraph(method, isIntrinsic);
         }
         return result;
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java	Mon Jun 29 20:06:19 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java	Tue Jun 30 12:39:18 2015 +0200
@@ -307,7 +307,7 @@
 
     public void decode(StructuredGraph targetGraph, ResolvedJavaMethod method, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
                     ParameterPlugin parameterPlugin) {
-        PEMethodScope methodScope = new PEMethodScope(targetGraph, null, null, lookupEncodedGraph(method), method, null, 0, loopExplosionPlugin, invocationPlugins, inlineInvokePlugins,
+        PEMethodScope methodScope = new PEMethodScope(targetGraph, null, null, lookupEncodedGraph(method, false), method, null, 0, loopExplosionPlugin, invocationPlugins, inlineInvokePlugins,
                         parameterPlugin, null);
         decode(methodScope, null);
         cleanupGraph(methodScope, null);
@@ -432,19 +432,16 @@
                 if (inlineInfo.getMethodToInline() == null) {
                     return false;
                 } else {
-                    if (inlineInfo.isIntrinsic()) {
-                        // TODO(da): add support for inlining intrinsics
-                        return false;
-                    }
-                    return doInline(methodScope, loopScope, invokeData, inlineInfo.getMethodToInline(), arguments);
+                    return doInline(methodScope, loopScope, invokeData, inlineInfo, arguments);
                 }
             }
         }
         return false;
     }
 
-    protected boolean doInline(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, ResolvedJavaMethod inlineMethod, ValueNode[] arguments) {
-        EncodedGraph graphToInline = lookupEncodedGraph(inlineMethod);
+    protected boolean doInline(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, InlineInfo inlineInfo, ValueNode[] arguments) {
+        ResolvedJavaMethod inlineMethod = inlineInfo.getMethodToInline();
+        EncodedGraph graphToInline = lookupEncodedGraph(inlineMethod, inlineInfo.isIntrinsic());
         if (graphToInline == null) {
             return false;
         }
@@ -579,7 +576,7 @@
         }
     }
 
-    protected abstract EncodedGraph lookupEncodedGraph(ResolvedJavaMethod method);
+    protected abstract EncodedGraph lookupEncodedGraph(ResolvedJavaMethod method, boolean isIntrinsic);
 
     @Override
     protected void handleFixedNode(MethodScope s, LoopScope loopScope, int nodeOrderId, FixedNode node) {