changeset 16325:e497100e1fbf

Merge
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Fri, 06 Jun 2014 01:19:20 +0200
parents cb196ea71d77 (current diff) 6b1bd708e254 (diff)
children 51f392557124
files graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/UnsafeAccess.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/FloatStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IllegalStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/IntegerStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/PrimitiveStamp.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampProvider.java graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/VoidStamp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.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/DefaultHotSpotLoweringProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MethodHandleNode.java graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConstant.java graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMField.java graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMFlag.java graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMType.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BinaryOpLogicNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/inlining/InliningUtil.java mx/mx_graal.py src/share/vm/graal/graalCompilerToVM.cpp src/share/vm/graal/graalVMToCompiler.cpp src/share/vm/graal/graalVMToCompiler.hpp test/whitelist_baseline.txt
diffstat 58 files changed, 1419 insertions(+), 1272 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java	Fri Jun 06 01:19:20 2014 +0200
@@ -436,4 +436,27 @@
                 throw new IllegalArgumentException("illegal call to bits on " + this);
         }
     }
+
+    public Constant getDefaultValue() {
+        switch (this) {
+            case Boolean:
+                return Constant.FALSE;
+            case Int:
+                return Constant.INT_0;
+            case Long:
+                return Constant.LONG_0;
+            case Float:
+                return Constant.FLOAT_0;
+            case Double:
+                return Constant.DOUBLE_0;
+            case Object:
+                return Constant.NULL_OBJECT;
+            case Byte:
+            case Char:
+            case Short:
+                return new PrimitiveConstant(this, 0);
+            default:
+                throw new IllegalArgumentException("illegal call to getDefaultValue on " + this);
+        }
+    }
 }
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java	Fri Jun 06 01:19:20 2014 +0200
@@ -28,4 +28,6 @@
 public interface PlatformKind {
 
     String name();
+
+    Constant getDefaultValue();
 }
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlock.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/cfg/AbstractBlock.java	Fri Jun 06 01:19:20 2014 +0200
@@ -59,4 +59,25 @@
     T getDominator();
 
     double probability();
