changeset 21007:f84166ee0798

removed application of NodeIntrinsificationPhase in ReplacementsImpl since node intrinsification is always done during graph parsing now
author Doug Simon <doug.simon@oracle.com>
date Fri, 17 Apr 2015 17:13:09 +0200
parents 44ee46c753b1
children 76e3f83aa4ac
files graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
diffstat 5 files changed, 2 insertions(+), 126 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Fri Apr 17 15:40:26 2015 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Fri Apr 17 17:13:09 2015 +0200
@@ -49,7 +49,6 @@
 import com.oracle.graal.phases.common.inlining.*;
 import com.oracle.graal.phases.common.inlining.policy.*;
 import com.oracle.graal.phases.tiers.*;
-import com.oracle.graal.replacements.*;
 
 /**
  * The following unit tests assert the presence of write barriers for both Serial and G1 GCs.
@@ -251,7 +250,6 @@
             StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
             HighTierContext highContext = getDefaultHighTierContext();
             MidTierContext midContext = new MidTierContext(getProviders(), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
-            new NodeIntrinsificationPhase(getMetaAccess(), getConstantReflection(), getSnippetReflection(), getProviders().getForeignCalls(), getProviders().getStampProvider()).apply(graph);
             new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext);
             new CanonicalizerPhase().apply(graph, highContext);
             new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Fri Apr 17 15:40:26 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/Replacements.java	Fri Apr 17 17:13:09 2015 +0200
@@ -59,15 +59,6 @@
     void registerSnippet(ResolvedJavaMethod method);
 
     /**
-     * Notifies this object during snippet specialization once the specialized snippet's constant
-     * parameters have been replaced with constant values.
-     *
-     * @param specializedSnippet the snippet in the process of being specialized. This is a copy of
-     *            the unspecialized snippet graph created during snippet preparation.
-     */
-    void notifyAfterConstantsBound(StructuredGraph specializedSnippet);
-
-    /**
      * Gets a graph that is a substitution for a given method.
      *
      * @param invokeBci the call site BCI if this request is made for inlining a substitute
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java	Fri Apr 17 15:40:26 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.replacements;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Node.ConstantNodeParameter;
-import com.oracle.graal.graph.Node.NodeIntrinsic;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.java.*;
-import com.oracle.graal.phases.*;
-
-/**
- * Checks that a graph contains no calls to {@link NodeIntrinsic} or {@link Fold} methods.
- */
-public class NodeIntrinsificationVerificationPhase extends Phase {
-
-    public static void verify(StructuredGraph graph) {
-        new NodeIntrinsificationVerificationPhase().apply(graph);
-    }
-
-    @Override
-    protected void run(StructuredGraph graph) {
-        for (MethodCallTargetNode n : graph.getNodes(MethodCallTargetNode.TYPE)) {
-            checkInvoke(n);
-        }
-    }
-
-    private static void checkInvoke(MethodCallTargetNode n) {
-        ResolvedJavaMethod target = n.targetMethod();
-        if (target.getAnnotation(Node.NodeIntrinsic.class) != null) {
-            error(n, "Intrinsification");
-        } else if (target.getAnnotation(Fold.class) != null) {
-            error(n, "Folding");
-        }
-    }
-
-    private static void error(MethodCallTargetNode n, String failedAction) throws GraalInternalError {
-        String context = n.graph().method().format("%H.%n");
-        String target = n.invoke().callTarget().targetName();
-        throw new GraalInternalError(failedAction + " of call to '" + target + "' in '" + context + "' failed, most likely due to a parameter annotated with @" +
-                        ConstantNodeParameter.class.getSimpleName() + " not being resolvable to a constant during compilation");
-    }
-}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Fri Apr 17 15:40:26 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Fri Apr 17 17:13:09 2015 +0200
@@ -64,7 +64,6 @@
     public final Providers providers;
     public final SnippetReflectionProvider snippetReflection;
     public final TargetDescription target;
