changeset 14884:1617b1e25d31

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 19 Mar 2014 11:43:57 +0100
parents 54fa8e06831c (current diff) aef9e4224076 (diff)
children 000c283d7b71
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/Marks.java
diffstat 62 files changed, 602 insertions(+), 277 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ObjectLocationIdentity.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ObjectLocationIdentity.java	Wed Mar 19 11:43:57 2014 +0100
@@ -25,7 +25,7 @@
 import java.util.*;
 
 /**
- * A {@link LocationIdentity} warpping an object.
+ * A {@link LocationIdentity} wrapping an object.
  */
 public final class ObjectLocationIdentity implements LocationIdentity {
 
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Wed Mar 19 11:43:57 2014 +0100
@@ -360,9 +360,9 @@
     }
 
     @Override
-    public void emitNullCheck(ValueNode v, DeoptimizingNode deoping) {
-        assert v.stamp() instanceof ObjectStamp;
-        append(new AMD64Move.NullCheckOp(load(operand(v)), state(deoping)));
+    public void emitNullCheck(ValueNode v, DeoptimizingNode deopt) {
+        assert v.kind() == Kind.Object : v + " - " + v.stamp() + " @ " + deopt;
+        append(new AMD64Move.NullCheckOp(load(operand(v)), state(deopt)));
     }
 
     @Override
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Mar 19 11:43:57 2014 +0100
@@ -200,7 +200,7 @@
 
         SchedulePhase schedule = new SchedulePhase();
         schedule.apply(graph);
-        Debug.dump(schedule, "final schedule");
+        Debug.dump(schedule, "Final HIR schedule");
         return schedule;
 
     }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Mar 19 11:43:57 2014 +0100
