changeset 11592:4dbd3e3adda6

Merge
author Mick Jordan <mick.jordan@oracle.com>
date Tue, 10 Sep 2013 09:30:09 -0700
parents e460aa80fa46 (current diff) 4cf51b630049 (diff)
children c47153857827
files
diffstat 30 files changed, 218 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/README_GRAAL.txt	Mon Sep 09 10:30:42 2013 -0700
+++ b/README_GRAAL.txt	Tue Sep 10 09:30:09 2013 -0700
@@ -14,8 +14,8 @@
 This builds the 'product' version of HotSpot with the Graal modifications.
 To build the debug or fastdebug versions:
 
-  mx build debug
-  mx build fastdebug
+  mx --vmbuild debug build
+  mx --vmbuild fastdebug build
 
 Running Graal
 -------------
@@ -26,11 +26,11 @@
 
 To select the fastdebug or debug versions of the VM:
 
-% mx --fastdebug vm ...
-% mx --debug vm ...
+% mx --vmbuild fastdebug vm ...
+% mx --vmbuild debug vm ...
 
 Graal has an optional bootstrap step where it compiles itself before
-compiling any application code. This bootstrap step currently takes about 7 seconds
+compiling any application code. This bootstrap step currently takes about 20 seconds
 on a fast x64 machine. It's useful to disable this bootstrap step when running small
 programs with the -XX:-BootstrapGraal options. For example:
 
@@ -45,26 +45,36 @@
 such with the -version option:
 
 % mx vm -XX:-BootstrapGraal -version
-java version "1.7.0_07"
-Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
-OpenJDK 64-Bit Graal VM (build 25.0-b10-internal, mixed mode)
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Graal VM (build 25.0-b43-internal, mixed mode)
 
 It's also possible to build and execute the standard HotSpot binaries
 using the --vm option:
 
 % mx --vm server build
 % mx --vm server vm -version
-java version "1.7.0_07"
-Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
-OpenJDK 64-Bit Server VM (build 25.0-b10-internal, mixed mode)
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Server VM (build 25.0-b43-internal, mixed mode)
 
 These standard binaries still include the code necessary to support use of the
 Graal compiler for explicit compilation requests. However, in this configuration
 the Graal compiler will not service VM issued compilation requests (e.g., upon
 counter overflow in the interpreter).
 
-To build a HotSpot binary that completely omits all VM support for Graal,
-define an environment variable OMIT_GRAAL (its value does not matter) and build
-with the --vm option as above (doing a clean first if necessary):
+To build and run a HotSpot binary that completely omits all VM support for Graal,
+use the following as a guide:
 
-% env OMIT_GRAAL= mx --vm server build
+% mx --vm server-nograal build
+% mx --vm server-nograal vm -version
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Server VM (build 25.0-b43-internal, mixed mode)
+
+% mx --vm client-nograal build
+% mx --vm client-nograal vm -version
+java version "1.7.0_25"
+Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
+OpenJDK 64-Bit Cleint VM (build 25.0-b43-internal, mixed mode)
+
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue Sep 10 09:30:09 2013 -0700
@@ -87,7 +87,7 @@
     }
 
     @BeforeClass
