changeset 15011:c8e575742f36

allow compilation with custom RegisterConfig
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 07 Apr 2014 19:21:22 +0200
parents f36e56e9dd9a
children 289a017dd9e2 62e9e9c6ac38 74c3ceb55e57
files graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.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.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java
diffstat 17 files changed, 112 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java	Mon Apr 07 19:21:22 2014 +0200
@@ -107,7 +107,7 @@
             List<? extends AbstractBlock<?>> codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blockMap.blocks.size(), blockMap.startBlock, blockProbabilities);
             LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder);
 
-            FrameMap frameMap = backend.newFrameMap();
+            FrameMap frameMap = backend.newFrameMap(null);
             TargetDescription target = backend.getTarget();
             CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
             this.lirGenRes = backend.newLIRGenerationResult(lir, frameMap, null);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java	Mon Apr 07 19:21:22 2014 +0200
@@ -113,14 +113,14 @@
 
         SchedulePhase schedule = null;
         try (Scope s = Debug.scope("FrontEnd")) {
-            schedule = GraalCompiler.emitHIR(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
+            schedule = GraalCompiler.emitFrontEnd(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE,
                             graph.method().getProfilingInfo(), new SpeculationLog(), getSuites());
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
 
         CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false);
-        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc);
+        LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null);
         return new RegisterStats(lirGen.getLIR());
     }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Apr 07 19:21:22 2014 +0200
@@ -138,23 +138,8 @@
         assert !graph.isFrozen();
         try (Scope s0 = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) {
             Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
-            SchedulePhase schedule = null;
-            try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
-                schedule = emitHIR(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites);
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
-            try (TimerCloseable a = BackEnd.start()) {
-                LIRGenerationResult lirGenRes = null;
-                lirGenRes = emitLIR(backend, target, schedule, graph, stub, cc);
-                try (Scope s = Debug.scope("CodeGen", lirGenRes)) {
-                    emitCode(backend, assumptions, lirGenRes, compilationResult, installedCodeOwner, factory);
-                } catch (Throwable e) {
-                    throw Debug.handle(e);
-                }
-            } catch (Throwable e) {
-                throw Debug.handle(e);
-            }
+            SchedulePhase schedule = emitFrontEnd(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites);
+            emitBackEnd(graph, stub, cc, installedCodeOwner, backend, target, compilationResult, factory, assumptions, schedule, null);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
@@ -172,37 +157,54 @@
     /**
      * Builds the graph, optimizes it.
      */
-    public static SchedulePhase emitHIR(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache,
+    public static SchedulePhase emitFrontEnd(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map<ResolvedJavaMethod, StructuredGraph> cache,
                     PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) {
-
-        if (speculationLog != null) {
-            speculationLog.collectFailedSpeculations();
-        }
+        try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) {
+            if (speculationLog != null) {
+                speculationLog.collectFailedSpeculations();
+            }
 
-        HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
-        if (graph.start().next() == null) {
-            graphBuilderSuite.apply(graph, highTierContext);
-            new DeadCodeEliminationPhase().apply(graph);
-        } else {
-            Debug.dump(graph, "initial state");
-        }
+            HighTierContext highTierContext = new HighTierContext(providers, assumptions, cache, graphBuilderSuite, optimisticOpts);
+            if (graph.start().next() == null) {
+                graphBuilderSuite.apply(graph, highTierContext);
+                new DeadCodeEliminationPhase().apply(graph);
+            } else {
+                Debug.dump(graph, "initial state");
+            }
+
+            suites.getHighTier().apply(graph, highTierContext);
+            graph.maybeCompress();
+
+            MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
+            suites.getMidTier().apply(graph, midTierContext);
+            graph.maybeCompress();
 
-        suites.getHighTier().apply(graph, highTierContext);
-        graph.maybeCompress();
+            LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
+            suites.getLowTier().apply(graph, lowTierContext);
+            graph.maybeCompress();
 
-        MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
-        suites.getMidTier().apply(graph, midTierContext);
-        graph.maybeCompress();
+            SchedulePhase schedule = new SchedulePhase();
+            schedule.apply(graph);
+            Debug.dump(schedule, "Final HIR schedule");
+            return schedule;
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
+    }
 
-        LowTierContext lowTierContext = new LowTierContext(providers, assumptions, target);
-        suites.getLowTier().apply(graph, lowTierContext);
-        graph.maybeCompress();
-
-        SchedulePhase schedule = new SchedulePhase();
-        schedule.apply(graph);
-        Debug.dump(schedule, "Final HIR schedule");
-        return schedule;
-
+    public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend,
+                    TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, Assumptions assumptions, SchedulePhase schedule, RegisterConfig registerConfig) {
+        try (TimerCloseable a = BackEnd.start()) {
+            LIRGenerationResult lirGen = null;
+            lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig);
+            try (Scope s = Debug.scope("CodeGen", lirGen)) {
+                emitCode(backend, assumptions, lirGen, compilationResult, installedCodeOwner, factory);
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
+        } catch (Throwable e) {
+            throw Debug.handle(e);
+        }
     }
 
     private static void emitBlock(NodeLIRBuilder nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<ScheduledNode>> blockMap) {
@@ -216,7 +218,7 @@
         }
     }
 