+
+    /**
+     * True if block {@code a} dominates block {@code b}.
+     */
+    static boolean dominates(AbstractBlock<?> a, AbstractBlock<?> b) {
+        return isDominatedBy(b, a);
+    }
+
+    /**
+     * True if block {@code a} is dominated by block {@code b}.
+     */
+    static boolean isDominatedBy(AbstractBlock<?> a, AbstractBlock<?> b) {
+        if (a == b) {
+            return true;
+        }
+        if (a.getDominator() == null) {
+            return false;
+        }
+        return isDominatedBy(a.getDominator(), b);
+    }
+
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Fri Jun 06 01:19:20 2014 +0200
@@ -74,31 +74,33 @@
     void walk() {
         try (Scope s = Debug.scope("OptimizingLinearScanWalker")) {
             for (AbstractBlock<?> block : allocator.sortedBlocks) {
-                int nextBlock = allocator.getFirstLirInstructionId(block);
-                try (Scope s1 = Debug.scope("LSRAOptimization")) {
-                    Debug.log("next block: %s (%d)", block, nextBlock);
-                }
-                try (Indent indent0 = Debug.indent()) {
-                    walkTo(nextBlock);
-
+                if (block.getPredecessorCount() == 1) {
+                    int nextBlock = allocator.getFirstLirInstructionId(block);
                     try (Scope s1 = Debug.scope("LSRAOptimization")) {
-                        boolean changed = true;
-                        // we need to do this because the active lists might change
-                        loop: while (changed) {
-                            changed = false;
-                            try (Indent indent1 = Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
-                                for (Interval active = activeLists.get(RegisterBinding.Any); active != Interval.EndMarker; active = active.next) {
-                                    Debug.log("active   (any): %s", active);
-                                    if (optimize(nextBlock, block, active, RegisterBinding.Any)) {
-                                        changed = true;
-                                        break loop;
+                        Debug.log("next block: %s (%d)", block, nextBlock);
+                    }
+                    try (Indent indent0 = Debug.indent()) {
+                        walkTo(nextBlock);
+
+                        try (Scope s1 = Debug.scope("LSRAOptimization")) {
+                            boolean changed = true;
+                            // we need to do this because the active lists might change
+                            loop: while (changed) {
+                                changed = false;
+                                try (Indent indent1 = Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
+                                    for (Interval active = activeLists.get(RegisterBinding.Any); active != Interval.EndMarker; active = active.next) {
+                                        Debug.log("active   (any): %s", active);
+                                        if (optimize(nextBlock, block, active, RegisterBinding.Any)) {
+                                            changed = true;
+                                            break loop;
+                                        }
                                     }
-                                }
-                                for (Interval active = activeLists.get(RegisterBinding.Stack); active != Interval.EndMarker; active = active.next) {
-                                    Debug.log("active (stack): %s", active);
-                                    if (optimize(nextBlock, block, active, RegisterBinding.Stack)) {
-                                        changed = true;
-                                        break loop;
+                                    for (Interval active = activeLists.get(RegisterBinding.Stack); active != Interval.EndMarker; active = active.next) {
+                                        Debug.log("active (stack): %s", active);
+                                        if (optimize(nextBlock, block, active, RegisterBinding.Stack)) {
+                                            changed = true;
+                                            break loop;
+                                        }
                                     }
                                 }
                             }
@@ -115,10 +117,8 @@
         assert currentBlock != null : "block must not be null";
         assert currentInterval != null : "interval must not be null";
 
-        if (currentBlock.getPredecessorCount() != 1) {
-            // more than one predecessors -> optimization not possible
-            return false;
-        }
+        assert currentBlock.getPredecessorCount() == 1 : "more than one predecessors -> optimization not possible";
+
         if (!currentInterval.isSplitChild()) {
             // interval is not a split child -> no need for optimization
             return false;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java	Fri Jun 06 01:19:20 2014 +0200
@@ -455,7 +455,7 @@
 
     private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) {
         PlatformKind kind = gen.getPlatformKind(node.object().stamp());
-        gen.emitCompareBranch(kind, operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability);
+        gen.emitCompareBranch(kind, operand(node.object()), kind.getDefaultValue(), Condition.EQ, false, trueSuccessor, falseSuccessor, trueSuccessorProbability);
     }
 
     public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessor, LabelRef falseSuccessor, double trueSuccessorProbability) {
@@ -483,7 +483,7 @@
         if (node instanceof IsNullNode) {
             IsNullNode isNullNode = (IsNullNode) node;
             PlatformKind kind = gen.getPlatformKind(isNullNode.object().stamp());
-            return gen.emitConditionalMove(kind, operand(isNullNode.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueValue, falseValue);
+            return gen.emitConditionalMove(kind, operand(isNullNode.object()), kind.getDefaultValue(), Condition.EQ, false, trueValue, falseValue);
         } else if (node instanceof CompareNode) {
             CompareNode compare = (CompareNode) node;
             PlatformKind kind = gen.getPlatformKind(compare.x().stamp());
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeBitMap.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeBitMap.java	Fri Jun 06 01:19:20 2014 +0200
@@ -123,8 +123,9 @@
 
     public void grow() {
         nodeCount = Math.max(nodeCount, graph().nodeIdCount());
-        int newLength = Math.max((bits.length * 3 / 2) + 1, sizeForNodeCount(nodeCount));
+        int newLength = sizeForNodeCount(nodeCount);
         if (newLength > bits.length) {
+            newLength = Math.max(newLength, (bits.length * 3 / 2) + 1);
             bits = Arrays.copyOf(bits, newLength);
         }
     }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java	Fri Jun 06 01:19:20 2014 +0200
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.hotspot.amd64;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
 
 import java.util.*;
 
@@ -32,7 +32,6 @@
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.phases.util.*;
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java	Fri Jun 06 01:19:20 2014 +0200
@@ -22,13 +22,12 @@
  */
 package com.oracle.graal.hotspot.ptx;
 
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.java.*;
 import com.oracle.graal.nodes.spi.*;
--- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java	Fri Jun 06 01:19:20 2014 +0200
@@ -153,7 +153,7 @@
                 out.println("    case " + len + ":");
                 out.printf("      if (strncmp(name, \"PrintFlags\", %d) == 0) {%n", len);
                 out.println("        if (value[0] == '+') {");
-                out.println("          VMToCompiler::setOption(hotSpotOptionsClass, name_handle, Handle(), '?', Handle(), 0L);");
+                out.println("          set_option_helper(hotSpotOptionsClass, name_handle, Handle(), '?', Handle(), 0L);");
                 out.println("        }");
                 out.println("        return true;");
                 out.println("      }");
@@ -170,14 +170,14 @@
                     out.printf("        Handle option = get_OptionValue(\"L%s;\", \"%s\", \"L%s;\", CHECK_(true));%n", toInternalName(declaringClass), desc.getFieldName(),
                                     toInternalName(getFieldType(desc)));
                     if (isBoolean) {
-                        out.println("        VMToCompiler::setOption(hotSpotOptionsClass, name_handle, option, value[0], Handle(), 0L);");
+                        out.println("        set_option_helper(hotSpotOptionsClass, name_handle, option, value[0], Handle(), 0L);");
                     } else if (desc.getType() == String.class) {
                         out.println("        Handle stringValue = java_lang_String::create_from_str(value, CHECK_(true));");
-                        out.println("        VMToCompiler::setOption(hotSpotOptionsClass, name_handle, option, 's', stringValue, 0L);");
+                        out.println("        set_option_helper(hotSpotOptionsClass, name_handle, option, 's', stringValue, 0L);");
                     } else {
                         char spec = getPrimitiveSpecChar(desc);
                         out.println("        jlong primitiveValue = parse_primitive_option_value('" + spec + "', name_handle, value, CHECK_(true));");
-                        out.println("        VMToCompiler::setOption(hotSpotOptionsClass, name_handle, option, '" + spec + "', Handle(), primitiveValue);");
+                        out.println("        set_option_helper(hotSpotOptionsClass, name_handle, option, '" + spec + "', Handle(), primitiveValue);");
                     }
                     out.println("        return true;");
                     out.println("      }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationQueue.java	Fri Jun 06 01:19:20 2014 +0200
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2014, 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.hotspot;
+
+import static com.oracle.graal.compiler.GraalDebugConfig.*;
+import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.hotspot.CompilationQueue.Options.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
+
+import java.lang.reflect.*;
+import java.util.concurrent.*;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.CompilationTask.Enqueueing;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.options.*;
+import com.oracle.graal.printer.*;
+
+/**
+ * A queue for running {@link CompilationTask}s on background compilation thread(s). The singleton
+ * {@linkplain #queue() instance} is created the first time this class is accessed.
+ * <p>
+ * Note that this is independent of the HotSpot C++ {@code CompileQueue} used by the
+ * {@code CompileBroker}.
+ */
+public class CompilationQueue {
+
+    static {
+        try (InitTimer t = timer("initialize CompilationQueue")) {
+
+            // Must be first to ensure any options accessed by the rest of the class
+            // initializer are initialized from the command line.
+            HotSpotOptions.initialize();
+
+            // The singleton queue instance is created the first time this class
+            queue = new CompilationQueue();
+        }
+    }
+
+    public static class Options {
+
+        //@formatter:off
+        @Option(help = "Print compilation queue activity periodically")
+        private static final OptionValue<Boolean> PrintQueue = new OptionValue<>(false);
+
+        @Option(help = "Interval in milliseconds at which to print compilation rate periodically. " +
+                       "The compilation statistics are reset after each print out so this option " +
+                       "is incompatible with -XX:+CITime and -XX:+CITimeEach.")
+        public static final OptionValue<Integer> PrintCompRate = new OptionValue<>(0);
+
+        @Option(help = "Print bootstrap progress and summary")
+        static final OptionValue<Boolean> PrintBootstrap = new OptionValue<>(true);
+
+        @Option(help = "Time limit in milliseconds for bootstrap (-1 for no limit)")
+        static final OptionValue<Integer> TimedBootstrap = new OptionValue<>(-1);
+
+        @Option(help = "Number of compilation threads to use")
+        static final StableOptionValue<Integer> Threads = new StableOptionValue<Integer>() {
+
+            @Override
+            public Integer initialValue() {
+                return Runtime.getRuntime().availableProcessors();
+            }
+        };
+        //@formatter:on
+
+    }
+
+    /**
+     * Prints and resets the Graal compilation rate statistics.
+     */
+    private static native void printAndResetCompRate();
+
+    /**
+     * The singleton queue instance.
+     */
+    private static final CompilationQueue queue;
+
+    /**
+     * Gets the singleton queue instance.
+     */
+    public static final CompilationQueue queue() {
+        assert queue != null;
+        return queue;
+    }
+
+    /**
+     * The thread pool used to service the queue.
+     *
+     * Most access to the thread pool is wrapped to ensure that
+     * {@link CompilationTask#isWithinEnqueue} is in the proper state.
+     */
+    final ThreadPoolExecutor executor;
+
+    private CompilationQueue() {
+        CompilerThreadFactory factory = new CompilerThreadFactory("GraalCompilerThread", new DebugConfigAccess() {
+            public GraalDebugConfig getDebugConfig() {
+                return Debug.isEnabled() ? DebugEnvironment.initialize(HotSpotGraalRuntime.Options.LogFile.getStream()) : null;
+            }
+        });
+
+        executor = new ThreadPoolExecutor(Options.Threads.getValue(), Options.Threads.getValue(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>(), factory);
+
+        // Create queue status printing thread.
+        if (Options.PrintQueue.getValue()) {
+            Thread t = new Thread() {
+
+                @Override
+                public void run() {
+                    while (true) {
+                        TTY.println(CompilationQueue.this.toString());
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException e) {
+                        }
+                    }
+                }
+            };
+            t.setDaemon(true);
+            t.start();
+        }
+
+        if (Options.PrintCompRate.getValue() != 0) {
+            Thread t = new Thread() {
+
+                @Override
+                public void run() {
+                    while (true) {
+                        printAndResetCompRate();
+                        try {
+                            Thread.sleep(Options.PrintCompRate.getValue());
+                        } catch (InterruptedException e) {
+                        }
+                    }
+                }
+            };
+            t.setDaemon(true);
+            t.start();
+        }
+    }
+
+    public long getCompletedTaskCount() {
+        try (Enqueueing enqueueing = new Enqueueing()) {
+            // Don't allow new enqueues while reading the state of queue.
+            return executor.getCompletedTaskCount();
+        }
+    }
+
+    public long getTaskCount() {
+        try (Enqueueing enqueueing = new Enqueueing()) {
+            // Don't allow new enqueues while reading the state of queue.
+            return executor.getTaskCount();
+        }
+    }
+
+    public void execute(CompilationTask task) {
+        // The caller is expected to have set the within enqueue state.
+        assert CompilationTask.isWithinEnqueue();
+        executor.execute(task);
+    }
+
+    /**
+     * Shuts down the compilation queue.
+     *
+     * Called from VM.
+     */
+    private static void shutdown() throws Exception {
+        queue.executor.shutdownNow();
+        if (Debug.isEnabled() && (Dump.getValue() != null || areMetricsOrTimersEnabled())) {
+            // Wait up to 2 seconds to flush out all graph dumps and stop metrics/timers
+            // being updated.
+            queue.executor.awaitTermination(2, TimeUnit.SECONDS);
+        }
+    }
+
+    /**
+     * This method is the first method compiled during {@linkplain #bootstrap() bootstrapping}. Put
+     * any code in there that warms up compiler paths that are otherwise not exercised during
+     * bootstrapping and lead to later deoptimization when application code is compiled.
+     */
+    @Deprecated
+    private synchronized void compileWarmup() {
+        // Method is synchronized to exercise the synchronization code in the compiler.
+    }
+
+    /**
+     * Adds some compilation tasks to the queue and then loops until the queue has completed all its
+     * scheduled tasks or the timeout specified by {@link Options#TimedBootstrap} expires.
+     *
+     * Called from VM.
+     */
+    private static void bootstrap() throws Throwable {
+        if (PrintBootstrap.getValue()) {
+            TTY.print("Bootstrapping Graal");
+            TTY.flush();
+        }
+
+        long boostrapStartTime = System.currentTimeMillis();
+
+        boolean firstRun = true;
+        do {
+            // Initialize compile queue with a selected set of methods.
+            Class<Object> objectKlass = Object.class;
+            if (firstRun) {
+                enqueue(CompilationQueue.class.getDeclaredMethod("compileWarmup"));
+                enqueue(objectKlass.getDeclaredMethod("equals", Object.class));
+                enqueue(objectKlass.getDeclaredMethod("toString"));
+                firstRun = false;
+            } else {
+                for (int i = 0; i < 100; i++) {
+                    enqueue(CompilationQueue.class.getDeclaredMethod("bootstrap"));
+                }
+            }
+
+            // Compile until the queue is empty.
+            int z = 0;
+            while (true) {
+                if (queue().getCompletedTaskCount() >= Math.max(3, queue().getTaskCount())) {
+                    break;
+                }
+
+                Thread.sleep(100);
+                while (z < queue().getCompletedTaskCount() / 100) {
+                    ++z;
+                    if (PrintBootstrap.getValue()) {
+                        TTY.print(".");
+                        TTY.flush();
+                    }
+                }
+
+                // Are we out of time?
+                final int timedBootstrap = TimedBootstrap.getValue();
+                if (timedBootstrap != -1) {
+                    if ((System.currentTimeMillis() - boostrapStartTime) > timedBootstrap) {
+                        break;
+                    }
+                }
+            }
+        } while ((System.currentTimeMillis() - boostrapStartTime) <= TimedBootstrap.getValue());
+
+        if (ResetDebugValuesAfterBootstrap.getValue()) {
+            new DebugValuesPrinter().printDebugValues("bootstrap", true);
+            runtime().getCompilerToVM().resetCompilationStatistics();
+        }
+        phaseTransition("bootstrap");
+
+        if (PrintBootstrap.getValue()) {
+            TTY.println(" in %d ms (compiled %d methods)", System.currentTimeMillis() - boostrapStartTime, queue().getCompletedTaskCount());
+        }
+
+        System.gc();
+        phaseTransition("bootstrap2");
+    }
+
+    private static void enqueue(Method m) throws Throwable {
+        JavaMethod javaMethod = runtime().getHostProviders().getMetaAccess().lookupJavaMethod(m);
+        assert !((HotSpotResolvedJavaMethod) javaMethod).isAbstract() && !((HotSpotResolvedJavaMethod) javaMethod).isNative() : javaMethod;
+        CompilationTask.compileMethod((HotSpotResolvedJavaMethod) javaMethod, StructuredGraph.INVOCATION_ENTRY_BCI, 0L, false);
+    }
+
+    @Override
+    public String toString() {
+        return executor.toString();
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Fri Jun 06 01:19:20 2014 +0200
@@ -27,12 +27,15 @@
 import static com.oracle.graal.compiler.GraalCompiler.*;
 import static com.oracle.graal.compiler.common.GraalOptions.*;
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
-import static com.oracle.graal.hotspot.bridge.VMToCompilerImpl.*;
+import static com.oracle.graal.hotspot.CompilationQueue.*;
+import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
 import static com.oracle.graal.nodes.StructuredGraph.*;
 import static com.oracle.graal.phases.common.inlining.InliningUtil.*;
 
 import java.io.*;
 import java.lang.management.*;
+import java.security.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -47,6 +50,7 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.internal.*;
+import com.oracle.graal.hotspot.CompilationQueue.Options;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.events.*;
 import com.oracle.graal.hotspot.events.EventProvider.CompilationEvent;
@@ -60,10 +64,20 @@
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.tiers.*;
 
-import edu.umd.cs.findbugs.annotations.*;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+//JaCoCo Exclude
 
 public class CompilationTask implements Runnable, Comparable<Object> {
 
+    static {
+        try (InitTimer t = timer("initialize CompilationTask")) {
+            // Must be first to ensure any options accessed by the rest of the class
+            // initializer are initialized from the command line.
+            HotSpotOptions.initialize();
+        }
+    }
+
     // Keep static finals in a group with withinEnqueue as the last one. CompilationTask can be
     // called from within it's own clinit so it needs to be careful about accessing state. Once
     // withinEnqueue is non-null we assume that CompilationTask is fully initialized.
@@ -409,7 +423,7 @@
             if (ctask != 0L) {
                 unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, processedBytes);
             }
-            if ((config.ciTime || config.ciTimeEach || PrintCompRate.getValue() != 0) && installedCode != null) {
+            if ((config.ciTime || config.ciTimeEach || Options.PrintCompRate.getValue() != 0) && installedCode != null) {
                 long time = CompilationTime.getCurrentValue() - previousCompilationTime;
                 TimeUnit timeUnit = CompilationTime.getTimeUnit();
                 long timeUnitsPerSecond = timeUnit.convert(1, TimeUnit.SECONDS);
@@ -474,4 +488,69 @@
     public String toString() {
         return "Compilation[id=" + id + ", " + MetaUtil.format("%H.%n(%p)", method) + (entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI ? "" : "@" + entryBCI) + "]";
     }
+
+    /**
+     * Entry point for the VM to schedule a compilation for a metaspace Method.
+     *
+     * Called from the VM.
+     */
+    @SuppressWarnings("unused")
+    private static void compileMetaspaceMethod(long metaspaceMethod, final int entryBCI, long ctask, final boolean blocking) {
+        final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
+        if (ctask != 0L) {
+            // This is on a VM CompilerThread - no user frames exist
+            compileMethod(method, entryBCI, ctask, false);
+        } else {
+            // We have to use a privileged action here because compilations are
+            // enqueued from user code which very likely contains unprivileged frames.
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
+                    compileMethod(method, entryBCI, 0L, blocking);
+                    return null;
+                }
+            });
+        }
+    }
+
+    /**
+     * Compiles a method to machine code.
+     */
+    static void compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, long ctask, final boolean blocking) {
+        if (ctask != 0L) {
+            HotSpotBackend backend = runtime().getHostBackend();
+            CompilationTask task = new CompilationTask(null, backend, method, entryBCI, ctask, false);
+            task.runCompilation();
+            return;
+        }
+
+        if (isWithinEnqueue()) {
+            // This is required to avoid deadlocking a compiler thread. The issue is that a
+            // java.util.concurrent.BlockingQueue is used to implement the compilation worker
+            // queues. If a compiler thread triggers a compilation, then it may be blocked trying
+            // to add something to its own queue.
+            return;
+        }
+
+        // Don't allow blocking compiles from CompilerThreads
+        boolean block = blocking && !(Thread.currentThread() instanceof CompilerThread);
+        try (Enqueueing enqueueing = new Enqueueing()) {
+            if (method.tryToQueueForCompilation()) {
+                assert method.isQueuedForCompilation();
+
+                try {
+                    CompilationQueue queue = queue();
+                    if (!queue.executor.isShutdown()) {
+                        HotSpotBackend backend = runtime().getHostBackend();
+                        CompilationTask task = new CompilationTask(queue.executor, backend, method, entryBCI, ctask, block);
+                        queue.execute(task);
+                        if (block) {
+                            task.block();
+                        }
+                    }
+                } catch (RejectedExecutionException e) {
+                    // The compile queue was already shut down.
+                }
+            }
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/DebugValuesPrinter.java	Fri Jun 06 01:19:20 2014 +0200
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2014, 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.hotspot;
+
+import static com.oracle.graal.compiler.GraalDebugConfig.*;
+
+import java.io.*;
+import java.util.*;
+
+import com.oracle.graal.compiler.common.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.internal.*;
+
+/**
+ * Facility for printing the {@linkplain KeyRegistry#getDebugValues() values} collected across all
+ * {@link DebugValueMap#getTopLevelMaps() threads}.
+ */
+public class DebugValuesPrinter {
+
+    public void printDebugValues(String phase, boolean reset) throws GraalInternalError {
+        if (Debug.isEnabled() && areMetricsOrTimersEnabled()) {
+            TTY.println();
+            if (phase != null) {
+                TTY.println("<DebugValues:" + phase + ">");
+            } else {
+                TTY.println("<DebugValues>");
+            }
+            List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
+            List<DebugValue> debugValues = KeyRegistry.getDebugValues();
+            if (debugValues.size() > 0) {
+                try {
+                    ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues);
+                    Collections.sort(sortedValues);
+
+                    String summary = DebugValueSummary.getValue();
+                    if (summary == null) {
+                        summary = "Complete";
+                    }
+                    switch (summary) {
+                        case "Name":
+                            printSummary(topLevelMaps, sortedValues);
+                            break;
+                        case "Partial": {
+                            DebugValueMap globalMap = new DebugValueMap("Global");
+                            for (DebugValueMap map : topLevelMaps) {
+                                flattenChildren(map, globalMap);
+                            }
+                            globalMap.normalize();
+                            printMap(new DebugValueScope(null, globalMap), sortedValues);
+                            break;
+                        }
+                        case "Complete": {
+                            DebugValueMap globalMap = new DebugValueMap("Global");
+                            for (DebugValueMap map : topLevelMaps) {
+                                globalMap.addChild(map);
+                            }
+                            globalMap.group();
+                            globalMap.normalize();
+                            printMap(new DebugValueScope(null, globalMap), sortedValues);
+                            break;
+                        }
+                        case "Thread":
+                            for (DebugValueMap map : topLevelMaps) {
+                                TTY.println("Showing the results for thread: " + map.getName());
+                                map.group();
+                                map.normalize();
+                                printMap(new DebugValueScope(null, map), sortedValues);
+                            }
+                            break;
+                        default:
+                            throw new GraalInternalError("Unknown summary type: %s", summary);
+                    }
+                    if (reset) {
+                        for (DebugValueMap topLevelMap : topLevelMaps) {
+                            topLevelMap.reset();
+                        }
+                    }
+                } catch (Throwable e) {
+                    // Don't want this to change the exit status of the VM
+                    PrintStream err = System.err;
+                    err.println("Error while printing debug values:");
+                    e.printStackTrace();
+                }
+            }
+            if (phase != null) {
+                TTY.println("</DebugValues:" + phase + ">");
+            } else {
+                TTY.println("</DebugValues>");
+            }
+        }
+    }
+
+    private void flattenChildren(DebugValueMap map, DebugValueMap globalMap) {
+        globalMap.addChild(map);
+        for (DebugValueMap child : map.getChildren()) {
+            flattenChildren(child, globalMap);
+        }
+        map.clearChildren();
+    }
+
+    private void printSummary(List<DebugValueMap> topLevelMaps, List<DebugValue> debugValues) {
+        DebugValueMap result = new DebugValueMap("Summary");
+        for (int i = debugValues.size() - 1; i >= 0; i--) {
+            DebugValue debugValue = debugValues.get(i);
+            int index = debugValue.getIndex();
+            long total = collectTotal(topLevelMaps, index);
+            result.setCurrentValue(index, total);
+        }
+        printMap(new DebugValueScope(null, result), debugValues);
+    }
+
+    private long collectTotal(List<DebugValueMap> maps, int index) {
+        long total = 0;
+        for (int i = 0; i < maps.size(); i++) {
+            DebugValueMap map = maps.get(i);
+            total += map.getCurrentValue(index);
+            total += collectTotal(map.getChildren(), index);
+        }
+        return total;
+    }
+
+    /**
+     * Tracks the scope when printing a {@link DebugValueMap}, allowing "empty" scopes to be
+     * omitted. An empty scope is one in which there are no (nested) non-zero debug values.
+     */
+    static class DebugValueScope {
+
+        final DebugValueScope parent;
+        final int level;
+        final DebugValueMap map;
+        private boolean printed;
+
+        public DebugValueScope(DebugValueScope parent, DebugValueMap map) {
+            this.parent = parent;
+            this.map = map;
+            this.level = parent == null ? 0 : parent.level + 1;
+        }
+
+        public void print() {
+            if (!printed) {
+                printed = true;
+                if (parent != null) {
+                    parent.print();
+                }
+                printIndent(level);
+                TTY.println("%s", map.getName());
+            }
+        }
+    }
+
+    private void printMap(DebugValueScope scope, List<DebugValue> debugValues) {
+
+        for (DebugValue value : debugValues) {
+            long l = scope.map.getCurrentValue(value.getIndex());
+            if (l != 0 || !SuppressZeroDebugValues.getValue()) {
+                scope.print();
+                printIndent(scope.level + 1);
+                TTY.println(value.getName() + "=" + value.toString(l));
+            }
+        }
+
+        for (DebugValueMap child : scope.map.getChildren()) {
+            printMap(new DebugValueScope(scope, child), debugValues);
+        }
+    }
+
+    private static void printIndent(int level) {
+        for (int i = 0; i < level; ++i) {
+            TTY.print("    ");
+        }
+        TTY.print("|-> ");
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Fri Jun 06 01:19:20 2014 +0200
@@ -22,10 +22,12 @@
  */
 package com.oracle.graal.hotspot;
 
+import static com.oracle.graal.compiler.GraalDebugConfig.*;
 import static com.oracle.graal.compiler.common.GraalOptions.*;
 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer.*;
+import static com.oracle.graal.hotspot.CompileTheWorld.Options.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
 import static sun.reflect.Reflection.*;
 
 import java.lang.reflect.*;
@@ -44,11 +46,16 @@
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.CompileTheWorld.Config;
 import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.debug.*;
 import com.oracle.graal.hotspot.events.*;
 import com.oracle.graal.hotspot.logging.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.java.*;
 import com.oracle.graal.options.*;
+import com.oracle.graal.printer.*;
+import com.oracle.graal.replacements.*;
 import com.oracle.graal.runtime.*;
 
 //JaCoCo Exclude
@@ -58,66 +65,14 @@
  */
 public final class HotSpotGraalRuntime implements GraalRuntime, RuntimeProvider, StackIntrospection {
 
-    /**
-     * A facility for timing a step in the initialization sequence for the runtime. This exists
-     * separate from {@link DebugTimer} as it must be independent from all other Graal code so as to
-     * not perturb the initialization sequence.
-     */
-    public static class InitTimer implements AutoCloseable {
-        final String name;
-        final long start;
-
-        private InitTimer(String name) {
-            this.name = name;
-            this.start = System.currentTimeMillis();
-            System.out.println("START: " + SPACES.substring(0, timerDepth * 2) + name);
-            assert Thread.currentThread() == initializingThread;
-            timerDepth++;
-        }
-
-        public void close() {
-            final long end = System.currentTimeMillis();
-            timerDepth--;
-            System.out.println(" DONE: " + SPACES.substring(0, timerDepth * 2) + name + " [" + (end - start) + " ms]");
-        }
-
-        public static InitTimer timer(String name) {
-            return ENABLED ? new InitTimer(name) : null;
-        }
-
-        public static InitTimer timer(String name, Object suffix) {
-            return ENABLED ? new InitTimer(name + suffix) : null;
-        }
-
-        /**
-         * Specified initialization timing is enabled. This must only be set via a system property
-         * as the timing facility is used to time initialization of {@link HotSpotOptions}.
-         */
-        private static final boolean ENABLED = Boolean.getBoolean("graal.runtime.TimeInit");
-        public static int timerDepth = 0;
-        public static final String SPACES = "                                            ";
-        public static final Thread initializingThread = Thread.currentThread();
-    }
-
     private static final HotSpotGraalRuntime instance;
 
-    /**
-     * Initializes the native part of the Graal runtime.
-     */
-    private static native void init(Class<?> compilerToVMClass);
-
     static {
-        try (InitTimer t = timer("initialize natives")) {
-            init(CompilerToVMImpl.class);
-        }
-
         try (InitTimer t = timer("initialize HotSpotOptions")) {
-            // The options must be processed before any code using them...
             HotSpotOptions.initialize();
         }
 
         try (InitTimer t = timer("HotSpotGraalRuntime.<init>")) {
-            // ... including code in the constructor
             instance = new HotSpotGraalRuntime();
         }
 
@@ -156,30 +111,70 @@
         // proxied methods. Some of these static initializers (e.g. in
         // HotSpotMethodData) rely on the static 'instance' field being set
         // to retrieve configuration details.
-        VMToCompiler toCompiler = this.vmToCompiler;
         CompilerToVM toVM = this.compilerToVm;
 
         if (CountingProxy.ENABLED) {
-            toCompiler = CountingProxy.getProxy(VMToCompiler.class, toCompiler);
             toVM = CountingProxy.getProxy(CompilerToVM.class, toVM);
         }
         if (Logger.ENABLED) {
-            toCompiler = LoggingProxy.getProxy(VMToCompiler.class, toCompiler);
             toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM);
         }
 
-        this.vmToCompiler = toCompiler;
         this.compilerToVm = toVM;
 
-        this.vmToCompiler.startRuntime();
+        TTY.initialize(Options.LogFile.getStream());
+
+        if (Log.getValue() == null && Meter.getValue() == null && Time.getValue() == null && Dump.getValue() == null) {
+            if (MethodFilter.getValue() != null) {
+                TTY.println("WARNING: Ignoring MethodFilter option since Log, Meter, Time and Dump options are all null");
+            }
+        }
+
+        if (Debug.isEnabled()) {
+            DebugEnvironment.initialize(LogFile.getStream());
+
+            String summary = DebugValueSummary.getValue();
+            if (summary != null) {
+                switch (summary) {
+                    case "Name":
+                    case "Partial":
+                    case "Complete":
+                    case "Thread":
+                        break;
+                    default:
+                        throw new GraalInternalError("Unsupported value for DebugSummaryValue: %s", summary);
+                }
+            }
+        }
+
+        final HotSpotProviders hostProviders = hostBackend.getProviders();
+        assert VerifyOptionsPhase.checkOptions(hostProviders.getMetaAccess());
+
+        // Complete initialization of backends
+        try (InitTimer st = timer(hostBackend.getTarget().arch.getName(), ".completeInitialization")) {
+            hostBackend.completeInitialization();
+        }
+        for (HotSpotBackend backend : backends.values()) {
+            if (backend != hostBackend) {
+                try (InitTimer st = timer(backend.getTarget().arch.getName(), ".completeInitialization")) {
+                    backend.completeInitialization();
+                }
+            }
+        }
+
+        BenchmarkCounters.initialize(toVM);
+
+        runtimeStartTime = System.nanoTime();
     }
 
-    // Options must not be directly declared in HotSpotGraalRuntime - see VerifyOptionsPhase
-    static class Options {
+    public static class Options {
 
         // @formatter:off
         @Option(help = "The runtime configuration to use")
         static final OptionValue<String> GraalRuntime = new OptionValue<>("");
+
+        @Option(help = "File to which logging is sent")
+        public static final PrintStreamOption LogFile = new PrintStreamOption();
         // @formatter:on
     }
 
@@ -265,7 +260,6 @@
     }
 
     protected/* final */CompilerToVM compilerToVm;
-    protected/* final */VMToCompiler vmToCompiler;
 
     protected final HotSpotVMConfig config;
     private final HotSpotBackend hostBackend;
@@ -291,10 +285,7 @@
 
     private HotSpotGraalRuntime() {
         CompilerToVM toVM = new CompilerToVMImpl();
-        VMToCompiler toCompiler = new VMToCompilerImpl(this);
-
         compilerToVm = toVM;
-        vmToCompiler = toCompiler;
         try (InitTimer t = timer("HotSpotVMConfig<init>")) {
             config = new HotSpotVMConfig(compilerToVm);
         }
@@ -401,10 +392,6 @@
         return compilerToVm;
     }
 
-    public VMToCompiler getVMToCompiler() {
-        return vmToCompiler;
-    }
-
     /**
      * Converts a name to a Java type.
      *
@@ -601,4 +588,45 @@
             return result;
         }
     }
+
+    private long runtimeStartTime;
+
+    /**
+     * Take action related to entering a new execution phase.
+     *
+     * @param phase the execution phase being entered
+     */
+    static void phaseTransition(String phase) {
+        CompilationStatistics.clear(phase);
+    }
+
+    /**
+     * Called from the VM.
+     */
+    @SuppressWarnings("unused")
+    private void compileTheWorld() throws Throwable {
+        int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue();
+        for (int i = 0; i < iterations; i++) {
+            getCompilerToVM().resetCompilationStatistics();
+            TTY.println("CompileTheWorld : iteration " + i);
+            CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(),
+                            CompileTheWorldStopAt.getValue(), CompileTheWorldVerbose.getValue());
+            ctw.compile();
+        }
+        System.exit(0);
+    }
+
+    /**
+     * Shuts down the runtime.
+     *
+     * Called from the VM.
+     */
+    @SuppressWarnings("unused")
+    private void shutdown() throws Exception {
+        new DebugValuesPrinter().printDebugValues(ResetDebugValuesAfterBootstrap.getValue() ? "application" : null, false);
+        phaseTransition("final");
+
+        SnippetCounter.printGroups(TTY.out().out());
+        BenchmarkCounters.shutdown(getCompilerToVM(), runtimeStartTime);
+    }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java	Fri Jun 06 01:19:20 2014 +0200
@@ -23,14 +23,13 @@
 package com.oracle.graal.hotspot;
 
 import static com.oracle.graal.compiler.common.GraalOptions.*;
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer.*;
+import static com.oracle.graal.hotspot.InitTimer.*;
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.debug.Debug.Scope;
-import com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.nodes.spi.*;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Fri Jun 06 01:19:20 2014 +0200
@@ -23,8 +23,8 @@
 package com.oracle.graal.hotspot;
 
 import static com.oracle.graal.compiler.GraalDebugConfig.*;
+import static com.oracle.graal.hotspot.CompilationQueue.Options.*;
 import static com.oracle.graal.hotspot.HotSpotOptionsLoader.*;
-import static com.oracle.graal.hotspot.bridge.VMToCompilerImpl.*;
 import static java.lang.Double.*;
 
 import java.lang.reflect.*;
@@ -37,8 +37,8 @@
 import com.oracle.graal.phases.common.inlining.*;
 
 /**
- * Called from {@code graalCompiler.cpp} to set Graal options from the HotSpot command line. Such
- * options are (currently) distinguished by a {@code "-G:"} prefix.
+ * Sets Graal options from the HotSpot command line. Such options are distinguished by a
+ * {@code "-G:"} prefix.
  */
 public class HotSpotOptions {
 
@@ -52,6 +52,9 @@
     static {
         boolean timeCompilations = parseVMOptions();
         if (timeCompilations || PrintCompRate.getValue() != 0) {
+            if (timeCompilations && PrintCompRate.getValue() != 0) {
+                throw new GraalInternalError("PrintCompRate is incompatible with CITime and CITimeEach");
+            }
             unconditionallyEnableTimerOrMetric(InliningUtil.class, "InlinedBytecodes");
             unconditionallyEnableTimerOrMetric(CompilationTask.class, "CompilationTime");
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Jun 06 01:19:20 2014 +0200
@@ -1180,6 +1180,9 @@
     @HotSpotVMField(name = "CardTableModRefBS::byte_map_base", type = "jbyte*", get = HotSpotVMField.Type.OFFSET) @Stable private int cardTableModRefBSByteMapBaseOffset;
     @HotSpotVMConstant(name = "CardTableModRefBS::card_shift") @Stable public int cardTableModRefBSCardShift;
 
+    @HotSpotVMValue(expression = "(jbyte)CardTableModRefBS::dirty_card_val()") @Stable public byte dirtyCardValue;
+    @HotSpotVMValue(expression = "(jbyte)G1SATBCardTableModRefBS::g1_young_card_val()") @Stable public byte g1YoungCardValue;
+
     public long cardtableStartAddress() {
         final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset);
         final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java	Fri Jun 06 01:19:20 2014 +0200
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014, 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.hotspot;
+
+import com.oracle.graal.debug.*;
+
+import edu.umd.cs.findbugs.annotations.*;
+
+/**
+ * A facility for timing a step in the runtime or compilation queue initialization sequence. This
+ * exists separate from {@link DebugTimer} as it must be independent from all other Graal code so as
+ * to not perturb the initialization sequence.
+ */
+public class InitTimer implements AutoCloseable {
+    final String name;
+    final long start;
+
+    private InitTimer(String name) {
+        this.name = name;
+        this.start = System.currentTimeMillis();
+        System.out.println("START: " + SPACES.substring(0, timerDepth * 2) + name);
+        assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread;
+        timerDepth++;
+    }
+
+    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field")
+    public void close() {
+        final long end = System.currentTimeMillis();
+        timerDepth--;
+        System.out.println(" DONE: " + SPACES.substring(0, timerDepth * 2) + name + " [" + (end - start) + " ms]");
+    }
+
+    public static InitTimer timer(String name) {
+        return ENABLED ? new InitTimer(name) : null;
+    }
+
+    public static InitTimer timer(String name, Object suffix) {
+        return ENABLED ? new InitTimer(name + suffix) : null;
+    }
+
+    /**
+     * Specifies if initialization timing is enabled. This can only be set via a system property as
+     * the timing facility is used to time initialization of {@link HotSpotOptions}.
+     */
+    private static final boolean ENABLED = Boolean.getBoolean("graal.runtime.TimeInit");
+
+    public static int timerDepth = 0;
+    public static final String SPACES = "                                            ";
+
+    /**
+     * Used to assert the invariant that all initialization happens on the same thread.
+     */
+    public static final Thread initializingThread;
+    static {
+        if (ENABLED) {
+            initializingThread = Thread.currentThread();
+            System.out.println("INITIALIZING THREAD: " + initializingThread);
+        } else {
+            initializingThread = null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/PrintStreamOption.java	Fri Jun 06 01:19:20 2014 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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.hotspot;
+
+import java.io.*;
+
+import com.oracle.graal.options.*;
+
+/**
+ * An option that encapsulates and configures a print stream.
+ */
+public class PrintStreamOption extends OptionValue<String> {
+
+    public PrintStreamOption() {
+        super(null);
+    }
+
+    /**
+     * The print stream to which output will be written.
+     *
+     * Declared {@code volatile} to enable safe use of double-checked locking in
+     * {@link #getStream()} and {@link #setValue(Object)}.
+     */
+    private volatile PrintStream ps;
+
+    /**
+     * Gets the print stream configured by this option.
+     */
+    public PrintStream getStream() {
+        if (ps == null) {
+            if (getValue() != null) {
+                synchronized (this) {
+                    if (ps == null) {
+                        try {
+                            final boolean enableAutoflush = true;
+                            ps = new PrintStream(new FileOutputStream(getValue()), enableAutoflush);
+                        } catch (FileNotFoundException e) {
+                            throw new RuntimeException("couldn't open file: " + getValue(), e);
+                        }
+                    }
+                }
+            } else {
+                ps = System.out;
+            }
+        }
+        return ps;
+    }
+
+    @Override
+    public void setValue(Object v) {
+        if (ps != null) {
+            synchronized (this) {
+                if (ps != null) {
+                    ps.close();
+                    ps = null;
+                }
+            }
+        }
+        super.setValue(v);
+    }
+}
\ No newline at end of file
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Jun 06 01:19:20 2014 +0200
@@ -241,8 +241,6 @@
      */
     void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, InstalledCode installedCode);
 
-    void printCompilationStatistics(boolean perCompiler, boolean aggregate);
-
     void resetCompilationStatistics();
 
     void initializeConfiguration(HotSpotVMConfig config);
@@ -334,7 +332,7 @@
 
     /**
      * Gets the value of a metaspace {@code Symbol} as a String.
-     * 
+     *
      * @param metaspaceSymbol
      */
     String getSymbol(long metaspaceSymbol);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java	Fri Jun 06 01:19:20 2014 +0200
@@ -23,6 +23,8 @@
 
 package com.oracle.graal.hotspot.bridge;
 
+import static com.oracle.graal.hotspot.InitTimer.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.meta.*;
@@ -32,6 +34,17 @@
  */
 public class CompilerToVMImpl implements CompilerToVM {
 
+    /**
+     * Initializes the native part of the Graal runtime.
+     */
+    private static native void init();
+
+    static {
+        try (InitTimer t = timer("CompilerToVMImpl.init")) {
+            init();
+        }
+    }
+
     private native int installCode0(HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
 
     @Override
@@ -157,8 +170,6 @@
     public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethod method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond,
                     InstalledCode installedCode);
 
-    public synchronized native void printCompilationStatistics(boolean perCompiler, boolean aggregate);
-
     public native void resetCompilationStatistics();
 
     public native long[] collectCounters();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompiler.java	Fri Jun 06 00:18:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011, 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.hotspot.bridge;
-
-import java.io.*;
-
-/**
- * Calls from HotSpot into Java.
- */
-public interface VMToCompiler {
-
-    void startRuntime();
-
-    void startCompiler(boolean bootstrapEnabled) throws Throwable;
-
-    void bootstrap() throws Throwable;
-
-    /**
-     * Compiles a method to machine code. This method is called from the VM
-     * (VMToCompiler::compileMethod).
-     *
-     * @param ctask the CompileTask pointer if this is a request from a HotSpot compiler thread
-     */
-    void compileMethod(long metaspaceMethod, int entryBCI, long ctask, boolean blocking);
-
-    void shutdownCompiler() throws Exception;
-
-    void shutdownRuntime() throws Throwable;
-
-    void compileTheWorld() throws Throwable;
-
-    PrintStream log();
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Jun 06 00:18:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,627 +0,0 @@
-/*
- * Copyright (c) 2011, 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.hotspot.bridge;
-
-import static com.oracle.graal.compiler.GraalDebugConfig.*;
-import static com.oracle.graal.hotspot.CompileTheWorld.Options.*;
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer.*;
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.security.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import com.oracle.graal.api.meta.*;
-import com.oracle.graal.compiler.*;
-import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess;
-import com.oracle.graal.compiler.common.*;
-import com.oracle.graal.debug.*;
-import com.oracle.graal.debug.internal.*;
-import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.CompilationTask.Enqueueing;
-import com.oracle.graal.hotspot.CompileTheWorld.Config;
-import com.oracle.graal.hotspot.HotSpotGraalRuntime.InitTimer;
-import com.oracle.graal.hotspot.debug.*;
-import com.oracle.graal.hotspot.meta.*;
-import com.oracle.graal.java.*;
-import com.oracle.graal.nodes.*;
-import com.oracle.graal.options.*;
-import com.oracle.graal.printer.*;
-import com.oracle.graal.replacements.*;
-
-/**
- * Exits from the HotSpot VM into Java code.
- */
-public class VMToCompilerImpl implements VMToCompiler {
-
-    //@formatter:off
-    @Option(help = "File to which compiler logging is sent")
-    private static final OptionValue<String> LogFile = new OptionValue<>(null);
-
-    @Option(help = "Print compilation queue activity periodically")
-    private static final OptionValue<Boolean> PrintQueue = new OptionValue<>(false);
-
-    @Option(help = "Interval in milliseconds at which to print compilation rate periodically. " +
-                   "The compilation statistics are reset after each print out so this option " +
-                   "is incompatible with -XX:+CITime and -XX:+CITimeEach.")
-    public static final OptionValue<Integer> PrintCompRate = new OptionValue<>(0);
-
-    @Option(help = "Print bootstrap progress and summary")
-    private static final OptionValue<Boolean> PrintBootstrap = new OptionValue<>(true);
-
-    @Option(help = "Time limit in milliseconds for bootstrap (-1 for no limit)")
-    private static final OptionValue<Integer> TimedBootstrap = new OptionValue<>(-1);
-
-    @Option(help = "Number of compilation threads to use")
-    private static final StableOptionValue<Integer> Threads = new StableOptionValue<Integer>() {
-
-        @Override
-        public Integer initialValue() {
-            return Runtime.getRuntime().availableProcessors();
-        }
-    };
-
-    //@formatter:on
-
-    private final HotSpotGraalRuntime runtime;
-
-    private Queue compileQueue;
-
-    /**
-     * Wrap access to the thread pool to ensure that {@link CompilationTask#isWithinEnqueue} state
-     * is in the proper state.
-     */
-    static class Queue {
-        private final ThreadPoolExecutor executor;
-
-        Queue(CompilerThreadFactory factory) {
-            executor = new ThreadPoolExecutor(Threads.getValue(), Threads.getValue(), 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>(), factory);
-        }
-
-        public long getCompletedTaskCount() {
-            try (Enqueueing enqueueing = new Enqueueing()) {
-                // Don't allow new enqueues while reading the state of queue.
-                return executor.getCompletedTaskCount();
-            }
-        }
-
-        public long getTaskCount() {
-            try (Enqueueing enqueueing = new Enqueueing()) {
-                // Don't allow new enqueues while reading the state of queue.
-                return executor.getTaskCount();
-            }
-        }
-
-        public void execute(CompilationTask task) {
-            // The caller is expected to have set the within enqueue state.
-            assert CompilationTask.isWithinEnqueue();
-            executor.execute(task);
-        }
-
-        /**
-         * @see ExecutorService#isShutdown()
-         */
-        public boolean isShutdown() {
-            return executor.isShutdown();
-        }
-
-        public void shutdown() throws InterruptedException {
-            assert CompilationTask.isWithinEnqueue();
-            executor.shutdownNow();
-            if (Debug.isEnabled() && (Dump.getValue() != null || areMetricsOrTimersEnabled())) {
-                // Wait up to 2 seconds to flush out all graph dumps and stop metrics/timers
-                // being updated.
-                executor.awaitTermination(2, TimeUnit.SECONDS);
-            }
-        }
-
-        @Override
-        public String toString() {
-            return executor.toString();
-        }
-    }
-
-    private volatile boolean bootstrapRunning;
-
-    private PrintStream log = System.out;
-
-    private long runtimeStartTime;
-
-    public VMToCompilerImpl(HotSpotGraalRuntime runtime) {
-        this.runtime = runtime;
-    }
-
-    public void startRuntime() {
-
-        if (LogFile.getValue() != null) {
-            try {
-                final boolean enableAutoflush = true;
-                log = new PrintStream(new FileOutputStream(LogFile.getValue()), enableAutoflush);
-            } catch (FileNotFoundException e) {
-                throw new RuntimeException("couldn't open log file: " + LogFile.getValue(), e);
-            }
-        }
-
-        TTY.initialize(log);
-
-        if (Log.getValue() == null && Meter.getValue() == null && Time.getValue() == null && Dump.getValue() == null) {
-            if (MethodFilter.getValue() != null) {
-                TTY.println("WARNING: Ignoring MethodFilter option since Log, Meter, Time and Dump options are all null");
-            }
-        }
-
-        if (Debug.isEnabled()) {
-            DebugEnvironment.initialize(log);
-
-            String summary = DebugValueSummary.getValue();
-            if (summary != null) {
-                switch (summary) {
-                    case "Name":
-                    case "Partial":
-                    case "Complete":
-                    case "Thread":
-                        break;
-                    default:
-                        throw new GraalInternalError("Unsupported value for DebugSummaryValue: %s", summary);
-                }
-            }
-        }
-
-        HotSpotBackend hostBackend = runtime.getHostBackend();
-        final HotSpotProviders hostProviders = hostBackend.getProviders();
-        assert VerifyOptionsPhase.checkOptions(hostProviders.getMetaAccess());
-
-        // Complete initialization of backends
-        try (InitTimer st = timer(hostBackend.getTarget().arch.getName(), ".completeInitialization")) {
-            hostBackend.completeInitialization();
-        }
-        for (HotSpotBackend backend : runtime.getBackends().values()) {
-            if (backend != hostBackend) {
-                try (InitTimer st = timer(backend.getTarget().arch.getName(), ".completeInitialization")) {
-                    backend.completeInitialization();
-                }
-            }
-        }
-
-        BenchmarkCounters.initialize(runtime.getCompilerToVM());
-
-        runtimeStartTime = System.nanoTime();
-    }
-
-    public void startCompiler(boolean bootstrapEnabled) throws Throwable {
-        try (InitTimer timer = timer("startCompiler")) {
-            startCompiler0(bootstrapEnabled);
-        }
-    }
-
-    private void startCompiler0(boolean bootstrapEnabled) throws Throwable {
-
-        bootstrapRunning = bootstrapEnabled;
-
-        if (runtime.getConfig().useGraalCompilationQueue) {
-
-            // Create compilation queue.
-            CompilerThreadFactory factory = new CompilerThreadFactory("GraalCompilerThread", new DebugConfigAccess() {
-                public GraalDebugConfig getDebugConfig() {
-                    return Debug.isEnabled() ? DebugEnvironment.initialize(log) : null;
-                }
-            });
-            compileQueue = new Queue(factory);
-
-            // Create queue status printing thread.
-            if (PrintQueue.getValue()) {
-                Thread t = new Thread() {
-
-                    @Override
-                    public void run() {
-                        while (true) {
-                            TTY.println(compileQueue.toString());
-                            try {
-                                Thread.sleep(1000);
-                            } catch (InterruptedException e) {
-                            }
-                        }
-                    }
-                };
-                t.setDaemon(true);
-                t.start();
-            }
-
-            if (PrintCompRate.getValue() != 0) {
-                if (runtime.getConfig().ciTime || runtime.getConfig().ciTimeEach) {
-                    throw new GraalInternalError("PrintCompRate is incompatible with CITime and CITimeEach");
-                }
-                Thread t = new Thread() {
-
-                    @Override
-                    public void run() {
-                        while (true) {
-                            runtime.getCompilerToVM().printCompilationStatistics(true, false);
-                            runtime.getCompilerToVM().resetCompilationStatistics();
-                            try {
-                                Thread.sleep(PrintCompRate.getValue());
-                            } catch (InterruptedException e) {
-                            }
-                        }
-                    }
-                };
-                t.setDaemon(true);
-                t.start();
-            }
-        }
-    }
-
-    /**
-     * Take action related to entering a new execution phase.
-     *
-     * @param phase the execution phase being entered
-     */
-    protected void phaseTransition(String phase) {
-        CompilationStatistics.clear(phase);
-    }
-
-    /**
-     * This method is the first method compiled during bootstrapping. Put any code in there that
-     * warms up compiler paths that are otherwise not exercised during bootstrapping and lead to
-     * later deoptimization when application code is compiled.
-     */
-    @SuppressWarnings("unused")
-    @Deprecated
-    private synchronized void compileWarmup() {
-        // Method is synchronized to exercise the synchronization code in the compiler.
-    }
-
-    public void bootstrap() throws Throwable {
-        if (PrintBootstrap.getValue()) {
-            TTY.print("Bootstrapping Graal");
-            TTY.flush();
-        }
-
-        long boostrapStartTime = System.currentTimeMillis();
-
-        boolean firstRun = true;
-        do {
-            // Initialize compile queue with a selected set of methods.
-            Class<Object> objectKlass = Object.class;
-            if (firstRun) {
-                enqueue(getClass().getDeclaredMethod("compileWarmup"));
-                enqueue(objectKlass.getDeclaredMethod("equals", Object.class));
-                enqueue(objectKlass.getDeclaredMethod("toString"));
-                firstRun = false;
-            } else {
-                for (int i = 0; i < 100; i++) {
-                    enqueue(getClass().getDeclaredMethod("bootstrap"));
-                }
-            }
-
-            // Compile until the queue is empty.
-            int z = 0;
-            while (true) {
-                if (compileQueue.getCompletedTaskCount() >= Math.max(3, compileQueue.getTaskCount())) {
-                    break;
-                }
-
-                Thread.sleep(100);
-                while (z < compileQueue.getCompletedTaskCount() / 100) {
-                    ++z;
-                    if (PrintBootstrap.getValue()) {
-                        TTY.print(".");
-                        TTY.flush();
-                    }
-                }
-
-                // Are we out of time?
-                final int timedBootstrap = TimedBootstrap.getValue();
-                if (timedBootstrap != -1) {
-                    if ((System.currentTimeMillis() - boostrapStartTime) > timedBootstrap) {
-                        break;
-                    }
-                }
-            }
-        } while ((System.currentTimeMillis() - boostrapStartTime) <= TimedBootstrap.getValue());
-
-        if (ResetDebugValuesAfterBootstrap.getValue()) {
-            printDebugValues("bootstrap", true);
-            runtime.getCompilerToVM().resetCompilationStatistics();
-        }
-        phaseTransition("bootstrap");
-
-        bootstrapRunning = false;
-
-        if (PrintBootstrap.getValue()) {
-            TTY.println(" in %d ms (compiled %d methods)", System.currentTimeMillis() - boostrapStartTime, compileQueue.getCompletedTaskCount());
-        }
-
-        System.gc();
-        phaseTransition("bootstrap2");
-    }
-
-    public void compileTheWorld() throws Throwable {
-        int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue();
-        for (int i = 0; i < iterations; i++) {
-            runtime.getCompilerToVM().resetCompilationStatistics();
-            TTY.println("CompileTheWorld : iteration " + i);
-            CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(),
-                            CompileTheWorldStopAt.getValue(), CompileTheWorldVerbose.getValue());
-            ctw.compile();
-        }
-        System.exit(0);
-    }
-
-    private void enqueue(Method m) throws Throwable {
-        JavaMethod javaMethod = runtime.getHostProviders().getMetaAccess().lookupJavaMethod(m);
-        assert !((HotSpotResolvedJavaMethod) javaMethod).isAbstract() && !((HotSpotResolvedJavaMethod) javaMethod).isNative() : javaMethod;
-        compileMethod((HotSpotResolvedJavaMethod) javaMethod, StructuredGraph.INVOCATION_ENTRY_BCI, 0L, false);
-    }
-
-    public void shutdownCompiler() throws Exception {
-        if (runtime.getConfig().useGraalCompilationQueue) {
-            try (Enqueueing enqueueing = new Enqueueing()) {
-                // We have to use a privileged action here because shutting down the compiler might
-                // be called from user code which very likely contains unprivileged frames.
-                AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
-                    public Void run() throws Exception {
-                        if (compileQueue != null) {
-                            compileQueue.shutdown();
-                        }
-                        return null;
-                    }
-                });
-            }
-        }
-    }
-
-    public void shutdownRuntime() throws Exception {
-        printDebugValues(ResetDebugValuesAfterBootstrap.getValue() ? "application" : null, false);
-        phaseTransition("final");
-
-        SnippetCounter.printGroups(TTY.out().out());
-        BenchmarkCounters.shutdown(runtime.getCompilerToVM(), runtimeStartTime);
-    }
-
-    private void printDebugValues(String phase, boolean reset) throws GraalInternalError {
-        if (Debug.isEnabled() && areMetricsOrTimersEnabled()) {
-            TTY.println();
-            if (phase != null) {
-                TTY.println("<DebugValues:" + phase + ">");
-            } else {
-                TTY.println("<DebugValues>");
-            }
-            List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
-            List<DebugValue> debugValues = KeyRegistry.getDebugValues();
-            if (debugValues.size() > 0) {
-                try {
-                    ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues);
-                    Collections.sort(sortedValues);
-
-                    String summary = DebugValueSummary.getValue();
-                    if (summary == null) {
-                        summary = "Complete";
-                    }
-                    switch (summary) {
-                        case "Name":
-                            printSummary(topLevelMaps, sortedValues);
-                            break;
-                        case "Partial": {
-                            DebugValueMap globalMap = new DebugValueMap("Global");
-                            for (DebugValueMap map : topLevelMaps) {
-                                flattenChildren(map, globalMap);
-                            }
-                            globalMap.normalize();
-                            printMap(new DebugValueScope(null, globalMap), sortedValues);
-                            break;
-                        }
-                        case "Complete": {
-                            DebugValueMap globalMap = new DebugValueMap("Global");
-                            for (DebugValueMap map : topLevelMaps) {
-                                globalMap.addChild(map);
-                            }
-                            globalMap.group();
-                            globalMap.normalize();
-                            printMap(new DebugValueScope(null, globalMap), sortedValues);
-                            break;
-                        }
-                        case "Thread":
-                            for (DebugValueMap map : topLevelMaps) {
-                                TTY.println("Showing the results for thread: " + map.getName());
-                                map.group();
-                                map.normalize();
-                                printMap(new DebugValueScope(null, map), sortedValues);
-                            }
-                            break;
-                        default:
-                            throw new GraalInternalError("Unknown summary type: %s", summary);
-                    }
-                    if (reset) {
-                        for (DebugValueMap topLevelMap : topLevelMaps) {
-                            topLevelMap.reset();
-                        }
-                    }
-                } catch (Throwable e) {
-                    // Don't want this to change the exit status of the VM
-                    PrintStream err = System.err;
-                    err.println("Error while printing debug values:");
-                    e.printStackTrace();
-                }
-            }
-            if (phase != null) {
-                TTY.println("</DebugValues:" + phase + ">");
-            } else {
-                TTY.println("</DebugValues>");
-            }
-        }
-    }
-
-    private void flattenChildren(DebugValueMap map, DebugValueMap globalMap) {
-        globalMap.addChild(map);
-        for (DebugValueMap child : map.getChildren()) {
-            flattenChildren(child, globalMap);
-        }
-        map.clearChildren();
-    }
-
-    private static void printSummary(List<DebugValueMap> topLevelMaps, List<DebugValue> debugValues) {
-        DebugValueMap result = new DebugValueMap("Summary");
-        for (int i = debugValues.size() - 1; i >= 0; i--) {
-            DebugValue debugValue = debugValues.get(i);
-            int index = debugValue.getIndex();
-            long total = collectTotal(topLevelMaps, index);
-            result.setCurrentValue(index, total);
-        }
-        printMap(new DebugValueScope(null, result), debugValues);
-    }
-
-    private static long collectTotal(List<DebugValueMap> maps, int index) {
-        long total = 0;
-        for (int i = 0; i < maps.size(); i++) {
-            DebugValueMap map = maps.get(i);
-            total += map.getCurrentValue(index);
-            total += collectTotal(map.getChildren(), index);
-        }
-        return total;
-    }
-
-    /**
-     * Tracks the scope when printing a {@link DebugValueMap}, allowing "empty" scopes to be
-     * omitted. An empty scope is one in which there are no (nested) non-zero debug values.
-     */
-    static class DebugValueScope {
-
-        final DebugValueScope parent;
-        final int level;
-        final DebugValueMap map;
-        private boolean printed;
-
-        public DebugValueScope(DebugValueScope parent, DebugValueMap map) {
-            this.parent = parent;
-            this.map = map;
-            this.level = parent == null ? 0 : parent.level + 1;
-        }
-
-        public void print() {
-            if (!printed) {
-                printed = true;
-                if (parent != null) {
-                    parent.print();
-                }
-                printIndent(level);
-                TTY.println("%s", map.getName());
-            }
-        }
-    }
-
-    private static void printMap(DebugValueScope scope, List<DebugValue> debugValues) {
-
-        for (DebugValue value : debugValues) {
-            long l = scope.map.getCurrentValue(value.getIndex());
-            if (l != 0 || !SuppressZeroDebugValues.getValue()) {
-                scope.print();
-                printIndent(scope.level + 1);
-                TTY.println(value.getName() + "=" + value.toString(l));
-            }
-        }
-
-        for (DebugValueMap child : scope.map.getChildren()) {
-            printMap(new DebugValueScope(scope, child), debugValues);
-        }
-    }
-
-    private static void printIndent(int level) {
-        for (int i = 0; i < level; ++i) {
-            TTY.print("    ");
-        }
-        TTY.print("|-> ");
-    }
-
-    @Override
-    public void compileMethod(long metaspaceMethod, final int entryBCI, long ctask, final boolean blocking) {
-        final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
-        if (ctask != 0L) {
-            // This is on a VM CompilerThread - no user frames exist
-            compileMethod(method, entryBCI, ctask, false);
-        } else {
-            // We have to use a privileged action here because compilations are
-            // enqueued from user code which very likely contains unprivileged frames.
-            AccessController.doPrivileged(new PrivilegedAction<Void>() {
-                public Void run() {
-                    compileMethod(method, entryBCI, 0L, blocking);
-                    return null;
-                }
-            });
-        }
-    }
-
-    /**
-     * Compiles a method to machine code.
-     */
-    void compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, long ctask, final boolean blocking) {
-        if (ctask != 0L) {
-            HotSpotBackend backend = runtime.getHostBackend();
-            CompilationTask task = new CompilationTask(null, backend, method, entryBCI, ctask, false);
-            task.runCompilation();
-            return;
-        }
-
-        boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI;
-        if (osrCompilation && bootstrapRunning) {
-            // no OSR compilations during bootstrap - the compiler is just too slow at this point,
-            // and we know that there are no endless loops
-            return;
-        }
-
-        if (CompilationTask.isWithinEnqueue()) {
-            // This is required to avoid deadlocking a compiler thread. The issue is that a
-            // java.util.concurrent.BlockingQueue is used to implement the compilation worker
-            // queues. If a compiler thread triggers a compilation, then it may be blocked trying
-            // to add something to its own queue.
-            return;
-        }
-
-        // Don't allow blocking compiles from CompilerThreads
-        boolean block = blocking && !(Thread.currentThread() instanceof CompilerThread);
-        try (Enqueueing enqueueing = new Enqueueing()) {
-            if (method.tryToQueueForCompilation()) {
-                assert method.isQueuedForCompilation();
-
-                try {
-                    if (!compileQueue.executor.isShutdown()) {
-                        HotSpotBackend backend = runtime.getHostBackend();
-                        CompilationTask task = new CompilationTask(compileQueue.executor, backend, method, entryBCI, ctask, block);
-                        compileQueue.execute(task);
-                        if (block) {
-                            task.block();
-                        }
-                    }
-                } catch (RejectedExecutionException e) {
-                    // The compile queue was already shut down.
-                }
-            }
-        }
-    }
-
-    @Override
-    public PrintStream log() {
-        return log;
-    }
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java	Fri Jun 06 01:19:20 2014 +0200
@@ -27,9 +27,10 @@
 import java.util.*;
 
 import com.oracle.graal.debug.*;
+import com.oracle.graal.hotspot.bridge.*;
 
 /**
- * Scoped logging class used to display the call hierarchy of VMToCompiler/CompilerToVM calls.
+ * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls.
  */
 public class Logger {
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java	Fri Jun 06 01:19:20 2014 +0200
@@ -167,7 +167,7 @@
     public void generate(NodeLIRBuilderTool gen) {
         HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen.getLIRGeneratorTool();
         boolean nonNull;
-        if (getInput().stamp() instanceof ObjectStamp) {
+        if (getInput().stamp() instanceof AbstractObjectStamp) {
             nonNull = StampTool.isObjectNonNull(getInput().stamp());
         } else {
             // metaspace pointers are never null
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java	Fri Jun 06 01:19:20 2014 +0200
@@ -26,6 +26,7 @@
 import com.oracle.graal.compiler.common.spi.*;
 import com.oracle.graal.compiler.common.type.*;
 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
+import com.oracle.graal.hotspot.meta.*;
 
 public class NarrowOopStamp extends AbstractObjectStamp {
 
@@ -39,6 +40,10 @@
         public String toString() {
             return name();
         }
+
+        public Constant getDefaultValue() {
+            return HotSpotCompressedNullConstant.COMPRESSED_NULL;
+        }
     };
 
     private final CompressEncoding encoding;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java	Fri Jun 06 01:19:20 2014 +0200
@@ -207,7 +207,7 @@
 
     /**
      * Reads the pending deoptimization value for the given thread.
-     * 
+     *
      * @return {@code true} if there was a pending deoptimization
      */
     public static int readPendingDeoptimization(Word thread) {
@@ -416,6 +416,16 @@
     }
 
     @Fold
+    public static byte dirtyCardValue() {
+        return config().dirtyCardValue;
+    }
+
+    @Fold
+    public static byte g1YoungCardValue() {
+        return config().g1YoungCardValue;
+    }
+
+    @Fold
     public static int cardTableShift() {
         return config().cardtableShift();
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java	Fri Jun 06 01:19:20 2014 +0200
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.hotspot.replacements;
 
+import static com.oracle.graal.api.code.MemoryBarriers.*;
 import static com.oracle.graal.compiler.common.GraalOptions.*;
 import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*;
 import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*;
@@ -213,22 +214,26 @@
                 g1EffectiveAfterNullPostWriteBarrierCounter.inc();
 
                 // If the card is already dirty, (hence already enqueued) skip the insertion.
-                if (probability(NOT_FREQUENT_PROBABILITY, cardByte != (byte) 0)) {
-                    log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), Word.unsigned(cardByte).rawValue());
-                    cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION);
-                    g1ExecutedPostWriteBarrierCounter.inc();
+                if (probability(NOT_FREQUENT_PROBABILITY, cardByte != g1YoungCardValue())) {
+                    MembarNode.memoryBarrier(STORE_LOAD);
+                    byte cardByteReload = cardAddress.readByte(0);
+                    if (probability(NOT_FREQUENT_PROBABILITY, cardByteReload != dirtyCardValue())) {
+                        log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), Word.unsigned(cardByte).rawValue());
+                        cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION);
+                        g1ExecutedPostWriteBarrierCounter.inc();
 
-                    // If the thread local card queue is full, issue a native call which will
-                    // initialize a new one and add the card entry.
-                    if (probability(FREQUENT_PROBABILITY, indexValue.notEqual(0))) {
-                        Word nextIndex = indexValue.subtract(wordSize());
-                        Word logAddress = bufferAddress.add(nextIndex);
-                        // Log the object to be scanned as well as update
-                        // the card queue's next index.
-                        logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION);
-                        indexAddress.writeWord(0, nextIndex, GC_INDEX_LOCATION);
-                    } else {
-                        g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
+                        // If the thread local card queue is full, issue a native call which will
+                        // initialize a new one and add the card entry.
+                        if (probability(FREQUENT_PROBABILITY, indexValue.notEqual(0))) {
+                            Word nextIndex = indexValue.subtract(wordSize());
+                            Word logAddress = bufferAddress.add(nextIndex);
+                            // Log the object to be scanned as well as update
+                            // the card queue's next index.
+                            logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION);
+                            indexAddress.writeWord(0, nextIndex, GC_INDEX_LOCATION);
+                        } else {
+                            g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
+                        }
                     }
                 }
             }
@@ -293,19 +298,23 @@
             Word cardAddress = Word.unsigned((start + cardStart) + count);
             byte cardByte = cardAddress.readByte(0);
             // If the card is already dirty, (hence already enqueued) skip the insertion.
-            if (cardByte != (byte) 0) {
-                cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION);
-                // If the thread local card queue is full, issue a native call which will
-                // initialize a new one and add the card entry.
-                if (indexValue != 0) {
-                    indexValue = indexValue - wordSize();
-                    Word logAddress = bufferAddress.add(Word.unsigned(indexValue));
-                    // Log the object to be scanned as well as update
-                    // the card queue's next index.
-                    logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION);
-                    indexAddress.writeWord(0, Word.unsigned(indexValue), GC_INDEX_LOCATION);
-                } else {
-                    g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
+            if (probability(NOT_FREQUENT_PROBABILITY, cardByte != g1YoungCardValue())) {
+                MembarNode.memoryBarrier(STORE_LOAD);
+                byte cardByteReload = cardAddress.readByte(0);
+                if (probability(NOT_FREQUENT_PROBABILITY, cardByteReload != dirtyCardValue())) {
+                    cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION);
+                    // If the thread local card queue is full, issue a native call which will
+                    // initialize a new one and add the card entry.
+                    if (indexValue != 0) {
+                        indexValue = indexValue - wordSize();
+                        Word logAddress = bufferAddress.add(Word.unsigned(indexValue));
+                        // Log the object to be scanned as well as update
+                        // the card queue's next index.
+                        logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION);
+                        indexAddress.writeWord(0, Word.unsigned(indexValue), GC_INDEX_LOCATION);
+                    } else {
+                        g1PostBarrierStub(G1WBPOSTCALL, cardAddress);
+                    }
                 }
             }
         }
--- a/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java	Fri Jun 06 01:19:20 2014 +0200
@@ -127,6 +127,8 @@
         "}",
         "",
         "#define set_boolean(name, value) vmconfig_oop->bool_field_put(fs.offset(), value)",
+        "#define set_byte(name, value) vmconfig_oop->byte_field_put(fs.offset(), (jbyte)value)",
+        "#define set_short(name, value) vmconfig_oop->short_field_put(fs.offset(), (jshort)value)",
         "#define set_int(name, value) vmconfig_oop->int_field_put(fs.offset(), (int)value)",
         "#define set_long(name, value) vmconfig_oop->long_field_put(fs.offset(), value)",
         "#define set_address(name, value) do { set_long(name, (jlong) value); } while (0)",
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ArrayEqualsOp.java	Fri Jun 06 01:19:20 2014 +0200
@@ -59,8 +59,8 @@
     @Temp({REG}) protected Value temp2;
     @Temp({REG}) protected Value temp3;
     @Temp({REG}) protected Value temp4;
-    @Temp({REG}) protected Value vectorTemp1;
-    @Temp({REG}) protected Value vectorTemp2;
+    @Temp({REG, ILLEGAL}) protected Value vectorTemp1;
+    @Temp({REG, ILLEGAL}) protected Value vectorTemp2;
 
     public AMD64ArrayEqualsOp(LIRGeneratorTool tool, Kind kind, Value result, Value array1, Value array2, Value length) {
         this.kind = kind;
@@ -84,6 +84,9 @@
         if (supportsSSE41(tool.target())) {
             this.vectorTemp1 = tool.newVariable(Kind.Double);
             this.vectorTemp2 = tool.newVariable(Kind.Double);
+        } else {
+            this.vectorTemp1 = Value.ILLEGAL;
+            this.vectorTemp2 = Value.ILLEGAL;
         }
     }
 
@@ -128,7 +131,7 @@
 
     /**
      * Returns if the underlying AMD64 architecture supports SSE 4.1 instructions.
-     * 
+     *
      * @param target target description of the underlying architecture
      * @return true if the underlying architecture supports SSE 4.1
      */
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/FloatEqualsNode.java	Fri Jun 06 01:19:20 2014 +0200
@@ -42,7 +42,7 @@
      */
     public FloatEqualsNode(ValueNode x, ValueNode y) {
         super(x, y);
-        assert x.stamp() instanceof FloatStamp && y.stamp() instanceof FloatStamp;
+        assert x.stamp() instanceof FloatStamp && y.stamp() instanceof FloatStamp : x.stamp() + " " + y.stamp();
         assert x.stamp().isCompatible(y.stamp());
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IsNullNode.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IsNullNode.java	Fri Jun 06 01:19:20 2014 +0200
@@ -53,7 +53,7 @@
     @Override
     public boolean verify() {
         assertTrue(object() != null, "is null input must not be null");
-        assertTrue(object().stamp() instanceof ObjectStamp || object().stamp() instanceof IllegalStamp, "is null input must be an object");
+        assertTrue(object().stamp() instanceof AbstractObjectStamp, "is null input must be an object");
         return super.verify();
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java	Fri Jun 06 01:19:20 2014 +0200
@@ -167,20 +167,6 @@
         return "B" + id;
     }
 
-    public boolean dominates(Block block) {
-        return block.isDominatedBy(this);
-    }
-
-    public boolean isDominatedBy(Block block) {
-        if (block == this) {
-            return true;
-        }
-        if (getDominator() == null) {
-            return false;
-        }
-        return getDominator().isDominatedBy(block);
-    }
-
     public double probability() {
         return probability;
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampTool.java	Fri Jun 06 01:19:20 2014 +0200
@@ -504,8 +504,8 @@
      *         always null
      */
     public static boolean isObjectAlwaysNull(Stamp stamp) {
-        if (stamp instanceof ObjectStamp && stamp.isLegal()) {
-            return ((ObjectStamp) stamp).alwaysNull();
+        if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
+            return ((AbstractObjectStamp) stamp).alwaysNull();
         }
         return false;
     }
@@ -530,8 +530,8 @@
      *         always null
      */
     public static boolean isObjectNonNull(Stamp stamp) {
-        if (stamp instanceof ObjectStamp && stamp.isLegal()) {
-            return ((ObjectStamp) stamp).nonNull();
+        if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
+            return ((AbstractObjectStamp) stamp).nonNull();
         }
         return false;
     }
@@ -555,8 +555,8 @@
      * @return the Java type this stamp has if it is a legal Object stamp, null otherwise
      */
     public static ResolvedJavaType typeOrNull(Stamp stamp) {
-        if (stamp instanceof ObjectStamp && stamp.isLegal()) {
-            return ((ObjectStamp) stamp).type();
+        if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
+            return ((AbstractObjectStamp) stamp).type();
         }
         return null;
     }
@@ -584,8 +584,8 @@
      * @return true if this node represents a legal object stamp whose Java type is known exactly
      */
     public static boolean isExactType(Stamp stamp) {
-        if (stamp instanceof ObjectStamp && stamp.isLegal()) {
-            return ((ObjectStamp) stamp).isExactType();
+        if (stamp instanceof AbstractObjectStamp && stamp.isLegal()) {
+            return ((AbstractObjectStamp) stamp).isExactType();
         }
         return false;
     }
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Fri Jun 06 01:19:20 2014 +0200
@@ -107,7 +107,15 @@
             optionName = fieldName;
         }
 
-        String optionType = declaredFieldType.getTypeArguments().get(0).toString();
+        DeclaredType declaredOptionValueType = declaredFieldType;
+        while (!types.isSameType(types.erasure(declaredOptionValueType), types.erasure(optionValueType))) {
+            List<? extends TypeMirror> directSupertypes = types.directSupertypes(declaredFieldType);
+            assert !directSupertypes.isEmpty();
+            declaredOptionValueType = (DeclaredType) directSupertypes.get(0);
+        }
+
+        assert !declaredOptionValueType.getTypeArguments().isEmpty();
+        String optionType = declaredOptionValueType.getTypeArguments().get(0).toString();
         if (optionType.startsWith("java.lang.")) {
             optionType = optionType.substring("java.lang.".length());
         }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Fri Jun 06 00:18:30 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java	Fri Jun 06 01:19:20 2014 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.api.meta.LocationIdentity.*;
 import static com.oracle.graal.compiler.common.GraalOptions.*;
 import static com.oracle.graal.nodes.cfg.ControlFlowGraph.*;
+import static com.oracle.graal.compiler.common.cfg.AbstractBlock.*;
 
 import java.util.*;
 
@@ -442,7 +443,7 @@
                     FloatingReadNode read = (FloatingReadNode) node;
                     block = optimalBlock(read, strategy);
                     Debug.log("schedule for %s: %s", read, block);
-                    assert earliestBlock.dominates(block) : String.format("%s (%s) cannot be scheduled before earliest schedule (%s). location: %s", read, block, earliestBlock,
+                    assert dominates(earliestBlock, block) : String.format("%s (%s) cannot be scheduled before earliest schedule (%s). location: %s", read, block, earliestBlock,
                                     read.getLocationIdentity());
                 } else {
                     block = latestBlock(node, strategy);
@@ -461,7 +462,7 @@
                         FloatingReadNode read = (FloatingReadNode) node;
                         MemoryNode lastLocationAccess = read.getLastLocationAccess();
                         Block upperBound = blockForMemoryNode(lastLocationAccess);
-                        assert upperBound.dominates(block) : String.format(
+                        assert dominates(upperBound, block) : String.format(
                                         "out of loop movement voilated memory semantics for %s (location %s). moved to %s but upper bound is %s (earliest: %s, latest: %s)", read,
                                         read.getLocationIdentity(), block, upperBound, earliestBlock, latest);
                     }
@@ -470,7 +471,7 @@
             default:
                 throw new GraalInternalError("unknown scheduling strategy");
         }
-        if (!earliestBlock.dominates(block)) {
+        if (!dominates(earliestBlock, block)) {
             throw new SchedulingError("%s: Graph cannot be scheduled : inconsistent for %s, %d usages, (%s needs to dominate %s)", node.graph(), node, node.usages().count(), earliestBlock, block);
         }
         cfg.getNodeToBlock().set(node, block);
@@ -512,10 +513,10 @@
 
         Block upperBoundBlock = blockForMemoryNode(n.getLastLocationAccess());
         Block earliestBlock = earliestBlock(n);
-        assert upperBoundBlock.dominates(earliestBlock) : "upper bound (" + upperBoundBlock + ") should dominate earliest (" + earliestBlock + ")";
+        assert dominates(upperBoundBlock, earliestBlock) : "upper bound (" + upperBoundBlock + ") should dominate earliest (" + earliestBlock + ")";
 
         Block latestBlock = latestBlock(n, strategy);
-        assert latestBlock != null && earliestBlock.dominates(latestBlock) : "earliest (" + earliestBlock + ") should dominate latest block (" + latestBlock + ")";
+        assert latestBlock != null && dominates(earliestBlock, latestBlock) : "earliest (" + earliestBlock + ") should dominate latest block (" + latestBlock + ")";
 
         Debug.log("processing %s (accessing %s): latest %s, earliest %s, upper bound %s (%s)", n, locid, latestBlock, earliestBlock, upperBoundBlock, n.getLastLocationAccess());
         if (earliestBlock == latestBlock) {
@@ -577,7 +578,7 @@
     private static Deque<Block> computePathInDominatorTree(Block earliestBlock, Block latestBlock) {
         Deque<Block> path = new LinkedList<>();
         Block currentBlock = latestBlock;
-        while (currentBlock != null && earliestBlock.dominates(currentBlock)) {
+        while (currentBlock != null && dominates(earliestBlock, currentBlock)) {
             path.push(currentBlock);
             currentBlock = currentBlock.getDominator();
         }
@@ -632,7 +633,7 @@
         }
 
         if (assertionEnabled()) {
-            if (cdbc.block != null && !earliestBlock(node).dominates(cdbc.block)) {
+            if (cdbc.block != null && !dominates(earliestBlock(node), cdbc.block)) {
                 throw new SchedulingError("failed to find correct latest schedule for %s. cdbc: %s, earliest: %s", node, cdbc.block, earliestBlock(node));
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/script/TruffleScriptEngineFactory.java	Fri Jun 06 01:19:20 2014 +0200
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.truffle.api.script;
+
+import javax.script.*;
+
+/**
+ * Tool access to the creation of Truffle execution engines.
+ */
+public abstract class TruffleScriptEngineFactory implements ScriptEngineFactory {
+
+    // TODO (mlvdv) first step, based on a suggestion from NetBeans
+    /**
+     * To be called by each concrete factory just after each engine instance is created, presenting
+     * an opportunity for an IDE to interrupt in a language-independent way.
+     *
+     * @param engine a just-created engine
+     */
+    protected void engineCreated(ScriptEngine engine) {
+    }
+
+}
--- a/mx/mx_graal.py	Fri Jun 06 00:18:30 2014 +0200
+++ b/mx/mx_graal.py	Fri Jun 06 01:19:20 2014 +0200
@@ -737,26 +737,35 @@
                 return
         else:
             cpus = multiprocessing.cpu_count()
-            runCmd = [mx.gmake_cmd()]
-            runCmd.append(build + buildSuffix)
+            makeDir = join(_graal_home, 'make')
+            runCmd = [mx.gmake_cmd(), '-C', makeDir]
+
             env = os.environ.copy()
 
+            # These must be passed as environment variables
+            env.setdefault('LANG', 'C')
+            env['JAVA_HOME'] = jdk
+
+            def setMakeVar(name, default, env=None):
+                """Sets a make variable on the command line to the value
+                   of the variable in 'env' with the same name if defined
+                   and 'env' is not None otherwise to 'default'
+                """
+                runCmd.append(name + '=' + (env.get(name, default) if env else default))
+
             if opts2.D:
                 for nv in opts2.D:
                     name, value = nv.split('=', 1)
-                    env[name.strip()] = value
-
-            env.setdefault('ARCH_DATA_MODEL', '64')
-            env.setdefault('LANG', 'C')
-            env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus))
-            env.setdefault('ALT_BOOTDIR', mx.java().jdk)
+                    setMakeVar(name.strip(), value)
 
-            if not mx._opts.verbose:
-                runCmd.append('MAKE_VERBOSE=')
-            env['JAVA_HOME'] = jdk
+            setMakeVar('ARCH_DATA_MODEL', '64', env=env)
+            setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env)
+            setMakeVar('ALT_BOOTDIR', mx.java().jdk, env=env)
+
+            setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '')
             if vm.endswith('nograal'):
-                env['INCLUDE_GRAAL'] = 'false'
-                env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()))
+                setMakeVar('INCLUDE_GRAAL', 'false')
+                setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()), env=env)
             else:
                 # extract latest release tag for graal
                 try:
@@ -768,34 +777,39 @@
                 if tags:
                     # extract the most recent tag
                     tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0]
-                    env.setdefault('USER_RELEASE_SUFFIX', tag)
-                    env.setdefault('GRAAL_VERSION', tag[len("graal-"):])
+                    setMakeVar('USER_RELEASE_SUFFIX', tag)
+                    setMakeVar('GRAAL_VERSION', tag[len("graal-"):])
                 else:
                     version = 'unknown-{}-{}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
-                    env.setdefault('USER_RELEASE_SUFFIX', 'graal-' + version)
-                    env.setdefault('GRAAL_VERSION', version)
-                env['INCLUDE_GRAAL'] = 'true'
-            env.setdefault('INSTALL', 'y')
+                    setMakeVar('USER_RELEASE_SUFFIX', 'graal-' + version)
+                    setMakeVar('GRAAL_VERSION', version)
+                setMakeVar('INCLUDE_GRAAL', 'true')
+            setMakeVar('INSTALL', 'y', env=env)
             if mx.get_os() == 'solaris':
                 # If using sparcWorks, setup flags to avoid make complaining about CC version
                 cCompilerVersion = subprocess.Popen('CC -V', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stderr.readlines()[0]
                 if cCompilerVersion.startswith('CC: Sun C++'):
                     compilerRev = cCompilerVersion.split(' ')[3]
-                    env.setdefault('ENFORCE_COMPILER_REV', compilerRev)
-                    env.setdefault('ENFORCE_CC_COMPILER_REV', compilerRev)
+                    setMakeVar('ENFORCE_COMPILER_REV', compilerRev, env=env)
+                    setMakeVar('ENFORCE_CC_COMPILER_REV', compilerRev, env=env)
                     if build == 'jvmg':
-                        # I want ALL the symbols when I'm debugging on Solaris
-                        # Some Makefile variable are overloaded by environment variable so we need to explicitely
-                        # pass them down in the command line. This one is an example of that.
-                        runCmd.append('STRIP_POLICY=no_strip')
+                        # We want ALL the symbols when debugging on Solaris
+                        setMakeVar('STRIP_POLICY', 'no_strip')
             # This removes the need to unzip the *.diz files before debugging in gdb
-            env.setdefault('ZIP_DEBUGINFO_FILES', '0')
+            setMakeVar('ZIP_DEBUGINFO_FILES', '0', env=env)
 
             # Clear these 2 variables as having them set can cause very confusing build problems
             env.pop('LD_LIBRARY_PATH', None)
             env.pop('CLASSPATH', None)
 
-            mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env)
+            if mx._opts.verbose:
+                # Issue an env prefix that can be used to run the make on the command line
+                envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]])
+                if len(envPrefix):
+                    mx.log('env ' + envPrefix + ' \\')
+
+            runCmd.append(build + buildSuffix)
+            mx.run(runCmd, err=filterXusage, env=env)
 
         jvmCfg = _vmCfgInJdk(jdk)
         if not exists(jvmCfg):
@@ -1002,6 +1016,8 @@
             prefixArgs = ['-esa', '-ea']
         else:
             prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea']
+        if gc_after_test:
+            prefixArgs.append('-XX:-DisableExplicitGC')
         with open(testfile) as fp:
             testclasses = [l.rstrip() for l in fp.readlines()]
         if len(testclasses) == 1:
--- a/mxtool/mx.py	Fri Jun 06 00:18:30 2014 +0200
+++ b/mxtool/mx.py	Fri Jun 06 01:19:20 2014 +0200
@@ -2651,11 +2651,10 @@
             for line in f:
                 line = line.strip()
                 m = pattern.match(line)
-                if m is None:
+                p = project(m.group(1), fatalIfMissing=False) if m else None
+                if m is None or p is None:
                     out.write(line + '\n')
                 else:
-                    p = project(m.group(1))
-
                     for pkg in p.defined_java_packages():
                         if not pkg.startswith(p.name):
                             abort('package in {0} does not have prefix matching project name: {1}'.format(p, pkg))
--- a/src/gpu/hsail/vm/gpu_hsail.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/gpu/hsail/vm/gpu_hsail.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -39,7 +39,6 @@
 #include "hsailJavaCallArguments.hpp"
 #include "code/pcDesc.hpp"
 #include "code/scopeDesc.hpp"
-#include "graal/graalVMToCompiler.hpp"
 #include "gpu_hsail_Frame.hpp"
 
 // Entry to GPU native method implementation that transitions current thread to '_thread_in_vm'.
--- a/src/share/vm/classfile/systemDictionary.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/classfile/systemDictionary.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -209,6 +209,7 @@
   do_klass(HotSpotObjectConstant_klass,           com_oracle_graal_hotspot_meta_HotSpotObjectConstant,          Opt) \
   do_klass(HotSpotMetaspaceConstant_klass,        com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstant,       Opt) \
   do_klass(HotSpotStackFrameReference_klass,      com_oracle_graal_hotspot_HotSpotStackFrameReference,          Opt) \
+  do_klass(CompilationTask_klass,                 com_oracle_graal_hotspot_CompilationTask,                     Opt) \
   /* graal.api.code */                                                                                               \
   do_klass(Assumptions_klass,                     com_oracle_graal_api_code_Assumptions,                        Opt) \
   do_klass(Assumptions_ConcreteMethod_klass,      com_oracle_graal_api_code_Assumptions_ConcreteMethod,         Opt) \
--- a/src/share/vm/classfile/vmSymbols.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -303,7 +303,6 @@
   template(com_oracle_graal_hotspot_HotSpotCompiledRuntimeStub,      "com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub")           \
   template(com_oracle_graal_hotspot_HotSpotForeignCallLinkage,       "com/oracle/graal/hotspot/HotSpotForeignCallLinkage")            \
   template(com_oracle_graal_hotspot_HotSpotReferenceMap,             "com/oracle/graal/hotspot/HotSpotReferenceMap")                  \
-  template(com_oracle_graal_hotspot_bridge_VMToCompiler,             "com/oracle/graal/hotspot/bridge/VMToCompiler")                  \
   template(com_oracle_graal_hotspot_bridge_CompilerToVMImpl,         "com/oracle/graal/hotspot/bridge/CompilerToVMImpl")              \
   template(com_oracle_graal_hotspot_data_DataSection,                "com/oracle/graal/hotspot/data/DataSection")                     \
   template(com_oracle_graal_hotspot_data_DataSectionReference,       "com/oracle/graal/hotspot/data/DataSectionReference")            \
@@ -318,6 +317,7 @@
   template(com_oracle_graal_hotspot_meta_HotSpotObjectConstant,      "com/oracle/graal/hotspot/meta/HotSpotObjectConstant")           \
   template(com_oracle_graal_hotspot_meta_HotSpotMetaspaceConstant,   "com/oracle/graal/hotspot/meta/HotSpotMetaspaceConstant")        \
   template(com_oracle_graal_hotspot_HotSpotStackFrameReference,      "com/oracle/graal/hotspot/HotSpotStackFrameReference")           \
+  template(com_oracle_graal_hotspot_CompilationTask,                 "com/oracle/graal/hotspot/CompilationTask")                      \
   /* graal.api.meta */                                                                                                                \
   template(com_oracle_graal_api_meta_Constant,                       "com/oracle/graal/api/meta/Constant")                            \
   template(com_oracle_graal_api_meta_PrimitiveConstant,              "com/oracle/graal/api/meta/PrimitiveConstant")                   \
@@ -356,13 +356,9 @@
   /* graal.gpu */                                                                                                                     \
   template(com_oracle_graal_gpu_ExternalCompilationResult,           "com/oracle/graal/gpu/ExternalCompilationResult")                \
   /* graal method and field names */                                                                                                  \
-  template(compileMethod_name,                    "compileMethod")                                                                    \
-  template(compileMethod_signature,               "(JIJZ)V")                                                                          \
-  template(setOption_name,                        "setOption")                                                                        \
-  template(setOption_signature,                   "(Ljava/lang/String;)Z")                                                            \
-  template(getVMToCompiler_name,                  "getVMToCompiler")                                                                  \
-  template(getVMToCompiler_signature,             "()Lcom/oracle/graal/hotspot/bridge/VMToCompiler;")                                 \
-                                                                      \
+  template(compileMetaspaceMethod_name,               "compileMetaspaceMethod")                                                       \
+  template(compileMetaspaceMethod_signature,          "(JIJZ)V")                                                                      \
+                                                                                                  \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \
   template(class_initializer_name,                    "<clinit>")                                 \
--- a/src/share/vm/compiler/abstractCompiler.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/compiler/abstractCompiler.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -46,6 +46,9 @@
       _bytes += bytes;
       _count++;
     }
+    void reset() {
+      _time.reset();
+    }
   };
 
  public:
--- a/src/share/vm/compiler/compileBroker.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/compiler/compileBroker.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -1152,11 +1152,11 @@
     assert(TieredCompilation || comp_level == CompLevel_full_optimization, "incorrect compile level");
     assert(CompLevel_full_optimization == CompLevel_highest_tier, "incorrect level definition");
     if (comp_level == CompLevel_full_optimization) {
-      if (!JavaThread::current()->is_graal_compiling()) {
+      JavaThread* javaThread = JavaThread::current();
+      if (javaThread->can_schedule_graal_compilation()) {
         bool blockingCompilation = is_compile_blocking(method, osr_bci);
+        NoGraalCompilationScheduling ngcs(javaThread);
         GraalCompiler::instance()->compile_method(method, osr_bci, NULL, blockingCompilation);
-      } else {
-        // Can't enqueue this request because there would be no one to service it, so simply return.
       }
       return;
     }
@@ -2358,6 +2358,17 @@
   }
 }
 
+#ifdef GRAAL
+void CompileBroker::print_times(AbstractCompiler* comp) {
+  CompilerStatistics* stats = comp->stats();
+  tty->print_cr("  %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}",
+                comp->name(), stats->bytes_per_second(),
+                stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count,
+                stats->_osr._time.seconds(), stats->_osr._bytes, stats->_osr._count,
+                stats->_nmethods_size, stats->_nmethods_code_size);
+}
+#endif
+
 void CompileBroker::print_times(bool per_compiler, bool aggregate) {
 #ifdef GRAAL
   elapsedTimer standard_compilation;
@@ -2400,11 +2411,7 @@
       nmethods_code_size += stats->_nmethods_code_size;
 
       if (per_compiler) {
-        tty->print_cr("  %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}",
-                      comp->name(), stats->bytes_per_second(),
-                      stats->_standard._time.seconds(), stats->_standard._bytes, stats->_standard._count,
-                      stats->_osr._time.seconds(), stats->_osr._bytes, stats->_osr._count,
-                      stats->_nmethods_size, stats->_nmethods_code_size);
+        print_times(comp);
       }
     }
   }
--- a/src/share/vm/compiler/compileBroker.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/compiler/compileBroker.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -438,6 +438,11 @@
   // Redefine Classes support
   static void mark_on_stack();
 
+#ifdef GRAAL
+  // Print curent compilation time stats for a given compiler
+  static void print_times(AbstractCompiler* comp);
+#endif
+
   // Print a detailed accounting of compilation time
   static void print_times(bool per_compiler = true, bool aggregate = true);
 
--- a/src/share/vm/graal/graalCompiler.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -25,7 +25,6 @@
 #include "memory/oopFactory.hpp"
 #include "runtime/javaCalls.hpp"
 #include "graal/graalCompiler.hpp"
-#include "graal/graalVMToCompiler.hpp"
 #include "graal/graalEnv.hpp"
 #include "graal/graalRuntime.hpp"
 #include "runtime/compilationPolicy.hpp"
@@ -35,7 +34,7 @@
 
 GraalCompiler::GraalCompiler() : AbstractCompiler(graal) {
 #ifdef COMPILERGRAAL
-  _started = false;
+  _bootstrapping = false;
 #endif
   assert(_instance == NULL, "only one instance allowed");
   _instance = this;
@@ -63,15 +62,17 @@
   {
     HandleMark hm;
 
-    bool bootstrap = UseGraalCompilationQueue && (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal);
-    VMToCompiler::startCompiler(bootstrap);
-    _started = true;
+    _bootstrapping = UseGraalCompilationQueue && (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal);
+
+    if (UseGraalCompilationQueue) {
+      start_compilation_queue();
+    }
 
     // Graal is considered as application code so we need to
     // stop the VM deferring compilation now.
     CompilationPolicy::completed_vm_startup();
 
-    if (bootstrap) {
+    if (_bootstrapping) {
       // Avoid -Xcomp and -Xbatch problems by turning on interpreter and background compilation for bootstrapping.
       FlagSetting a(UseInterpreter, true);
       FlagSetting b(BackgroundCompilation, true);
@@ -81,12 +82,12 @@
       // allowing a complete bootstrap
       FlagSetting c(CompileTheWorld, false);
 #endif
-      VMToCompiler::bootstrap();
+      bootstrap();
     }
 
 #ifndef PRODUCT
     if (CompileTheWorld) {
-      VMToCompiler::compileTheWorld();
+      compile_the_world();
     }
 #endif
   }
@@ -94,18 +95,58 @@
 }
 
 #ifdef COMPILERGRAAL
+void GraalCompiler::start_compilation_queue() {
+  JavaThread* THREAD = JavaThread::current();
+  HandleMark hm(THREAD);
+  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD);
+  KlassHandle klass = GraalRuntime::load_required_class(name);
+  NoGraalCompilationScheduling ngcs(THREAD);
+  klass->initialize(THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling start_compilation_queue");
+}
+
+
+void GraalCompiler::shutdown_compilation_queue() {
+  JavaThread* THREAD = JavaThread::current();
+  HandleMark hm(THREAD);
+  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD);
+  KlassHandle klass = GraalRuntime::load_required_class(name);
+  JavaValue result(T_VOID);
+  JavaCallArguments args;
+  JavaCalls::call_static(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown_compilation_queue");
+}
+
+void GraalCompiler::bootstrap() {
+  JavaThread* THREAD = JavaThread::current();
+  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/CompilationQueue", THREAD);
+  KlassHandle klass = GraalRuntime::load_required_class(name);
+  JavaValue result(T_VOID);
+  TempNewSymbol bootstrap = SymbolTable::new_symbol("bootstrap", THREAD);
+  NoGraalCompilationScheduling ngcs(THREAD);
+  JavaCalls::call_static(&result, klass, bootstrap, vmSymbols::void_method_signature(), THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling bootstrap");
+}
+
 void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task, jboolean blocking) {
   GRAAL_EXCEPTION_CONTEXT
-  if (!_started) {
-    CompilationPolicy::policy()->delay_compilation(method());
-    return;
+
+  bool is_osr = entry_bci != InvocationEntryBci;
+  if (_bootstrapping && is_osr) {
+      // no OSR compilations during bootstrap - the compiler is just too slow at this point,
+      // and we know that there are no endless loops
+      return;
   }
 
-  assert(_started, "must already be started");
   ResourceMark rm;
-  thread->set_is_graal_compiling(true);
-  VMToCompiler::compileMethod(method(), entry_bci, (jlong) (address) task, blocking);
-  thread->set_is_graal_compiling(false);
+  JavaValue result(T_VOID);
+  JavaCallArguments args;
+  args.push_long((jlong) (address) method());
+  args.push_int(entry_bci);
+  args.push_long((jlong) (address) task);
+  args.push_int(blocking);
+  JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling compile_method");
 }
 
 
@@ -115,9 +156,8 @@
 }
 
 void GraalCompiler::shutdown() {
-  if (_started) {
-    VMToCompiler::shutdownCompiler();
-    _started = false;
+  if (UseGraalCompilationQueue) {
+    shutdown_compilation_queue();
   }
 }
 
@@ -127,3 +167,21 @@
 }
 
 #endif // COMPILERGRAAL
+
+#ifndef PRODUCT
+void GraalCompiler::compile_the_world() {
+  // We turn off CompileTheWorld so that Graal can
+  // be compiled by C1/C2 when Graal does a CTW.
+  CompileTheWorld = false;
+
+  JavaThread* THREAD = JavaThread::current();
+  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
+  KlassHandle klass = GraalRuntime::load_required_class(name);
+  TempNewSymbol compileTheWorld = SymbolTable::new_symbol("compileTheWorld", THREAD);
+  JavaValue result(T_VOID);
+  JavaCallArguments args;
+  args.push_oop(GraalRuntime::get_HotSpotGraalRuntime());
+  JavaCalls::call_special(&result, klass, compileTheWorld, vmSymbols::void_method_signature(), &args, THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling compile_the_world");
+}
+#endif
--- a/src/share/vm/graal/graalCompiler.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/graal/graalCompiler.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -31,8 +31,11 @@
 private:
 
 #ifdef COMPILERGRAAL
-  // Set to true once VMToCompiler.startCompiler() returns
-  bool _started;
+  bool _bootstrapping;
+
+  void start_compilation_queue();
+  void shutdown_compilation_queue();
+  void bootstrap();
 #endif
 
   static GraalCompiler* _instance;
@@ -66,8 +69,46 @@
   // Print compilation timers and statistics
   virtual void print_timers();
 
+  // Print compilation statistics
+  void reset_compilation_stats();
+
   void shutdown();
+#endif // COMPILERGRAAL
+
+#ifndef PRODUCT
+  void compile_the_world();
 #endif
 };
 
+#ifdef COMPILERGRAAL
+/**
+ * Creates a scope in which scheduling a Graal compilation is disabled.
+ * Scheduling a compilation can happen anywhere a counter can overflow and
+ * calling back into the Java code for scheduling a compilation (i.e.,
+ * CompilationTask.compileMetaspaceMethod()) from such arbitrary locations
+ * can cause objects to be in an unexpected state.
+ *
+ * In addition, it can be useful to disable compilation scheduling in
+ * other circumstances such as when initializing the Graal compilation
+ * queue or when running the Graal bootstrap process.
+ */
+class NoGraalCompilationScheduling: public StackObj {
+ private:
+  JavaThread* _thread;
+ public:
+
+  NoGraalCompilationScheduling(JavaThread *thread) {
+    assert(thread == JavaThread::current(), "not the current thread");
+    assert(thread->can_schedule_graal_compilation(), "recursive Graal compilation scheduling");
+    _thread = thread;
+    thread->set_can_schedule_graal_compilation(false);
+  }
+
+  ~NoGraalCompilationScheduling() {
+    assert(!_thread->can_schedule_graal_compilation(), "unexpected Graal compilation scheduling state");
+    _thread->set_can_schedule_graal_compilation(true);
+  }
+};
+#endif // COMPILERGRAAL
+
 #endif // SHARE_VM_GRAAL_GRAAL_COMPILER_HPP
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -37,7 +37,6 @@
 #include "graal/graalEnv.hpp"
 #include "graal/graalJavaAccess.hpp"
 #include "graal/graalCodeInstaller.hpp"
-#include "graal/graalVMToCompiler.hpp"
 #include "gc_implementation/g1/heapRegion.hpp"
 #include "runtime/javaCalls.hpp"
 #include "runtime/deoptimization.hpp"
@@ -515,18 +514,10 @@
   }
 C2V_END
 
-C2V_VMENTRY(void, printCompilationStatistics, (JNIEnv *jniEnv, jobject, jboolean per_compiler, jboolean aggregate))
-  CompileBroker::print_times(per_compiler == JNI_TRUE, aggregate == JNI_TRUE);
-C2V_END
-
 C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject))
   CompilerStatistics* stats = GraalCompiler::instance()->stats();
-  stats->_standard._time.reset();
-  stats->_standard._bytes = 0;
-  stats->_standard._count = 0;
-  stats->_osr._time.reset();
-  stats->_osr._bytes = 0;
-  stats->_osr._count = 0;
+  stats->_standard.reset();
+  stats->_osr.reset();
 C2V_END
 
 C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jlong codeBlob))
@@ -1058,7 +1049,6 @@
   {CC"initializeConfiguration",                      CC"("HS_CONFIG")V",                                                       FN_PTR(initializeConfiguration)},
   {CC"installCode0",                                 CC"("HS_COMPILED_CODE INSTALLED_CODE SPECULATION_LOG")I",                 FN_PTR(installCode0)},
   {CC"notifyCompilationStatistics",                  CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V",                         FN_PTR(notifyCompilationStatistics)},
-  {CC"printCompilationStatistics",                   CC"(ZZ)V",                                                                FN_PTR(printCompilationStatistics)},
   {CC"resetCompilationStatistics",                   CC"()V",                                                                  FN_PTR(resetCompilationStatistics)},
   {CC"disassembleCodeBlob",                          CC"(J)"STRING,                                                            FN_PTR(disassembleCodeBlob)},
   {CC"executeCompiledMethodVarargs",                 CC"(["OBJECT INSTALLED_CODE")"OBJECT,                                     FN_PTR(executeCompiledMethodVarargs)},
--- a/src/share/vm/graal/graalRuntime.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/graal/graalRuntime.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -23,9 +23,10 @@
 
 #include "precompiled.hpp"
 #include "asm/codeBuffer.hpp"
+#include "compiler/compileBroker.hpp"
 #include "graal/graalRuntime.hpp"
-#include "graal/graalVMToCompiler.hpp"
 #include "graal/graalCompilerToVM.hpp"
+#include "graal/graalCompiler.hpp"
 #include "graal/graalJavaAccess.hpp"
 #include "graal/graalEnv.hpp"
 #include "memory/oopFactory.hpp"
@@ -37,6 +38,7 @@
 #include "utilities/debug.hpp"
 
 address GraalRuntime::_external_deopt_i2c_entry = NULL;
+jobject GraalRuntime::_HotSpotGraalRuntime_instance = NULL;
 
 void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) {
   uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
@@ -60,7 +62,7 @@
 
     env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count());
   }
-  check_pending_exception("Could not register natives");
+  GUARANTEE_NO_PENDING_EXCEPTION("Could not register natives");
 }
 
 BufferBlob* GraalRuntime::initialize_buffer_blob() {
@@ -638,7 +640,7 @@
 
 // private static GraalRuntime Graal.initializeRuntime()
 JVM_ENTRY(jobject, JVM_GetGraalRuntime(JNIEnv *env, jclass c))
-  return VMToCompiler::get_HotSpotGraalRuntime_jobject();
+  return GraalRuntime::get_HotSpotGraalRuntime_jobject();
 JVM_END
 
 // private static String[] Graal.getServiceImpls(Class service)
@@ -650,11 +652,34 @@
 
 // private static TruffleRuntime Truffle.createRuntime()
 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c))
-  return JNIHandles::make_local(VMToCompiler::create_HotSpotTruffleRuntime()());
+  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD);
+  KlassHandle klass = GraalRuntime::load_required_class(name);
+
+  TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD);
+  TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD);
+  JavaValue result(T_OBJECT);
+  JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotTruffleRuntime");
+  return JNIHandles::make_local((oop) result.get_jobject());
 JVM_END
 
-// private static void HotSpotGraalRuntime.init(Class compilerToVMClass)
-JVM_ENTRY(void, JVM_InitializeGraalNatives(JNIEnv *env, jclass c, jclass c2vmClass))
+Handle GraalRuntime::get_HotSpotGraalRuntime() {
+  if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) {
+    Thread* THREAD = Thread::current();
+    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
+    KlassHandle klass = load_required_class(name);
+    TempNewSymbol runtime = SymbolTable::new_symbol("runtime", THREAD);
+    TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", THREAD);
+    JavaValue result(T_OBJECT);
+    JavaCalls::call_static(&result, klass, runtime, sig, THREAD);
+    GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotGraalRuntime");
+    _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject());
+  }
+  return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance));
+}
+
+// private static void CompilerToVMImpl.init()
+JVM_ENTRY(void, JVM_InitializeGraalNatives(JNIEnv *env, jclass c2vmClass))
   GraalRuntime::initialize_natives(env, c2vmClass);
 JVM_END
 