@@ -167,7 +167,7 @@
      * @return the scope entered by this method which will be exited when its {@link Scope#close()}
      *         method is called
      */
-    public static Scope scope(String name, Object... context) {
+    public static Scope scope(CharSequence name, Object... context) {
         if (ENABLED) {
             return DebugScope.getInstance().scope(name, null, context);
         } else {
@@ -195,7 +195,7 @@
      * @return the scope entered by this method which will be exited when its {@link Scope#close()}
      *         method is called
      */
-    public static Scope sandbox(String name, DebugConfig config, Object... context) {
+    public static Scope sandbox(CharSequence name, DebugConfig config, Object... context) {
         if (ENABLED) {
             DebugConfig sandboxConfig = config == null ? silentConfig() : config;
             return DebugScope.getInstance().scope(name, sandboxConfig, context);
@@ -379,11 +379,11 @@
      * <p>
      * A disabled metric has virtually no overhead.
      */
-    public static DebugMetric metric(String name) {
-        if (Boolean.getBoolean(ENABLE_METRIC_PROPERTY_NAME_PREFIX + name)) {
-            return new MetricImpl(name, false);
+    public static DebugMetric metric(CharSequence name) {
+        if (enabledMetrics != null && enabledMetrics.contains(name.toString())) {
+            return new MetricImpl(name.toString(), false);
         } else if (ENABLED) {
-            return new MetricImpl(name, true);
+            return new MetricImpl(name.toString(), true);
         } else {
             return VOID_METRIC;
         }
@@ -495,15 +495,33 @@
     };
 
     /**
-     * @see #timer(String)
+     * @see #timer(CharSequence)
      */
     public static final String ENABLE_TIMER_PROPERTY_NAME_PREFIX = "graal.debug.timer.";
 
     /**
-     * @see #metric(String)
+     * @see #metric(CharSequence)
      */
     public static final String ENABLE_METRIC_PROPERTY_NAME_PREFIX = "graal.debug.metric.";
 
+    private static final Set<String> enabledMetrics;
+    private static final Set<String> enabledTimers;
+    static {
+        Set<String> metrics = new HashSet<>();
+        Set<String> timers = new HashSet<>();
+        for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
+            String name = e.getKey().toString();
+            if (name.startsWith(ENABLE_METRIC_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) {
+                metrics.add(name.substring(ENABLE_METRIC_PROPERTY_NAME_PREFIX.length()));
+            }
+            if (name.startsWith(ENABLE_TIMER_PROPERTY_NAME_PREFIX) && Boolean.parseBoolean(e.getValue().toString())) {
+                timers.add(name.substring(ENABLE_TIMER_PROPERTY_NAME_PREFIX.length()));
+            }
+        }
+        enabledMetrics = metrics.isEmpty() ? null : metrics;
+        enabledTimers = timers.isEmpty() ? null : timers;
+    }
+
     /**
      * Creates a {@linkplain DebugTimer timer} that is enabled iff debugging is
      * {@linkplain #isEnabled() enabled} or the system property whose name is formed by adding to
@@ -514,11 +532,11 @@
      * <p>
      * A disabled timer has virtually no overhead.
      */
-    public static DebugTimer timer(String name) {
-        if (Boolean.getBoolean(ENABLE_TIMER_PROPERTY_NAME_PREFIX + name)) {
-            return new TimerImpl(name, false);
+    public static DebugTimer timer(CharSequence name) {
+        if (enabledTimers != null && enabledTimers.contains(name.toString())) {
+            return new TimerImpl(name.toString(), false);
         } else if (ENABLED) {
-            return new TimerImpl(name, true);
+            return new TimerImpl(name.toString(), true);
         } else {
             return VOID_TIMER;
         }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugConfig.java	Wed Mar 19 11:43:57 2014 +0100
@@ -45,7 +45,7 @@
      * Determines if metering is enabled in the {@linkplain Debug#currentScope() current debug
      * scope}.
      * 
-     * @see Debug#metric(String)
+     * @see Debug#metric(CharSequence)
      */
     boolean isMeterEnabled();
 
@@ -76,7 +76,7 @@
     void removeFromContext(Object o);
 
     /**
-     * @see Debug#timer(String)
+     * @see Debug#timer(CharSequence)
      */
     boolean isTimeEnabled();
 
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugHistogram.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/DebugHistogram.java	Wed Mar 19 11:43:57 2014 +0100
@@ -72,6 +72,10 @@
             count++;
         }
 
+        public void add(int n) {
+            count += n;
+        }
+
         public int getCount() {
             return count;
         }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Mar 19 11:43:57 2014 +0100
@@ -231,13 +231,13 @@
      * @param newContextObjects objects to be appended to the debug context
      * @return the new scope which will be exited when its {@link #close()} method is called
      */
-    public DebugScope scope(String name, DebugConfig sandboxConfig, Object... newContextObjects) {
+    public DebugScope scope(CharSequence name, DebugConfig sandboxConfig, Object... newContextObjects) {
         DebugScope newScope = null;
         if (sandboxConfig != null) {
-            newScope = new DebugScope(name, name, this, true, newContextObjects);
+            newScope = new DebugScope(name.toString(), name.toString(), this, true, newContextObjects);
             configTL.set(sandboxConfig);
         } else {
-            newScope = this.createChild(name, newContextObjects);
+            newScope = this.createChild(name.toString(), newContextObjects);
         }
         instanceTL.set(newScope);
         newScope.updateFlags();
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java	Wed Mar 19 11:43:57 2014 +0100
@@ -458,6 +458,7 @@
      * newInput: removes this node from oldInput's usages and adds this node to newInput's usages.
      */
     protected void updateUsages(Node oldInput, Node newInput) {
+        assert isAlive() && (newInput == null || newInput.isAlive()) : "adding " + newInput + " to " + this + " instead of " + oldInput;
         if (oldInput != newInput) {
             if (oldInput != null) {
                 if (oldInput.recordsUsages()) {
@@ -482,6 +483,7 @@
      * this node to newSuccessor's predecessors.
      */
     protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) {
+        assert isAlive() && (newSuccessor == null || newSuccessor.isAlive()) : "adding " + newSuccessor + " to " + this + " instead of " + oldSuccessor;
         assert graph == null || !graph.isFrozen();
         if (oldSuccessor != newSuccessor) {
             if (oldSuccessor != null) {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Wed Mar 19 11:43:57 2014 +0100
@@ -41,8 +41,8 @@
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.nfi.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
@@ -249,7 +249,7 @@
     public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedEntry) {
         HotSpotProviders providers = getProviders();
         if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) {
-            crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY);
+            MarkId.recordMark(crb, MarkId.UNVERIFIED_ENTRY);
             CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, new JavaType[]{providers.getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false);
             Register inlineCacheKlass = rax; // see definition of IC_Klass in
                                              // c1_LIRAssembler_x86.cpp
@@ -271,9 +271,9 @@
         }
 
         asm.align(config.codeEntryAlignment);
-        crb.recordMark(Marks.MARK_OSR_ENTRY);
+        MarkId.recordMark(crb, MarkId.OSR_ENTRY);
         asm.bind(verifiedEntry);
-        crb.recordMark(Marks.MARK_VERIFIED_ENTRY);
+        MarkId.recordMark(crb, MarkId.VERIFIED_ENTRY);
     }
 
     /**
@@ -293,9 +293,9 @@
         HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
         if (!frameContext.isStub) {
             HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls();
-            crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY);
+            MarkId.recordMark(crb, MarkId.EXCEPTION_HANDLER_ENTRY);
             AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null);
-            crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY);
+            MarkId.recordMark(crb, MarkId.DEOPT_HANDLER_ENTRY);
             AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null);
         } else {
             // No need to emit the stubs for entries back into the method since
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -24,13 +24,13 @@
 
 import static com.oracle.graal.amd64.AMD64.*;
 import static com.oracle.graal.asm.NumUtil.*;
-import static com.oracle.graal.hotspot.bridge.Marks.*;
 import static com.oracle.graal.phases.GraalOptions.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.asm.*;
@@ -82,21 +82,21 @@
             // co-located with the immutable code.
             asm.movq(scratch, (AMD64Address) crb.recordDataReferenceInCode(pollingPageAddress, alignment));
             final int pos = asm.position();
-            crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR);
+            MarkId.recordMark(crb, atReturn ? MarkId.POLL_RETURN_FAR : MarkId.POLL_FAR);
             if (state != null) {
                 crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
             }
             asm.testl(rax, new AMD64Address(scratch));
         } else if (isPollingPageFar(config)) {
             asm.movq(scratch, config.safepointPollingAddress);
-            crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR);
+            MarkId.recordMark(crb, atReturn ? MarkId.POLL_RETURN_FAR : MarkId.POLL_FAR);
             final int pos = asm.position();
             if (state != null) {
                 crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
             }
             asm.testl(rax, new AMD64Address(scratch));
         } else {
-            crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR);
+            MarkId.recordMark(crb, atReturn ? MarkId.POLL_RETURN_NEAR : MarkId.POLL_NEAR);
             final int pos = asm.position();
             if (state != null) {
                 crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -26,7 +26,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
@@ -55,7 +55,7 @@
         // The mark for an invocation that uses an inline cache must be placed at the
         // instruction that loads the Klass from the inline cache.
         AMD64Move.move(crb, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod);
-        crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL);
+        MarkId.recordMark(crb, invokeKind == InvokeKind.Static ? MarkId.INVOKESTATIC : MarkId.INVOKESPECIAL);
         // This must be emitted exactly like this to ensure it's patchable
         masm.movq(AMD64.rax, HotSpotGraalRuntime.runtime().getConfig().nonOopBits);
         super.emitCode(crb, masm);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -28,7 +28,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.AMD64Call.DirectCallOp;
 import com.oracle.graal.lir.asm.*;
@@ -53,7 +53,7 @@
     public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
         // The mark for an invocation that uses an inline cache must be placed at the
         // instruction that loads the Klass from the inline cache.
-        crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE);
+        MarkId.recordMark(crb, invokeKind == Virtual ? MarkId.INVOKEVIRTUAL : MarkId.INVOKEINTERFACE);
         // This must be emitted exactly like this to ensure it's patchable
         masm.movq(AMD64.rax, HotSpotGraalRuntime.runtime().getConfig().nonOopBits);
         super.emitCode(crb, masm);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -29,7 +29,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.amd64.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.amd64.*;
 import com.oracle.graal.lir.amd64.AMD64Call.IndirectCallOp;
@@ -58,7 +58,7 @@
 
     @Override
     public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
-        crb.recordMark(Marks.MARK_INLINE_INVOKE);
+        MarkId.recordMark(crb, MarkId.INLINE_INVOKE);
         Register callReg = asRegister(targetAddress);
         assert !callReg.equals(METHOD);
         AMD64Call.indirectCall(crb, masm, callReg, callTarget, state);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Wed Mar 19 11:43:57 2014 +0100
@@ -34,8 +34,8 @@
 import com.oracle.graal.compiler.gen.LIRGenerator;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.stubs.Stub;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.StandardOp.*;
@@ -189,7 +189,7 @@
         // Emit the prefix
 
         if (unverifiedStub != null) {
-            crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY);
+            MarkId.recordMark(crb, MarkId.UNVERIFIED_ENTRY);
             // We need to use JavaCall here because we haven't entered the frame yet.
             CallingConvention cc = regConfig.getCallingConvention(JavaCall, null, new JavaType[]{getProviders().getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false);
             Register inlineCacheKlass = g5; // see MacroAssembler::ic_call
@@ -204,8 +204,8 @@
         }
 
         masm.align(config.codeEntryAlignment);
-        crb.recordMark(Marks.MARK_OSR_ENTRY);
-        crb.recordMark(Marks.MARK_VERIFIED_ENTRY);
+        MarkId.recordMark(crb, MarkId.OSR_ENTRY);
+        MarkId.recordMark(crb, MarkId.VERIFIED_ENTRY);
 
         // Emit code for the LIR
         crb.emit(lir);
@@ -213,9 +213,9 @@
         HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
         HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls();
         if (!frameContext.isStub) {
-            crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY);
+            MarkId.recordMark(crb, MarkId.EXCEPTION_HANDLER_ENTRY);
             SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null);
-            crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY);
+            MarkId.recordMark(crb, MarkId.DEOPT_HANDLER_ENTRY);
             SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null);
         } else {
             // No need to emit the stubs for entries back into the method since
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -23,13 +23,13 @@
 package com.oracle.graal.hotspot.sparc;
 
 import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
-import static com.oracle.graal.hotspot.bridge.Marks.*;
 import static com.oracle.graal.sparc.SPARC.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.lir.asm.*;
@@ -61,7 +61,7 @@
     public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) {
         final int pos = masm.position();
         new Setx(config.safepointPollingAddress, scratch).emit(masm);
-        crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR);
+        MarkId.recordMark(crb, atReturn ? MarkId.POLL_RETURN_FAR : MarkId.POLL_FAR);
         if (state != null) {
             crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT);
         }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -28,7 +28,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp;
@@ -42,7 +42,6 @@
 @Opcode("CALL_DIRECT")
 final class SPARCHotspotDirectStaticCallOp extends DirectCallOp {
 
-    private static final long nonOopBits = HotSpotGraalRuntime.runtime().getConfig().nonOopBits;
     private final Constant metaspaceMethod;
     private final InvokeKind invokeKind;
 
@@ -58,9 +57,9 @@
         // The mark for an invocation that uses an inline cache must be placed at the
         // instruction that loads the Klass from the inline cache.
         SPARCMove.move(crb, masm, g5.asValue(Kind.Long), metaspaceMethod);
-        crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL);
+        MarkId.recordMark(crb, invokeKind == InvokeKind.Static ? MarkId.INVOKESTATIC : MarkId.INVOKESPECIAL);
         // SPARCMove.move(crb, masm, g3.asValue(Kind.Long), Constant.LONG_0);
-        new Setx(nonOopBits, g3, true).emit(masm);
+        new Setx(HotSpotGraalRuntime.runtime().getConfig().nonOopBits, g3, true).emit(masm);
         super.emitCode(crb, masm);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -29,7 +29,7 @@
 import com.oracle.graal.asm.sparc.*;
 import com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.sparc.SPARCCall.DirectCallOp;
 import com.oracle.graal.lir.asm.*;
@@ -54,7 +54,7 @@
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
         // The mark for an invocation that uses an inline cache must be placed at the
         // instruction that loads the Klass from the inline cache.
-        crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE);
+        MarkId.recordMark(crb, invokeKind == Virtual ? MarkId.INVOKEVIRTUAL : MarkId.INVOKEINTERFACE);
         new Setx(HotSpotGraalRuntime.runtime().getConfig().nonOopBits, g3, true).emit(masm);
         super.emitCode(crb, masm);
     }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java	Wed Mar 19 11:43:57 2014 +0100
@@ -29,7 +29,7 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.asm.sparc.*;
-import com.oracle.graal.hotspot.bridge.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.sparc.*;
 import com.oracle.graal.lir.sparc.SPARCCall.IndirectCallOp;
@@ -58,7 +58,7 @@
 
     @Override
     public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-        crb.recordMark(Marks.MARK_INLINE_INVOKE);
+        MarkId.recordMark(crb, MarkId.INLINE_INVOKE);
         Register callReg = asRegister(targetAddress);
         assert !callReg.equals(METHOD);
         SPARCCall.indirectCall(crb, masm, callReg, callTarget, state);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java	Wed Mar 19 11:43:57 2014 +0100
@@ -27,7 +27,6 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.target.*;
-import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
 import com.oracle.graal.hotspot.stubs.*;
 import com.oracle.graal.lir.*;
@@ -51,7 +50,8 @@
 
     /**
      * Descriptor for {@link ExceptionHandlerStub}. This stub is called by the
-     * {@linkplain Marks#MARK_EXCEPTION_HANDLER_ENTRY exception handler} in a compiled method.
+     * {@linkplain HotSpotVMConfig#codeInstallerMarkIdExceptionHandlerEntry exception handler} in a
+     * compiled method.
      */
     public static final ForeignCallDescriptor EXCEPTION_HANDLER = new ForeignCallDescriptor("exceptionHandler", void.class, Object.class, Word.class);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Mar 19 11:43:57 2014 +0100
@@ -1422,6 +1422,22 @@
     @HotSpotVMConstant(name = "CompilerToVM::KLASS_TAG") @Stable public int compilerToVMKlassTag;
     @HotSpotVMConstant(name = "CompilerToVM::SYMBOL_TAG") @Stable public int compilerToVMSymbolTag;
 
+    @HotSpotVMConstant(name = "CodeInstaller::VERIFIED_ENTRY") @Stable public int codeInstallerMarkIdVerifiedEntry;
+    @HotSpotVMConstant(name = "CodeInstaller::UNVERIFIED_ENTRY") @Stable public int codeInstallerMarkIdUnverifiedEntry;
+    @HotSpotVMConstant(name = "CodeInstaller::OSR_ENTRY") @Stable public int codeInstallerMarkIdOsrEntry;
+    @HotSpotVMConstant(name = "CodeInstaller::EXCEPTION_HANDLER_ENTRY") @Stable public int codeInstallerMarkIdExceptionHandlerEntry;
+    @HotSpotVMConstant(name = "CodeInstaller::DEOPT_HANDLER_ENTRY") @Stable public int codeInstallerMarkIdDeoptHandlerEntry;
+    @HotSpotVMConstant(name = "CodeInstaller::INVOKEINTERFACE") @Stable public int codeInstallerMarkIdInvokeinterface;
+    @HotSpotVMConstant(name = "CodeInstaller::INVOKEVIRTUAL") @Stable public int codeInstallerMarkIdInvokevirtual;
+    @HotSpotVMConstant(name = "CodeInstaller::INVOKESTATIC") @Stable public int codeInstallerMarkIdInvokestatic;
+    @HotSpotVMConstant(name = "CodeInstaller::INVOKESPECIAL") @Stable public int codeInstallerMarkIdInvokespecial;
+    @HotSpotVMConstant(name = "CodeInstaller::INLINE_INVOKE") @Stable public int codeInstallerMarkIdInlineInvoke;
+    @HotSpotVMConstant(name = "CodeInstaller::POLL_NEAR") @Stable public int codeInstallerMarkIdPollNear;
+    @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_NEAR") @Stable public int codeInstallerMarkIdPollReturnNear;
+    @HotSpotVMConstant(name = "CodeInstaller::POLL_FAR") @Stable public int codeInstallerMarkIdPollFar;
+    @HotSpotVMConstant(name = "CodeInstaller::POLL_RETURN_FAR") @Stable public int codeInstallerMarkIdPollReturnFar;
+    @HotSpotVMConstant(name = "CodeInstaller::INVOKE_INVALID") @Stable public int codeInstallerMarkIdInvokeInvalid;
+
     public boolean check() {
         for (Field f : getClass().getDeclaredFields()) {
             int modifiers = f.getModifiers();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/Marks.java	Mon Mar 17 16:43:34 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 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;
-
-/**
- * Constants used to mark special positions in code being installed into the code cache by Graal C++
- * code. These constants need to be kept in sync with those of the same name defined in
- * graalCodeInstaller.hpp.
- */
-public interface Marks {
-
-    int MARK_VERIFIED_ENTRY = 1;
-    int MARK_UNVERIFIED_ENTRY = 2;
-    int MARK_OSR_ENTRY = 3;
-    int MARK_EXCEPTION_HANDLER_ENTRY = 4;
-    int MARK_DEOPT_HANDLER_ENTRY = 5;
-    int MARK_INVOKEINTERFACE = 6;
-    int MARK_INVOKEVIRTUAL = 7;
-    int MARK_INVOKESTATIC = 8;
-    int MARK_INVOKESPECIAL = 9;
-    int MARK_INLINE_INVOKE = 10;
-    int MARK_POLL_NEAR = 11;
-    int MARK_POLL_RETURN_NEAR = 12;
-    int MARK_POLL_FAR = 13;
-    int MARK_POLL_RETURN_FAR = 14;
-}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java	Wed Mar 19 11:43:57 2014 +0100
@@ -50,10 +50,10 @@
  * infrastructure is enabled by specifying either the GenericDynamicCounters or
  * BenchmarkDynamicCounters option.<br/>
  * 
- * The counters are kept in a special area in the native JavaThread object, and the number of
- * counters is configured in {@code thread.hpp (GRAAL_COUNTERS_SIZE)}. This file also contains an
- * option to exclude compiler threads ({@code GRAAL_COUNTERS_EXCLUDE_COMPILER_THREADS}, which
- * defaults to true).
+ * The counters are kept in a special area allocated for each native JavaThread object, and the
+ * number of counters is configured using {@code -XX:GraalCounterSize=value}.
+ * {@code -XX:+/-GraalCountersExcludeCompiler} configures whether to exclude compiler threads
+ * (defaults to true).
  * 
  * The subsystems that use the logging need to have their own options to turn on the counters, and
  * insert DynamicCounterNodes when they're enabled.
@@ -64,12 +64,10 @@
  * <h1>Example</h1> In order to create statistics about allocations within the DaCapo pmd benchmark
  * the following steps are necessary:
  * <ul>
- * <li>Modify {@code thread.hpp}: increase GRAAL_COUNTER_SIZE. The actual required value depends on
- * the granularity of the profiling, 10000 should be enough for most cases. This will increase the
- * JavaThread structure by 80kb.</li>
- * <li>Also in {@code thread.hpp}: GRAAL_COUNTERS_EXCLUDE_COMPILER_THREADS specifies whether the
- * numbers generated by compiler threads should be excluded (default: true).</li>
- * <li>Build the Graal VM.</li>
+ * <li>Set {@code -XX:GraalCounterSize=value}. The actual required value depends on the granularity
+ * of the profiling, 10000 should be enough for most cases.</li>
+ * <li>Also: {@code -XX:+/-GraalCountersExcludeCompiler} specifies whether the numbers generated by
+ * compiler threads should be excluded (default: true).</li>
  * <li>Start the DaCapo pmd benchmark with
  * {@code "-G:BenchmarkDynamicCounters=err, starting ====, PASSED in "} and
  * {@code -G:+ProfileAllocations}.</li>
@@ -330,7 +328,7 @@
 
             int index = BenchmarkCounters.getIndex(counter);
             if (index >= config.graalCountersSize) {
-                throw new GraalInternalError("too many counters, reduce number of counters or increase GRAAL_COUNTERS_SIZE (current value: " + config.graalCountersSize + ")");
+                throw new GraalInternalError("too many counters, reduce number of counters or increase -XX:GraalCounterSize=... (current value: " + config.graalCountersSize + ")");
             }
             ConstantLocationNode arrayLocation = ConstantLocationNode.create(LocationIdentity.ANY_LOCATION, Kind.Long, config.graalCountersThreadOffset, graph);
             ReadNode readArray = graph.add(new ReadNode(thread, arrayLocation, StampFactory.forKind(wordKind), BarrierType.NONE, false));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Wed Mar 19 11:43:57 2014 +0100
@@ -36,11 +36,13 @@
 import com.oracle.graal.api.code.CompilationResult.PrimitiveData;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
 import com.oracle.graal.hotspot.data.*;
 import com.oracle.graal.java.*;
+import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.printer.*;
 
 /**
@@ -60,6 +62,54 @@
 
     protected abstract RegisterConfig createRegisterConfig();
 
+    /**
+     * Constants used to mark special positions in code being installed into the code cache by Graal
+     * C++ code.
+     */
+    public enum MarkId {
+        VERIFIED_ENTRY(config().codeInstallerMarkIdVerifiedEntry),
+        UNVERIFIED_ENTRY(config().codeInstallerMarkIdUnverifiedEntry),
+        OSR_ENTRY(config().codeInstallerMarkIdOsrEntry),
+        EXCEPTION_HANDLER_ENTRY(config().codeInstallerMarkIdExceptionHandlerEntry),
+        DEOPT_HANDLER_ENTRY(config().codeInstallerMarkIdDeoptHandlerEntry),
+        INVOKEINTERFACE(config().codeInstallerMarkIdInvokeinterface),
+        INVOKEVIRTUAL(config().codeInstallerMarkIdInvokevirtual),
+        INVOKESTATIC(config().codeInstallerMarkIdInvokestatic),
+        INVOKESPECIAL(config().codeInstallerMarkIdInvokespecial),
+        INLINE_INVOKE(config().codeInstallerMarkIdInlineInvoke),
+        POLL_NEAR(config().codeInstallerMarkIdPollNear),
+        POLL_RETURN_NEAR(config().codeInstallerMarkIdPollReturnNear),
+        POLL_FAR(config().codeInstallerMarkIdPollFar),
+        POLL_RETURN_FAR(config().codeInstallerMarkIdPollReturnFar);
+
+        private final int value;
+
+        private MarkId(int value) {
+            this.value = value;
+        }
+
+        private static HotSpotVMConfig config() {
+            return HotSpotGraalRuntime.runtime().getConfig();
+        }
+
+        public static MarkId getEnum(int value) {
+            for (MarkId e : values()) {
+                if (e.value == value) {
+                    return e;
+                }
+            }
+            throw GraalInternalError.shouldNotReachHere("unknown enum value " + value);
+        }
+
+        /**
+         * Helper method to {@link CompilationResultBuilder#recordMark(Object) record a mark} with a
+         * {@link CompilationResultBuilder}.
+         */
+        public static void recordMark(CompilationResultBuilder crb, MarkId mark) {
+            crb.recordMark(mark.value);
+        }
+    }
+
     @Override
     public String disassemble(CompilationResult compResult, InstalledCode installedCode) {
         byte[] code = installedCode == null ? Arrays.copyOf(compResult.getTargetCode(), compResult.getTargetCodeSize()) : installedCode.getCode();
@@ -88,7 +138,7 @@
                 hcf.addOperandComment(site.pcOffset, "{" + site.data.toString() + "}");
             }
             for (Mark mark : compResult.getMarks()) {
-                hcf.addComment(mark.pcOffset, getMarkName(mark));
+                hcf.addComment(mark.pcOffset, MarkId.getEnum((int) mark.id).toString());
             }
         }
         return hcf.toEmbeddedString();
@@ -114,25 +164,6 @@
         return String.valueOf(call.target);
     }
 
-    /**
-     * Decodes a mark to a mnemonic if possible.
-     */
-    private static String getMarkName(Mark mark) {
-        Field[] fields = Marks.class.getDeclaredFields();
-        for (Field f : fields) {
-            if (Modifier.isStatic(f.getModifiers()) && f.getName().startsWith("MARK_")) {
-                f.setAccessible(true);
-                try {
-                    if (f.get(null).equals(mark.id)) {
-                        return f.getName();
-                    }
-                } catch (Exception e) {
-                }
-            }
-        }
-        return "MARK:" + mark.id;
-    }
-
     private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) {
         if (!compResult.getExceptionHandlers().isEmpty()) {
             String nl = HexCodeFile.NEW_LINE;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java	Wed Mar 19 11:43:57 2014 +0100
@@ -757,7 +757,7 @@
         ValueNode arrayLength = readArrayLength(n.graph(), array, tool.getConstantReflection());
         if (arrayLength == null) {
             Stamp stamp = StampFactory.positiveInt();
-            ReadNode readArrayLength = g.add(new ReadNode(array, ConstantLocationNode.create(FINAL_LOCATION, Kind.Int, runtime.getConfig().arrayLengthOffset, g), stamp, BarrierType.NONE, false));
+            ReadNode readArrayLength = g.add(new ReadNode(array, ConstantLocationNode.create(ARRAY_LENGTH_LOCATION, Kind.Int, runtime.getConfig().arrayLengthOffset, g), stamp, BarrierType.NONE, false));
             g.addBeforeFixed(n, readArrayLength);
             readArrayLength.setGuard(createNullCheck(array, readArrayLength, tool));
             arrayLength = readArrayLength;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java	Wed Mar 19 11:43:57 2014 +0100
@@ -373,9 +373,8 @@
     }
 
     /**
-     * Gets the compilation level of the currently installed code for this method.
-     * 
-     * @return compilation level
+     * @param level
+     * @return true if the currently installed code was generated at {@code level}.
      */
     public boolean hasCompiledCodeAtLevel(int level) {
         long compiledCode = getCompiledCode();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java	Wed Mar 19 11:43:57 2014 +0100
@@ -363,6 +363,10 @@
     @Override
     public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) {
         assert method instanceof HotSpotMethod;
+        if (!isAbstract(method.getModifiers()) && method.getDeclaringClass().equals(this)) {
+            return method;
+        }
+
         final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(metaspaceKlass(), method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor());
         if (resolvedMetaspaceMethod == 0) {
             return null;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Wed Mar 19 11:43:57 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -31,16 +31,16 @@
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.hotspot.nodes.*;
 import com.oracle.graal.replacements.*;
 import com.oracle.graal.replacements.Snippet.*;
 import com.oracle.graal.word.*;
 
 /**
- * Stub called by the {@linkplain Marks#MARK_EXCEPTION_HANDLER_ENTRY exception handler entry point}
- * in a compiled method. This entry point is used when returning to a method to handle an exception
+ * Stub called by the {@linkplain MarkId#EXCEPTION_HANDLER_ENTRY exception handler entry point} in a
+ * compiled method. This entry point is used when returning to a method to handle an exception
  * thrown by a callee. It is not used for routing implicit exceptions. Therefore, it does not need
  * to save any registers as HotSpot uses a caller save convention.
  * <p>
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Wed Mar 19 11:43:57 2014 +0100
@@ -70,7 +70,7 @@
     public static final class RuntimeCalls {
 
         public static final ForeignCallDescriptor CREATE_NULL_POINTER_EXCEPTION = new ForeignCallDescriptor("createNullPointerException", NullPointerException.class);
-        public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", IndexOutOfBoundsException.class, int.class);
+        public static final ForeignCallDescriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new ForeignCallDescriptor("createOutOfBoundsException", ArrayIndexOutOfBoundsException.class, int.class);
     }
 
     /**
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopParseLong.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopParseLong.java	Wed Mar 19 11:43:57 2014 +0100
@@ -27,6 +27,25 @@
 
 public class LoopParseLong extends JTTTest {
 
+    @SuppressWarnings("unused")
+    public static long testShortened(String s, int radix) throws NumberFormatException {
+        long result = 0;
+        boolean negative = false;
+        int len = s.length();
+        char firstChar = s.charAt(0);
+        if (firstChar < '0') {
+            if (firstChar == '-') {
+                negative = true;
+            } else if (firstChar != '+') {
+                throw new NumberFormatException();
+            }
+            if (len == 1) {
+                throw new NumberFormatException();
+            }
+        }
+        return result;
+    }
+
     public static long test(String s, int radix) throws NumberFormatException {
         if (s == null) {
             throw new NumberFormatException("null");
@@ -81,6 +100,8 @@
 
     @LongTest
     public void run0() throws Throwable {
+        runTest("testShortened", "7", 10);
+        runTest("testShortened", "-100", 10);
         runTest("test", "7", 10);
         runTest("test", "-100", 10);
     }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/AndNode.java	Wed Mar 19 11:43:57 2014 +0100
@@ -66,6 +66,14 @@
             if ((rawY & mask) == 0) {
                 return ConstantNode.forIntegerStamp(stamp(), 0, graph());
             }
+            if (x().stamp() instanceof IntegerStamp) {
+                IntegerStamp xStamp = (IntegerStamp) x().stamp();
+                if (((xStamp.upMask() | xStamp.downMask()) & ~rawY) == 0) {
+                    // No bits are set which are outside the mask, so the mask will have no effect.
+                    return x();
+                }
+            }
+
             return BinaryNode.reassociate(this, ValueNode.isConstantPredicate());
         }
         return this;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ReinterpretNode.java	Wed Mar 19 11:43:57 2014 +0100
@@ -93,6 +93,10 @@
         if (stamp().isCompatible(value.stamp())) {
             return value;
         }
+        if (value instanceof ReinterpretNode) {
+            ReinterpretNode reinterpret = (ReinterpretNode) value;
+            return value.graph().unique(new ReinterpretNode(stamp(), reinterpret.value()));
+        }
         return this;
     }
 
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java	Wed Mar 19 11:43:57 2014 +0100
@@ -172,7 +172,7 @@
                 String declaringClass = option.declaringClass;
                 Name fieldName = option.field.getSimpleName();
                 String comma = i == info.options.size() - 1 ? "" : ",";
-                out.printf("            new %s(\"%s\", %s.class, \"%s\", %s.class, \"%s\", %s)%s%n", desc, name, type, help, declaringClass, fieldName, optionValue, comma);
+                out.printf("            new %s(\"%s\", %s.class, \"%s\", %s.class, \"%s\", %s)%s\n", desc, name, type, help, declaringClass, fieldName, optionValue, comma);
                 i++;
             }
             out.println("        );");
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Wed Mar 19 11:43:57 2014 +0100
@@ -36,7 +36,38 @@
  */
 public abstract class BasePhase<C> {
 
-    private final String name;
+    /**
+     * Phase name lazily computed from the phase class.
+     */
+    class Name extends LazyName {
+
+        @Override
+        public String createString() {
+            String s = BasePhase.this.getClass().getSimpleName();
+            if (s.endsWith("Phase")) {
+                return s.substring(0, s.length() - "Phase".length());
+            }
+            return s;
+        }
+    }
+
+    /**
+     * Lazily computed debug value name composed of a prefix and a phase's name.
+     */
+    class DebugValueName extends LazyName {
+        final String prefix;
+
+        public DebugValueName(String prefix) {
+            this.prefix = prefix;
+        }
+
+        @Override
+        public String createString() {
+            return prefix + name;
+        }
+    }
+
+    private final CharSequence name;
 
     private final DebugTimer phaseTimer;
     private final DebugMetric phaseMetric;
@@ -49,25 +80,20 @@
     }
 
     protected BasePhase() {
-        String nm = this.getClass().getSimpleName();
-        if (nm.endsWith("Phase")) {
-            name = nm.substring(0, nm.length() - "Phase".length());
-        } else {
-            name = nm;
-        }
-        assert checkName(name);
-        phaseTimer = Debug.timer("PhaseTime_" + name);
-        phaseMetric = Debug.metric("PhaseCount_" + name);
+        name = new Name();
+        assert checkName(name.toString());
+        phaseTimer = Debug.timer(new DebugValueName("PhaseTime_"));
+        phaseMetric = Debug.metric(new DebugValueName("PhaseCount_"));
     }
 
     protected BasePhase(String name) {
         assert checkName(name);
         this.name = name;
-        phaseTimer = Debug.timer("PhaseTime_" + name);
-        phaseMetric = Debug.metric("PhaseCount_" + name);
+        phaseTimer = Debug.timer(new DebugValueName("PhaseTime_"));
+        phaseMetric = Debug.metric(new DebugValueName("PhaseCount_"));
     }
 
-    protected String getDetailedName() {
+    protected CharSequence getDetailedName() {
         return getName();
     }
 
@@ -88,7 +114,7 @@
         }
     }
 
-    public final String getName() {
+    public final CharSequence getName() {
         return name;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/LazyName.java	Wed Mar 19 11:43:57 2014 +0100
@@ -0,0 +1,60 @@
+/*
+ * 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.phases;
+
+import com.oracle.graal.debug.*;
+
+/**
+ * A name whose {@link String} value is computed only when it is needed. This is useful in
+ * combination with debugging facilities such as {@link Debug#scope(CharSequence, Object...)} where
+ * the {@link String} value of a name is only needed if debugging is enabled.
+ */
+public abstract class LazyName implements CharSequence {
+
+    private String value;
+
+    public int length() {
+        return toString().length();
+    }
+
+    public char charAt(int index) {
+        return toString().charAt(index);
+    }
+
+    public CharSequence subSequence(int start, int end) {
+        return toString().subSequence(start, end);
+    }
+
+    @Override
+    public final String toString() {
+        if (value == null) {
+            value = createString();
+        }
+        return value;
+    }
+
+    /**
+     * Creates the {@link String} value of this name.
+     */
+    protected abstract String createString();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/MethodDebugValueName.java	Wed Mar 19 11:43:57 2014 +0100
@@ -0,0 +1,45 @@
+/*
+ * 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.phases.util;
+
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.phases.*;
+
+/**
+ * Lazily computed debug value name composed of a prefix and a {@linkplain JavaMethod#getName()
+ * method name}.
+ */
+public class MethodDebugValueName extends LazyName {
+    final String prefix;
+    final JavaMethod method;
+
+    public MethodDebugValueName(String prefix, JavaMethod method) {
+        this.prefix = prefix;
+        this.method = method;
+    }
+
+    @Override
+    public String createString() {
+        return prefix + "[" + method.getName() + "]";
+    }
+}
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java	Wed Mar 19 11:43:57 2014 +0100
@@ -41,6 +41,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.cfg.*;
+import com.oracle.graal.phases.schedule.*;
 
 /**
  * Utility for printing Graal IR at various compilation phases.
@@ -51,6 +52,7 @@
     protected LIR lir;
     protected LIRGenerator lirGenerator;
     protected ControlFlowGraph cfg;
+    protected SchedulePhase schedule;
 
     /**
      * Creates a control flow graph printer.
@@ -118,7 +120,7 @@
     private NodeBitMap printedNodes;
 
     private boolean inFixedSchedule(Node node) {
-        return lir != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null;
+        return lir != null || schedule != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null;
     }
 
     /**
@@ -186,6 +188,19 @@
     }
 
     private void printBlock(Block block, boolean printNodes) {
+        printBlockProlog(block);
+        if (printNodes) {
+            printNodes(block);
+        }
+        printBlockEpilog(block);
+    }
+
+    private void printBlockEpilog(Block block) {
+        printLIR(block);
+        end("block");
+    }
+
+    private void printBlockProlog(Block block) {
         begin("block");
 
         out.print("name \"").print(blockToString(block)).println('"');
@@ -230,12 +245,6 @@
             out.print("loop_index ").println(block.getLoop().index);
             out.print("loop_depth ").println(block.getLoop().depth);
         }
-
-        if (printNodes) {
-            printNodes(block);
-        }
-        printLIR(block);
-        end("block");
     }
 
     private void printNodes(Block block) {
@@ -287,7 +296,7 @@
         }
 
         if (unscheduled) {
-            assert lir == null : "unscheduled nodes can only be present before LIR generation";
+            assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation";
             out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
         } else if (node instanceof FixedWithNextNode) {
             out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
@@ -464,7 +473,7 @@
             return "-";
         }
         String prefix;
-        if (node instanceof AbstractBeginNode && lir == null) {
+        if (node instanceof AbstractBeginNode && (lir == null && schedule == null)) {
             prefix = "B";
         } else if (node instanceof ValueNode) {
             ValueNode value = (ValueNode) node;
@@ -480,7 +489,7 @@
     }
 
     private String blockToString(Block block) {
-        if (lir == null) {
+        if (lir == null && schedule == null) {
             // During all the front-end phases, the block schedule is built only for the debug
             // output.
             // Therefore, the block numbers would be different for every CFG printed -> use the id
@@ -539,4 +548,46 @@
         out.printf(" \"%s\"", interval.spillState());
         out.println();
     }
+
+    public void printSchedule(String message, SchedulePhase theSchedule) {
+        schedule = theSchedule;
+        cfg = schedule.getCFG();
+        printedNodes = new NodeBitMap(cfg.graph);
+
+        begin("cfg");
+        out.print("name \"").print(message).println('"');
+        for (Block b : schedule.getCFG().getBlocks()) {
+            if (schedule.nodesFor(b) != null) {
+                printScheduledBlock(b, schedule.nodesFor(b));
+            }
+        }
+        end("cfg");
+
+        schedule = null;
+        cfg = null;
+        printedNodes = null;
+    }
+
+    private void printScheduledBlock(Block block, List<ScheduledNode> nodesFor) {
+        printBlockProlog(block);
+        begin("IR");
+        out.println("HIR");
+        out.disableIndentation();
+
+        if (block.getBeginNode() instanceof MergeNode) {
+            // Currently phi functions are not in the schedule, so print them separately here.
+            for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) {
+                printNode(phi, false);
+            }
+        }
+
+        for (Node n : nodesFor) {
+            printNode(n, false);
+        }
+
+        out.enableIndentation();
+        end("IR");
+
+        printBlockEpilog(block);
+    }
 }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java	Wed Mar 19 11:43:57 2014 +0100
@@ -36,6 +36,7 @@
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.cfg.*;
+import com.oracle.graal.phases.schedule.*;
 
 /**
  * Observes compilation events and uses {@link CFGPrinter} to produce a control flow graph for the
@@ -162,6 +163,8 @@
             boolean printNodes = previousObject != object;
             cfgPrinter.printCFG(message, cfgPrinter.lir.codeEmittingOrder(), printNodes);
 
+        } else if (object instanceof SchedulePhase) {
+            cfgPrinter.printSchedule(message, (SchedulePhase) object);
         } else if (object instanceof StructuredGraph) {
             if (cfgPrinter.cfg == null) {
                 StructuredGraph graph = (StructuredGraph) object;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java	Wed Mar 19 11:43:57 2014 +0100
@@ -202,7 +202,7 @@
         for (Object o : Debug.context()) {
             JavaMethod method = asJavaMethod(o);
             if (method != null) {
-                if (lastMethodOrGraph == null || !asJavaMethod(lastMethodOrGraph).equals(method)) {
+                if (lastMethodOrGraph == null || asJavaMethod(lastMethodOrGraph) == null || !asJavaMethod(lastMethodOrGraph).equals(method)) {
                     result.add(MetaUtil.format("%H::%n(%p)", method));
                 } else {
                     // This prevents multiple adjacent method context objects for the same method
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java	Wed Mar 19 11:43:57 2014 +0100
@@ -329,4 +329,25 @@
         return Arrays.equals(a, b);
     }
 
+    @Test
+    public void testEqualsNodeGVN() {
+        test("testEqualsNodeGVNSnippet", true);
+    }
+
+    public static int[] intArrayCompare = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
+    public static int[] intArray;
+
+    public static boolean testEqualsNodeGVNSnippet(boolean b) {
+        int[] newIntArray = new int[]{0, 2, 3, 4, 5, 6, 7, 8, 9};
+        intArray = newIntArray;
+
+        if (b) {
+            newIntArray[0] = 1;
+            return Arrays.equals(newIntArray, intArrayCompare);
+        } else {
+            newIntArray[0] = 1;
+            return Arrays.equals(newIntArray, intArrayCompare);
+        }
+    }
+
 }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java	Wed Mar 19 11:43:57 2014 +0100
@@ -99,7 +99,7 @@
                 FrameStateProcessing frameStateProcessing = method.getAnnotation(Snippet.class).removeAllFrameStates() ? FrameStateProcessing.Removal
                                 : FrameStateProcessing.CollapseFrameForSingleSideEffect;
                 StructuredGraph newGraph = makeGraph(method, recursiveEntry, recursiveEntry, inliningPolicy(method), frameStateProcessing);
-                Debug.metric("SnippetNodeCount[" + method.getName() + "]").add(newGraph.getNodeCount());
+                Debug.metric(new MethodDebugValueName("SnippetNodeCount", method)).add(newGraph.getNodeCount());
                 if (!UseSnippetGraphCache) {
                     return newGraph;
                 }
@@ -201,8 +201,8 @@
                     }
                 }
             }
-            // We don't have per method guards for macro substitutions but at least respect the
-            // defaultGuard if there is one.
+            // We don't have per method guards for macro substitutions but at
+            // least respect the defaultGuard if there is one.
             if (macroSubstitution != null && (defaultGuard == null || defaultGuard.execute())) {
                 String originalName = originalName(substituteMethod, macroSubstitution.value());
                 JavaSignature originalSignature = originalSignature(substituteMethod, macroSubstitution.signature(), macroSubstitution.isStatic());
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java	Wed Mar 19 11:43:57 2014 +0100
@@ -97,8 +97,8 @@
 
         protected SnippetInfo(ResolvedJavaMethod method) {
             this.method = method;
-            instantiationCounter = Debug.metric("SnippetInstantiationCount[" + method.getName() + "]");
-            instantiationTimer = Debug.timer("SnippetInstantiationTime[" + method.getName() + "]");
+            instantiationCounter = Debug.metric(new MethodDebugValueName("SnippetInstantiationCount", method));
+            instantiationTimer = Debug.timer(new MethodDebugValueName("SnippetInstantiationTime", method));
             assert Modifier.isStatic(method.getModifiers()) : "snippet method must be static: " + MetaUtil.format("%H.%n", method);
             int count = method.getSignature().getParameterCount(false);
             constantParameters = new boolean[count];
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ArrayEqualsNode.java	Wed Mar 19 11:43:57 2014 +0100
@@ -31,13 +31,12 @@
 import com.oracle.graal.graph.spi.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.nodes.*;
-import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.type.*;
 
 /**
  * Compares two arrays with the same length.
  */
-public class ArrayEqualsNode extends FloatingNode implements LIRGenLowerable, Canonicalizable {
+public class ArrayEqualsNode extends FixedWithNextNode implements LIRGenLowerable, Canonicalizable {
 
     /** {@link Kind} of the arrays to compare. */
     private final Kind kind;
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java	Wed Mar 19 11:43:57 2014 +0100
@@ -29,8 +29,8 @@
 import com.oracle.graal.asm.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.hotspot.*;
-import com.oracle.graal.hotspot.bridge.*;
 import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.truffle.*;
@@ -51,10 +51,9 @@
     @Override
     public Mark recordMark(Object id) {
         Mark mark = super.recordMark(id);
-        if (Integer.valueOf(Marks.MARK_VERIFIED_ENTRY).equals(id)) {
-            HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
+        if (MarkId.getEnum((int) id) == MarkId.VERIFIED_ENTRY) {
             HotSpotRegistersProvider registers = HotSpotGraalRuntime.runtime().getHostProviders().getRegisters();
-            injectTailCallCode(config, registers);
+            injectTailCallCode(HotSpotGraalRuntime.runtime().getConfig(), registers);
         }
         return mark;
     }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNode.java	Wed Mar 19 11:43:57 2014 +0100
@@ -22,13 +22,14 @@
  */
 package com.oracle.graal.truffle;
 
+import java.util.*;
 import java.util.concurrent.atomic.*;
 
 import com.oracle.truffle.api.*;
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
 import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.NodeFilter;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
 
 /**
  * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
@@ -60,7 +61,7 @@
     }
 
     @SuppressWarnings("unused")
-    public void nodeReplaced(Node oldNode, Node newNode, String reason) {
+    public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
     }
 
     @Override
@@ -136,6 +137,16 @@
             // return false;
             // }
 
+            // disable recursive splitting for now
+            OptimizedCallTarget splitTarget = getCallTarget();
+            List<OptimizedCallTarget> compilationRoots = OptimizedCallNodeProfile.findCompilationRoots(this);
+            for (OptimizedCallTarget compilationRoot : compilationRoots) {
+                if (compilationRoot == splitTarget || compilationRoot.getSplitSource() == splitTarget) {
+                    // recursive call found
+                    return false;
+                }
+            }
+
             // max one child call and callCount > 2 and kind of small number of nodes
             if (isMaxSingleCall()) {
                 return true;
@@ -144,7 +155,7 @@
         }
 
         @Override
-        public void nodeReplaced(Node oldNode, Node newNode, String reason) {
+        public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
             trySplit = true;
         }
 
@@ -163,10 +174,11 @@
         }
 
         private int countPolymorphic() {
-            return NodeUtil.countNodes(getCallTarget().getRootNode(), new NodeFilter() {
-                public boolean isFiltered(Node node) {
+            return NodeUtil.countNodes(getCallTarget().getRootNode(), new NodeCountFilter() {
+                public boolean isCounted(Node node) {
                     NodeCost cost = node.getCost();
-                    return cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC;
+                    boolean polymorphic = cost == NodeCost.POLYMORPHIC || cost == NodeCost.MEGAMORPHIC;
+                    return polymorphic;
                 }
             });
         }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNodeProfile.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallNodeProfile.java	Wed Mar 19 11:43:57 2014 +0100
@@ -191,7 +191,7 @@
         return callNode.getCallCount() / (double) callTarget.getCompilationProfile().getCallCount();
     }
 
-    private static List<OptimizedCallTarget> findCompilationRoots(Node call) {
+    static List<OptimizedCallTarget> findCompilationRoots(Node call) {
         RootNode root = call.getRootNode();
         if (root == null) {
             return Collections.emptyList();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Wed Mar 19 11:43:57 2014 +0100
@@ -34,7 +34,7 @@
 import com.oracle.truffle.api.frame.*;
 import com.oracle.truffle.api.impl.*;
 import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeUtil.NodeFilter;
+import com.oracle.truffle.api.nodes.NodeUtil.NodeCountFilter;
 
 /**
  * Call target that is optimized by Graal upon surpassing a specific invocation threshold.
@@ -136,7 +136,7 @@
         return call(caller, args);
     }
 
-    private void invalidate(Node oldNode, Node newNode, String reason) {
+    private void invalidate(Node oldNode, Node newNode, CharSequence reason) {
         InstalledCode m = this.installedCode;
         if (m != null) {
             CompilerAsserts.neverPartOfCompilation();
@@ -147,7 +147,7 @@
         cancelInstalledTask(oldNode, newNode, reason);
     }
 
-    private void cancelInstalledTask(Node oldNode, Node newNode, String reason) {
+    private void cancelInstalledTask(Node oldNode, Node newNode, CharSequence reason) {
         Future<InstalledCode> task = this.installedCodeTask;
         if (task != null) {
             task.cancel(true);
@@ -298,7 +298,7 @@
     }
 
     @Override
-    public void nodeReplaced(Node oldNode, Node newNode, String reason) {
+    public void nodeReplaced(Node oldNode, Node newNode, CharSequence reason) {
         compilationProfile.reportNodeReplaced();
         invalidate(oldNode, newNode, reason);
 
@@ -382,7 +382,7 @@
         }
     }
 
-    private static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, String reason) {
+    private static void logOptimizingUnqueued(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
         if (TraceTruffleCompilationDetails.getValue()) {
             Map<String, Object> properties = new LinkedHashMap<>();
             addReplaceProperties(properties, oldNode, newNode);
@@ -405,7 +405,7 @@
         }
     }
 
-    private static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, String reason) {
+    private static void logOptimizedInvalidated(OptimizedCallTarget target, Node oldNode, Node newNode, CharSequence reason) {
         if (TraceTruffleCompilation.getValue()) {
             Map<String, Object> properties = new LinkedHashMap<>();
             addReplaceProperties(properties, oldNode, newNode);
@@ -414,7 +414,7 @@
         }
     }
 
-    private static void logOptimizingFailed(OptimizedCallTarget callSite, String reason) {
+    private static void logOptimizingFailed(OptimizedCallTarget callSite, CharSequence reason) {
         Map<String, Object> properties = new LinkedHashMap<>();
         properties.put("Reason", reason);
         log(0, "opt fail", callSite.toString(), properties);
@@ -461,14 +461,14 @@
     }
 
     static void addASTSizeProperty(RootNode target, Map<String, Object> properties) {
-        int polymorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeFilter() {
-            public boolean isFiltered(Node node) {
+        int polymorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
                 return node.getCost() == NodeCost.POLYMORPHIC;
             }
         }, true);
 
-        int megamorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeFilter() {
-            public boolean isFiltered(Node node) {
+        int megamorphicCount = NodeUtil.countNodes(target.getRootNode(), new NodeCountFilter() {
+            public boolean isCounted(Node node) {
                 return node.getCost() == NodeCost.MEGAMORPHIC;
             }
         }, true);
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Wed Mar 19 11:43:57 2014 +0100
@@ -78,7 +78,9 @@
                 graph.stopTrackingInputChange();
                 graph.stopTrackingUsagesDroppedZero();
 
-                Debug.dump(graph, "after " + getName() + " iteration");
+                if (Debug.isDumpEnabled()) {
+                    Debug.dump(graph, "after " + getName() + " iteration");
+                }
 
                 new DeadCodeEliminationPhase().apply(graph);
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Wed Mar 19 11:43:57 2014 +0100
@@ -335,8 +335,6 @@
             ObjectState[] objStates = new ObjectState[states.size()];
             boolean materialized;
             do {
-                mergeEffects.clear();
-                afterMergeEffects.clear();
                 materialized = false;
                 for (VirtualObjectNode object : virtualObjTemp) {
                     for (int i = 0; i < objStates.length; i++) {
@@ -382,6 +380,11 @@
                         materialized |= processPhi(phi, states, virtualObjTemp);
                     }
                 }
+                if (materialized) {
+                    newState.objectStates.clear();
+                    mergeEffects.clear();
+                    afterMergeEffects.clear();
+                }
             } while (materialized);
         }
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ReplaceObserver.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ReplaceObserver.java	Wed Mar 19 11:43:57 2014 +0100
@@ -31,5 +31,5 @@
  */
 public interface ReplaceObserver {
 
-    void nodeReplaced(Node oldNode, Node newNode, String reason);
+    void nodeReplaced(Node oldNode, Node newNode, CharSequence reason);
 }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/KillException.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/KillException.java	Wed Mar 19 11:43:57 2014 +0100
@@ -26,7 +26,6 @@
 
 import com.oracle.truffle.api.nodes.*;
 
-// TODO (mlvdv) does this need to extend ControlFlowException?  It was originally part of the Ruby Shell.
 /**
  * Controls breaking out of an execution context, such as a shell or eval.
  */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/QuitException.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/QuitException.java	Wed Mar 19 11:43:57 2014 +0100
@@ -26,7 +26,6 @@
 
 import com.oracle.truffle.api.nodes.*;
 
-//TODO (mlvdv) does this need to extend ControlFlowException?  It was originally part of the Ruby execution environment.
 /**
  * Controls breaking out of all executions and ending Truffle execution.
  */
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/CallNode.java	Wed Mar 19 11:43:57 2014 +0100
@@ -156,7 +156,7 @@
     }
 
     @Override
-    protected void onReplace(Node newNode, String reason) {
+    protected void onReplace(Node newNode, CharSequence reason) {
         super.onReplace(newNode, reason);
 
         /*
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Wed Mar 19 11:43:57 2014 +0100
@@ -186,7 +186,7 @@
      * @param reason a description of the reason for the replacement
      * @return the new node
      */
-    public final <T extends Node> T replace(T newNode, String reason) {
+    public final <T extends Node> T replace(T newNode, CharSequence reason) {
         CompilerDirectives.transferToInterpreterAndInvalidate();
         if (this.getParent() == null) {
             throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent.");
@@ -260,7 +260,7 @@
         return false;
     }
 
-    private void reportReplace(Node oldNode, Node newNode, String reason) {
+    private void reportReplace(Node oldNode, Node newNode, CharSequence reason) {
         RootNode rootNode = getRootNode();
         if (rootNode != null) {
             CallTarget target = rootNode.getCallTarget();
@@ -277,13 +277,13 @@
      * @param newNode the replacement node
      * @param reason the reason the replace supplied
      */
-    protected void onReplace(Node newNode, String reason) {
+    protected void onReplace(Node newNode, CharSequence reason) {
         if (TruffleOptions.TraceRewrites) {
             traceRewrite(newNode, reason);
         }
     }
 
-    private void traceRewrite(Node newNode, String reason) {
+    private void traceRewrite(Node newNode, CharSequence reason) {
 
         if (TruffleOptions.TraceRewritesFilterFromCost != null) {
             if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) {
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java	Wed Mar 19 11:43:57 2014 +0100
@@ -574,19 +574,19 @@
         return countNodes(root, null, false);
     }
 
-    public static int countNodes(Node root, NodeFilter filter) {
+    public static int countNodes(Node root, NodeCountFilter filter) {
         return countNodes(root, filter, false);
     }
 
-    public static int countNodes(Node root, NodeFilter filter, boolean visitInlinedCallNodes) {
+    public static int countNodes(Node root, NodeCountFilter filter, boolean visitInlinedCallNodes) {
         NodeCountVisitor nodeCount = new NodeCountVisitor(filter, visitInlinedCallNodes);
         root.accept(nodeCount);
         return nodeCount.nodeCount;
     }
 
-    public interface NodeFilter {
+    public interface NodeCountFilter {
 
-        boolean isFiltered(Node node);
+        boolean isCounted(Node node);
 
     }
 
@@ -594,16 +594,16 @@
 
         private final boolean visitInlinedCallNodes;
         int nodeCount;
-        private final NodeFilter filter;
+        private final NodeCountFilter filter;
 
-        private NodeCountVisitor(NodeFilter filter, boolean visitInlinedCallNodes) {
+        private NodeCountVisitor(NodeCountFilter filter, boolean visitInlinedCallNodes) {
             this.filter = filter;
             this.visitInlinedCallNodes = visitInlinedCallNodes;
         }
 
         @Override
         public boolean visit(Node node) {
-            if (filter == null || !filter.isFiltered(node)) {
+            if (filter == null || filter.isCounted(node)) {
                 nodeCount++;
             }
 
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Mar 17 16:43:34 2014 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Wed Mar 19 11:43:57 2014 +0100
@@ -214,19 +214,23 @@
                 if (method.getModifiers().contains(STATIC)) {
                     builder.type(targetClass.asType());
                 } else {
-                    ActualParameter parameter = null;
+                    ActualParameter firstParameter = null;
                     for (ActualParameter searchParameter : targetMethod.getParameters()) {
                         if (searchParameter.getSpecification().isSignature()) {
-                            parameter = searchParameter;
+                            firstParameter = searchParameter;
                             break;
                         }
                     }
-                    ActualParameter sourceParameter = sourceMethod.findParameter(parameter.getLocalName());
+                    if (firstParameter == null) {
+                        throw new AssertionError();
+                    }
+
+                    ActualParameter sourceParameter = sourceMethod.findParameter(firstParameter.getLocalName());
 
                     if (castedValues && sourceParameter != null) {
-                        builder.string(valueName(sourceParameter, parameter));
+                        builder.string(valueName(sourceParameter, firstParameter));
                     } else {
-                        builder.string(valueName(parameter));
+                        builder.string(valueName(firstParameter));
                     }
                 }
             }
@@ -967,7 +971,7 @@
             CodeTreeBuilder builder = method.createBuilder();
             if (node.isPolymorphic() && specialization == null) {
                 // assume next0 exists
-                builder.startIf().string("next0 != null && next0.getCost() == ").staticReference(nodeInfoKind, "MONOMORPHIC").end();
+                builder.startIf().string("next0 != null && next0.getCost() != ").staticReference(nodeInfoKind, "UNINITIALIZED").end();
                 builder.startBlock();
                 builder.startReturn().staticReference(nodeInfoKind, "POLYMORPHIC").end();
                 builder.end();
@@ -2631,6 +2635,9 @@
                 }
 
                 CodeExecutableElement superConstructor = createSuperConstructor(clazz, constructor);
+                if (superConstructor == null) {
+                    continue;
+                }
                 CodeTree body = superConstructor.getBodyTree();
                 CodeTreeBuilder builder = superConstructor.createBuilder();
                 builder.tree(body);
--- a/mx/mx_graal.py	Mon Mar 17 16:43:34 2014 +0100
+++ b/mx/mx_graal.py	Wed Mar 19 11:43:57 2014 +0100
@@ -83,6 +83,12 @@
 
 JDK_UNIX_PERMISSIONS = 0755
 
+def isVMSupported(vm):
+    if 'client' in vm and len(platform.mac_ver()[0]) != 0:
+        # Client VM not supported: java launcher on Mac OS X translates '-client' to '-server'
+        return False
+    return True
+
 def _get_vm():
     """
     Gets the configured VM, presenting a dialogue if there is no currently configured VM.
@@ -569,6 +575,10 @@
                 mx.log('only product build of original VM exists')
             continue
 
+        if not isVMSupported(vm):
+            mx.log('The ' + vm + ' VM is not supported on this platform - skipping')
+            continue
+
         vmDir = join(_vmLibDirInJdk(jdk), vm)
         if not exists(vmDir):
             if mx.get_os() != 'windows':
@@ -718,8 +728,8 @@
     if vm is None:
         vm = _get_vm()
 
-    if 'client' in vm and len(platform.mac_ver()[0]) != 0:
-        mx.abort("Client VM not supported: java launcher on Mac OS X translates '-client' to '-server'")
+    if not isVMSupported(vm):
+        mx.abort('The ' + vm + ' is not supported on this platform')
 
     if cwd is None:
         cwd = _vm_cwd
@@ -927,6 +937,10 @@
 
     allStart = time.time()
     for v in vms:
+        if not isVMSupported(v):
+            mx.log('The ' + v + ' VM is not supported on this platform - skipping')
+            continue
+
         for vmbuild in builds:
             if v == 'original' and vmbuild != 'product':
                 continue
@@ -1043,6 +1057,9 @@
 
         for vmbuild in ['product', 'fastdebug']:
             for theVm in ['client', 'server']:
+                if not isVMSupported(theVm):
+                    mx.log('The' + theVm + ' VM is not supported on this platform')
+                    continue
                 with VM(theVm, vmbuild):
                     t = Task('DaCapo_pmd:' + theVm + ':' + vmbuild)
                     dacapo(['pmd'])
@@ -1175,7 +1192,7 @@
         env = os.environ
         proxy = os.environ.get('http_proxy')
         if not (proxy is None) and len(proxy) > 0:
-            if proxy.contains('://'):
+            if '://' in proxy:
                 # Remove the http:// prefix (or any other protocol prefix)
                 proxy = proxy.split('://', 1)[1]
             # Separate proxy server name and port number
--- a/src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/cpu/sparc/vm/graalCodeInstaller_sparc.hpp	Wed Mar 19 11:43:57 2014 +0100
@@ -98,24 +98,24 @@
   }
 #endif
   switch (_next_call_type) {
-    case MARK_INLINE_INVOKE:
+    case INLINE_INVOKE:
       break;
-    case MARK_INVOKEVIRTUAL:
-    case MARK_INVOKEINTERFACE: {
+    case INVOKEVIRTUAL:
+    case INVOKEINTERFACE: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
       call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
       _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
       break;
     }
-    case MARK_INVOKESTATIC: {
+    case INVOKESTATIC: {
       assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
       call->set_destination(SharedRuntime::get_resolve_static_call_stub());
       _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
       break;
     }
-    case MARK_INVOKESPECIAL: {
+    case INVOKESPECIAL: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
       call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
@@ -130,16 +130,16 @@
 
 inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
   switch (mark) {
-    case MARK_POLL_NEAR: {
+    case POLL_NEAR: {
       fatal("unimplemented");
     }
-    case MARK_POLL_FAR:
+    case POLL_FAR:
       _instructions->relocate(pc, relocInfo::poll_type);
       break;
-    case MARK_POLL_RETURN_NEAR: {
+    case POLL_RETURN_NEAR: {
       fatal("unimplemented");
     }
-    case MARK_POLL_RETURN_FAR:
+    case POLL_RETURN_FAR:
       _instructions->relocate(pc, relocInfo::poll_return_type);
       break;
     default:
--- a/src/cpu/x86/vm/graalCodeInstaller_x86.hpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/cpu/x86/vm/graalCodeInstaller_x86.hpp	Wed Mar 19 11:43:57 2014 +0100
@@ -151,10 +151,10 @@
   }
 #endif
   switch (_next_call_type) {
-    case MARK_INLINE_INVOKE:
+    case INLINE_INVOKE:
       break;
-    case MARK_INVOKEVIRTUAL:
-    case MARK_INVOKEINTERFACE: {
+    case INVOKEVIRTUAL:
+    case INVOKEINTERFACE: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
 
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
@@ -164,7 +164,7 @@
                                              Assembler::call32_operand);
       break;
     }
-    case MARK_INVOKESTATIC: {
+    case INVOKESTATIC: {
       assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
 
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
@@ -173,7 +173,7 @@
                                              relocInfo::static_call_type, Assembler::call32_operand);
       break;
     }
-    case MARK_INVOKESPECIAL: {
+    case INVOKESPECIAL: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
       call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
@@ -197,24 +197,24 @@
 
 inline void CodeInstaller::pd_relocate_poll(address pc, jint mark) {
   switch (mark) {
-    case MARK_POLL_NEAR: {
+    case POLL_NEAR: {
       relocate_poll_near(pc);
       _instructions->relocate(pc, relocInfo::poll_type, Assembler::disp32_operand);
       break;
     }
-    case MARK_POLL_FAR:
+    case POLL_FAR:
       // This is a load from a register so there is no relocatable operand.
       // We just have to ensure that the format is not disp32_operand
       // so that poll_Relocation::fix_relocation_after_move does the right
       // thing (i.e. ignores this relocation record)
       _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand);
       break;
-    case MARK_POLL_RETURN_NEAR: {
+    case POLL_RETURN_NEAR: {
       relocate_poll_near(pc);
       _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::disp32_operand);
       break;
     }
-    case MARK_POLL_RETURN_FAR:
+    case POLL_RETURN_FAR:
       // see comment above for MARK_POLL_FAR
       _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand);
       break;
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Wed Mar 19 11:43:57 2014 +0100
@@ -192,7 +192,7 @@
 }
 
 static void record_metadata_in_patch(oop data, OopRecorder* oop_recorder) {
-  record_metadata_reference(MetaspaceData::annotation(data), MetaspaceData::value(data), MetaspaceData::compressed(data), oop_recorder);
+  record_metadata_reference(MetaspaceData::annotation(data), MetaspaceData::value(data), MetaspaceData::compressed(data) != 0, oop_recorder);
 }
 
 ScopeValue* CodeInstaller::get_scope_value(oop value, int total_frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, OopRecorder* oop_recorder) {
@@ -469,7 +469,7 @@
   _comments = (arrayOop) HotSpotCompiledCode::comments(compiled_code);
 #endif
 
-  _next_call_type = MARK_INVOKE_INVALID;
+  _next_call_type = INVOKE_INVALID;
 }
 
 // perform data and call relocation on the CodeBuffer
@@ -776,7 +776,7 @@
     CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset);
   }
 
-  _next_call_type = MARK_INVOKE_INVALID;
+  _next_call_type = INVOKE_INVALID;
 
   if (debug_info != NULL) {
     _debug_recorder->end_safepoint(next_pc_offset);
@@ -806,33 +806,33 @@
     address pc = _instructions->start() + pc_offset;
 
     switch (id) {
-      case MARK_UNVERIFIED_ENTRY:
+      case UNVERIFIED_ENTRY:
         _offsets.set_value(CodeOffsets::Entry, pc_offset);
         break;
-      case MARK_VERIFIED_ENTRY:
+      case VERIFIED_ENTRY:
         _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);
         break;
-      case MARK_OSR_ENTRY:
+      case OSR_ENTRY:
         _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
         break;
-      case MARK_EXCEPTION_HANDLER_ENTRY:
+      case EXCEPTION_HANDLER_ENTRY:
         _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
         break;
-      case MARK_DEOPT_HANDLER_ENTRY:
+      case DEOPT_HANDLER_ENTRY:
         _offsets.set_value(CodeOffsets::Deopt, pc_offset);
         break;
-      case MARK_INVOKEVIRTUAL:
-      case MARK_INVOKEINTERFACE:
-      case MARK_INLINE_INVOKE:
-      case MARK_INVOKESTATIC:
-      case MARK_INVOKESPECIAL:
+      case INVOKEVIRTUAL:
+      case INVOKEINTERFACE:
+      case INLINE_INVOKE:
+      case INVOKESTATIC:
+      case INVOKESPECIAL:
         _next_call_type = (MarkId) id;
         _invoke_mark_pc = pc;
         break;
-      case MARK_POLL_NEAR:
-      case MARK_POLL_FAR:
-      case MARK_POLL_RETURN_NEAR:
-      case MARK_POLL_RETURN_FAR:
+      case POLL_NEAR:
+      case POLL_FAR:
+      case POLL_RETURN_NEAR:
+      case POLL_RETURN_FAR:
         pd_relocate_poll(pc, id);
         break;
       default:
--- a/src/share/vm/graal/graalCodeInstaller.hpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.hpp	Wed Mar 19 11:43:57 2014 +0100
@@ -24,28 +24,30 @@
 #ifndef SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP
 #define SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP
 
+#include "graal/graalEnv.hpp"
+
 /*
  * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod.
  */
 class CodeInstaller {
+  friend class VMStructs;
 private:
-  // these need to correspond to Marks.java
   enum MarkId {
-    MARK_VERIFIED_ENTRY             = 1,
-    MARK_UNVERIFIED_ENTRY           = 2,
-    MARK_OSR_ENTRY                  = 3,
-    MARK_EXCEPTION_HANDLER_ENTRY    = 4,
-    MARK_DEOPT_HANDLER_ENTRY        = 5,
-    MARK_INVOKEINTERFACE            = 6,
-    MARK_INVOKEVIRTUAL              = 7,
-    MARK_INVOKESTATIC               = 8,
-    MARK_INVOKESPECIAL              = 9,
-    MARK_INLINE_INVOKE              = 10,
-    MARK_POLL_NEAR                  = 11,
-    MARK_POLL_RETURN_NEAR           = 12,
-    MARK_POLL_FAR                   = 13,
-    MARK_POLL_RETURN_FAR            = 14,
-    MARK_INVOKE_INVALID             = -1
+    VERIFIED_ENTRY             = 1,
+    UNVERIFIED_ENTRY           = 2,
+    OSR_ENTRY                  = 3,
+    EXCEPTION_HANDLER_ENTRY    = 4,
+    DEOPT_HANDLER_ENTRY        = 5,
+    INVOKEINTERFACE            = 6,
+    INVOKEVIRTUAL              = 7,
+    INVOKESTATIC               = 8,
+    INVOKESPECIAL              = 9,
+    INLINE_INVOKE              = 10,
+    POLL_NEAR                  = 11,
+    POLL_RETURN_NEAR           = 12,
+    POLL_FAR                   = 13,
+    POLL_RETURN_FAR            = 14,
+    INVOKE_INVALID             = -1
   };
 
   Arena         _arena;
--- a/src/share/vm/graal/graalRuntime.cpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/share/vm/graal/graalRuntime.cpp	Wed Mar 19 11:43:57 2014 +0100
@@ -539,7 +539,12 @@
   Handle receiverHandle(thread, receiver);
   MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock);
   JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle());
-  return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
+  if (receiverThread == NULL) {
+    // The other thread may exit during this process, which is ok so return false.
+    return JNI_FALSE;
+  } else {
+    return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
+  }
 JRT_END
 
 // JVM_InitializeGraalRuntime
--- a/src/share/vm/graal/vmStructs_graal.hpp	Mon Mar 17 16:43:34 2014 +0100
+++ b/src/share/vm/graal/vmStructs_graal.hpp	Wed Mar 19 11:43:57 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -26,6 +26,7 @@
 #define SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP
 
 #include "compiler/abstractCompiler.hpp"
+#include "graal/graalCodeInstaller.hpp"
 #include "graal/graalCompilerToVM.hpp"
 #include "graal/graalEnv.hpp"
 
@@ -48,5 +49,21 @@
                                                                                                   \
   declare_constant(CompilerToVM::KLASS_TAG)                                                       \
   declare_constant(CompilerToVM::SYMBOL_TAG)                                                      \
+                                                                                                  \
+  declare_constant(CodeInstaller::VERIFIED_ENTRY)                                                 \
+  declare_constant(CodeInstaller::UNVERIFIED_ENTRY)                                               \
+  declare_constant(CodeInstaller::OSR_ENTRY)                                                      \
+  declare_constant(CodeInstaller::EXCEPTION_HANDLER_ENTRY)                                        \
+  declare_constant(CodeInstaller::DEOPT_HANDLER_ENTRY)                                            \
+  declare_constant(CodeInstaller::INVOKEINTERFACE)                                                \
+  declare_constant(CodeInstaller::INVOKEVIRTUAL)                                                  \
+  declare_constant(CodeInstaller::INVOKESTATIC)                                                   \
+  declare_constant(CodeInstaller::INVOKESPECIAL)                                                  \
+  declare_constant(CodeInstaller::INLINE_INVOKE)                                                  \
+  declare_constant(CodeInstaller::POLL_NEAR)                                                      \
+  declare_constant(CodeInstaller::POLL_RETURN_NEAR)                                               \
+  declare_constant(CodeInstaller::POLL_FAR)                                                       \
+  declare_constant(CodeInstaller::POLL_RETURN_FAR)                                                \
+  declare_constant(CodeInstaller::INVOKE_INVALID)                                                 \
 
 #endif // SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP