changeset 22517:9f627bdaca98

Merge
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 26 Aug 2015 15:22:34 -0700
parents d3d19b31e9a4 (current diff) 8cf9fa4368de (diff)
children f5a11121bbee
files graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java
diffstat 9 files changed, 245 insertions(+), 230 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Wed Aug 26 15:22:34 2015 -0700
@@ -138,10 +138,6 @@
     @Option(help = "Perform platform dependent validation of the Java heap at returns", type = OptionType.Debug)
     public static final OptionValue<Boolean> VerifyHeapAtReturn = new OptionValue<>(false);
 
-    // Ideal graph visualizer output settings
-    @Option(help = "Dump IdealGraphVisualizer output in binary format", type = OptionType.Debug)
-    public static final OptionValue<Boolean> PrintBinaryGraphs = new OptionValue<>(true);
-
     @Option(help = "Output probabilities for fixed nodes during binary graph dumping", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintGraphProbabilities = new OptionValue<>(false);
 
@@ -154,9 +150,16 @@
     @Option(help = "Enable dumping to the IdealGraphVisualizer.", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintIdealGraph = new OptionValue<>(true);
 
-    @Option(help = "", type = OptionType.Debug)
+    // Ideal graph visualizer output settings
+    @Option(help = "Dump IdealGraphVisualizer output in binary format", type = OptionType.Debug)
+    public static final OptionValue<Boolean> PrintBinaryGraphs = new OptionValue<>(true);
+
+    @Option(help = "Print Ideal graphs as opposed to sending them over the network.", type = OptionType.Debug)
     public static final OptionValue<Boolean> PrintIdealGraphFile = new OptionValue<>(false);
 
+    @Option(help = "The directory into which to dump the Ideal graph files.")
+    public static final OptionValue<String> DumpPath = new OptionValue<>("");
+
     @Option(help = "", type = OptionType.Debug)
     public static final OptionValue<String> PrintIdealGraphAddress = new OptionValue<>("127.0.0.1");
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FixedValueAnchorNode.java	Wed Aug 26 15:22:34 2015 -0700
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.nodes.extended;
 
-import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodeinfo.*;
 import com.oracle.graal.nodes.*;
@@ -39,7 +38,7 @@
     }
 
     public FixedValueAnchorNode(ValueNode object) {
-        super(TYPE, StampFactory.forNodeIntrinsic());
+        super(TYPE, object.stamp());
         this.object = object;
     }
 
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Wed Aug 26 15:22:34 2015 -0700
@@ -23,19 +23,20 @@
 package com.oracle.graal.printer;
 
 import java.io.*;
+import java.nio.file.*;
 import java.util.*;
 import java.util.concurrent.atomic.*;
 
 import jdk.internal.jvmci.code.*;
 import jdk.internal.jvmci.common.*;
-import com.oracle.graal.debug.*;
-
 import jdk.internal.jvmci.meta.*;
 import jdk.internal.jvmci.service.*;
 
 import com.oracle.graal.code.*;
+import com.oracle.graal.compiler.common.*;
 import com.oracle.graal.compiler.common.cfg.*;
 import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.lir.*;
@@ -110,9 +111,6 @@
         return true;
     }
 
-    private static final long timestamp = System.currentTimeMillis();
-    private static final AtomicInteger uniqueId = new AtomicInteger();
-
     private static boolean isFrontendObject(Object object) {
         return object instanceof Graph || object instanceof BciBlockMapping;
     }