@@ -665,6 +690,17 @@
   return GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false);
 JVM_END
 
+#ifdef COMPILERGRAAL
+// private static boolean CompilationQueue.printAndResetCompRate()
+JVM_ENTRY(void, JVM_PrintAndResetGraalCompRate(JNIEnv *env, jclass c))
+  GraalCompiler* comp = GraalCompiler::instance();
+  CompileBroker::print_times(comp);
+  CompilerStatistics* stats = comp->stats();
+  stats->_standard.reset();
+  stats->_osr.reset();
+JVM_END
+#endif
+
 bool GraalRuntime::parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS) {
   ResourceMark rm(THREAD);
 
@@ -712,7 +748,7 @@
   }
 
   if (!valid) {
-    VMToCompiler::setOption(hotSpotOptionsClass, name_handle, Handle(), ' ', Handle(), 0L);
+    set_option_helper(hotSpotOptionsClass, name_handle, Handle(), ' ', Handle(), 0L);
     char buf[200];
     jio_snprintf(buf, sizeof(buf), "Invalid Graal option %s", arg);
     THROW_MSG(vmSymbols::java_lang_InternalError(), buf);
@@ -797,6 +833,21 @@
   THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L);
 }
 
+void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, Handle name, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) {
+  Thread* THREAD = Thread::current();
+  TempNewSymbol setOption = SymbolTable::new_symbol("setOption", THREAD);
+  TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/graal/options/OptionValue;CLjava/lang/String;J)V", THREAD);
+  JavaValue result(T_VOID);
+  JavaCallArguments args;
+  args.push_oop(name());
+  args.push_oop(option());
+  args.push_int(spec);
+  args.push_oop(stringValue());
+  args.push_long(primitiveValue);
+  JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, THREAD);
+  GUARANTEE_NO_PENDING_EXCEPTION("Error while calling set_option_helper");
+}
+
 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) {
   TempNewSymbol name = SymbolTable::new_symbol(declaringClass, THREAD);
   Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
@@ -832,4 +883,47 @@
   return service;
 }
 
