changeset 23271:8b7b4f1e3274

Ensure that Suites creation properly tracks overrides
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 07 Jan 2016 10:31:36 -0800
parents 1375f94fdf30
children 724a078f7410
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java graal/com.oracle.graal.java/src/com/oracle/graal/java/SuitesProviderBase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/PhaseSuite.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesCreator.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java
diffstat 15 files changed, 230 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Thu Jan 07 10:31:36 2016 -0800
@@ -179,7 +179,7 @@
     }
 
     protected Suites createSuites() {
-        Suites ret = backend.getSuites().createSuites();
+        Suites ret = backend.getSuites().getDefaultSuites().copy();
         ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class);
         PhaseSuite.findNextPhase(iter, CanonicalizerPhase.class);
         iter.add(new Phase("ComputeLoopFrequenciesPhase") {
@@ -214,7 +214,7 @@
     }
 
     protected LIRSuites createLIRSuites() {
-        LIRSuites ret = backend.getSuites().createLIRSuites();
+        LIRSuites ret = backend.getSuites().getDefaultLIRSuites().copy();
         return ret;
     }
 
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java	Thu Jan 07 10:31:36 2016 -0800
@@ -105,12 +105,12 @@
              * The optimization phases that are applied to the graph. This is the main configuration
              * point for Graal. Add or remove phases to customize your compilation.
              */
-            Suites suites = backend.getSuites().createSuites();
+            Suites suites = backend.getSuites().getDefaultSuites();
 
             /*
              * The low-level phases that are applied to the low-level representation.
              */
-            LIRSuites lirSuites = backend.getSuites().createLIRSuites();
+            LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites();
 
             /*
              * The calling convention for the machine code. You should have a very good reason
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Thu Jan 07 10:31:36 2016 -0800
@@ -219,8 +219,8 @@
             CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
             // create suites everytime, as we modify options for the compiler
             SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites();
-            final Suites suitesLocal = suitesProvider.createSuites();
-            final LIRSuites lirSuitesLocal = suitesProvider.createLIRSuites();
+            final Suites suitesLocal = suitesProvider.getDefaultSuites();
+            final LIRSuites lirSuitesLocal = suitesProvider.getDefaultLIRSuites();
             final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph),
                             suitesLocal, lirSuitesLocal, new CompilationResult(), CompilationResultBuilderFactory.Default);
             addMethod(method, compResult);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java	Thu Jan 07 10:31:36 2016 -0800
@@ -34,6 +34,7 @@
 import com.oracle.graal.hotspot.phases.WriteBarrierAdditionPhase;
 import com.oracle.graal.hotspot.phases.WriteBarrierVerificationPhase;
 import com.oracle.graal.java.GraphBuilderPhase;
+import com.oracle.graal.java.SuitesProviderBase;
 import com.oracle.graal.lir.phases.LIRSuites;
 import com.oracle.graal.nodes.EncodedGraph;
 import com.oracle.graal.nodes.GraphEncoder;
@@ -42,8 +43,6 @@
 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
 import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration;
 import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.DebugInfoMode;
-import com.oracle.graal.options.DerivedOptionValue;
-import com.oracle.graal.options.DerivedOptionValue.OptionSupplier;
 import com.oracle.graal.phases.BasePhase;
 import com.oracle.graal.phases.PhaseSuite;
 import com.oracle.graal.phases.common.AddressLoweringPhase;
@@ -51,62 +50,30 @@
 import com.oracle.graal.phases.common.ExpandLogicPhase;
 import com.oracle.graal.phases.tiers.HighTierContext;
 import com.oracle.graal.phases.tiers.Suites;
-import com.oracle.graal.phases.tiers.SuitesProvider;
+import com.oracle.graal.phases.tiers.SuitesCreator;
 
 /**
- * HotSpot implementation of {@link SuitesProvider}.
+ * HotSpot implementation of {@link SuitesCreator}.
  */
-public class HotSpotSuitesProvider implements SuitesProvider {
+public class HotSpotSuitesProvider extends SuitesProviderBase {
 
-    protected final DerivedOptionValue<Suites> defaultSuites;
-    protected final PhaseSuite<HighTierContext> defaultGraphBuilderSuite;
-    private final DerivedOptionValue<LIRSuites> defaultLIRSuites;
     protected final HotSpotVMConfig config;
     protected final HotSpotGraalRuntimeProvider runtime;
 
     private final AddressLowering addressLowering;
-    private final SuitesProvider defaultSuitesProvider;
-
-    private class SuitesSupplier implements OptionSupplier<Suites> {
-
-        private static final long serialVersionUID = -3444304453553320390L;
-
-        public Suites get() {
-            return createSuites();
-        }
-
-    }
+    private final SuitesCreator defaultSuitesCreator;
 
-    private class LIRSuitesSupplier implements OptionSupplier<LIRSuites> {
-
-        private static final long serialVersionUID = -1558586374095874299L;
-
-        public LIRSuites get() {
-            return createLIRSuites();
-        }
-
-    }
-
-    public HotSpotSuitesProvider(SuitesProvider defaultSuitesProvider, HotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, AddressLowering addressLowering) {
+    public HotSpotSuitesProvider(SuitesCreator defaultSuitesCreator, HotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, AddressLowering addressLowering) {
+        this.defaultSuitesCreator = defaultSuitesCreator;
         this.config = config;
         this.runtime = runtime;
         this.addressLowering = addressLowering;
-        this.defaultSuitesProvider = defaultSuitesProvider;
         this.defaultGraphBuilderSuite = createGraphBuilderSuite();
-        this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
-        this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
     }
 
-    public Suites getDefaultSuites() {
-        return defaultSuites.getValue();
-    }
-
-    public PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() {
-        return defaultGraphBuilderSuite;
-    }
-
+    @Override
     public Suites createSuites() {
-        Suites ret = defaultSuitesProvider.createSuites();
+        Suites ret = defaultSuitesCreator.createSuites();
 
         if (ImmutableCode.getValue()) {
             // lowering introduces class constants, therefore it must be after lowering
@@ -127,7 +94,7 @@
     }
 
     protected PhaseSuite<HighTierContext> createGraphBuilderSuite() {
-        PhaseSuite<HighTierContext> suite = defaultSuitesProvider.getDefaultGraphBuilderSuite().copy();
+        PhaseSuite<HighTierContext> suite = defaultSuitesCreator.getDefaultGraphBuilderSuite().copy();
         assert appendGraphEncoderTest(suite);
         return suite;
     }
@@ -170,12 +137,9 @@
         return newGbs;
     }
 
-    public LIRSuites getDefaultLIRSuites() {
-        return defaultLIRSuites.getValue();
-    }
-
+    @Override
     public LIRSuites createLIRSuites() {
-        LIRSuites suites = defaultSuitesProvider.createLIRSuites();
+        LIRSuites suites = defaultSuitesCreator.createLIRSuites();
         String profileInstructions = HotSpotBackend.Options.ASMInstructionProfiling.getValue();
         if (profileInstructions != null) {
             suites.getPostAllocationOptimizationStage().appendPhase(new HotSpotInstructionProfiling(profileInstructions));
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java	Thu Jan 07 10:31:36 2016 -0800
@@ -25,71 +25,33 @@
 import com.oracle.graal.lir.phases.LIRSuites;
 import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration;
 import com.oracle.graal.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
-import com.oracle.graal.options.DerivedOptionValue;
-import com.oracle.graal.options.DerivedOptionValue.OptionSupplier;
 import com.oracle.graal.phases.PhaseSuite;
 import com.oracle.graal.phases.tiers.CompilerConfiguration;
 import com.oracle.graal.phases.tiers.HighTierContext;
 import com.oracle.graal.phases.tiers.Suites;
-import com.oracle.graal.phases.tiers.SuitesProvider;
 
-public class DefaultSuitesProvider implements SuitesProvider {
+public class DefaultSuitesProvider extends SuitesProviderBase {
 
     private final CompilerConfiguration compilerConfiguration;
 
-    private final DerivedOptionValue<Suites> defaultSuites;
-    private final PhaseSuite<HighTierContext> defaultGraphBuilderSuite;
-    private final DerivedOptionValue<LIRSuites> defaultLIRSuites;
-
-    private class SuitesSupplier implements OptionSupplier<Suites> {
-
-        private static final long serialVersionUID = 2677805381215454728L;
-
-        public Suites get() {
-            return createSuites();
-        }
-
+    public DefaultSuitesProvider(CompilerConfiguration compilerConfiguration, Plugins plugins) {
+        super();
+        this.defaultGraphBuilderSuite = createGraphBuilderSuite(plugins);
+        this.compilerConfiguration = compilerConfiguration;
     }
 
-    private class LIRSuitesSupplier implements OptionSupplier<LIRSuites> {
-
-        private static final long serialVersionUID = 312070237227476252L;
-
-        public LIRSuites get() {
-            return createLIRSuites();
-        }
-
-    }
-
-    public DefaultSuitesProvider(CompilerConfiguration compilerConfiguration, Plugins plugins) {
-        this.compilerConfiguration = compilerConfiguration;
-        this.defaultGraphBuilderSuite = createGraphBuilderSuite(plugins);
-        this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
-        this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
-    }
-
-    public Suites getDefaultSuites() {
-        return defaultSuites.getValue();
-    }
-
+    @Override
     public Suites createSuites() {
         return Suites.createSuites(compilerConfiguration);
     }
 
-    public PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() {
-        return defaultGraphBuilderSuite;
-    }
-
     protected PhaseSuite<HighTierContext> createGraphBuilderSuite(Plugins plugins) {
         PhaseSuite<HighTierContext> suite = new PhaseSuite<>();
         suite.appendPhase(new GraphBuilderPhase(GraphBuilderConfiguration.getDefault(plugins)));
         return suite;
     }
 
-    public LIRSuites getDefaultLIRSuites() {
-        return defaultLIRSuites.getValue();
-    }
-
+    @Override
     public LIRSuites createLIRSuites() {
         return Suites.createLIRSuites(compilerConfiguration);
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/SuitesProviderBase.java	Thu Jan 07 10:31:36 2016 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, 2015, 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.java;
+
+import com.oracle.graal.lir.phases.LIRSuites;
+import com.oracle.graal.options.DerivedOptionValue;
+import com.oracle.graal.options.DerivedOptionValue.OptionSupplier;
+import com.oracle.graal.phases.PhaseSuite;
+import com.oracle.graal.phases.tiers.HighTierContext;
+import com.oracle.graal.phases.tiers.Suites;
+import com.oracle.graal.phases.tiers.SuitesCreator;
+
+public abstract class SuitesProviderBase implements SuitesCreator {
+
+    protected final DerivedOptionValue<Suites> defaultSuites;
+    protected PhaseSuite<HighTierContext> defaultGraphBuilderSuite;
+    protected final DerivedOptionValue<LIRSuites> defaultLIRSuites;
+
+    private class SuitesSupplier implements OptionSupplier<Suites> {
+
+        private static final long serialVersionUID = 2677805381215454728L;
+
+        public Suites get() {
+            Suites suites = createSuites();
+            suites.setImmutable();
+            return suites;
+        }
+
+    }
+
+    private class LIRSuitesSupplier implements OptionSupplier<LIRSuites> {
+
+        private static final long serialVersionUID = 312070237227476252L;
+
+        public LIRSuites get() {
+            LIRSuites lirSuites = createLIRSuites();
+            lirSuites.setImmutable();
+            return lirSuites;
+        }
+
+    }
+
+    public SuitesProviderBase() {
+        this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier());
+        this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier());
+    }
+
+    public final Suites getDefaultSuites() {
+        return defaultSuites.getValue();
+    }
+
+    public PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite() {
+        return defaultGraphBuilderSuite;
+    }
+
+    public final LIRSuites getDefaultLIRSuites() {
+        return defaultLIRSuites.getValue();
+    }
+
+    public abstract LIRSuites createLIRSuites();
+
+    public abstract Suites createSuites();
+}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java	Thu Jan 07 10:31:36 2016 -0800
@@ -23,6 +23,7 @@
 package com.oracle.graal.lir.phases;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.ListIterator;
 
@@ -32,7 +33,8 @@
 import com.oracle.graal.lir.gen.LIRGenerationResult;
 
 public class LIRPhaseSuite<C> extends LIRPhase<C> {
-    private final List<LIRPhase<C>> phases;
+    private List<LIRPhase<C>> phases;
+    private boolean immutable;
 
     public LIRPhaseSuite() {
         phases = new ArrayList<>();
@@ -94,4 +96,15 @@
         suite.phases.addAll(phases);
         return suite;
     }
+
+    public boolean isImmutable() {
+        return immutable;
+    }
+
+    public synchronized void setImmutable() {
+        if (!immutable) {
+            phases = Collections.unmodifiableList(phases);
+            immutable = true;
+        }
+    }
 }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java	Thu Jan 07 10:31:36 2016 -0800
@@ -38,6 +38,7 @@
     private final LIRPhaseSuite<PreAllocationOptimizationContext> preAllocOptStage;
     private final LIRPhaseSuite<AllocationContext> allocStage;
     private final LIRPhaseSuite<PostAllocationOptimizationContext> postAllocStage;
+    private boolean immutable;
 
     public LIRSuites(LIRPhaseSuite<PreAllocationOptimizationContext> preAllocOptStage, LIRPhaseSuite<AllocationContext> allocStage, LIRPhaseSuite<PostAllocationOptimizationContext> postAllocStage) {
         this.preAllocOptStage = preAllocOptStage;
@@ -83,4 +84,20 @@
         return postAllocStage;
     }
 
+    public boolean isImmutable() {
+        return immutable;
+    }
+
+    public synchronized void setImmutable() {
+        if (!immutable) {
+            preAllocOptStage.setImmutable();
+            allocStage.setImmutable();
+            postAllocStage.setImmutable();
+            immutable = true;
+        }
+    }
+
+    public LIRSuites copy() {
+        return new LIRSuites(preAllocOptStage.copy(), allocStage.copy(), postAllocStage.copy());
+    }
 }
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/DerivedOptionValue.java	Thu Jan 07 10:31:36 2016 -0800
@@ -35,13 +35,11 @@
     public interface OptionSupplier<T> extends Supplier<T>, Serializable {
     }
 
-    private final T initialValue;
+    private T initialValue;
     private final OptionSupplier<T> supplier;
 
     public DerivedOptionValue(OptionSupplier<T> supplier) {
         this.supplier = supplier;
-        assert OptionValue.getOverrideScope() == null : "derived option value should be initialized outside any override scope";
-        this.initialValue = createValue();
     }
 
     public T getValue() {
@@ -49,6 +47,9 @@
         if (overrideScope != null) {
             return overrideScope.getDerived(this);
         } else {
+            if (initialValue == null) {
+                initialValue = createValue();
+            }
             return initialValue;
         }
     }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/PhaseSuite.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/PhaseSuite.java	Thu Jan 07 10:31:36 2016 -0800
@@ -23,6 +23,7 @@
 package com.oracle.graal.phases;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.ListIterator;
 
@@ -33,12 +34,24 @@
  */
 public class PhaseSuite<C> extends BasePhase<C> {
 
-    private final List<BasePhase<? super C>> phases;
+    private List<BasePhase<? super C>> phases;
+    private boolean immutable;
 
     public PhaseSuite() {
         this.phases = new ArrayList<>();
     }
 
+    public boolean isImmutable() {
+        return immutable;
+    }
+
+    public synchronized void setImmutable() {
+        if (!immutable) {
+            phases = Collections.unmodifiableList(phases);
+            immutable = true;
+        }
+    }
+
     /**
      * Add a new phase at the beginning of this suite.
      */
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java	Thu Jan 07 10:31:36 2016 -0800
@@ -30,6 +30,7 @@
     private final PhaseSuite<HighTierContext> highTier;
     private final PhaseSuite<MidTierContext> midTier;
     private final PhaseSuite<LowTierContext> lowTier;
+    private boolean immutable;
 
     public PhaseSuite<HighTierContext> getHighTier() {
         return highTier;
@@ -56,4 +57,21 @@
     public static LIRSuites createLIRSuites(CompilerConfiguration config) {
         return new LIRSuites(config.createPreAllocationOptimizationStage(), config.createAllocationStage(), config.createPostAllocationOptimizationStage());
     }
+
+    public boolean isImmutable() {
+        return immutable;
+    }
+
+    public synchronized void setImmutable() {
+        if (!immutable) {
+            highTier.setImmutable();
+            midTier.setImmutable();
+            lowTier.setImmutable();
+            immutable = true;
+        }
+    }
+
+    public Suites copy() {
+        return new Suites(highTier.copy(), midTier.copy(), lowTier.copy());
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesCreator.java	Thu Jan 07 10:31:36 2016 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, 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.phases.tiers;
+
+import com.oracle.graal.lir.phases.LIRSuites;
+
+/**
+ * Interface used for composing {@link SuitesProvider}s.
+ */
+public interface SuitesCreator extends SuitesProvider {
+    /**
+     * Create a new set of phase suites based on the current option settings.
+     */
+    Suites createSuites();
+
+    /**
+     * Create a new set of low-level phase suites based on the current option settings.
+     */
+    LIRSuites createLIRSuites();
+}
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java	Thu Jan 07 10:31:36 2016 -0800
@@ -25,33 +25,29 @@
 import com.oracle.graal.lir.phases.LIRSuites;
 import com.oracle.graal.phases.PhaseSuite;
 
+/**
+ * Main interface providing access to suites used for compilation.
+ */
+
 public interface SuitesProvider {
 
     /**
-     * Get the default phase suites of this compiler.
+     * Get the default phase suites of this compiler. This will take in account any options which
+     * enabled at the time of call, returning an appropriately constructed suite. The returned suite
+     * is immutable by default but {@link Suites#copy} can be used to create a customized version.
      */
     Suites getDefaultSuites();
 
     /**
-     * Create a new set of phase suites. Initially, the suites are the same as the
-     * {@link #getDefaultSuites default} suites.
-     */
-    Suites createSuites();
-
-    /**
      * Get the default phase suite for creating new graphs.
      */
     PhaseSuite<HighTierContext> getDefaultGraphBuilderSuite();
 
     /**
-     * Get the default phase suites of this compiler.
+     * Get the default LIR phase suites of this compiler. This will take in account any options
+     * enabled active at the time of call, returning an appropriately constructed suite. The
+     * returned suite is immutable by default but {@link LIRSuites#copy} can be used to create a
+     * customized version.
      */
     LIRSuites getDefaultLIRSuites();
-
-    /**
-     * Create a new set of low-level phase suites. Initially, the suites are the same as the
-     * {@link #getDefaultLIRSuites default} suites.
-     */
-    LIRSuites createLIRSuites();
-
 }
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Thu Jan 07 10:31:36 2016 -0800
@@ -240,8 +240,8 @@
     private CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
         HotSpotProviders providers = getHotSpotProviders();
         SuitesProvider suitesProvider = providers.getSuites();
-        Suites suites = suitesProvider.createSuites();
-        LIRSuites lirSuites = suitesProvider.createLIRSuites();
+        Suites suites = suitesProvider.getDefaultSuites().copy();
+        LIRSuites lirSuites = suitesProvider.getDefaultLIRSuites();
         removeInliningPhase(suites);
         StructuredGraph graph = new StructuredGraph(javaMethod, AllowAssumptions.NO);
 
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java	Thu Jan 07 08:33:16 2016 -0800
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/nfi/HotSpotNativeFunctionInterface.java	Thu Jan 07 10:31:36 2016 -0800
@@ -174,8 +174,8 @@
     @SuppressWarnings("try")
     private InstalledCode installNativeFunctionStub(long functionPointer, Class<?> returnType, Class<?>... argumentTypes) {
         StructuredGraph g = getGraph(providers, factory, functionPointer, returnType, argumentTypes);
-        Suites suites = providers.getSuites().createSuites();
-        LIRSuites lirSuites = providers.getSuites().createLIRSuites();
+        Suites suites = providers.getSuites().getDefaultSuites();
+        LIRSuites lirSuites = providers.getSuites().getDefaultLIRSuites();
         PhaseSuite<HighTierContext> phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy();
         CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, g.method(), false);
         CompilationResult compResult = GraalCompiler.compileGraph(g, cc, g.method(), providers, backend, phaseSuite, OptimisticOptimizations.ALL, DefaultProfilingInfo.get(TriState.UNKNOWN), suites,