@@ -127,7 +125,7 @@
         }
 
         if (cfgPrinter == null) {
-            cfgFile = new File("compilations-" + timestamp + "_" + uniqueId.incrementAndGet() + ".cfg");
+            cfgFile = getCFGPath().toFile();
             try {
                 OutputStream out = new BufferedOutputStream(new FileOutputStream(cfgFile));
                 cfgPrinter = new CFGPrinter(out);
@@ -224,6 +222,16 @@
         return object instanceof List<?> && ((List<?>) object).size() > 0 && ((List<?>) object).get(0) instanceof AbstractBlockBase<?>;
     }
 
+    private static long timestamp;
+    private static final AtomicInteger uniqueId = new AtomicInteger();
+
+    private static Path getCFGPath() {
+        if (timestamp == 0) {
+            timestamp = System.currentTimeMillis();
+        }
+        return Paths.get(GraalOptions.DumpPath.getValue(), "compilations-" + timestamp + "_" + uniqueId.incrementAndGet() + ".cfg");
+    }
+
     /** Lazy initialization to delay service lookup until disassembler is actually needed. */
     static class DisassemblerHolder {
         private static final DisassemblerProvider disassembler;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Aug 26 15:22:34 2015 -0700
@@ -29,8 +29,8 @@
 import java.net.*;
 import java.nio.channels.*;
 import java.nio.file.*;
-import java.text.*;
 import java.util.*;
+import java.util.concurrent.atomic.*;
 
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.Debug.*;
@@ -87,48 +87,37 @@
         return dumpIds[depth - 1]++;
     }
 
-    // This field must be lazily initialized as this class may be loaded in a version
-    // VM startup phase at which not all required features (such as system properties)
-    // are online.
-    private static volatile SimpleDateFormat sdf;
-
     private void initializeFilePrinter() {
-        String ext;
-        if (PrintBinaryGraphs.getValue()) {
-            ext = ".bgv";
-        } else {
-            ext = ".gv.xml";
-        }
-        if (sdf == null) {
-            sdf = new SimpleDateFormat("YYYY-MM-dd-HHmm");
-        }
-
-        // DateFormats are inherently unsafe for multi-threaded use. Use a synchronized block.
-        String prefix;
-        synchronized (sdf) {
-            prefix = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date());
-        }
-
-        String num = "";
-        File file;
-        int i = 0;
-        while ((file = new File(prefix + num + ext)).exists()) {
-            num = "-" + Integer.toString(++i);
-        }
+        Path path = getFilePrinterPath();
         try {
             if (PrintBinaryGraphs.getValue()) {
-                printer = new BinaryGraphPrinter(FileChannel.open(file.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW));
+                printer = new BinaryGraphPrinter(FileChannel.open(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW));
             } else {
-                printer = new IdealGraphPrinter(new FileOutputStream(file), true);
+                printer = new IdealGraphPrinter(Files.newOutputStream(path), true);
             }
-            TTY.println("Dumping IGV graphs to %s", file.getName());
+            TTY.println("Dumping IGV graphs to %s", path.toString());
         } catch (IOException e) {
-            TTY.println("Failed to open %s to dump IGV graphs : %s", file.getName(), e);
+            TTY.println("Failed to open %s to dump IGV graphs : %s", path.toString(), e);
             failuresCount++;
             printer = null;
         }
     }
 
+    private static long dumpIgvTimestamp;
+    private static final AtomicInteger dumpIgvId = new AtomicInteger();
+
+    private static Path getFilePrinterPath() {
+        // If this is the first time I have constructed a FilePrinterPath,
+        // get a time stamp in a (weak) attempt to make unique file names.
+        if (dumpIgvTimestamp == 0) {
+            dumpIgvTimestamp = System.currentTimeMillis();
+        }
+        // Encode the kind of the file in the extension.
+        final String ext = (PrintBinaryGraphs.getValue() ? ".bgv" : ".gv.xml");
+        // Construct the path to the file.
+        return Paths.get(DumpPath.getValue(), "runtime-graphs-" + dumpIgvTimestamp + "_" + dumpIgvId.incrementAndGet() + ext);
+    }
+
     private void initializeNetworkPrinter() {
         String host = PrintIdealGraphAddress.getValue();
         int port = PrintBinaryGraphs.getValue() ? PrintBinaryGraphPort.getValue() : PrintIdealGraphPort.getValue();
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraphKit.java	Wed Aug 26 15:22:34 2015 -0700
@@ -144,6 +144,15 @@
         return method;
     }
 