+void GraalRuntime::shutdown() {
+  if (_HotSpotGraalRuntime_instance != NULL) {
+    JavaThread* THREAD = JavaThread::current();
+    HandleMark hm(THREAD);
+    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
+    KlassHandle klass = load_required_class(name);
+    JavaValue result(T_VOID);
+    JavaCallArguments args;
+    args.push_oop(get_HotSpotGraalRuntime());
+    JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD);
+    GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown");
+
+    JNIHandles::destroy_global(_HotSpotGraalRuntime_instance);
+    _HotSpotGraalRuntime_instance = NULL;
+  }
+}
+
+void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
+  Thread* THREAD = Thread::current();
+  CLEAR_PENDING_EXCEPTION;
+
+  assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
+  JavaValue result(T_VOID);
+  JavaCalls::call_virtual(&result,
+                          exception,
+                          KlassHandle(THREAD,
+                          SystemDictionary::Throwable_klass()),
+                          vmSymbols::printStackTrace_name(),
+                          vmSymbols::void_method_signature(),
+                          THREAD);
+
+  vm_abort(dump_core);
+}
+
+Klass* GraalRuntime::load_required_class(Symbol* name) {
+  Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), Handle(), Thread::current());
+  if (klass == NULL) {
+    tty->print_cr("Could not load class %s", name->as_C_string());
+    vm_abort(false);
+  }
+  return klass;
+}
+
 #include "graalRuntime.inline.hpp"