-    public final NodeIntrinsificationPhase nodeIntrinsificationPhase;
     private GraphBuilderConfiguration.Plugins graphBuilderPlugins;
 
     /**
@@ -78,7 +77,7 @@
     }
 
     protected boolean hasGenericInvocationPluginAnnotation(ResolvedJavaMethod method) {
-        return nodeIntrinsificationPhase.getIntrinsic(method) != null || method.getAnnotation(Word.Operation.class) != null || nodeIntrinsificationPhase.isFoldable(method);
+        return method.getAnnotation(Node.NodeIntrinsic.class) != null || method.getAnnotation(Word.Operation.class) != null || method.getAnnotation(Fold.class) != null;
     }
 
     private static final int MAX_GRAPH_INLINING_DEPTH = 100; // more than enough
@@ -112,7 +111,7 @@
             // Force inlining when parsing replacements
             return new InlineInfo(method, true, true);
         } else {
-            assert nodeIntrinsificationPhase.getIntrinsic(method) == null : String.format("@%s method %s must only be called from within a replacement%n%s", NodeIntrinsic.class.getSimpleName(),
+            assert method.getAnnotation(NodeIntrinsic.class) == null : String.format("@%s method %s must only be called from within a replacement%n%s", NodeIntrinsic.class.getSimpleName(),
                             method.format("%h.%n"), b);
         }
         return null;
@@ -265,7 +264,6 @@
         this.target = target;
         this.graphs = new ConcurrentHashMap<>();
         this.snippetTemplateCache = CollectionsFactory.newMap();
-        this.nodeIntrinsificationPhase = createNodeIntrinsificationPhase();
     }
 
     private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true"));
@@ -320,20 +318,6 @@
     }
 
     @Override
-    public void notifyAfterConstantsBound(StructuredGraph specializedSnippet) {
-
-        // Do deferred intrinsification of node intrinsics
-
-        nodeIntrinsificationPhase.apply(specializedSnippet);
-        new CanonicalizerPhase().apply(specializedSnippet, new PhaseContext(providers));
-        NodeIntrinsificationVerificationPhase.verify(specializedSnippet);
-    }
-
-    protected NodeIntrinsificationPhase createNodeIntrinsificationPhase() {
-        return new NodeIntrinsificationPhase(providers.getMetaAccess(), providers.getConstantReflection(), snippetReflection, providers.getForeignCalls(), providers.getStampProvider());
-    }
-
-    @Override
     public StructuredGraph getSubstitution(ResolvedJavaMethod original, boolean fromBytecodeOnly, int invokeBci) {
         ResolvedJavaMethod substitute = null;
         if (!fromBytecodeOnly) {
@@ -558,10 +542,6 @@
          * Does final processing of a snippet graph.
          */
         protected void finalizeGraph(StructuredGraph graph) {
-            replacements.nodeIntrinsificationPhase.apply(graph);
-            if (!SnippetTemplate.hasConstantParameter(method)) {
-                NodeIntrinsificationVerificationPhase.verify(graph);
-            }
             int sideEffectCount = 0;
             assert (sideEffectCount = graph.getNodes().filter(e -> hasSideEffect(e)).count()) >= 0;
             new ConvertDeoptimizeToGuardPhase().apply(graph, null);
@@ -690,30 +670,6 @@
             return null;
         }
 
-        /**
-         * Called after a graph is inlined.
-         *
-         * @param caller the graph into which {@code callee} was inlined
-         * @param callee the graph that was inlined into {@code caller}
-         * @param beforeInlineData value returned by {@link #beforeInline}.
-         */
-        protected void afterInline(StructuredGraph caller, StructuredGraph callee, Object beforeInlineData) {
-            if (OptCanonicalizer.getValue()) {
-                new CanonicalizerPhase().apply(caller, new PhaseContext(replacements.providers));
-            }
-        }
-
-        /**
-         * Called after all inlining for a given graph is complete.
-         */
-        protected void afterInlining(StructuredGraph graph) {
-            replacements.nodeIntrinsificationPhase.apply(graph);
-            new DeadCodeEliminationPhase(Optional).apply(graph);
-            if (OptCanonicalizer.getValue()) {
-                new CanonicalizerPhase().apply(graph, new PhaseContext(replacements.providers));
-            }
-        }
-
         private StructuredGraph buildGraph(final ResolvedJavaMethod methodToParse, Object[] args) {
             assert methodToParse.hasBytecodes() : methodToParse;
             final StructuredGraph graph = buildInitialGraph(methodToParse, args);
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Fri Apr 17 15:40:26 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Fri Apr 17 17:13:09 2015 +0200
@@ -612,9 +612,6 @@
         snippetCopy.addDuplicates(snippetGraph.getNodes(), snippetGraph, snippetGraph.getNodeCount(), nodeReplacements);
 
         Debug.dump(snippetCopy, "Before specialization");
-        if (!nodeReplacements.isEmpty()) {
-            providers.getReplacements().notifyAfterConstantsBound(snippetCopy);
-        }
 
         // Gather the template parameters
         parameters = new Object[parameterCount];