+    public ResolvedJavaMethod findMethod(Class<?> declaringClass, String name, Class<?>... parameterTypes) {
+        try {
+            Method m = declaringClass.getDeclaredMethod(name, parameterTypes);
+            return providers.getMetaAccess().lookupJavaMethod(m);
+        } catch (NoSuchMethodException | SecurityException e) {
+            throw new AssertionError(e);
+        }
+    }
+
     /**
      * Creates and appends an {@link InvokeNode} for a call to a given method with a given set of
      * arguments.
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Aug 26 15:22:34 2015 -0700
@@ -592,214 +592,222 @@
 
         // Copy snippet graph, replacing constant parameters with given arguments
         final StructuredGraph snippetCopy = new StructuredGraph(snippetGraph.name, snippetGraph.method(), AllowAssumptions.NO);
-        if (!snippetGraph.isInlinedMethodRecordingEnabled()) {
-            snippetCopy.disableInlinedMethodRecording();
-        }
-        if (!snippetGraph.isUnsafeAccessTrackingEnabled()) {
-            snippetCopy.disableUnsafeAccessTracking();
-        }
+
+        try (Debug.Scope scope = Debug.scope("SpecializeSnippet", snippetCopy)) {
+            if (!snippetGraph.isInlinedMethodRecordingEnabled()) {
+                snippetCopy.disableInlinedMethodRecording();
+            }
+            if (!snippetGraph.isUnsafeAccessTrackingEnabled()) {
+                snippetCopy.disableUnsafeAccessTracking();
+            }
 
-        Map<Node, Node> nodeReplacements = Node.newIdentityMap();
-        nodeReplacements.put(snippetGraph.start(), snippetCopy.start());
+            Map<Node, Node> nodeReplacements = Node.newIdentityMap();
+            nodeReplacements.put(snippetGraph.start(), snippetCopy.start());
 
-        MetaAccessProvider metaAccess = providers.getMetaAccess();
-        assert checkTemplate(metaAccess, args, method, signature);
+            MetaAccessProvider metaAccess = providers.getMetaAccess();
+            assert checkTemplate(metaAccess, args, method, signature);
+
+            int parameterCount = args.info.getParameterCount();
+            VarargsPlaceholderNode[] placeholders = new VarargsPlaceholderNode[parameterCount];
 
-        int parameterCount = args.info.getParameterCount();
-        VarargsPlaceholderNode[] placeholders = new VarargsPlaceholderNode[parameterCount];
+            for (int i = 0; i < parameterCount; i++) {
+                if (args.info.isConstantParameter(i)) {
+                    Object arg = args.values[i];
+                    Kind kind = signature.getParameterKind(i);
+                    ConstantNode constantNode;
+                    if (arg instanceof Constant) {
+                        Stamp stamp = args.constStamps[i];
+                        if (stamp == null) {
+                            assert arg instanceof JavaConstant : "could not determine type of constant " + arg;
+                            constantNode = ConstantNode.forConstant((JavaConstant) arg, metaAccess, snippetCopy);
+                        } else {
+                            constantNode = ConstantNode.forConstant(stamp, (Constant) arg, metaAccess, snippetCopy);
+                        }
+                    } else {
+                        constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(kind, arg), metaAccess, snippetCopy);
+                    }
+                    nodeReplacements.put(snippetGraph.getParameter(i), constantNode);
+                } else if (args.info.isVarargsParameter(i)) {
+                    Varargs varargs = (Varargs) args.values[i];
+                    VarargsPlaceholderNode placeholder = snippetCopy.unique(new VarargsPlaceholderNode(varargs, providers.getMetaAccess()));
+                    nodeReplacements.put(snippetGraph.getParameter(i), placeholder);
+                    placeholders[i] = placeholder;
+                }
+            }
+            snippetCopy.addDuplicates(snippetGraph.getNodes(), snippetGraph, snippetGraph.getNodeCount(), nodeReplacements);
+
+            Debug.dump(snippetCopy, "Before specialization");
 
-        for (int i = 0; i < parameterCount; i++) {
-            if (args.info.isConstantParameter(i)) {
-                Object arg = args.values[i];
-                Kind kind = signature.getParameterKind(i);
-                ConstantNode constantNode;
-                if (arg instanceof Constant) {
-                    Stamp stamp = args.constStamps[i];
-                    if (stamp == null) {
-                        assert arg instanceof JavaConstant : "could not determine type of constant " + arg;
-                        constantNode = ConstantNode.forConstant((JavaConstant) arg, metaAccess, snippetCopy);
-                    } else {
-                        constantNode = ConstantNode.forConstant(stamp, (Constant) arg, metaAccess, snippetCopy);
+            // Gather the template parameters
+            parameters = new Object[parameterCount];
+            for (int i = 0; i < parameterCount; i++) {
+                if (args.info.isConstantParameter(i)) {
+                    parameters[i] = CONSTANT_PARAMETER;
+                } else if (args.info.isVarargsParameter(i)) {
+                    assert snippetCopy.getParameter(i) == null;
+                    Varargs varargs = (Varargs) args.values[i];
+                    int length = varargs.length;
+                    ParameterNode[] params = new ParameterNode[length];
+                    Stamp stamp = varargs.stamp;
+                    for (int j = 0; j < length; j++) {
+                        // Use a decimal friendly numbering make it more obvious how values map
+                        assert parameterCount < 10000;
+                        int idx = (i + 1) * 10000 + j;
+                        assert idx >= parameterCount : "collision in parameter numbering";
+                        ParameterNode local = snippetCopy.unique(new ParameterNode(idx, stamp));
+                        params[j] = local;
+                    }
+                    parameters[i] = params;
+
+                    VarargsPlaceholderNode placeholder = placeholders[i];
+                    assert placeholder != null;
+                    for (Node usage : placeholder.usages().snapshot()) {
+                        if (usage instanceof LoadIndexedNode) {
+                            LoadIndexedNode loadIndexed = (LoadIndexedNode) usage;
+                            Debug.dump(snippetCopy, "Before replacing %s", loadIndexed);
+                            LoadSnippetVarargParameterNode loadSnippetParameter = snippetCopy.add(new LoadSnippetVarargParameterNode(params, loadIndexed.index(), loadIndexed.stamp()));
+                            snippetCopy.replaceFixedWithFixed(loadIndexed, loadSnippetParameter);
+                            Debug.dump(snippetCopy, "After replacing %s", loadIndexed);
+                        } else if (usage instanceof StoreIndexedNode) {
+                            /*
+                             * The template lowering doesn't really treat this as an array so you
+                             * can't store back into the varargs. Allocate your own array if you
+                             * really need this and EA should eliminate it.
+                             */
+                            throw new JVMCIError("Can't store into VarargsParameter array");
+                        }
                     }
                 } else {
-                    constantNode = ConstantNode.forConstant(snippetReflection.forBoxed(kind, arg), metaAccess, snippetCopy);
-                }
-                nodeReplacements.put(snippetGraph.getParameter(i), constantNode);
-            } else if (args.info.isVarargsParameter(i)) {
-                Varargs varargs = (Varargs) args.values[i];
-                VarargsPlaceholderNode placeholder = snippetCopy.unique(new VarargsPlaceholderNode(varargs, providers.getMetaAccess()));
-                nodeReplacements.put(snippetGraph.getParameter(i), placeholder);
-                placeholders[i] = placeholder;
-            }
-        }
-        snippetCopy.addDuplicates(snippetGraph.getNodes(), snippetGraph, snippetGraph.getNodeCount(), nodeReplacements);
-
-        Debug.dump(snippetCopy, "Before specialization");
-
-        // Gather the template parameters
-        parameters = new Object[parameterCount];
-        for (int i = 0; i < parameterCount; i++) {
-            if (args.info.isConstantParameter(i)) {
-                parameters[i] = CONSTANT_PARAMETER;
-            } else if (args.info.isVarargsParameter(i)) {
-                assert snippetCopy.getParameter(i) == null;
-                Varargs varargs = (Varargs) args.values[i];
-                int length = varargs.length;
-                ParameterNode[] params = new ParameterNode[length];
-                Stamp stamp = varargs.stamp;
-                for (int j = 0; j < length; j++) {
-                    // Use a decimal friendly numbering make it more obvious how values map
-                    assert parameterCount < 10000;
-                    int idx = (i + 1) * 10000 + j;
-                    assert idx >= parameterCount : "collision in parameter numbering";
-                    ParameterNode local = snippetCopy.unique(new ParameterNode(idx, stamp));
-                    params[j] = local;
-                }
-                parameters[i] = params;
-
-                VarargsPlaceholderNode placeholder = placeholders[i];
-                assert placeholder != null;
-                for (Node usage : placeholder.usages().snapshot()) {
-                    if (usage instanceof LoadIndexedNode) {
-                        LoadIndexedNode loadIndexed = (LoadIndexedNode) usage;
-                        Debug.dump(snippetCopy, "Before replacing %s", loadIndexed);
-                        LoadSnippetVarargParameterNode loadSnippetParameter = snippetCopy.add(new LoadSnippetVarargParameterNode(params, loadIndexed.index(), loadIndexed.stamp()));
-                        snippetCopy.replaceFixedWithFixed(loadIndexed, loadSnippetParameter);
-                        Debug.dump(snippetCopy, "After replacing %s", loadIndexed);
-                    } else if (usage instanceof StoreIndexedNode) {
-                        // The template lowering doesn't really treat this as an array so you can't
-                        // store back into the varargs. Allocate your own array if you really need
-                        // this and EA should eliminate it.
-                        throw new JVMCIError("Can't store into VarargsParameter array");
+                    ParameterNode local = snippetCopy.getParameter(i);
+                    if (local == null) {
+                        // Parameter value was eliminated
+                        parameters[i] = UNUSED_PARAMETER;
+                    } else {
+                        parameters[i] = local;
                     }
                 }
-            } else {
-                ParameterNode local = snippetCopy.getParameter(i);
-                if (local == null) {
-                    // Parameter value was eliminated
-                    parameters[i] = UNUSED_PARAMETER;
-                } else {
-                    parameters[i] = local;
-                }
             }
-        }
 
-        // Do any required loop explosion
-        boolean exploded = false;
-        do {
-            exploded = false;
-            ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first();
-            if (explodeLoop != null) { // Earlier canonicalization may have removed the loop
-                // altogether
-                LoopBeginNode loopBegin = explodeLoop.findLoopBegin();
-                if (loopBegin != null) {
-                    LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin);
-                    Mark mark = snippetCopy.getMark();
-                    LoopTransformations.fullUnroll(loop, phaseContext, new CanonicalizerPhase());
-                    new CanonicalizerPhase().applyIncremental(snippetCopy, phaseContext, mark);
-                    loop.deleteUnusedNodes();
+            // Do any required loop explosion
+            boolean exploded = false;
+            do {
+                exploded = false;
+                ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first();
+                if (explodeLoop != null) { // Earlier canonicalization may have removed the loop
+                    // altogether
+                    LoopBeginNode loopBegin = explodeLoop.findLoopBegin();
+                    if (loopBegin != null) {
+                        LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin);
+                        Mark mark = snippetCopy.getMark();
+                        LoopTransformations.fullUnroll(loop, phaseContext, new CanonicalizerPhase());
+                        new CanonicalizerPhase().applyIncremental(snippetCopy, phaseContext, mark);
+                        loop.deleteUnusedNodes();
+                    }
+                    GraphUtil.removeFixedWithUnusedInputs(explodeLoop);
+                    exploded = true;
                 }
-                GraphUtil.removeFixedWithUnusedInputs(explodeLoop);
-                exploded = true;
-            }
-        } while (exploded);
+            } while (exploded);
 