--- a/src/share/vm/graal/graalRuntime.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/graal/graalRuntime.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -31,6 +31,7 @@
 class GraalRuntime: public CHeapObj<mtCompiler> {
  private:
 
+  static jobject _HotSpotGraalRuntime_instance;
   static address _external_deopt_i2c_entry;
 
   /**
@@ -77,6 +78,11 @@
   static bool set_option(KlassHandle hotSpotOptionsClass, const char* name, int name_len, Handle name_handle, const char* value, TRAPS);
 
   /**
+   * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue)
+   */
+  static void set_option_helper(KlassHandle hotSpotOptionsClass, Handle name, Handle option, jchar spec, Handle stringValue, jlong primitiveValue);
+
+  /**
    * Instantiates a service object, calls its default constructor and returns it.
    *
    * @param name the name of a class implementing com.oracle.graal.api.runtime.Service
@@ -87,6 +93,20 @@
 
   static void initialize_natives(JNIEnv *env, jclass c2vmClass);
 
+  static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_instance != NULL; }
+
+  /**
+   * Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary
+   */
+  static Handle get_HotSpotGraalRuntime();
+
+  static jobject get_HotSpotGraalRuntime_jobject() {
+    get_HotSpotGraalRuntime();
+    return _HotSpotGraalRuntime_instance;
+  }
+
+  static void shutdown();
+
   /**
    * Given an interface representing a Graal service (i.e. sub-interface of
    * com.oracle.graal.api.runtime.Service), gets an array of objects, one per
@@ -97,6 +117,19 @@
    */
   static Handle get_service_impls(KlassHandle serviceKlass, TRAPS);
 
+  /**
+   * Aborts the VM due to an unexpected exception.
+   */
+  static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false);
+
+#define GUARANTEE_NO_PENDING_EXCEPTION(error_message) do { \
+    if (HAS_PENDING_EXCEPTION) { \
+      GraalRuntime::abort_on_pending_exception(PENDING_EXCEPTION, error_message); \
+    } \
+  } while (0);
+
+  static Klass* load_required_class(Symbol* name);
+
   static BufferBlob* initialize_buffer_blob();
 
   static bool parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS);
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2011, 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.
- */
-
-#include "precompiled.hpp"
-#include "classfile/systemDictionary.hpp"
-#include "graal/graalVMToCompiler.hpp"
-#include "runtime/gpu.hpp"
-
-// these are *global* handles
-jobject VMToCompiler::_HotSpotGraalRuntime_instance = NULL;
-jobject VMToCompiler::_VMToCompiler_instance = NULL;
-Klass* VMToCompiler::_VMToCompiler_klass = NULL;
-
-static Klass* loadClass(Symbol* name) {
-  Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), Handle(), Thread::current());
-  if (klass == NULL) {
-    tty->print_cr("Could not load class %s", name->as_C_string());
-    vm_abort(false);
-  }
-  return klass;
-}
-
-KlassHandle VMToCompiler::VMToCompiler_klass() {
-  if (_VMToCompiler_klass == NULL) {
-    TempNewSymbol VMToCompiler = SymbolTable::new_symbol("com/oracle/graal/hotspot/bridge/VMToCompiler", Thread::current());
-    Klass* result = loadClass(VMToCompiler);
-    _VMToCompiler_klass = result;
-  }
-  return _VMToCompiler_klass;
-}
-
-Handle VMToCompiler::create_HotSpotTruffleRuntime() {
-  Thread* THREAD = Thread::current();
-  TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD);
-  KlassHandle klass = loadClass(name);
-
-  TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD);
-  TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD);
-  JavaValue result(T_OBJECT);
-  JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD);
-  check_pending_exception("Couldn't initialize HotSpotTruffleRuntime");
-  return Handle((oop) result.get_jobject());
-}
-
-Handle VMToCompiler::get_HotSpotGraalRuntime() {
-  if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) {
-    Thread* THREAD = Thread::current();
-    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
-    KlassHandle klass = loadClass(name);
-    TempNewSymbol runtime = SymbolTable::new_symbol("runtime", THREAD);
-    TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", THREAD);
-    JavaValue result(T_OBJECT);
-    JavaCalls::call_static(&result, klass, runtime, sig, THREAD);
-    check_pending_exception("Couldn't initialize HotSpotGraalRuntime");
-    _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject());
-  }
-  return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance));
-}
-
-Handle VMToCompiler::VMToCompiler_instance() {
-  if (JNIHandles::resolve(_VMToCompiler_instance) == NULL) {
-    Thread* THREAD = Thread::current();
-    TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
-    KlassHandle klass = loadClass(name);
-    TempNewSymbol getVMToCompiler = SymbolTable::new_symbol("getVMToCompiler", THREAD);
-    TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/bridge/VMToCompiler;", THREAD);
-    JavaValue result(T_OBJECT);
-    JavaCallArguments args;
-    args.set_receiver(get_HotSpotGraalRuntime());
-    JavaCalls::call_virtual(&result, klass, getVMToCompiler, sig, &args, THREAD);
-    check_pending_exception("Couldn't get VMToCompiler");
-    _VMToCompiler_instance = JNIHandles::make_global((oop) result.get_jobject());
-  }
-  return Handle(JNIHandles::resolve_non_null(_VMToCompiler_instance));
-}
-
-void VMToCompiler::setOption(KlassHandle hotSpotOptionsClass, Handle name, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) {
-  assert(!option.is_null(), "npe");
-  Thread* THREAD = Thread::current();
-  TempNewSymbol setOption = SymbolTable::new_symbol("setOption", THREAD);
-  TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/graal/options/OptionValue;CLjava/lang/String;J)V", THREAD);
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  args.push_oop(name());
-  args.push_oop(option());
-  args.push_int(spec);
-  args.push_oop(stringValue());
-  args.push_long(primitiveValue);
-  JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, THREAD);
-  check_pending_exception("Error while calling setOption");
-}
-
-#ifdef COMPILERGRAAL
-void VMToCompiler::bootstrap() {
-  JavaThread* THREAD = JavaThread::current();
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  TempNewSymbol bootstrap = SymbolTable::new_symbol("bootstrap", THREAD);
-  args.push_oop(VMToCompiler_instance());
-  JavaCalls::call_interface(&result, VMToCompiler_klass(), bootstrap, vmSymbols::void_method_signature(), &args, THREAD);
-  check_pending_exception("Error while calling bootstrap");
-}
-
-void VMToCompiler::startCompiler(jboolean bootstrap_enabled) {
-  JavaThread* THREAD = JavaThread::current();
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  TempNewSymbol startCompiler = SymbolTable::new_symbol("startCompiler", THREAD);
-  args.push_oop(VMToCompiler_instance());
-  args.push_int(bootstrap_enabled);
-  JavaCalls::call_interface(&result, VMToCompiler_klass(), startCompiler, vmSymbols::bool_void_signature(), &args, THREAD);
-  check_pending_exception("Error while calling startCompiler");
-}
-
-void VMToCompiler::compileMethod(Method* method, int entry_bci, jlong ctask, jboolean blocking) {
-  assert(method != NULL, "just checking");
-  Thread* THREAD = Thread::current();
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  args.push_oop(VMToCompiler_instance());
-  args.push_long((jlong) (address) method);
-  args.push_int(entry_bci);
-  args.push_long(ctask);
-  args.push_int(blocking);
-  JavaCalls::call_interface(&result, VMToCompiler_klass(), vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
-  check_pending_exception("Error while calling compileMethod");
-}
-
-void VMToCompiler::shutdownCompiler() {
-  JavaThread* THREAD = JavaThread::current();
-  HandleMark hm(THREAD);
-  TempNewSymbol shutdownCompiler = SymbolTable::new_symbol("shutdownCompiler", THREAD);
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  args.push_oop(VMToCompiler_instance());
-  JavaCalls::call_interface(&result, VMToCompiler_klass(), shutdownCompiler, vmSymbols::void_method_signature(), &args, THREAD);
-  check_pending_exception("Error while calling shutdownCompiler");
-}
-#endif // COMPILERGRAAL
-
-void VMToCompiler::shutdownRuntime() {
-  if (_HotSpotGraalRuntime_instance != NULL) {
-    JavaThread* THREAD = JavaThread::current();
-    HandleMark hm(THREAD);
-    TempNewSymbol shutdownRuntime = SymbolTable::new_symbol("shutdownRuntime", THREAD);
-    JavaValue result(T_VOID);
-    JavaCallArguments args;
-    args.push_oop(VMToCompiler_instance());
-    JavaCalls::call_interface(&result, VMToCompiler_klass(), shutdownRuntime, vmSymbols::void_method_signature(), &args, THREAD);
-    check_pending_exception("Error while calling shutdownRuntime");
-
-    JNIHandles::destroy_global(_HotSpotGraalRuntime_instance);
-    JNIHandles::destroy_global(_VMToCompiler_instance);
-
-    _HotSpotGraalRuntime_instance = NULL;
-    _VMToCompiler_instance = NULL;
-    _VMToCompiler_klass = NULL;
-  }
-}
-
-#ifndef PRODUCT
-void VMToCompiler::compileTheWorld() {
-  // We turn off CompileTheWorld so that Graal can
-  // be compiled by C1/C2 when Graal does a CTW.
-  CompileTheWorld = false;
-
-  JavaThread* THREAD = JavaThread::current();
-  TempNewSymbol compileTheWorld = SymbolTable::new_symbol("compileTheWorld", THREAD);
-  JavaValue result(T_VOID);
-  JavaCallArguments args;
-  args.push_oop(VMToCompiler_instance());
-  JavaCalls::call_interface(&result, VMToCompiler_klass(), compileTheWorld, vmSymbols::void_method_signature(), &args, THREAD);
-  check_pending_exception("Error while calling compileTheWorld");
-}
-#endif
--- a/src/share/vm/graal/graalVMToCompiler.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2011, 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.
- */
-
-#ifndef SHARE_VM_GRAAL_GRAAL_VM_TO_COMPILER_HPP
-#define SHARE_VM_GRAAL_GRAAL_VM_TO_COMPILER_HPP
-
-#include "memory/allocation.hpp"
-#include "oops/oop.hpp"
-#include "runtime/handles.hpp"
-#include "runtime/thread.hpp"
-#include "classfile/javaClasses.hpp"
-#include "runtime/jniHandles.hpp"
-#include "runtime/javaCalls.hpp"
-
-class VMToCompiler : public AllStatic {
-
-private:
-  static jobject _HotSpotGraalRuntime_instance;
-  static jobject _VMToCompiler_instance;
-
-  static Klass* _VMToCompiler_klass;
-
-  static KlassHandle VMToCompiler_klass();
-  static Handle VMToCompiler_instance();
-
-public:
-
-  static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_instance != NULL; }
-
-  // Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary
-  static Handle get_HotSpotGraalRuntime();
-
-  // Creates a new HotSpotTruffleRuntime object
-  static Handle create_HotSpotTruffleRuntime();
-
-  static jobject get_HotSpotGraalRuntime_jobject() {
-    get_HotSpotGraalRuntime();
-    return _HotSpotGraalRuntime_instance;
-  }
-
-  // public static void HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue);
-  static void setOption(KlassHandle hotSpotOptionsClass, Handle name, Handle option, jchar spec, Handle stringValue, jlong primitiveValue);
-
-#ifdef COMPILERGRAAL
-  // public abstract void startCompiler(boolean bootstrapEnabled);
-  static void startCompiler(jboolean bootstrap_enabled);
-
-  // public abstract void bootstrap();
-  static void bootstrap();
-
-  // public abstract boolean compileMethod(long metaspaceMethod, int entryBCI, long ctask, boolean blocking);
-  static void compileMethod(Method* method, int entry_bci, jlong ctask, jboolean blocking);
-
-  // public abstract void shutdownCompiler();
-  static void shutdownCompiler();
-#endif
-  
-  // public abstract void shutdownRuntime();
-  static void shutdownRuntime();
-  
-#ifndef PRODUCT
-  // public abstract void compileTheWorld();
-  static void compileTheWorld();
-#endif
-};
-
-inline void check_pending_exception(const char* message, bool dump_core = false) {
-  Thread* THREAD = Thread::current();
-  if (THREAD->has_pending_exception()) {
-    Handle exception = PENDING_EXCEPTION;
-    CLEAR_PENDING_EXCEPTION;
-
-    assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
-    JavaValue result(T_VOID);
-    JavaCalls::call_virtual(&result,
-                            exception,
-                            KlassHandle(THREAD,
-                            SystemDictionary::Throwable_klass()),
-                            vmSymbols::printStackTrace_name(),
-                            vmSymbols::void_method_signature(),
-                            THREAD);
-
-    vm_abort(dump_core);
-  }
-}
-
-#endif // SHARE_VM_GRAAL_GRAAL_VM_TO_COMPILER_HPP
--- a/src/share/vm/oops/instanceKlass.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/oops/instanceKlass.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -61,7 +61,7 @@
 #include "utilities/macros.hpp"
 #ifdef GRAAL
 #include "classfile/javaAssertions.hpp"
