# HG changeset patch # User Doug Simon # Date 1435660758 -7200 # Node ID 769e2e74e4f3528b91af820b1e9d520345a63410 # Parent 3b8028e55761d5237d1704cfc83df54bd9fd9ed8 added support for inlining intrinsics to PEGraphDecoder (GRAAL-1170) diff -r 3b8028e55761 -r 769e2e74e4f3 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CachingPEGraphDecoder.java --- 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; } diff -r 3b8028e55761 -r 769e2e74e4f3 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/PEGraphDecoder.java --- 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) {