-    public static void initializeDebgging() {
+    public static void initializeDebugging() {
         DebugEnvironment.initialize(System.out);
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Tue Sep 10 09:30:09 2013 -0700
@@ -36,8 +36,6 @@
 public class GraalDebugConfig implements DebugConfig {
 
     // @formatter:off
-    @Option(help = "Enable scope-based debugging", name = "Debug")
-    public static final OptionValue<Boolean> DebugEnabled = new OptionValue<>(true);
     @Option(help = "Pattern for scope(s) to in which dumping is enabled (see DebugFilter and Debug.dump)")
     public static final OptionValue<String> Dump = new OptionValue<>(null);
     @Option(help = "Pattern for scope(s) to in which metering is enabled (see DebugFilter and Debug.metric)")
@@ -68,6 +66,10 @@
     };
     // @formatter:on
 
+    public static boolean areDebugScopePatternsEnabled() {
+        return DumpOnError.getValue() || Dump.getValue() != null || Meter.getValue() != null || Time.getValue() != null || Log.getValue() != null;
+    }
+
     private final DebugFilter logFilter;
     private final DebugFilter meterFilter;
     private final DebugFilter timerFilter;
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Tue Sep 10 09:30:09 2013 -0700
@@ -330,7 +330,7 @@
 
     public static DebugMetric metric(String name) {
         if (ENABLED) {
-            return new MetricImpl(name);
+            return new MetricImpl(name, true);
         } else {
             return VOID_METRIC;
         }
@@ -405,11 +405,19 @@
 
         public void add(long value) {
         }
+
+        public void setConditional(boolean flag) {
+            throw new InternalError("Cannot make void metric conditional");
+        }
+
+        public boolean isConditional() {
+            return false;
+        }
     };
 
     public static DebugTimer timer(String name) {
         if (ENABLED) {
-            return new TimerImpl(name);
+            return new TimerImpl(name, true);
         } else {
             return VOID_TIMER;
         }
@@ -420,5 +428,13 @@
         public TimerCloseable start() {
             return TimerImpl.VOID_CLOSEABLE;
         }
+
+        public void setConditional(boolean flag) {
+            throw new InternalError("Cannot make void timer conditional");
+        }
+
+        public boolean isConditional() {
+            return false;
+        }
     };
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugMetric.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugMetric.java	Tue Sep 10 09:30:09 2013 -0700
@@ -22,9 +22,32 @@
  */
 package com.oracle.graal.debug;
 
+/**
+ * A counter for some value of interest.
+ */
 public interface DebugMetric {
 
+    /**
+     * Adds 1 to this counter if metering is {@link Debug#isMeterEnabled() enabled} or this is an
+     * {@linkplain #isConditional() unconditional} metric.
+     */
     void increment();
 
+    /**
+     * Adds {@code value} to this counter if metering is {@link Debug#isMeterEnabled() enabled} or
+     * this is an {@linkplain #isConditional() unconditional} metric.
+     */
     void add(long value);
+
+    /**
+     * Sets a flag determining if this counter is only enabled if metering is
+     * {@link Debug#isMeterEnabled() enabled}.
+     */
+    void setConditional(boolean flag);
+
+    /**
+     * Determines if this counter is only enabled if metering is {@link Debug#isMeterEnabled()
+     * enabled}.
+     */
+    boolean isConditional();
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugTimer.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugTimer.java	Tue Sep 10 09:30:09 2013 -0700
@@ -24,7 +24,36 @@
 
 import com.oracle.graal.debug.internal.*;
 
+/**
+ * A timer for some activity of interest. A timer should be deployed using the try-with-resources
+ * pattern:
+ * 
+ * <pre>
+ * try (TimerCloseable a = timer.start()) {
+ *     // the code to time
+ * }
+ * </pre>
+ */
 public interface DebugTimer {
 
+    /**
+     * Starts this timer if timing is {@linkplain Debug#isTimeEnabled() enabled} or this is an
+     * {@linkplain #isConditional() unconditional} timer.
+     * 
+     * @return an object that must be closed once the activity has completed to add the elapsed time
+     *         since this call to the total for this timer
+     */
     TimerCloseable start();
+
+    /**
+     * Sets a flag determining if this timer is only enabled if metering is
+     * {@link Debug#isMeterEnabled() enabled}.
+     */
+    void setConditional(boolean flag);
+
+    /**
+     * Determines if this timer is only enabled if metering is {@link Debug#isMeterEnabled()
+     * enabled}.
+     */
+    boolean isConditional();
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/MetricImpl.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/MetricImpl.java	Tue Sep 10 09:30:09 2013 -0700
@@ -26,8 +26,11 @@
 
 public final class MetricImpl extends DebugValue implements DebugMetric {
 
-    public MetricImpl(String name) {
+    private boolean conditional;
+
+    public MetricImpl(String name, boolean conditional) {
         super(name);
+        this.conditional = conditional;
     }
 
     public void increment() {
@@ -35,7 +38,7 @@
     }
 
     public void add(long value) {
-        if (Debug.isMeterEnabled()) {
+        if (!conditional || Debug.isMeterEnabled()) {
             super.addToCurrentValue(value);
         }
     }
@@ -44,4 +47,12 @@
     public String toString(long value) {
         return Long.toString(value);
     }
+
+    public void setConditional(boolean flag) {
+        conditional = flag;
+    }
+
+    public boolean isConditional() {
+        return conditional;
+    }
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerCloseable.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerCloseable.java	Tue Sep 10 09:30:09 2013 -0700
@@ -22,6 +22,12 @@
  */
 package com.oracle.graal.debug.internal;
 
+import com.oracle.graal.debug.*;
+
+/**
+ * An object returned by {@link DebugTimer#start()} that when closed, stops the associated timer and
+ * adds the elapsed time since {@code start()} to the total for the timer.
+ */
 public interface TimerCloseable extends AutoCloseable {
 
     void close();
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Tue Sep 10 09:30:09 2013 -0700
@@ -38,9 +38,19 @@
     };
 
     private ThreadLocal<Long> valueToSubstract = new ThreadLocal<>();
+    private boolean conditional;
 
-    public TimerImpl(String name) {
+    public TimerImpl(String name, boolean conditional) {
         super(name);
+        this.conditional = conditional;
+    }
+
+    public void setConditional(boolean flag) {
+        conditional = flag;
+    }
+
+    public boolean isConditional() {
+        return conditional;
     }
 
     @Override
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java	Tue Sep 10 09:30:09 2013 -0700
@@ -25,7 +25,6 @@
 import java.util.*;
 
 import com.oracle.graal.graph.GraphEvent.NodeEvent;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.graph.Node.ValueNumberable;
 import com.oracle.graal.graph.iterators.*;
 
@@ -156,7 +155,7 @@
     int usageModCount(Node node) {
         int id = extractOriginalNodeId(node);
         if (id >= 0 && id < nodeUsageModCounts.length) {
-            return nodeUsageModCounts[node.id];
+            return nodeUsageModCounts[id];
         }
         return 0;
     }
@@ -414,7 +413,7 @@
     private static final Node PLACE_HOLDER = new Node() {
     };
 
-    private class TypedNodeIterator<T extends IterableNodeType> implements Iterator<T> {
+    private class TypedNodeIterator<T extends Node.IterableNodeType> implements Iterator<T> {
 
         private final int[] ids;
         private final Node[] current;
@@ -520,7 +519,7 @@
      * @param type the type of node to return
      * @return an {@link Iterable} providing all the matching nodes.
      */
-    public <T extends Node & IterableNodeType> NodeIterable<T> getNodes(final Class<T> type) {
+    public <T extends Node & Node.IterableNodeType> NodeIterable<T> getNodes(final Class<T> type) {
         final NodeClass nodeClass = NodeClass.get(type);
         return new AbstractNodeIterable<T>() {
 
@@ -537,7 +536,7 @@
      * @param type the type of node that is checked for occurrence
      * @return whether there is at least one such node
      */
-    public <T extends Node & IterableNodeType> boolean hasNode(final Class<T> type) {
+    public <T extends Node & Node.IterableNodeType> boolean hasNode(final Class<T> type) {
         return getNodes(type).iterator().hasNext();
     }
 
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Tue Sep 10 09:30:09 2013 -0700
@@ -31,7 +31,6 @@
 
 import com.oracle.graal.graph.Graph.DuplicationReplacement;
 import com.oracle.graal.graph.Node.Input;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.graph.Node.Successor;
 import com.oracle.graal.graph.Node.Verbosity;
 
@@ -40,7 +39,7 @@
  * <ul>
  * <li>The offsets of fields annotated with {@link Input} and {@link Successor} as well as methods
  * for iterating over such fields.</li>
- * <li>The identifier for an {@link IterableNodeType} class.</li>
+ * <li>The identifier for an {@link Node.IterableNodeType} class.</li>
  * </ul>
  */
 public final class NodeClass extends FieldIntrospection {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java	Tue Sep 10 09:30:09 2013 -0700
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.hotspot;
 
-import static com.oracle.graal.compiler.GraalDebugConfig.*;
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import java.io.*;
@@ -52,7 +51,7 @@
     @Override
     public void run() {
         GraalDebugConfig hotspotDebugConfig = null;
-        if (DebugEnabled.getValue()) {
+        if (Debug.isEnabled()) {
             PrintStream log = graalRuntime().getVMToCompiler().log();
             DebugEnvironment.initialize(log);
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Tue Sep 10 09:30:09 2013 -0700
@@ -23,6 +23,8 @@
 
 package com.oracle.graal.hotspot;
 
+import static com.oracle.graal.compiler.GraalDebugConfig.*;
+import static com.oracle.graal.hotspot.HotSpotVMConfig.*;
 import static java.nio.file.Files.*;
 
 import java.io.*;
@@ -30,6 +32,7 @@
 import java.nio.file.*;
 import java.util.*;
 
+import com.oracle.graal.debug.*;
 import com.oracle.graal.hotspot.logging.*;
 import com.oracle.graal.options.*;
 
@@ -174,6 +177,16 @@
     }
 
     /**
+     * Called from VM code once all Graal command line options have been processed by
+     * {@link #setOption(String)}.
+     */
+    public static void finalizeOptions() {
+        if (areDebugScopePatternsEnabled() || getVMOption("CITime")) {
+            Debug.enable();
+        }
+    }
+
+    /**
      * Wraps some given text to one or more lines of a given maximum width.
      * 
      * @param text text to wrap
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Tue Sep 10 09:30:09 2013 -0700
@@ -38,7 +38,7 @@
 
     private static final long serialVersionUID = -4744897993263044184L;
 
-    private final HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
+    private static final HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
 
     HotSpotVMConfig(CompilerToVM c2vm) {
         c2vm.initializeConfiguration(this);
@@ -52,9 +52,9 @@
      * @return value of option
      * @throws IllegalArgumentException if option doesn't exist
      */
-    private int getVMOptionInt(String name) {
+    public static int getVMOptionInt(String name) {
         String value = diagnostic.getVMOption(name).getValue();
-        return new Integer(value).intValue();
+        return Integer.valueOf(value).intValue();
     }
 
     /**
@@ -64,7 +64,7 @@
      * @param defaultValue default value if option is not exists (e.g. development options)
      * @return value of option or defaultValue if option doesn't exist
      */
-    private int getVMOption(String name, int defaultValue) {
+    public static int getVMOption(String name, int defaultValue) {
         try {
             return getVMOptionInt(name);
         } catch (IllegalArgumentException e) {
@@ -79,9 +79,9 @@
      * @return value of option
      * @throws IllegalArgumentException if option doesn't exist
      */
-    private boolean getVMOption(String name) {
+    public static boolean getVMOption(String name) {
         String value = diagnostic.getVMOption(name).getValue();
-        return new Boolean(value).booleanValue();
+        return Boolean.valueOf(value).booleanValue();
     }
 
     /**
@@ -91,7 +91,7 @@
      * @param defaultValue default value if option is not exists (e.g. development options)
      * @return value of option or defaultValue if option doesn't exist
      */
-    private boolean getVMOption(String name, boolean defaultValue) {
+    public static boolean getVMOption(String name, boolean defaultValue) {
         try {
             return getVMOption(name);
         } catch (IllegalArgumentException e) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue Sep 10 09:30:09 2013 -0700
@@ -29,6 +29,7 @@
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 import static com.oracle.graal.java.GraphBuilderPhase.*;
 import static com.oracle.graal.phases.GraalOptions.*;
+import static com.oracle.graal.phases.common.InliningUtil.*;
 
 import java.io.*;
 import java.lang.reflect.*;
@@ -51,7 +52,6 @@
 import com.oracle.graal.options.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.PhasePlan.PhasePosition;
-import com.oracle.graal.phases.common.*;
 import com.oracle.graal.printer.*;
 import com.oracle.graal.replacements.*;
 
@@ -105,8 +105,6 @@
 
     private PrintStream log = System.out;
 
-    private boolean quietMeterAndTime;
-
     private long compilerStartTime;
 
     public VMToCompilerImpl(HotSpotGraalRuntime compiler) {
@@ -165,13 +163,12 @@
         }
 
         if (config.ciTime) {
-            quietMeterAndTime = (Meter.getValue() == null && Time.getValue() == null);
-            DebugEnabled.setValue(true);
-            Meter.setValue("");
-            Time.setValue("");
+            BytecodesParsed.setConditional(false);
+            InlinedBytecodes.setConditional(false);
+            CompilationTime.setConditional(false);
         }
 
-        if (DebugEnabled.getValue()) {
+        if (Debug.isEnabled()) {
             DebugEnvironment.initialize(log);
 
             String summary = DebugValueSummary.getValue();
@@ -374,7 +371,7 @@
         CompilationStatistics.clear(phase);
         if (graalRuntime.getConfig().ciTime) {
             parsedBytecodesPerSecond = MetricRateInPhase.snapshot(phase, parsedBytecodesPerSecond, BytecodesParsed, CompilationTime, TimeUnit.SECONDS);
-            inlinedBytecodesPerSecond = MetricRateInPhase.snapshot(phase, inlinedBytecodesPerSecond, InliningUtil.InlinedBytecodes, CompilationTime, TimeUnit.SECONDS);
+            inlinedBytecodesPerSecond = MetricRateInPhase.snapshot(phase, inlinedBytecodesPerSecond, InlinedBytecodes, CompilationTime, TimeUnit.SECONDS);
         }
     }
 
@@ -476,7 +473,7 @@
             CompilationTask.withinEnqueue.set(Boolean.FALSE);
         }
 
-        if (Debug.isEnabled() && !quietMeterAndTime) {
+        if (Debug.isEnabled() && areDebugScopePatternsEnabled()) {
             List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
             List<DebugValue> debugValues = KeyRegistry.getDebugValues();
             if (debugValues.size() > 0) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/VerifyHotSpotOptionsPhase.java	Tue Sep 10 09:30:09 2013 -0700
@@ -57,22 +57,26 @@
             for (OptionDescriptor desc : opts) {
                 if (HotSpotOptions.isHotSpotOption(desc)) {
                     HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) runtime.lookupJavaType(desc.getDeclaringClass());
-                    if (!checked.contains(holder)) {
-                        checked.add(holder);
-                        for (ResolvedJavaMethod method : holder.getMethods()) {
-                            if (method.isClassInitializer()) {
-                                StructuredGraph graph = new StructuredGraph(method);
-                                new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
-                                new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph);
-                            }
-                        }
-                    }
+                    checkType(runtime, checked, holder);
                 }
             }
         }
         return true;
     }
 
+    private static void checkType(HotSpotRuntime runtime, Set<HotSpotResolvedObjectType> checked, HotSpotResolvedObjectType holder) {
+        if (!checked.contains(holder)) {
+            checked.add(holder);
+            for (ResolvedJavaMethod method : holder.getMethods()) {
+                if (method.isClassInitializer()) {
+                    StructuredGraph graph = new StructuredGraph(method);
+                    new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
+                    new VerifyHotSpotOptionsPhase(holder, runtime).apply(graph);
+                }
+            }
+        }
+    }
+
     private final HotSpotRuntime runtime;
     private final ResolvedJavaType declaringClass;
     private final ResolvedJavaType optionValueType;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.loop.phases.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
@@ -37,7 +37,7 @@
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.replacements.nodes.*;
 
-public class ArrayCopyNode extends MacroNode implements Virtualizable, IterableNodeType, Lowerable {
+public class ArrayCopyNode extends MacroNode implements Virtualizable, Node.IterableNodeType, Lowerable {
 
     public ArrayCopyNode(Invoke invoke) {
         super(invoke);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/InfopointNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -23,14 +23,14 @@
 package com.oracle.graal.nodes;
 
 import com.oracle.graal.api.code.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
+import com.oracle.graal.graph.Node;
 import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
  * Nodes of this type are inserted into the graph to denote points of interest to debugging.
  */
-public class InfopointNode extends AbstractStateSplit implements LIRLowerable, IterableNodeType {
+public class InfopointNode extends AbstractStateSplit implements LIRLowerable, Node.IterableNodeType {
 
     public final InfopointReason reason;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Tue Sep 10 09:30:09 2013 -0700
@@ -23,7 +23,6 @@
 package com.oracle.graal.truffle;
 
 import static com.oracle.graal.api.code.CodeUtil.*;
-import static com.oracle.graal.compiler.GraalDebugConfig.*;
 
 import java.util.*;
 import java.util.concurrent.*;
@@ -84,7 +83,7 @@
 
         this.partialEvaluator = new PartialEvaluator(metaAccessProvider, replacements, truffleCache);
 
-        if (DebugEnabled.getValue()) {
+        if (Debug.isEnabled()) {
             DebugEnvironment.initialize(System.out);
         }
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameGetNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameGetNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -25,7 +25,6 @@
 import sun.misc.*;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
@@ -40,7 +39,7 @@
  * Intrinsic node for read access to a Truffle frame.
  */
 @NodeInfo(nameTemplate = "FrameGet{p#slotKind/s}{p#frameSlot/s}")
-public class FrameGetNode extends FrameAccessNode implements IterableNodeType, Virtualizable, Lowerable {
+public class FrameGetNode extends FrameAccessNode implements Node.IterableNodeType, Virtualizable, Lowerable {
 
     public FrameGetNode(Kind kind, ValueNode frame, ValueNode slot, ResolvedJavaField field) {
         super(StampFactory.forKind(kind), kind, frame, slot, field);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameSetNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/FrameSetNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -23,7 +23,6 @@
 package com.oracle.graal.truffle.nodes.frame;
 
 import com.oracle.graal.api.meta.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
@@ -37,7 +36,7 @@
  * Intrinsic node for write access to a Truffle frame.
  */
 @NodeInfo(nameTemplate = "FrameSet{p#slotKind/s}{p#frameSlot/s}")
-public class FrameSetNode extends FrameAccessNode implements IterableNodeType, Virtualizable, Lowerable {
+public class FrameSetNode extends FrameAccessNode implements Node.IterableNodeType, Virtualizable, Lowerable {
 
     @Input private ValueNode value;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/MaterializeFrameNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/MaterializeFrameNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -22,7 +22,6 @@
  */
 package com.oracle.graal.truffle.nodes.frame;
 
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.truffle.*;
@@ -31,7 +30,7 @@
  * Intrinsic node for materializing a Truffle frame.
  */
 @NodeInfo(nameTemplate = "MaterializeFrame{p#frame/s}")
-public class MaterializeFrameNode extends FixedWithNextNode implements IterableNodeType {
+public class MaterializeFrameNode extends FixedWithNextNode implements Node.IterableNodeType {
 
     @Input private ValueNode frame;
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java	Tue Sep 10 09:30:09 2013 -0700
@@ -27,7 +27,6 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.runtime.*;
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.nodes.spi.*;
@@ -43,7 +42,7 @@
  * Intrinsic node representing the call for creating a frame in the {@link OptimizedCallTarget}
  * class.
  */
-public class NewFrameNode extends FixedWithNextNode implements IterableNodeType, VirtualizableAllocation, Canonicalizable {
+public class NewFrameNode extends FixedWithNextNode implements Node.IterableNodeType, VirtualizableAllocation, Canonicalizable {
 
     static final ResolvedJavaType FRAME_TYPE = Graal.getRequiredCapability(MetaAccessProvider.class).lookupJavaType(FrameWithoutBoxing.class);
 
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/VerifyNoIntrinsicsLeftPhase.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/phases/VerifyNoIntrinsicsLeftPhase.java	Tue Sep 10 09:30:09 2013 -0700
@@ -23,7 +23,6 @@
 package com.oracle.graal.truffle.phases;
 
 import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.Node.IterableNodeType;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.truffle.*;
@@ -40,7 +39,7 @@
         verifyNoInstanceLeft(graph, NewFrameNode.class);
     }
 
-    public static <T extends Node & IterableNodeType> void verifyNoInstanceLeft(StructuredGraph graph, Class<T> clazz) {
+    public static <T extends Node & Node.IterableNodeType> void verifyNoInstanceLeft(StructuredGraph graph, Class<T> clazz) {
         if (graph.getNodes(clazz).count() != 0) {
             throw new VerificationError("Found unexpected node(s): %s", graph.getNodes(clazz));
         }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Tue Sep 10 09:30:09 2013 -0700
@@ -2003,6 +2003,10 @@
                 startCallTypeSystemMethod(getContext(), builder, child.getNodeData(), cast.getMethodName());
             }
 
+            if (targetExecutable.getType().needsCastTo(context, targetParameter.getTypeSystemType()) && cast == null) {
+                startCallTypeSystemMethod(getContext(), builder, child.getNodeData(), TypeSystemCodeGenerator.expectTypeMethodName(targetParameter.getTypeSystemType()));
+            }
+
             NodeData node = getModel().getNode();
             ActualParameter sourceParameter = sourceExecutable.findParameter(targetParameter.getLocalName());
             if (sourceParameter == null) {
@@ -2011,6 +2015,11 @@
                 CodeTree var = CodeTreeBuilder.singleString(valueNameEvaluated(targetParameter));
                 builder.tree(createExpectExecutableType(node, sourceParameter.getTypeSystemType(), targetExecutable, var));
             }
+
+            if (targetExecutable.getType().needsCastTo(context, targetParameter.getTypeSystemType())) {
+                builder.end().end();
+            }
+
             if (cast != null) {
                 builder.end().end();
             }
@@ -2049,6 +2058,10 @@
         }
 
         private boolean hasUnexpectedType(ExecutableTypeData target, ActualParameter sourceParameter, TypeData type) {
+            boolean targetCast = target.getType().needsCastTo(context, type);
+            if (targetCast && getModel().getNode().getTypeSystem().lookupCast(target.getType(), type) == null) {
+                return true;
+            }
             if (sourceParameter == null) {
                 return target.hasUnexpectedValue(getContext());
             } else {
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemParser.java	Mon Sep 09 10:30:42 2013 -0700
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemParser.java	Tue Sep 10 09:30:09 2013 -0700
@@ -108,7 +108,6 @@
             cast.getTargetType().addTypeCast(cast);
         }
 
-        verifyImplicitCasts(typeSystem);
         verifyGenericTypeChecksAndCasts(typeSystem);
         verifyMethodSignatures(typeSystem);
         verifyNamesUnique(typeSystem);
@@ -116,24 +115,6 @@
         return typeSystem;
     }
 
-    private static void verifyImplicitCasts(TypeSystemData typeSystem) {
-        Set<TypeData> types = new HashSet<>();
-        Set<TypeData> duplicateSourceTypes = new HashSet<>();
-        for (ImplicitCastData cast : typeSystem.getImplicitCasts()) {
-            if (types.contains(cast.getSourceType())) {
-                duplicateSourceTypes.add(cast.getSourceType());
-            }
-            types.add(cast.getSourceType());
-        }
-        for (TypeData duplicateType : duplicateSourceTypes) {
-            for (ImplicitCastData cast : typeSystem.getImplicitCasts()) {
-                if (cast.getSourceType().equals(duplicateType)) {
-                    cast.addError("Duplicate cast source type %s.", Utils.getSimpleName(duplicateType.getPrimitiveType()), ImplicitCast.class.getSimpleName());
-                }
-            }
-        }
-    }
-
     private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) {
         for (TypeData type : typeSystem.getTypes()) {
             if (!type.getTypeChecks().isEmpty()) {
--- a/src/share/vm/classfile/vmSymbols.hpp	Mon Sep 09 10:30:42 2013 -0700
+++ b/src/share/vm/classfile/vmSymbols.hpp	Tue Sep 10 09:30:09 2013 -0700
@@ -356,6 +356,7 @@
   template(compileMethod_signature,               "(JLcom/oracle/graal/hotspot/meta/HotSpotResolvedObjectType;IZ)V")                  \
   template(setOption_name,                        "setOption")                                                                        \
   template(setOption_signature,                   "(Ljava/lang/String;)Z")                                                            \
+  template(finalizeOptions_name,                  "finalizeOptions")                                                                  \
   template(createUnresolvedJavaMethod_name,       "createUnresolvedJavaMethod")                                                       \
   template(createUnresolvedJavaMethod_signature,  "(Ljava/lang/String;Ljava/lang/String;Lcom/oracle/graal/api/meta/JavaType;)Lcom/oracle/graal/api/meta/JavaMethod;") \
   template(createSignature_name,                  "createSignature")                                                                  \
--- a/src/share/vm/graal/graalCompiler.cpp	Mon Sep 09 10:30:42 2013 -0700
+++ b/src/share/vm/graal/graalCompiler.cpp	Tue Sep 10 09:30:09 2013 -0700
@@ -95,6 +95,8 @@
         vm_abort(false);
       }
     }
+    VMToCompiler::finalizeOptions();
+
     if (UseCompiler) {
       VMToCompiler::startCompiler(BootstrapGraal);
       _initialized = true;
--- a/src/share/vm/graal/graalVMToCompiler.cpp	Mon Sep 09 10:30:42 2013 -0700
+++ b/src/share/vm/graal/graalVMToCompiler.cpp	Tue Sep 10 09:30:09 2013 -0700
@@ -90,23 +90,31 @@
 }
 
 void VMToCompiler::initOptions() {
-  KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions());
+  KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions());
   Thread* THREAD = Thread::current();
-  compilerKlass->initialize(THREAD);
+  optionsKlass->initialize(THREAD);
   check_pending_exception("Error while calling initOptions");
 }
 
 jboolean VMToCompiler::setOption(Handle option) {
   assert(!option.is_null(), "");
-  KlassHandle compilerKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions());
+  KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions());
 
   Thread* THREAD = Thread::current();
   JavaValue result(T_BOOLEAN);
-  JavaCalls::call_static(&result, compilerKlass, vmSymbols::setOption_name(), vmSymbols::setOption_signature(), option, THREAD);
+  JavaCalls::call_static(&result, optionsKlass, vmSymbols::setOption_name(), vmSymbols::setOption_signature(), option, THREAD);
   check_pending_exception("Error while calling setOption");
   return result.get_jboolean();
 }
 
+void VMToCompiler::finalizeOptions() {
+  KlassHandle optionsKlass = loadClass(vmSymbols::com_oracle_graal_hotspot_HotSpotOptions());
+  Thread* THREAD = Thread::current();
+  JavaValue result(T_VOID);
+  JavaCalls::call_static(&result, optionsKlass, vmSymbols::finalizeOptions_name(), vmSymbols::void_method_signature(), THREAD);
+  check_pending_exception("Error while calling finalizeOptions");
+}
+
 void VMToCompiler::compileMethod(Method* method, Handle holder, int entry_bci, jboolean blocking) {
   assert(method != NULL, "just checking");
   assert(!holder.is_null(), "just checking");
--- a/src/share/vm/graal/graalVMToCompiler.hpp	Mon Sep 09 10:30:42 2013 -0700
+++ b/src/share/vm/graal/graalVMToCompiler.hpp	Tue Sep 10 09:30:09 2013 -0700
@@ -57,6 +57,9 @@
   // public static boolean HotSpotOptions.setOption(String option);
   static jboolean setOption(Handle option);
 
+  // public static void HotSpotOptions.finalizeOptions();
+  static void finalizeOptions();
+
   // public abstract boolean compileMethod(long vmId, String name, int entry_bci, boolean blocking);
   static void compileMethod(Method* method, Handle holder, int entry_bci, jboolean blocking);