-#include "graal/graalVMToCompiler.hpp"
+#include "graal/graalRuntime.hpp"
 #endif
 #if INCLUDE_ALL_GCS
 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp"
@@ -1209,7 +1209,7 @@
 #ifdef GRAAL
   if (this_oop->is_subtype_of(SystemDictionary::Node_klass())) {
     if (this_oop() != SystemDictionary::Node_klass()) {
-      if (!VMToCompiler::is_HotSpotGraalRuntime_initialized() && JavaAssertions::systemClassDefault() == false) {
+      if (!GraalRuntime::is_HotSpotGraalRuntime_initialized() && JavaAssertions::systemClassDefault() == false) {
         // We want to ensure that the process of initializing HotSpotGraalRuntime
         // is fast since it executes at VM startup. We must avoid triggering
         // class initialization of any Node classes during this process.
--- a/src/share/vm/prims/jni.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/prims/jni.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -35,7 +35,7 @@
 #include "utilities/macros.hpp"
 #ifdef GRAAL
 #include "graal/graalCompiler.hpp"
-#include "graal/graalVMToCompiler.hpp"
+#include "graal/graalRuntime.hpp"
 #endif
 #if INCLUDE_ALL_GCS
 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
@@ -5218,7 +5218,7 @@
       // stop the VM deferring compilation now.
       CompilationPolicy::completed_vm_startup();
 
-      VMToCompiler::compileTheWorld();
+      GraalCompiler::instance()->compile_the_world();
     }
 #endif
 #else
--- a/src/share/vm/prims/nativeLookup.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/prims/nativeLookup.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -124,11 +124,14 @@
   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 #ifdef GRAAL
-  void     JNICALL JVM_InitializeGraalNatives(JNIEnv *env, jclass c, jclass compilerToVMClass);
+  void     JNICALL JVM_InitializeGraalNatives(JNIEnv *env, jclass compilerToVMClass);
   jobject  JNICALL JVM_GetGraalRuntime(JNIEnv *env, jclass c);
   jobject  JNICALL JVM_GetGraalServiceImpls(JNIEnv *env, jclass c);
   jobject  JNICALL JVM_CreateTruffleRuntime(JNIEnv *env, jclass c);
   jboolean JNICALL JVM_ParseGraalOptions(JNIEnv *env, jclass hotspotOptionsClass);
+#ifdef COMPILERGRAAL
+  void     JNICALL JVM_PrintAndResetGraalCompRate(JNIEnv *env, jclass c);
+#endif
 #endif
 }
 
@@ -141,11 +144,14 @@
   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 #ifdef GRAAL
-  { CC"Java_com_oracle_graal_api_runtime_Graal_initializeRuntime",   NULL, FN_PTR(JVM_GetGraalRuntime)             },
-  { CC"Java_com_oracle_graal_api_runtime_Services_getServiceImpls",  NULL, FN_PTR(JVM_GetGraalServiceImpls)        },
-  { CC"Java_com_oracle_truffle_api_Truffle_createRuntime",           NULL, FN_PTR(JVM_CreateTruffleRuntime)        },
-  { CC"Java_com_oracle_graal_hotspot_HotSpotGraalRuntime_init",      NULL, FN_PTR(JVM_InitializeGraalNatives)      },
-  { CC"Java_com_oracle_graal_hotspot_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseGraalOptions)           },
+  { CC"Java_com_oracle_graal_api_runtime_Graal_initializeRuntime",            NULL, FN_PTR(JVM_GetGraalRuntime)           },
+  { CC"Java_com_oracle_graal_api_runtime_Services_getServiceImpls",           NULL, FN_PTR(JVM_GetGraalServiceImpls)      },
+  { CC"Java_com_oracle_truffle_api_Truffle_createRuntime",                    NULL, FN_PTR(JVM_CreateTruffleRuntime)      },
+  { CC"Java_com_oracle_graal_hotspot_bridge_CompilerToVMImpl_init",           NULL, FN_PTR(JVM_InitializeGraalNatives)    },
+  { CC"Java_com_oracle_graal_hotspot_HotSpotOptions_parseVMOptions",          NULL, FN_PTR(JVM_ParseGraalOptions)         },
+#ifdef COMPILERGRAAL
+  { CC"Java_com_oracle_graal_hotspot_CompilationQueue_printAndResetCompRate", NULL, FN_PTR(JVM_PrintAndResetGraalCompRate)},
+#endif
 #endif
 };
 
--- a/src/share/vm/runtime/compilationPolicy.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/runtime/compilationPolicy.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -203,7 +203,7 @@
 // - if neither is defined - always return zero.
 int NonTieredCompPolicy::compiler_count(CompLevel comp_level) {
   assert(!TieredCompilation, "This policy should not be used with TieredCompilation");
-#ifdef COMPILER2
+#if defined(COMPILER2) || defined(COMPILERGRAAL)
   if (is_c2_compile(comp_level)) {
     return _compiler_count;
   } else {
--- a/src/share/vm/runtime/java.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/runtime/java.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -32,7 +32,7 @@
 #include "interpreter/bytecodeHistogram.hpp"
 #ifdef GRAAL
 #include "graal/graalCompiler.hpp"
-#include "graal/graalVMToCompiler.hpp"
+#include "graal/graalRuntime.hpp"
 #endif
 #include "memory/genCollectedHeap.hpp"
 #include "memory/oopFactory.hpp"
@@ -489,7 +489,7 @@
     GraalCompiler::instance()->shutdown();
   }
 #endif
-  VMToCompiler::shutdownRuntime();
+  GraalRuntime::shutdown();
 #endif
 
   // The only difference between this and Win32's _onexit procs is that
--- a/src/share/vm/runtime/thread.cpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/runtime/thread.cpp	Fri Jun 06 01:19:20 2014 +0200
@@ -1483,7 +1483,7 @@
 #ifdef GRAAL
   _graal_alternate_call_target = NULL;
   _graal_implicit_exception_pc = NULL;
-  _graal_compiling = false;
+  _graal_can_schedule_compilation = true;
   if (GraalCounterSize > 0) {
     _graal_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal);
     memset(_graal_counters, 0, sizeof(jlong) * GraalCounterSize);
--- a/src/share/vm/runtime/thread.hpp	Fri Jun 06 00:18:30 2014 +0200
+++ b/src/share/vm/runtime/thread.hpp	Fri Jun 06 01:19:20 2014 +0200
@@ -922,8 +922,8 @@
 
 #ifdef GRAAL
   address   _graal_alternate_call_target;
-  address   _graal_implicit_exception_pc;  // pc at which the most recent implicit exception occurred
-  bool      _graal_compiling;
+  address   _graal_implicit_exception_pc;    // pc at which the most recent implicit exception occurred
+  bool      _graal_can_schedule_compilation; // see NoGraalCompilationScheduling
 
   jlong*    _graal_counters;
 
@@ -1310,8 +1310,8 @@
 #ifdef GRAAL
   void set_graal_alternate_call_target(address a) { _graal_alternate_call_target = a; }
   void set_graal_implicit_exception_pc(address a) { _graal_implicit_exception_pc = a; }
-  bool is_graal_compiling()                       { return _graal_compiling;          }
-  void set_is_graal_compiling(bool b)             { _graal_compiling = b;             }
+  bool can_schedule_graal_compilation()           { return _graal_can_schedule_compilation; }
+  void set_can_schedule_graal_compilation(bool b) { _graal_can_schedule_compilation = b;    }
 #endif
 
   // Exception handling for compiled methods
@@ -1882,6 +1882,8 @@
 
 #ifdef COMPILERGRAAL
   virtual bool can_call_java() const;
+#else
+  virtual bool can_call_java() const             { return false; }
 #endif
 
   // Hide this compiler thread from external view.