-    public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc) {
+    public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc, RegisterConfig registerConfig) {
         Block[] blocks = schedule.getCFG().getBlocks();
         Block startBlock = schedule.getCFG().getStartBlock();
         assert startBlock != null;
@@ -241,7 +243,7 @@
             throw Debug.handle(e);
         }
         try (Scope ds = Debug.scope("BackEnd", lir)) {
-            FrameMap frameMap = backend.newFrameMap();
+            FrameMap frameMap = backend.newFrameMap(registerConfig);
             LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMap, stub);
             LIRGenerator lirGen = backend.newLIRGenerator(cc, lirGenRes);
             NodeLIRBuilder nodeLirGen = backend.newNodeLIRGenerator(graph, lirGen);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Mon Apr 07 19:21:22 2014 +0200
@@ -64,7 +64,11 @@
         return providers.getCodeCache().getTarget();
     }
 
-    public abstract FrameMap newFrameMap();
+    /**
+     * The given registerConfig is optional, in case null is passed the default RegisterConfig from
+     * the CodeCacheProvider will be used.
+     */
+    public abstract FrameMap newFrameMap(RegisterConfig registerConfig);
 
     public abstract LIRGenerator newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes);
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Apr 07 19:21:22 2014 +0200
@@ -67,8 +67,8 @@
     }
 
     @Override
-    public FrameMap newFrameMap() {
-        return new AMD64FrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new AMD64FrameMap(getCodeCache(), registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Mon Apr 07 19:21:22 2014 +0200
@@ -141,6 +141,11 @@
     }
 
     public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) {
+        this(architecture, config, initAllocatable(config.useCompressedOops));
+        assert callerSaved.length == allocatable.length || RegisterPressure.getValue() != null;
+    }
+
+    public AMD64HotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config, Register[] allocatable) {
         this.architecture = architecture;
         this.maxFrameSize = config.maxFrameSize;
 
@@ -153,14 +158,13 @@
         }
 
         csl = null;
-        allocatable = initAllocatable(config.useCompressedOops);
+        this.allocatable = allocatable.clone();
         Set<Register> callerSaveSet = new HashSet<>();
         Collections.addAll(callerSaveSet, allocatable);
         Collections.addAll(callerSaveSet, xmmParameterRegisters);
         Collections.addAll(callerSaveSet, javaGeneralParameterRegisters);
         Collections.addAll(callerSaveSet, nativeGeneralParameterRegisters);
         callerSaved = callerSaveSet.toArray(new Register[callerSaveSet.size()]);
-        assert callerSaved.length == allocatable.length || RegisterPressure.getValue() != null;
 
         allAllocatableAreCallerSaved = true;
         attributesMap = RegisterAttributes.createMap(this, AMD64.allRegisters);
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java	Mon Apr 07 19:21:22 2014 +0200
@@ -361,8 +361,8 @@
      * Use the HSAIL register set when the compilation target is HSAIL.
      */
     @Override
