changeset 12488:1a4dc163cd0a

abstracted HotSpotGraalRuntime as a RuntimeProvider which removes the recent selector addition to the Graal capabilities API and also makes Truffle independent of the graal.hotspot project (GRAAL-363)
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Oct 2013 18:23:14 +0200
parents 28d7a11ba008
children 0c651af30cc8 11f217e8476a
files graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/NameAndSignature.java graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestBytecodeDisassemblerProvider.java graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/GraalRuntime.java graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java graal/com.oracle.graal.runtime/src/com/oracle/graal/runtime/RuntimeProvider.java graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ExactMathTest.java graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleRuntimeTest.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java mx/projects
diffstat 35 files changed, 247 insertions(+), 179 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/NameAndSignature.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/NameAndSignature.java	Fri Oct 18 18:23:14 2013 +0200
@@ -27,10 +27,11 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.runtime.*;
 
 class NameAndSignature {
 
-    public static final MetaAccessProvider runtime = Graal.getRequiredCapability(MetaAccessProvider.class);
+    public static final MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
 
     final String name;
     final Class returnType;
@@ -71,14 +72,14 @@
     public boolean signatureEquals(ResolvedJavaMethod m) {
         Signature s = m.getSignature();
         ResolvedJavaType declaringClass = m.getDeclaringClass();
-        if (!s.getReturnType(declaringClass).resolve(declaringClass).equals(runtime.lookupJavaType(returnType))) {
+        if (!s.getReturnType(declaringClass).resolve(declaringClass).equals(metaAccess.lookupJavaType(returnType))) {
             return false;
         }
         if (s.getParameterCount(false) != parameterTypes.length) {
             return false;
         }
         for (int i = 0; i < parameterTypes.length; i++) {
-            if (!s.getParameterType(i, declaringClass).resolve(declaringClass).equals(runtime.lookupJavaType(parameterTypes[i]))) {
+            if (!s.getParameterType(i, declaringClass).resolve(declaringClass).equals(metaAccess.lookupJavaType(parameterTypes[i]))) {
                 return false;
             }
         }
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestBytecodeDisassemblerProvider.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestBytecodeDisassemblerProvider.java	Fri Oct 18 18:23:14 2013 +0200
@@ -25,7 +25,7 @@
 import org.junit.*;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.java.*;
 
 /**
  * Tests for {@link BytecodeDisassemblerProvider}.
@@ -40,7 +40,7 @@
      */
     @Test
     public void disassembleTest() {
-        BytecodeDisassemblerProvider dis = Graal.getRuntime().getCapability(BytecodeDisassemblerProvider.class);
+        BytecodeDisassemblerProvider dis = new BytecodeDisassembler();
         if (dis != null) {
             int count = 0;
             for (ResolvedJavaMethod m : methods.values()) {
--- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TypeUniverse.java	Fri Oct 18 18:23:14 2013 +0200
@@ -33,6 +33,8 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * Context for type related api.meta tests.
@@ -40,13 +42,17 @@
 public class TypeUniverse {
 
     public final Unsafe unsafe;
-    public final MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
-    public final ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class);
+
+    public final MetaAccessProvider metaAccess;
+    public final ConstantReflectionProvider constantReflection;
     public final Collection<Class<?>> classes = new HashSet<>();
     public final Map<Class<?>, Class<?>> arrayClasses = new HashMap<>();
     public final List<Constant> constants = new ArrayList<>();
 
     public TypeUniverse() {
+        Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
+        metaAccess = providers.getMetaAccess();
+        constantReflection = providers.getConstantReflection();
         Unsafe theUnsafe = null;
         try {
             theUnsafe = Unsafe.getUnsafe();
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java	Fri Oct 18 18:23:14 2013 +0200
@@ -69,10 +69,5 @@
         public <T> T getCapability(Class<T> clazz) {
             return null;
         }
-
-        @Override
-        public <T> T getCapability(Class<T> clazz, String selector) {
-            return null;
-        }
     }
 }
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/GraalRuntime.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/GraalRuntime.java	Fri Oct 18 18:23:14 2013 +0200
@@ -27,14 +27,4 @@
     String getName();
 
     <T> T getCapability(Class<T> clazz);
-
-    /**
-     * Requests a capability represented by a given class.
-     * 
-     * @param selector a value the runtime will use to refine the capability returned (if any). An
-     *            example may be the name of an architecture when asking for a capability
-     *            representing a compiler backend.
-     */
-    <T> T getCapability(Class<T> clazz, String selector);
-
 }
--- a/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -30,6 +30,8 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.asm.*;
+import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.test.*;
 
 public abstract class AssemblerTest extends GraalTest {
@@ -43,8 +45,9 @@
     }
 
     public AssemblerTest() {
-        this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
-        this.codeCache = Graal.getRequiredCapability(CodeCacheProvider.class);
+        Providers providers = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
+        this.metaAccess = providers.getMetaAccess();
+        this.codeCache = providers.getCodeCache();
     }
 
     public MetaAccessProvider getMetaAccess() {
@@ -62,7 +65,7 @@
 
         InstalledCode code = codeCache.addMethod(method, compResult);
 
-        DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class);
+        DisassemblerProvider dis = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getDisassembler();
         if (dis != null) {
             String disasm = dis.disassemble(code);
             Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
--- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -26,6 +26,7 @@
 
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.hotspot.hsail.*;
+import com.oracle.graal.hsail.*;
 import com.oracle.graal.nodes.*;
 
 /**
@@ -34,7 +35,7 @@
 public class BasicHSAILTest extends GraalCompilerTest {
 
     public BasicHSAILTest() {
-        super("HSAIL");
+        super(HSAIL.class);
     }
 
     public void testAdd() {
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java	Fri Oct 18 18:23:14 2013 +0200
@@ -42,6 +42,7 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.ptx.*;
 
 public abstract class PTXTestBase extends GraalCompilerTest {
 
@@ -55,7 +56,7 @@
     }
 
     public PTXTestBase() {
-        super("PTX");
+        super(PTX.class);
     }
 
     protected CompilationResult compile(String test) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -54,6 +54,7 @@
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.printer.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.test.*;
 
 /**
@@ -82,9 +83,9 @@
     private final Suites suites;
 
     public GraalCompilerTest() {
-        this.backend = Graal.getRequiredCapability(Backend.class);
+        this.backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
         this.providers = getBackend().getProviders();
-        this.suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
+        this.suites = backend.getSuites().createSuites();
     }
 
     /**
@@ -93,16 +94,17 @@
      * 
      * @param arch the name of the desired backend architecture
      */
-    public GraalCompilerTest(String arch) {
-        Backend b = Graal.getRuntime().getCapability(Backend.class, arch);
+    public GraalCompilerTest(Class<? extends Architecture> arch) {
+        RuntimeProvider runtime = Graal.getRequiredCapability(RuntimeProvider.class);
+        Backend b = runtime.getBackend(arch);
         if (b != null) {
             this.backend = b;
         } else {
             // Fall back to the default/host backend
-            this.backend = Graal.getRuntime().getCapability(Backend.class);
+            this.backend = runtime.getHostBackend();
         }
         this.providers = backend.getProviders();
-        this.suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
+        this.suites = backend.getSuites().createSuites();
     }
 
     @BeforeClass
@@ -530,7 +532,7 @@
                             Debug.dump(new Object[]{compResult, code}, "After code installation");
                         }
                         if (Debug.isLogEnabled()) {
-                            DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class);
+                            DisassemblerProvider dis = backend.getDisassembler();
                             if (dis != null) {
                                 String text = dis.disassemble(code);
                                 if (text != null) {
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Fri Oct 18 18:23:14 2013 +0200
@@ -32,7 +32,6 @@
 import com.oracle.graal.alloc.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.alloc.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
@@ -290,17 +289,4 @@
 
         Debug.dump(result, "After code generation");
     }
-
-    /**
-     * Creates a set of providers via {@link Graal#getRequiredCapability(Class)}.
-     */
-    public static Providers getGraalProviders() {
-        MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
-        CodeCacheProvider codeCache = Graal.getRequiredCapability(CodeCacheProvider.class);
-        ConstantReflectionProvider constantReflection = Graal.getRequiredCapability(ConstantReflectionProvider.class);
-        ForeignCallsProvider foreignCalls = Graal.getRequiredCapability(ForeignCallsProvider.class);
-        LoweringProvider lowerer = Graal.getRequiredCapability(LoweringProvider.class);
-        Replacements replacements = Graal.getRequiredCapability(Replacements.class);
-        return new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements);
-    }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Fri Oct 18 18:23:14 2013 +0200
@@ -29,6 +29,7 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
 
 /**
@@ -54,6 +55,10 @@
         return providers.getForeignCalls();
     }
 
+    public abstract SuitesProvider getSuites();
+
+    public abstract DisassemblerProvider getDisassembler();
+
     public TargetDescription getTarget() {
         return providers.getCodeCache().getTarget();
     }
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java	Fri Oct 18 18:23:14 2013 +0200
@@ -33,10 +33,10 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hsail.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.type.*;
@@ -44,6 +44,7 @@
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * Class that represents a HSAIL compilation result. Includes the compiled HSAIL code.
@@ -79,7 +80,8 @@
     static final HSAILHotSpotBackend backend;
     static {
         // Look for installed HSAIL backend
-        HSAILHotSpotBackend b = (HSAILHotSpotBackend) Graal.getRuntime().getCapability(Backend.class, "HSAIL");
+        RuntimeProvider runtime = Graal.getRequiredCapability(RuntimeProvider.class);
+        HSAILHotSpotBackend b = (HSAILHotSpotBackend) runtime.getBackend(HSAIL.class);
         if (b == null) {
             // Fall back to a new instance
             b = new HSAILHotSpotBackendFactory().createBackend(runtime(), runtime().getHostBackend());
@@ -138,7 +140,7 @@
         phasePlan.addPhase(PhasePosition.AFTER_PARSING, new HSAILPhase());
         new HSAILPhase().apply(graph);
         CallingConvention cc = getHSAILCallingConvention(Type.JavaCallee, target, graph.method(), false);
-        SuitesProvider suitesProvider = Graal.getRequiredCapability(SuitesProvider.class);
+        SuitesProvider suitesProvider = backend.getSuites();
         try {
             HSAILCompilationResult compResult = GraalCompiler.compileGraph(graph, cc, graph.method(), providers, backend, target, null, phasePlan, OptimisticOptimizations.NONE, new SpeculationLog(),
                             suitesProvider.getDefaultSuites(), new HSAILCompilationResult());
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -41,6 +41,7 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * use
@@ -204,7 +205,7 @@
         phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
         CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
         // create suites everytime, as we modify options for the compiler
-        final Suites suitesLocal = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
+        final Suites suitesLocal = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites();
         final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL,
                         new SpeculationLog(), suitesLocal, new CompilationResult());
         addMethod(method, compResult);
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -33,6 +33,7 @@
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * The following tests perform object/array equality and assignments in various ways. The selected
@@ -43,7 +44,7 @@
     private final MetaAccessProvider metaAccess;
 
     public CompressedOopTest() {
-        this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
+        this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
     }
 
     private HotSpotInstalledCode getInstalledCode(String name) throws Exception {
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -35,6 +35,7 @@
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.runtime.*;
 
 public class InstalledCodeExecuteHelperTest extends GraalCompilerTest {
 
@@ -43,7 +44,7 @@
     Object[] argsToBind;
 
     public InstalledCodeExecuteHelperTest() {
-        this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
+        this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
     }
 
     @Test
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -43,6 +43,7 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * The following unit tests assert the presence of write barriers for both Serial and G1 GCs.
@@ -58,7 +59,7 @@
     private final MetaAccessProvider metaAccess;
 
     public WriteBarrierAdditionTest() {
-        this.metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
+        this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
     }
 
     public static class Container {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Oct 18 18:23:14 2013 +0200
@@ -140,7 +140,11 @@
 
                     @Override
                     public CompilationResult call() throws Exception {
-                        backend.getRuntime().evictDeoptedGraphs();
+                        GraphCache graphCache = backend.getRuntime().getGraphCache();
+                        if (graphCache != null) {
+                            graphCache.removeStaleGraphs();
+                        }
+
                         HotSpotProviders providers = backend.getProviders();
                         Replacements replacements = providers.getReplacements();
                         graph = replacements.getMethodSubstitution(method);
@@ -153,8 +157,8 @@
                         InliningUtil.InlinedBytecodes.add(method.getCodeSize());
                         CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
                         Suites suites = providers.getSuites().getDefaultSuites();
-                        return GraalCompiler.compileGraph(graph, cc, method, providers, backend, backend.getTarget(), backend.getRuntime().getCache(), plan, optimisticOpts,
-                                        method.getSpeculationLog(), suites, new CompilationResult());
+                        return GraalCompiler.compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, plan, optimisticOpts, method.getSpeculationLog(), suites,
+                                        new CompilationResult());
                     }
                 });
             } finally {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Fri Oct 18 18:23:14 2013 +0200
@@ -22,12 +22,14 @@
  */
 package com.oracle.graal.hotspot;
 
+import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.word.*;
 
 /**
@@ -82,4 +84,14 @@
     public HotSpotProviders getProviders() {
         return (HotSpotProviders) super.getProviders();
     }
+
+    @Override
+    public SuitesProvider getSuites() {
+        return getProviders().getSuites();
+    }
+
+    @Override
+    public DisassemblerProvider getDisassembler() {
+        return getProviders().getDisassembler();
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Oct 18 18:23:14 2013 +0200
@@ -38,15 +38,14 @@
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.logging.*;
 import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.tiers.*;
+import com.oracle.graal.runtime.*;
 
 /**
  * Singleton class holding the instance of the {@link GraalRuntime}.
  */
-public final class HotSpotGraalRuntime implements GraalRuntime {
+public final class HotSpotGraalRuntime implements GraalRuntime, RuntimeProvider {
 
     private static final HotSpotGraalRuntime instance = new HotSpotGraalRuntime();
     static {
@@ -173,15 +172,13 @@
     protected/* final */CompilerToGPU compilerToGpu;
     protected/* final */VMToCompiler vmToCompiler;
 
-    protected final HotSpotProviders hostProviders;
-
     private HotSpotRuntimeInterpreterInterface runtimeInterpreterInterface;
     private volatile HotSpotGraphCache cache;
 
     protected final HotSpotVMConfig config;
     private final HotSpotBackend hostBackend;
 
-    private final Map<String, HotSpotBackend> backends = new HashMap<>();
+    private final Map<Class<? extends Architecture>, HotSpotBackend> backends = new HashMap<>();
 
     private HotSpotGraalRuntime() {
         CompilerToVM toVM = new CompilerToVMImpl();
@@ -210,31 +207,36 @@
             printConfig(config);
         }
 
-        String hostArchitecture = getHostArchitecture();
-        hostBackend = findFactory(hostArchitecture).createBackend(this, null);
-        hostProviders = hostBackend.getProviders();
-        backends.put(hostArchitecture, hostBackend);
+        String hostArchitecture = getHostArchitectureName();
+        hostBackend = registerBackend(findFactory(hostArchitecture).createBackend(this, null));
 
-        String[] gpuArchitectures = getGPUArchitectures();
+        String[] gpuArchitectures = getGPUArchitectureNames();
         for (String arch : gpuArchitectures) {
             HotSpotBackendFactory factory = findFactory(arch);
             if (factory == null) {
                 throw new GraalInternalError("No backend available for specified GPU architecture \"%s\"", arch);
             }
-            backends.put(factory.getArchitecture(), factory.createBackend(this, hostBackend));
+            registerBackend(factory.createBackend(this, hostBackend));
         }
 
         GraalOptions.StackShadowPages.setValue(config.stackShadowPages);
         if (GraalOptions.CacheGraphs.getValue()) {
-            cache = new HotSpotGraphCache();
+            cache = new HotSpotGraphCache(compilerToVm);
         }
     }
 
+    private HotSpotBackend registerBackend(HotSpotBackend backend) {
+        Class<? extends Architecture> arch = backend.getTarget().arch.getClass();
+        HotSpotBackend oldValue = backends.put(arch, backend);
+        assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName();
+        return backend;
+    }
+
     /**
      * Gets the host architecture name for the purpose of finding the corresponding
      * {@linkplain HotSpotBackendFactory backend}.
      */
-    private static String getHostArchitecture() {
+    private static String getHostArchitectureName() {
         String arch = System.getProperty("os.arch");
         switch (arch) {
             case "x86_64":
@@ -253,7 +255,7 @@
      * a comma separated list of names in the {@value #GRAAL_GPU_ISALIST_PROPERTY_NAME} system
      * property. If this property is not set, then the GPU native support code is queried.
      */
-    private String[] getGPUArchitectures() {
+    private String[] getGPUArchitectureNames() {
         String gpuList = System.getProperty(GRAAL_GPU_ISALIST_PROPERTY_NAME);
         if (gpuList != null) {
             String[] gpus = gpuList.split(",");
@@ -285,7 +287,7 @@
         return hostBackend.getTarget();
     }
 
-    public HotSpotGraphCache getCache() {
+    public HotSpotGraphCache getGraphCache() {
         return cache;
     }
 
@@ -335,26 +337,13 @@
 
     public HotSpotRuntimeInterpreterInterface getRuntimeInterpreterInterface() {
         if (runtimeInterpreterInterface == null) {
-            runtimeInterpreterInterface = new HotSpotRuntimeInterpreterInterface(hostProviders.getMetaAccess());
+            runtimeInterpreterInterface = new HotSpotRuntimeInterpreterInterface(getHostProviders().getMetaAccess());
         }
         return runtimeInterpreterInterface;
     }
 
     public HotSpotProviders getHostProviders() {
-        return hostProviders;
-    }
-
-    public void evictDeoptedGraphs() {
-        if (cache != null) {
-            long[] deoptedGraphs = getCompilerToVM().getDeoptedLeafGraphIds();
-            if (deoptedGraphs != null) {
-                if (deoptedGraphs.length == 0) {
-                    cache.clear();
-                } else {
-                    cache.removeGraphs(deoptedGraphs);
-                }
-            }
-        }
+        return getHostBackend().getProviders();
     }
 
     @Override
@@ -363,60 +352,24 @@
     }
 
     @SuppressWarnings("unchecked")
-    public static <T> T getCapability(HotSpotBackend backend, Class<T> clazz) {
-        HotSpotProviders providers = backend.getProviders();
-        if (clazz == LoweringProvider.class) {
-            return (T) providers.getLowerer();
-        }
-        if (clazz == CodeCacheProvider.class) {
-            return (T) providers.getCodeCache();
-        }
-        if (clazz == MetaAccessProvider.class) {
-            return (T) providers.getMetaAccess();
-        }
-        if (clazz == ConstantReflectionProvider.class) {
-            return (T) providers.getConstantReflection();
-        }
-        if (clazz == ForeignCallsProvider.class) {
-            return (T) providers.getForeignCalls();
-        }
-        if (clazz == DisassemblerProvider.class) {
-            return (T) providers.getDisassembler();
-        }
-        if (clazz == BytecodeDisassemblerProvider.class) {
-            return (T) providers.getBytecodeDisassembler();
-        }
-        if (clazz == SuitesProvider.class) {
-            return (T) providers.getSuites();
-        }
-        if (clazz == Replacements.class) {
-            return (T) providers.getReplacements();
-        }
-        if (clazz == HotSpotRegistersProvider.class) {
-            return (T) providers.getRegisters();
-        }
-        if (clazz == Backend.class) {
-            return (T) backend;
+    @Override
+    public <T> T getCapability(Class<T> clazz) {
+        if (clazz == RuntimeProvider.class) {
+            return (T) this;
         }
         return null;
     }
 
-    @Override
-    public <T> T getCapability(Class<T> clazz) {
-        return getCapability(clazz, null);
-    }
-
-    @Override
-    public <T> T getCapability(Class<T> clazz, String selector) {
-        HotSpotBackend backend = selector == null ? hostBackend : backends.get(selector);
-        return backend == null ? null : getCapability(backend, clazz);
-    }
-
     public HotSpotBackend getHostBackend() {
         return hostBackend;
     }
 
-    public Map<String, HotSpotBackend> getBackends() {
+    public <T extends Architecture> Backend getBackend(Class<T> arch) {
+        assert arch != Architecture.class;
+        return backends.get(arch);
+    }
+
+    public Map<Class<? extends Architecture>, HotSpotBackend> getBackends() {
         return Collections.unmodifiableMap(backends);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Oct 18 18:23:14 2013 +0200
@@ -193,7 +193,7 @@
                     List<LoweringProvider> initializedLowerers = new ArrayList<>();
                     List<ForeignCallsProvider> initializedForeignCalls = new ArrayList<>();
 
-                    for (Map.Entry<String, HotSpotBackend> e : runtime.getBackends().entrySet()) {
+                    for (Map.Entry<?, HotSpotBackend> e : runtime.getBackends().entrySet()) {
                         HotSpotBackend backend = e.getValue();
                         HotSpotProviders providers = backend.getProviders();
 
@@ -361,8 +361,8 @@
         bootstrapRunning = false;
 
         TTY.println(" in %d ms (compiled %d methods)", System.currentTimeMillis() - startTime, compileQueue.getCompletedTaskCount());
-        if (runtime.getCache() != null) {
-            runtime.getCache().clear();
+        if (runtime.getGraphCache() != null) {
+            runtime.getGraphCache().clear();
         }
         System.gc();
         phaseTransition("bootstrap2");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java	Fri Oct 18 18:23:14 2013 +0200
@@ -30,6 +30,7 @@
 import java.util.Map.Entry;
 
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 
@@ -96,7 +97,8 @@
 
     private final Map<Long, WeakReference<ResolvedJavaMethod>> cachedGraphIds = Collections.synchronizedMap(new LRUCache());
 
-    public HotSpotGraphCache() {
+    public HotSpotGraphCache(CompilerToVM compilerToVM) {
+        this.compilerToVM = compilerToVM;
         if (PrintGraphCache.getValue()) {
             Runtime.getRuntime().addShutdownHook(new Thread() {
 
@@ -127,7 +129,7 @@
     }
 
     @Override
-    public void put(StructuredGraph graph, boolean hasMatureProfilingInfo) {
+    public boolean put(StructuredGraph graph, boolean hasMatureProfilingInfo) {
         assert graph.method() != null;
         if (hasMatureProfilingInfo) {
             cachedGraphIds.put(graph.graphId(), new WeakReference<>(graph.method()));
@@ -136,7 +138,9 @@
             if (PrintGraphCache.getValue()) {
                 putCounter++;
             }
+            return true;
         }
+        return false;
     }
 
     public void clear() {
@@ -174,4 +178,17 @@
             }
         }
     }
+
+    private final CompilerToVM compilerToVM;
+
+    public void removeStaleGraphs() {
+        long[] deoptedGraphs = compilerToVM.getDeoptedLeafGraphIds();
+        if (deoptedGraphs != null) {
+            if (deoptedGraphs.length == 0) {
+                clear();
+            } else {
+                removeGraphs(deoptedGraphs);
+            }
+        }
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProviders.java	Fri Oct 18 18:23:14 2013 +0200
@@ -23,7 +23,6 @@
 package com.oracle.graal.hotspot.meta;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 
@@ -59,10 +58,6 @@
         return disassembler;
     }
 
-    public BytecodeDisassemblerProvider getBytecodeDisassembler() {
-        return new BytecodeDisassembler();
-    }
-
     @Override
     public HotSpotForeignCallsProvider getForeignCalls() {
         return (HotSpotForeignCallsProvider) super.getForeignCalls();
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java	Fri Oct 18 18:23:14 2013 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.java.decompiler.test.example.*;
 import com.oracle.graal.printer.*;
+import com.oracle.graal.runtime.*;
 
 public class Test {
 
@@ -38,7 +39,7 @@
      */
     public static void main(String[] args) throws NoSuchMethodException, SecurityException {
         DebugEnvironment.initialize(System.out);
-        MetaAccessProvider metaAccess = Graal.getRequiredCapability(MetaAccessProvider.class);
+        MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess();
         Method method = Example.class.getDeclaredMethod("loop7", new Class[]{int.class, int.class});
         final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method);
         TestUtil.compileMethod(javaMethod);
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java	Fri Oct 18 18:23:14 2013 +0200
@@ -36,12 +36,15 @@
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
 
 public class TestUtil {
 
     public static void compileMethod(ResolvedJavaMethod method) {
-        Providers providers = GraalCompiler.getGraalProviders();
-        Suites suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
+        Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
+        Providers providers = backend.getProviders();
+        SuitesProvider suitesProvider = backend.getSuites();
+        Suites suites = suitesProvider.createSuites();
         StructuredGraph graph = new StructuredGraph(method);
         MetaAccessProvider metaAccess = providers.getMetaAccess();
         ForeignCallsProvider foreignCalls = providers.getForeignCalls();
@@ -50,7 +53,6 @@
         GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
         phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
         CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
-        Backend backend = Graal.getRequiredCapability(Backend.class);
         GraalCompiler.compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites,
                         new CompilationResult());
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java	Fri Oct 18 18:23:14 2013 +0200
@@ -25,10 +25,32 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.*;
 
+/**
+ * A cache for graphs associated with {@linkplain StructuredGraph#method() methods}.
+ */
 public interface GraphCache {
 
-    void put(StructuredGraph graph, boolean hasMatureProfilingInfo);
+    /**
+     * Requests that a graph be added to this cache.
+     * 
+     * @param hasMatureProfilingInfo indicates that the caller has
+     *            {@linkplain ProfilingInfo#isMature() mature} profiling info for the method
+     *            associated with the graph
+     * @return true if {@code graph} was added to this cache, false otherwise
+     */
+    boolean put(StructuredGraph graph, boolean hasMatureProfilingInfo);
 
+    /**
+     * Gets the graph from this cache associated with a given method.
+     * 
+     * @param method a method for which a cached graph is requested
+     * @return the graph cached for {@code method} or null if it does not exist
+     */
     StructuredGraph get(ResolvedJavaMethod method);
 
+    /**
+     * The cache will remove graphs it considers stale. For example, graphs associated with
+     * installed code that has subsequently be deoptimized might be considered stale.
+     */
+    void removeStaleGraphs();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.runtime/src/com/oracle/graal/runtime/RuntimeProvider.java	Fri Oct 18 18:23:14 2013 +0200
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009, 2012, 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.runtime;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.nodes.spi.*;
+
+/**
+ * A runtime supporting a host backend as well, zero or more additional backends and an optional
+ * {@linkplain GraphCache graph cache}.
+ */
+public interface RuntimeProvider {
+
+    /**
+     * Gets the host backend.
+     */
+    Backend getHostBackend();
+
+    /**
+     * Gets the backend for a given architecture.
+     * 
+     * @param arch a specific architecture class
+     */
+    <T extends Architecture> Backend getBackend(Class<T> arch);
+
+    /**
+     * Gets the graph cache (if any) maintained by this runtime.
+     */
+    GraphCache getGraphCache();
+}
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ExactMathTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/ExactMathTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -27,6 +27,7 @@
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.substitutions.*;
 import com.oracle.truffle.api.*;
 
@@ -36,7 +37,8 @@
 
     public ExactMathTest() {
         if (!substitutionsInstalled) {
-            Graal.getRequiredCapability(Replacements.class).registerSubstitutions(ExactMathSubstitutions.class);
+            Replacements replacements = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getReplacements();
+            replacements.registerSubstitutions(ExactMathSubstitutions.class);
             substitutionsInstalled = true;
         }
     }
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -28,6 +28,7 @@
 import org.junit.*;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.test.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.java.*;
@@ -41,6 +42,7 @@
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.printer.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.virtual.phases.ea.*;
 import com.oracle.truffle.api.*;
@@ -58,7 +60,7 @@
         Replacements truffleReplacements = ((GraalTruffleRuntime) Truffle.getRuntime()).getReplacements();
         Providers providers = getProviders().copyWith(truffleReplacements);
         TruffleCache truffleCache = new TruffleCache(providers, GraphBuilderConfiguration.getDefault(), TruffleCompilerImpl.Optimizations);
-        this.partialEvaluator = new PartialEvaluator(providers, truffleCache);
+        this.partialEvaluator = new PartialEvaluator(Graal.getRequiredCapability(RuntimeProvider.class), providers, truffleCache);
 
         DebugEnvironment.initialize(System.out);
     }
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleRuntimeTest.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/TruffleRuntimeTest.java	Fri Oct 18 18:23:14 2013 +0200
@@ -26,8 +26,8 @@
 
 import org.junit.*;
 
-import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.truffle.api.*;
 
@@ -35,7 +35,7 @@
 
     @Test
     public void testGraalCapabilities() {
-        assertNotNull(Graal.getRuntime().getCapability(MetaAccessProvider.class));
+        assertNotNull(Graal.getRuntime().getCapability(RuntimeProvider.class));
     }
 
     @Test
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Fri Oct 18 18:23:14 2013 +0200
@@ -29,7 +29,6 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.debug.*;
-import com.oracle.graal.hotspot.meta.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
@@ -54,7 +53,7 @@
         }
     }
 
-    private HotSpotNmethod compiledMethod;
+    private InstalledCode compiledMethod;
     private final TruffleCompiler compiler;
     private final CompilationPolicy compilationPolicy;
 
@@ -129,7 +128,7 @@
     public void compile() {
         CompilerAsserts.neverPartOfCompilation();
         try {
-            compiledMethod = (HotSpotNmethod) compiler.compile(this);
+            compiledMethod = compiler.compile(this);
             if (compiledMethod == null) {
                 throw new BailoutException(String.format("code installation failed (codeSize=%s)", codeSize));
             } else {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Fri Oct 18 18:23:14 2013 +0200
@@ -36,8 +36,6 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.Node;
 import com.oracle.graal.graph.spi.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.loop.*;
 import com.oracle.graal.nodes.*;
@@ -51,6 +49,7 @@
 import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.nodes.asserts.*;
 import com.oracle.graal.truffle.nodes.frame.*;
 import com.oracle.graal.truffle.nodes.frame.NewFrameNode.VirtualOnlyInstanceNode;
@@ -70,15 +69,15 @@
     private final CanonicalizerPhase canonicalizer;
     private final ResolvedJavaType[] skippedExceptionTypes;
     private Set<Constant> constantReceivers;
-    private final HotSpotGraphCache cache;
+    private final GraphCache cache;
     private final TruffleCache truffleCache;
 
-    public PartialEvaluator(Providers providers, TruffleCache truffleCache) {
+    public PartialEvaluator(RuntimeProvider runtime, Providers providers, TruffleCache truffleCache) {
         this.providers = providers;
         CustomCanonicalizer customCanonicalizer = new PartialEvaluatorCanonicalizer(providers.getMetaAccess(), providers.getConstantReflection());
         this.canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue(), customCanonicalizer);
         this.skippedExceptionTypes = TruffleCompilerImpl.getSkippedExceptionTypes(providers.getMetaAccess());
-        this.cache = HotSpotGraalRuntime.runtime().getCache();
+        this.cache = runtime.getGraphCache();
         this.truffleCache = truffleCache;
 
         try {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Fri Oct 18 18:23:14 2013 +0200
@@ -36,7 +36,6 @@
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.internal.*;
-import com.oracle.graal.hotspot.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
@@ -45,6 +44,7 @@
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.printer.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.nodes.*;
@@ -59,7 +59,7 @@
     private final PartialEvaluator partialEvaluator;
     private final Backend backend;
     private final ResolvedJavaType[] skippedExceptionTypes;
-    private final HotSpotGraalRuntime runtime;
+    private final RuntimeProvider runtime;
     private final TruffleCache truffleCache;
 
     private static final Class[] SKIPPED_EXCEPTION_CLASSES = new Class[]{SlowPathException.class, UnexpectedResultException.class, ArithmeticException.class};
@@ -68,18 +68,18 @@
                     OptimisticOptimizations.Optimization.RemoveNeverExecutedCode, OptimisticOptimizations.Optimization.UseTypeCheckedInlining, OptimisticOptimizations.Optimization.UseTypeCheckHints);
 
     public TruffleCompilerImpl() {
+        this.runtime = Graal.getRequiredCapability(RuntimeProvider.class);
+        this.backend = runtime.getHostBackend();
         Replacements truffleReplacements = ((GraalTruffleRuntime) Truffle.getRuntime()).getReplacements();
-        this.providers = GraalCompiler.getGraalProviders().copyWith(truffleReplacements);
-        this.suites = Graal.getRequiredCapability(SuitesProvider.class).createSuites();
-        this.backend = Graal.getRequiredCapability(Backend.class);
-        this.runtime = HotSpotGraalRuntime.runtime();
+        this.providers = backend.getProviders().copyWith(truffleReplacements);
+        this.suites = backend.getSuites().createSuites();
         this.skippedExceptionTypes = getSkippedExceptionTypes(providers.getMetaAccess());
 
         final GraphBuilderConfiguration config = GraphBuilderConfiguration.getEagerDefault();
         config.setSkippedExceptionTypes(skippedExceptionTypes);
         this.truffleCache = new TruffleCache(providers, config, TruffleCompilerImpl.Optimizations);
 
-        this.partialEvaluator = new PartialEvaluator(providers, truffleCache);
+        this.partialEvaluator = new PartialEvaluator(runtime, providers, truffleCache);
 
         if (Debug.isEnabled()) {
             DebugEnvironment.initialize(System.out);
@@ -113,7 +113,10 @@
         final StructuredGraph graph;
         final GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault();
         config.setSkippedExceptionTypes(skippedExceptionTypes);
-        runtime.evictDeoptedGraphs();
+        GraphCache graphCache = runtime.getGraphCache();
+        if (graphCache != null) {
+            graphCache.removeStaleGraphs();
+        }
 
         compilable.timeCompilationStarted = System.nanoTime();
         Assumptions assumptions = new Assumptions(true);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleReplacements.java	Fri Oct 18 18:23:14 2013 +0200
@@ -26,12 +26,13 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.replacements.*;
-import com.oracle.graal.compiler.*;
+import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
 import com.oracle.graal.replacements.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.substitutions.*;
 
 /**
@@ -47,7 +48,7 @@
     }
 
     static Replacements makeInstance() {
-        Providers graalProviders = GraalCompiler.getGraalProviders();
+        Providers graalProviders = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders();
         Replacements truffleReplacements = new TruffleReplacements(graalProviders);
 
         truffleReplacements.registerSubstitutions(CompilerAssertsSubstitutions.class);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Fri Oct 18 17:00:52 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Fri Oct 18 18:23:14 2013 +0200
@@ -34,6 +34,7 @@
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.nodes.virtual.*;
+import com.oracle.graal.runtime.*;
 import com.oracle.graal.truffle.*;
 import com.oracle.graal.truffle.nodes.*;
 import com.oracle.truffle.api.*;
@@ -45,7 +46,7 @@
  */
 public class NewFrameNode extends FixedWithNextNode implements IterableNodeType, VirtualizableAllocation, Canonicalizable {
 
-    static final ResolvedJavaType FRAME_TYPE = Graal.getRequiredCapability(MetaAccessProvider.class).lookupJavaType(FrameWithoutBoxing.class);
+    static final ResolvedJavaType FRAME_TYPE = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess().lookupJavaType(FrameWithoutBoxing.class);
 
     @Input private ValueNode descriptor;
     @Input private ValueNode caller;
--- a/mx/projects	Fri Oct 18 17:00:52 2013 +0200
+++ b/mx/projects	Fri Oct 18 18:23:14 2013 +0200
@@ -61,7 +61,7 @@
 # graal.api.meta.test
 project@com.oracle.graal.api.meta.test@subDir=graal
 project@com.oracle.graal.api.meta.test@sourceDirs=src
-project@com.oracle.graal.api.meta.test@dependencies=JUNIT,com.oracle.graal.api.meta,com.oracle.graal.api.runtime
+project@com.oracle.graal.api.meta.test@dependencies=JUNIT,com.oracle.graal.runtime,com.oracle.graal.java
 project@com.oracle.graal.api.meta.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.api.meta.test@javaCompliance=1.7
 project@com.oracle.graal.api.meta.test@workingSets=API,Graal,Test
@@ -117,7 +117,7 @@
 # graal.hotspot
 project@com.oracle.graal.hotspot@subDir=graal
 project@com.oracle.graal.hotspot@sourceDirs=src
-project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.printer
+project@com.oracle.graal.hotspot@dependencies=com.oracle.graal.replacements,com.oracle.graal.runtime,com.oracle.graal.printer
 project@com.oracle.graal.hotspot@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.hotspot@annotationProcessors=com.oracle.graal.replacements.verifier,com.oracle.graal.service.processor
 project@com.oracle.graal.hotspot@javaCompliance=1.7
@@ -414,6 +414,14 @@
 project@com.oracle.graal.compiler.sparc.test@javaCompliance=1.7
 project@com.oracle.graal.compiler.sparc.test@workingSets=Graal,SPARC,Test
 
+# graal.runtime
+project@com.oracle.graal.runtime@subDir=graal
+project@com.oracle.graal.runtime@sourceDirs=src
+project@com.oracle.graal.runtime@dependencies=com.oracle.graal.compiler
+project@com.oracle.graal.runtime@checkstyle=com.oracle.graal.graph
+project@com.oracle.graal.runtime@javaCompliance=1.7
+project@com.oracle.graal.runtime@workingSets=Graal
+
 # graal.bytecode
 project@com.oracle.graal.bytecode@subDir=graal
 project@com.oracle.graal.bytecode@sourceDirs=src
@@ -440,7 +448,7 @@
 # graal.java.decompiler.test
 project@com.oracle.graal.java.decompiler.test@subDir=graal
 project@com.oracle.graal.java.decompiler.test@sourceDirs=src
-project@com.oracle.graal.java.decompiler.test@dependencies=com.oracle.graal.printer
+project@com.oracle.graal.java.decompiler.test@dependencies=com.oracle.graal.printer,com.oracle.graal.runtime
 project@com.oracle.graal.java.decompiler.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.java.decompiler.test@javaCompliance=1.7
 project@com.oracle.graal.java.decompiler.test@workingSets=Graal,Test
@@ -464,7 +472,7 @@
 # graal.compiler.test
 project@com.oracle.graal.compiler.test@subDir=graal
 project@com.oracle.graal.compiler.test@sourceDirs=src
-project@com.oracle.graal.compiler.test@dependencies=com.oracle.graal.test,com.oracle.graal.printer
+project@com.oracle.graal.compiler.test@dependencies=com.oracle.graal.test,com.oracle.graal.printer,com.oracle.graal.runtime
 project@com.oracle.graal.compiler.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.compiler.test@javaCompliance=1.7
 project@com.oracle.graal.compiler.test@workingSets=Graal,Test
@@ -488,7 +496,7 @@
 # graal.asm.test
 project@com.oracle.graal.asm.test@subDir=graal
 project@com.oracle.graal.asm.test@sourceDirs=src
-project@com.oracle.graal.asm.test@dependencies=com.oracle.graal.api.runtime,com.oracle.graal.test,com.oracle.graal.asm
+project@com.oracle.graal.asm.test@dependencies=com.oracle.graal.test,com.oracle.graal.runtime
 project@com.oracle.graal.asm.test@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.asm.test@javaCompliance=1.7
 project@com.oracle.graal.asm.test@workingSets=Graal,Assembler,Test
@@ -628,7 +636,7 @@
 # graal.truffle
 project@com.oracle.graal.truffle@subDir=graal
 project@com.oracle.graal.truffle@sourceDirs=src
-project@com.oracle.graal.truffle@dependencies=com.oracle.truffle.api,com.oracle.graal.hotspot
+project@com.oracle.graal.truffle@dependencies=com.oracle.truffle.api,com.oracle.graal.replacements,com.oracle.graal.runtime,com.oracle.graal.printer
 project@com.oracle.graal.truffle@checkstyle=com.oracle.graal.graph
 project@com.oracle.graal.truffle@javaCompliance=1.7
 project@com.oracle.graal.truffle@workingSets=Graal,Truffle