-        GuardsStage guardsStage = args.cacheKey.guardsStage;
-        // Perform lowering on the snippet
-        if (!guardsStage.allowsFloatingGuards()) {
-            new GuardLoweringPhase().apply(snippetCopy, null);
-        }
-        snippetCopy.setGuardsStage(guardsStage);
-        try (Scope s = Debug.scope("LoweringSnippetTemplate", snippetCopy)) {
-            new LoweringPhase(new CanonicalizerPhase(), args.cacheKey.loweringStage).apply(snippetCopy, phaseContext);
-        } catch (Throwable e) {
-            throw Debug.handle(e);
-        }
+            GuardsStage guardsStage = args.cacheKey.guardsStage;
+            // Perform lowering on the snippet
+            if (!guardsStage.allowsFloatingGuards()) {
+                new GuardLoweringPhase().apply(snippetCopy, null);
+            }
+            snippetCopy.setGuardsStage(guardsStage);
+            try (Scope s = Debug.scope("LoweringSnippetTemplate", snippetCopy)) {
+                new LoweringPhase(new CanonicalizerPhase(), args.cacheKey.loweringStage).apply(snippetCopy, phaseContext);
+            } catch (Throwable e) {
+                throw Debug.handle(e);
+            }
 
-        ArrayList<StateSplit> curSideEffectNodes = new ArrayList<>();
-        ArrayList<DeoptimizingNode> curDeoptNodes = new ArrayList<>();
-        ArrayList<ValueNode> curStampNodes = new ArrayList<>();
-        for (Node node : snippetCopy.getNodes()) {
-            if (node instanceof ValueNode && ((ValueNode) node).stamp() == StampFactory.forNodeIntrinsic()) {
-                curStampNodes.add((ValueNode) node);
-            }
-            if (node instanceof StateSplit) {
-                StateSplit stateSplit = (StateSplit) node;
-                FrameState frameState = stateSplit.stateAfter();
-                if (stateSplit.hasSideEffect()) {
-                    curSideEffectNodes.add((StateSplit) node);
+            ArrayList<StateSplit> curSideEffectNodes = new ArrayList<>();
+            ArrayList<DeoptimizingNode> curDeoptNodes = new ArrayList<>();
+            ArrayList<ValueNode> curStampNodes = new ArrayList<>();
+            for (Node node : snippetCopy.getNodes()) {
+                if (node instanceof ValueNode && ((ValueNode) node).stamp() == StampFactory.forNodeIntrinsic()) {
+                    curStampNodes.add((ValueNode) node);
                 }
-                if (frameState != null) {
-                    stateSplit.setStateAfter(null);
+                if (node instanceof StateSplit) {
+                    StateSplit stateSplit = (StateSplit) node;
+                    FrameState frameState = stateSplit.stateAfter();
+                    if (stateSplit.hasSideEffect()) {
+                        curSideEffectNodes.add((StateSplit) node);
+                    }
+                    if (frameState != null) {
+                        stateSplit.setStateAfter(null);
+                    }
                 }
-            }
-            if (node instanceof DeoptimizingNode) {
-                DeoptimizingNode deoptNode = (DeoptimizingNode) node;
-                if (deoptNode.canDeoptimize()) {
-                    curDeoptNodes.add(deoptNode);
+                if (node instanceof DeoptimizingNode) {
+                    DeoptimizingNode deoptNode = (DeoptimizingNode) node;
+                    if (deoptNode.canDeoptimize()) {
+                        curDeoptNodes.add(deoptNode);
+                    }
                 }
             }
-        }
+
+            new DeadCodeEliminationPhase(Required).apply(snippetCopy);
 
-        new DeadCodeEliminationPhase(Required).apply(snippetCopy);
+            assert checkAllVarargPlaceholdersAreDeleted(parameterCount, placeholders);
 
-        assert checkAllVarargPlaceholdersAreDeleted(parameterCount, placeholders);
+            new FloatingReadPhase(true, true).apply(snippetCopy);
 
-        new FloatingReadPhase(true, true).apply(snippetCopy);
+            MemoryAnchorNode anchor = snippetCopy.add(new MemoryAnchorNode());
+            snippetCopy.start().replaceAtUsages(InputType.Memory, anchor);
 
-        MemoryAnchorNode anchor = snippetCopy.add(new MemoryAnchorNode());
-        snippetCopy.start().replaceAtUsages(InputType.Memory, anchor);
+            this.snippet = snippetCopy;
 
-        this.snippet = snippetCopy;
-
-        Debug.dump(snippet, "SnippetTemplate after fixing memory anchoring");
+            Debug.dump(snippet, "SnippetTemplate after fixing memory anchoring");
 
-        StartNode entryPointNode = snippet.start();
-        if (anchor.hasNoUsages()) {
-            anchor.safeDelete();
-            this.memoryAnchor = null;
-        } else {
-            snippetCopy.addAfterFixed(snippetCopy.start(), anchor);
-            this.memoryAnchor = anchor;
-        }
-        List<ReturnNode> returnNodes = snippet.getNodes(ReturnNode.TYPE).snapshot();
-        if (returnNodes.isEmpty()) {
-            this.returnNode = null;
-        } else if (returnNodes.size() == 1) {
-            this.returnNode = returnNodes.get(0);
-        } else {
-            AbstractMergeNode merge = snippet.add(new MergeNode());
-            List<MemoryMapNode> memMaps = returnNodes.stream().map(n -> n.getMemoryMap()).collect(Collectors.toList());
-            ValueNode returnValue = InliningUtil.mergeReturns(merge, returnNodes, null);
-            this.returnNode = snippet.add(new ReturnNode(returnValue));
-            MemoryMapImpl mmap = FloatingReadPhase.mergeMemoryMaps(merge, memMaps);
-            MemoryMapNode memoryMap = snippet.unique(new MemoryMapNode(mmap.getMap()));
-            this.returnNode.setMemoryMap(memoryMap);
-            for (MemoryMapNode mm : memMaps) {
-                if (mm != memoryMap && mm.isAlive()) {
-                    assert mm.hasNoUsages();
-                    GraphUtil.killWithUnusedFloatingInputs(mm);
+            StartNode entryPointNode = snippet.start();
+            if (anchor.hasNoUsages()) {
+                anchor.safeDelete();
+                this.memoryAnchor = null;
+            } else {
+                snippetCopy.addAfterFixed(snippetCopy.start(), anchor);
+                this.memoryAnchor = anchor;
+            }
+            List<ReturnNode> returnNodes = snippet.getNodes(ReturnNode.TYPE).snapshot();
+            if (returnNodes.isEmpty()) {
+                this.returnNode = null;
+            } else if (returnNodes.size() == 1) {
+                this.returnNode = returnNodes.get(0);
+            } else {
+                AbstractMergeNode merge = snippet.add(new MergeNode());
+                List<MemoryMapNode> memMaps = returnNodes.stream().map(n -> n.getMemoryMap()).collect(Collectors.toList());
+                ValueNode returnValue = InliningUtil.mergeReturns(merge, returnNodes, null);
+                this.returnNode = snippet.add(new ReturnNode(returnValue));
+                MemoryMapImpl mmap = FloatingReadPhase.mergeMemoryMaps(merge, memMaps);
+                MemoryMapNode memoryMap = snippet.unique(new MemoryMapNode(mmap.getMap()));
+                this.returnNode.setMemoryMap(memoryMap);
+                for (MemoryMapNode mm : memMaps) {
+                    if (mm != memoryMap && mm.isAlive()) {
+                        assert mm.hasNoUsages();
+                        GraphUtil.killWithUnusedFloatingInputs(mm);
+                    }
+                }
+                merge.setNext(this.returnNode);
+            }
+
+            this.sideEffectNodes = curSideEffectNodes;
+            this.deoptNodes = curDeoptNodes;
+            this.stampNodes = curStampNodes;
+
+            nodes = new ArrayList<>(snippet.getNodeCount());
+            for (Node node : snippet.getNodes()) {
+                if (node != entryPointNode && node != entryPointNode.stateAfter()) {
+                    nodes.add(node);
                 }
             }
-            merge.setNext(this.returnNode);
-        }
-
-        this.sideEffectNodes = curSideEffectNodes;
-        this.deoptNodes = curDeoptNodes;
-        this.stampNodes = curStampNodes;
 
-        nodes = new ArrayList<>(snippet.getNodeCount());
-        for (Node node : snippet.getNodes()) {
-            if (node != entryPointNode && node != entryPointNode.stateAfter()) {
-                nodes.add(node);
+            Debug.metric("SnippetTemplateNodeCount[%#s]", args).add(nodes.size());
+            if (UseSnippetTemplateCache && args.cacheable) {
+                args.info.notifyNewTemplate();
             }
+            Debug.dump(snippet, "SnippetTemplate final state");
+
+        } catch (Throwable ex) {
+            throw Debug.handle(ex);
         }
-
-        Debug.metric("SnippetTemplateNodeCount[%#s]", args).add(nodes.size());
-        if (UseSnippetTemplateCache && args.cacheable) {
-            args.info.notifyNewTemplate();
-        }
-        Debug.dump(snippet, "SnippetTemplate final state");
     }
 
     protected Object[] getConstantArgs(Arguments args) {
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Wed Aug 26 15:22:34 2015 -0700
@@ -70,9 +70,6 @@
 public final class HotSpotTruffleRuntime extends GraalTruffleRuntime {
 
     public static TruffleRuntime makeInstance() {
-        if (GraalTruffleRuntime.alternateRuntime != null) {
-            return GraalTruffleRuntime.alternateRuntime;
-        }
         return new HotSpotTruffleRuntime();
     }
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Wed Aug 26 15:22:34 2015 -0700
@@ -44,8 +44,6 @@
 
 public abstract class GraalTruffleRuntime implements TruffleRuntime {
 
-    public static TruffleRuntime alternateRuntime;
-
     private ArrayList<String> includes;
     private ArrayList<String> excludes;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Aug 26 13:27:03 2015 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Wed Aug 26 15:22:34 2015 -0700
@@ -113,6 +113,10 @@
         return snippetReflection;
     }
 
+    public GraphBuilderConfiguration getConfigForParsing() {
+        return configForParsing;
+    }
+
     public ResolvedJavaMethod[] getCompilationRootMethods() {
         return new ResolvedJavaMethod[]{callRootMethod, callInlinedMethod};
     }