-    public FrameMap newFrameMap() {
-        return new HSAILFrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new HSAILFrameMap(getCodeCache(), registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java	Mon Apr 07 19:21:22 2014 +0200
@@ -95,6 +95,7 @@
                     long.class, // objectParameterOffsets
                     long.class, // pinnedObjects
                     int.class); // encodedReturnTypeSize
+
     // @formatter:on
 
     public PTXHotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
@@ -154,8 +155,8 @@
     private static native long getLaunchKernelAddress();
 
     @Override
-    public FrameMap newFrameMap() {
-        return new PTXFrameMap(getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new PTXFrameMap(getCodeCache(), registerConfig);
     }
 
     /**
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Mon Apr 07 19:21:22 2014 +0200
@@ -74,8 +74,8 @@
     }
 
     @Override
-    public FrameMap newFrameMap() {
-        return new SPARCFrameMap(getProviders().getCodeCache());
+    public FrameMap newFrameMap(RegisterConfig registerConfig) {
+        return new SPARCFrameMap(getProviders().getCodeCache(), registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java	Mon Apr 07 19:21:22 2014 +0200
@@ -131,10 +131,14 @@
     }
 
     public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) {
+        this(target, initAllocatable(config.useCompressedOops));
+    }
+
+    public SPARCHotSpotRegisterConfig(TargetDescription target, Register[] allocatable) {
         this.architecture = target.arch;
 
         csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters);
-        allocatable = initAllocatable(config.useCompressedOops);
+        this.allocatable = allocatable.clone();
         attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters);
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Mon Apr 07 19:21:22 2014 +0200
@@ -24,6 +24,7 @@
 
 import static com.oracle.graal.compiler.GraalCompiler.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.phases.GraalOptions.*;
 
 import java.util.*;
 
@@ -41,6 +42,7 @@
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.schedule.*;
 
 //JaCoCo Exclude
 
@@ -108,6 +110,10 @@
         return linkage;
     }
 
+    public RegisterConfig getRegisterConfig() {
+        return null;
+    }
+
     /**
      * Gets the graph that from which the code for this stub will be compiled.
      */
@@ -145,9 +151,17 @@
                 CodeCacheProvider codeCache = providers.getCodeCache();
                 // The stub itself needs the incoming calling convention.
                 CallingConvention incomingCc = linkage.getIncomingCallingConvention();
-                final CompilationResult compResult = compileGraph(graph, Stub.this, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null,
-                                providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(),
-                                new CompilationResult(), CompilationResultBuilderFactory.Default);
+                TargetDescription target = codeCache.getTarget();
+
+                final CompilationResult compResult = new CompilationResult();
+                try (Scope s0 = Debug.scope("StubCompilation", graph, providers.getCodeCache())) {
+                    Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
+                    SchedulePhase schedule = emitFrontEnd(providers, target, graph, assumptions, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL,
+                                    getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites());
+                    emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, assumptions, schedule, getRegisterConfig());
+                } catch (Throwable e) {
+                    throw Debug.handle(e);
+                }
 
                 assert destroyedRegisters != null;
                 try (Scope s = Debug.scope("CodeInstall")) {
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java	Mon Apr 07 19:21:22 2014 +0200
@@ -69,8 +69,8 @@
  */
 public class AMD64FrameMap extends FrameMap {
 
-    public AMD64FrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public AMD64FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
         // (negative) offset relative to sp + total frame size
         initialSpillSize = returnAddressSize() + calleeSaveAreaSize();
         spillSize = initialSpillSize;
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java	Mon Apr 07 19:21:22 2014 +0200
@@ -37,8 +37,8 @@
  */
 public final class HSAILFrameMap extends FrameMap {
 
-    public HSAILFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public HSAILFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java	Mon Apr 07 19:21:22 2014 +0200
@@ -37,8 +37,8 @@
  */
 public final class PTXFrameMap extends FrameMap {
 
-    public PTXFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public PTXFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java	Mon Apr 07 19:21:22 2014 +0200
@@ -69,8 +69,8 @@
  */
 public final class SPARCFrameMap extends FrameMap {
 
-    public SPARCFrameMap(CodeCacheProvider codeCache) {
-        super(codeCache);
+    public SPARCFrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
+        super(codeCache, registerConfig);
         // offset relative to sp + total frame size
         initialSpillSize = 0;
         spillSize = initialSpillSize;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Apr 07 19:21:22 2014 +0200
@@ -84,11 +84,12 @@
     private boolean accessesCallerFrame;
 
     /**
-     * Creates a new frame map for the specified method.
+     * Creates a new frame map for the specified method. The given registerConfig is optional, in
+     * case null is passed the default RegisterConfig from the CodeCacheProvider will be used.
      */
-    public FrameMap(CodeCacheProvider codeCache) {
+    public FrameMap(CodeCacheProvider codeCache, RegisterConfig registerConfig) {
         this.target = codeCache.getTarget();
-        this.registerConfig = codeCache.getRegisterConfig();
+        this.registerConfig = registerConfig == null ? codeCache.getRegisterConfig() : registerConfig;
         this.frameSize = -1;
         this.outgoingSize = codeCache.getMinimumOutgoingSize();
         this.objectStackSlots = new ArrayList<>();
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Mon Apr 07 14:54:24 2014 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Mon Apr 07 19:21:22 2014 +0200
@@ -419,11 +419,15 @@
          */
         protected SnippetInfo snippet(Class<? extends Snippets> declaringClass, String methodName) {
             Method found = null;
-            for (Method method : declaringClass.getDeclaredMethods()) {
-                if (method.getAnnotation(Snippet.class) != null && (methodName == null || method.getName().equals(methodName))) {
-                    assert found == null : "found more than one @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
-                    found = method;
+            Class<?> clazz = declaringClass;
+            while (clazz != Object.class) {
+                for (Method method : clazz.getDeclaredMethods()) {
+                    if (method.getAnnotation(Snippet.class) != null && (methodName == null || method.getName().equals(methodName))) {
+                        assert found == null : "found more than one @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
+                        found = method;
+                    }
                 }
+                clazz = clazz.getSuperclass();
             }
             assert found != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName);
             ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(found);