changeset 13137:438ed35bed29

Change PhaseContext so that it does not subclass Providers, to avoid leaking low-level provider objects such as the CodeCacheProvdier to high-level optimization phases
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 22 Nov 2013 15:32:20 -0800
parents 3adfe375b01b
children c6a8a3af11ac
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/Providers.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java
diffstat 8 files changed, 47 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Fri Nov 22 15:32:20 2013 -0800
@@ -93,8 +93,7 @@
         }
         // the canonicalization before loop unrolling is needed to propagate the length into
         // additions, etc.
-        PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getForeignCalls(), tool.getLowerer(), tool.assumptions(),
-                        tool.getReplacements());
+        PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions());
         new CanonicalizerPhase(true).apply(snippetGraph, context);
         new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context);
         new CanonicalizerPhase(true).apply(snippetGraph, context);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LoweringTool.java	Fri Nov 22 15:32:20 2013 -0800
@@ -33,14 +33,10 @@
 
     MetaAccessProvider getMetaAccess();
 
-    CodeCacheProvider getCodeCache();
-
     LoweringProvider getLowerer();
 
     ConstantReflectionProvider getConstantReflection();
 
-    ForeignCallsProvider getForeignCalls();
-
     Replacements getReplacements();
 
     GuardingNode createNullCheckGuard(GuardedNode guardedNode, ValueNode object);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java	Fri Nov 22 15:32:20 2013 -0800
@@ -47,6 +47,7 @@
 import com.oracle.graal.phases.common.InliningUtil.InliningPolicy;
 import com.oracle.graal.phases.graph.*;
 import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.phases.util.*;
 
 public class InliningPhase extends AbstractInliningPhase {
 
@@ -185,7 +186,7 @@
         InlineInfo callee = calleeInfo.callee();
         try {
             List<Node> invokeUsages = callee.invoke().asNode().usages().snapshot();
-            callee.inline(context, callerAssumptions);
+            callee.inline(new Providers(context), callerAssumptions);
             callerAssumptions.record(calleeInfo.assumptions());
             metricInliningRuns.increment();
             Debug.dump(callerGraph, "after %s", callee);
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Fri Nov 22 15:32:20 2013 -0800
@@ -64,11 +64,6 @@
         }
 
         @Override
-        public CodeCacheProvider getCodeCache() {
-            return context.getCodeCache();
-        }
-
-        @Override
         public ConstantReflectionProvider getConstantReflection() {
             return context.getConstantReflection();
         }
@@ -79,11 +74,6 @@
         }
 
         @Override
-        public ForeignCallsProvider getForeignCalls() {
-            return context.getForeignCalls();
-        }
-
-        @Override
         public LoweringProvider getLowerer() {
             return context.getLowerer();
         }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java	Fri Nov 22 15:32:20 2013 -0800
@@ -23,6 +23,7 @@
 package com.oracle.graal.phases.tiers;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.util.*;
@@ -34,13 +35,18 @@
     private final GraphCache cache;
     private final OptimisticOptimizations optimisticOpts;
 
-    public HighTierContext(Providers copyFrom, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) {
-        super(copyFrom, assumptions);
+    public HighTierContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions,
+                    GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) {
+        super(metaAccess, constantReflection, lowerer, replacements, assumptions);
         this.plan = plan;
         this.cache = cache;
         this.optimisticOpts = optimisticOpts;
     }
 
+    public HighTierContext(Providers providers, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) {
+        this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions, cache, plan, optimisticOpts);
+    }
+
     public PhasePlan getPhasePlan() {
         return plan;
     }
@@ -54,6 +60,6 @@
     }
 
     public HighTierContext replaceAssumptions(Assumptions newAssumptions) {
-        return new HighTierContext(this, newAssumptions, getGraphCache(), getPhasePlan(), getOptimisticOptimizations());
+        return new HighTierContext(getMetaAccess(), getConstantReflection(), getLowerer(), getReplacements(), newAssumptions, getGraphCache(), getPhasePlan(), getOptimisticOptimizations());
     }
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java	Fri Nov 22 15:32:20 2013 -0800
@@ -27,19 +27,40 @@
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 
-public class PhaseContext extends Providers {
+public class PhaseContext {
 
+    private final MetaAccessProvider metaAccess;
+    private final ConstantReflectionProvider constantReflection;
+    private final LoweringProvider lowerer;
+    private final Replacements replacements;
     private final Assumptions assumptions;
 
-    public PhaseContext(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection, ForeignCallsProvider foreignCalls, LoweringProvider lowerer,
-                    Assumptions assumptions, Replacements replacements) {
-        super(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements);
+    public PhaseContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions) {
+        this.metaAccess = metaAccess;
+        this.constantReflection = constantReflection;
+        this.lowerer = lowerer;
+        this.replacements = replacements;
         this.assumptions = assumptions;
     }
 
-    public PhaseContext(Providers copyFrom, Assumptions assumptions) {
-        super(copyFrom);
-        this.assumptions = assumptions;
+    public PhaseContext(Providers providers, Assumptions assumptions) {
+        this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions);
+    }
+
+    public MetaAccessProvider getMetaAccess() {
+        return metaAccess;
+    }
+
+    public ConstantReflectionProvider getConstantReflection() {
+        return constantReflection;
+    }
+
+    public LoweringProvider getLowerer() {
+        return lowerer;
+    }
+
+    public Replacements getReplacements() {
+        return replacements;
     }
 
     public Assumptions getAssumptions() {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/Providers.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/Providers.java	Fri Nov 22 15:32:20 2013 -0800
@@ -25,6 +25,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.tiers.*;
 
 /**
  * A set of providers, some of which may not be present (i.e., null).
@@ -49,12 +50,11 @@
     }
 
     public Providers(Providers copyFrom) {
-        this.metaAccess = copyFrom.metaAccess;
-        this.codeCache = copyFrom.codeCache;
-        this.constantReflection = copyFrom.constantReflection;
-        this.foreignCalls = copyFrom.foreignCalls;
-        this.lowerer = copyFrom.lowerer;
-        this.replacements = copyFrom.replacements;
+        this(copyFrom.getMetaAccess(), copyFrom.getCodeCache(), copyFrom.getConstantReflection(), copyFrom.getForeignCalls(), copyFrom.getLowerer(), copyFrom.getReplacements());
+    }
+
+    public Providers(PhaseContext copyFrom) {
+        this(copyFrom.getMetaAccess(), null, copyFrom.getConstantReflection(), null, copyFrom.getLowerer(), copyFrom.getReplacements());
     }
 
     public MetaAccessProvider getMetaAccess() {
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Fri Nov 22 13:41:17 2013 -0800
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Fri Nov 22 15:32:20 2013 -0800
@@ -96,8 +96,7 @@
      */
     protected StructuredGraph lowerReplacement(final StructuredGraph replacementGraph, LoweringTool tool) {
         replacementGraph.setGuardsStage(graph().getGuardsStage());
-        final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getForeignCalls(), tool.getLowerer(), tool.assumptions(),
-                        tool.getReplacements());
+        final PhaseContext c = new PhaseContext(tool.getMetaAccess(), tool.getConstantReflection(), tool.getLowerer(), tool.getReplacements(), tool.assumptions());
         Debug.scope("LoweringReplacement", replacementGraph, new Runnable() {
 
             public void run() {