changeset 13704:10a2d66262ae

Merge.
author Christian Humer <christian.humer@gmail.com>
date Fri, 17 Jan 2014 16:55:59 +0100
parents 03b42f0fb635 (current diff) f30814642122 (diff)
children ac5b0f31f7a2
files
diffstat 52 files changed, 407 insertions(+), 184 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java	Fri Jan 17 16:55:59 2014 +0100
@@ -36,10 +36,11 @@
      * 
      * @param method a method to which the executable code is begin added
      * @param compResult the compilation result to be added
+     * @param speculationLog the speculation log to be used
      * @return a reference to the compiled and ready-to-run code or null if the code installation
      *         failed
      */
-    InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult);
+    InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog speculationLog);
 
     /**
      * Sets the given compilation result as the default implementation of the given method.
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java	Fri Jan 17 16:55:59 2014 +0100
@@ -142,15 +142,19 @@
      */
     public abstract static class Data {
 
-        public final int size;
-        public final int alignment;
+        private final int alignment;
 
-        public abstract void emit(ByteBuffer buffer);
-
-        protected Data(int size, int alignment) {
-            this.size = size;
+        protected Data(int alignment) {
             this.alignment = alignment;
         }
+
+        public int getAlignment() {
+            return alignment;
+        }
+
+        public abstract int getSize(Architecture arch);
+
+        public abstract void emit(Architecture arch, ByteBuffer buffer);
     }
 
     public static final class ConstantData extends Data {
@@ -158,17 +162,56 @@
         public final Constant constant;
 
         public ConstantData(Constant constant, int alignment) {
-            super(8, alignment);
+            super(alignment);
             this.constant = constant;
         }
 
         @Override
-        public void emit(ByteBuffer buffer) {
-            if (constant.getKind().isPrimitive()) {
-                buffer.putLong(constant.getPrimitive());
-            } else {
-                // emit placeholder for oop value
-                buffer.putLong(0);
+        public int getSize(Architecture arch) {
+            return arch.getSizeInBytes(constant.getPlatformKind());
+        }
+
+        @Override
+        public void emit(Architecture arch, ByteBuffer buffer) {
+            switch (constant.getKind()) {
+                case Boolean:
+                    assert getSize(arch) == 1;
+                    buffer.put(constant.asBoolean() ? (byte) 1 : (byte) 0);
+                    break;
+                case Byte:
+                    assert getSize(arch) == 1;
+                    buffer.put((byte) constant.asInt());
+                    break;
+                case Char:
+                    assert getSize(arch) == 2;
+                    buffer.putChar((char) constant.asInt());
+                    break;
+                case Short:
+                    assert getSize(arch) == 2;
+                    buffer.putShort((short) constant.asInt());
+                    break;
+                case Int:
+                    assert getSize(arch) == 4;
+                    buffer.putInt(constant.asInt());
+                    break;
+                case Long:
+                    assert getSize(arch) == 8;
+                    buffer.putLong(constant.asLong());
+                    break;
+                case Float:
+                    assert getSize(arch) == 4;
+                    buffer.putFloat(constant.asFloat());
+                    break;
+                case Double:
+                    assert getSize(arch) == 8;
+                    buffer.putDouble(constant.asDouble());
+                    break;
+                case Object:
+                    // placeholder for oop value
+                    for (int i = 0; i < getSize(arch); i++) {
+                        buffer.put((byte) 0);
+                    }
+                    break;
             }
         }
 
@@ -183,12 +226,17 @@
         public final byte[] data;
 
         public RawData(byte[] data, int alignment) {
-            super(data.length, alignment);
+            super(alignment);
             this.data = data;
         }
 
         @Override
-        public void emit(ByteBuffer buffer) {
+        public int getSize(Architecture arch) {
+            return data.length;
+        }
+
+        @Override
+        public void emit(Architecture arch, ByteBuffer buffer) {
             buffer.put(data);
         }
 
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/SpeculationLog.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/SpeculationLog.java	Fri Jan 17 16:55:59 2014 +0100
@@ -47,10 +47,15 @@
         }
     }
 
-    public Constant maySpeculate(Object reason) {
+    public boolean maySpeculate(Object reason) {
         if (failedSpeculations != null && failedSpeculations.contains(reason)) {
-            return null;
+            return false;
         }
+        return true;
+    }
+
+    public Constant speculate(Object reason) {
+        assert maySpeculate(reason);
         if (speculations == null) {
             synchronized (this) {
                 if (speculations == null) {
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/package-info.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/package-info.java	Fri Jan 17 16:55:59 2014 +0100
@@ -23,7 +23,7 @@
 /**
  * Package that defines the interface between a Java application that wants to install code and the runtime.
  * The runtime provides in implementation of the {@link com.oracle.graal.api.code.CodeCacheProvider} interface.
- * The method {@link com.oracle.graal.api.code.CodeCacheProvider#addMethod(com.oracle.graal.api.meta.ResolvedJavaMethod, CompilationResult)}
+ * The method {@link com.oracle.graal.api.code.CodeCacheProvider#addMethod(com.oracle.graal.api.meta.ResolvedJavaMethod, CompilationResult, SpeculationLog)}
  * can be used to install code for a given method.
  */
 package com.oracle.graal.api.code;
--- a/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.asm.test/src/com/oracle/graal/asm/test/AssemblerTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -63,7 +63,7 @@
         Buffer codeBuffer = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
         compResult.setTargetCode(codeBuffer.close(true), codeBuffer.position());
 
-        InstalledCode code = codeCache.addMethod(method, compResult);
+        InstalledCode code = codeCache.addMethod(method, compResult, null);
 
         DisassemblerProvider dis = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getDisassembler();
         if (dis != null) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -582,7 +582,7 @@
     }
 
     protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) {
-        return getCodeCache().addMethod(method, compResult);
+        return getCodeCache().addMethod(method, compResult, null);
     }
 
     /**
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -610,7 +610,7 @@
                 new FloatingReadPhase().apply(graph);
                 new RemoveValueProxyPhase().apply(graph);
 
-                MidTierContext midContext = new MidTierContext(getProviders(), assumptions, getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo());
+                MidTierContext midContext = new MidTierContext(getProviders(), assumptions, getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
                 new GuardLoweringPhase().apply(graph, midContext);
                 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
                 new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Fri Jan 17 16:55:59 2014 +0100
@@ -206,7 +206,7 @@
         suites.getHighTier().apply(graph, highTierContext);
         graph.maybeCompress();
 
-        MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo);
+        MidTierContext midTierContext = new MidTierContext(providers, assumptions, target, optimisticOpts, profilingInfo, speculationLog);
         suites.getMidTier().apply(graph, midTierContext);
         graph.maybeCompress();
 
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java	Fri Jan 17 16:55:59 2014 +0100
@@ -394,14 +394,8 @@
     private void moveValueToThread(Value v, int offset) {
         Kind wordKind = getProviders().getCodeCache().getTarget().wordKind;
         RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
-        AMD64AddressValue pendingDeoptAddress = new AMD64AddressValue(v.getKind(), thread, offset);
-        if (v instanceof Constant && !getCodeCache().needsDataPatch((Constant) v)) {
-            Constant constantActionAndReason = (Constant) v;
-            assert !getCodeCache().needsDataPatch(constantActionAndReason);
-            append(new StoreConstantOp(constantActionAndReason.getKind(), pendingDeoptAddress, constantActionAndReason, null));
-        } else {
-            append(new StoreOp(v.getKind(), pendingDeoptAddress, load(v), null));
-        }
+        AMD64AddressValue address = new AMD64AddressValue(v.getKind(), thread, offset);
+        emitStore(v.getKind(), address, v, null);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -49,7 +49,7 @@
     protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) {
         HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method;
         HotSpotNmethod installedCode = new HotSpotNmethod(hsMethod, compResult.getName(), true);
-        HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(hsMethod, compResult);
+        HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(runtime().getTarget().arch, hsMethod, compResult);
         CodeInstallResult result = runtime().getCompilerToVM().installCode(compiledNmethod, installedCode, null);
         Assert.assertEquals("Error installing method " + method + ": " + result, result, CodeInstallResult.OK);
 
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -248,7 +248,7 @@
         try (Scope s = Debug.scope("WriteBarrierAdditionTest", new DebugDumpScope(snippet))) {
             StructuredGraph graph = parse(snippet);
             HighTierContext highContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
-            MidTierContext midContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo());
+            MidTierContext midContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
             new InliningPhase(new InliningPhase.InlineEverythingPolicy(), new CanonicalizerPhase(true)).apply(graph, highContext);
             new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext);
             new GuardLoweringPhase().apply(graph, midContext);
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -616,7 +616,7 @@
             HighTierContext highTierContext = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
             new InliningPhase(new CanonicalizerPhase(true)).apply(graph, highTierContext);
 
-            MidTierContext midTierContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo());
+            MidTierContext midTierContext = new MidTierContext(getProviders(), new Assumptions(false), getCodeCache().getTarget(), OptimisticOptimizations.ALL, graph.method().getProfilingInfo(), null);
 
             new LoweringPhase(new CanonicalizerPhase(true), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highTierContext);
             new GuardLoweringPhase().apply(graph, midTierContext);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -71,12 +71,17 @@
         public Constant constant;
 
         public HotSpotData(int offset) {
-            super(0, 0);
+            super(0);
             this.offset = offset;
         }
 
         @Override
-        public void emit(ByteBuffer buffer) {
+        public int getSize(Architecture arch) {
+            return 0;
+        }
+
+        @Override
+        public void emit(Architecture arch, ByteBuffer buffer) {
         }
     }
 
@@ -100,7 +105,7 @@
          */
         public final HotSpotData[] patches;
 
-        public DataSection(Site[] sites) {
+        public DataSection(Architecture arch, Site[] sites) {
             int size = 0;
             int patchCount = 0;
             List<DataPatch> externalDataList = new ArrayList<>();
@@ -111,8 +116,8 @@
                     DataPatch dataPatch = (DataPatch) site;
                     if (dataPatch.externalData != null) {
                         Data d = dataPatch.externalData;
-                        size = NumUtil.roundUp(size, d.alignment);
-                        size += d.size;
+                        size = NumUtil.roundUp(size, d.getAlignment());
+                        size += d.getSize(arch);
                         externalDataList.add(dataPatch);
                         if (dataPatch.getConstant() != null && dataPatch.getConstant().getKind() == Kind.Object) {
                             patchCount++;
@@ -132,8 +137,8 @@
             for (DataPatch dataPatch : externalDataList) {
                 Data d = dataPatch.externalData;
 
-                alignment = Math.max(alignment, d.alignment);
-                index = NumUtil.roundUp(index, d.alignment);
+                alignment = Math.max(alignment, d.getAlignment());
+                index = NumUtil.roundUp(index, d.getAlignment());
                 buffer.position(index);
 
                 HotSpotData hsData = new HotSpotData(index);
@@ -144,8 +149,8 @@
                 }
                 dataPatch.externalData = hsData;
 
-                index += d.size;
-                d.emit(buffer);
+                index += d.getSize(arch);
+                d.emit(arch, buffer);
             }
 
             this.sectionAlignment = alignment;
@@ -163,10 +168,10 @@
         }
     }
 
-    public HotSpotCompiledCode(CompilationResult compResult) {
+    public HotSpotCompiledCode(Architecture arch, CompilationResult compResult) {
         this.comp = compResult;
         sites = getSortedSites(compResult);
-        dataSection = new DataSection(sites);
+        dataSection = new DataSection(arch, sites);
         if (compResult.getExceptionHandlers().isEmpty()) {
             exceptionHandlers = null;
         } else {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java	Fri Jan 17 16:55:59 2014 +0100
@@ -35,8 +35,8 @@
     public final int entryBCI;
     public final int id;
 
-    public HotSpotCompiledNmethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) {
-        super(compResult);
+    public HotSpotCompiledNmethod(Architecture arch, HotSpotResolvedJavaMethod method, CompilationResult compResult) {
+        super(arch, compResult);
         this.method = method;
         this.entryBCI = compResult.getEntryBCI();
         this.id = compResult.getId();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java	Fri Jan 17 16:55:59 2014 +0100
@@ -38,8 +38,8 @@
 
     public final String stubName;
 
-    public HotSpotCompiledRuntimeStub(Stub stub, CompilationResult compResult) {
-        super(compResult);
+    public HotSpotCompiledRuntimeStub(Architecture arch, Stub stub, CompilationResult compResult) {
+        super(arch, compResult);
         assert checkStubInvariants(compResult);
         this.stubName = stub.toString();
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java	Fri Jan 17 16:55:59 2014 +0100
@@ -170,7 +170,7 @@
      * @param code the details of the installed CodeBlob are written to this object
      * @return the outcome of the installation as a {@link CodeInstallResult}.
      */
-    CodeInstallResult installCode(HotSpotCompiledCode compiledCode, HotSpotInstalledCode code, SpeculationLog cache);
+    CodeInstallResult installCode(HotSpotCompiledCode compiledCode, HotSpotInstalledCode code, SpeculationLog speculationLog);
 
     /**
      * Notifies the VM of statistics for a completed compilation.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Fri Jan 17 16:55:59 2014 +0100
@@ -23,15 +23,14 @@
 package com.oracle.graal.hotspot.bridge;
 
 import static com.oracle.graal.compiler.GraalDebugConfig.*;
-import static com.oracle.graal.graph.UnsafeAccess.*;
 import static com.oracle.graal.hotspot.CompileTheWorld.Options.*;
-import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import java.io.*;
 import java.lang.reflect.*;
 import java.security.*;
 import java.util.*;
 import java.util.concurrent.*;
+
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.CompilerThreadFactory.DebugConfigAccess;
@@ -519,12 +518,7 @@
 
     @Override
     public void compileMethod(long metaspaceMethod, final int entryBCI, final boolean blocking) {
-        HotSpotVMConfig config = runtime().getConfig();
-        final long metaspaceConstMethod = unsafe.getAddress(metaspaceMethod + config.methodConstMethodOffset);
-        final long metaspaceConstantPool = unsafe.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset);
-        final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + config.constantPoolHolderOffset);
-        final HotSpotResolvedObjectType holder = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
-        final HotSpotResolvedJavaMethod method = holder.createMethod(metaspaceMethod);
+        final HotSpotResolvedJavaMethod method = HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
         // We have to use a privileged action here because compilations are enqueued from user code
         // which very likely contains unprivileged frames.
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Fri Jan 17 16:55:59 2014 +0100
@@ -169,21 +169,22 @@
 
     public HotSpotInstalledCode installMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) {
         HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), true);
-        runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, compResult), installedCode, method.getSpeculationLog());
+        runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target.arch, method, compResult), installedCode, method.getSpeculationLog());
         return logOrDump(installedCode, compResult);
     }
 
     @Override
-    public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) {
+    public InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log) {
         HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method;
         HotSpotInstalledCode code = new HotSpotNmethod(hotspotMethod, compResult.getName(), false);
-        CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(hotspotMethod, compResult), code, null);
+        CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target.arch, hotspotMethod, compResult), code, log);
         if (result != CodeInstallResult.OK) {
             return null;
         }
         return logOrDump(code, compResult);
     }
 
+    @Override
     public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) {
         HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method;
         return installMethod(hotspotMethod, compResult);
@@ -192,7 +193,7 @@
     public InstalledCode addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) {
         HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method;
         HotSpotInstalledCode icode = new HotSpotNmethod(javaMethod, compResult.getName(), false, true);
-        HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compResult);
+        HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(target.arch, javaMethod, compResult);
         CompilerToVM vm = runtime.getCompilerToVM();
         CodeInstallResult result = vm.installCode(compiled, icode, null);
         if (result != CodeInstallResult.OK) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AbstractMethodHandleNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AbstractMethodHandleNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -176,9 +176,9 @@
         // Create a method from the vmtarget pointer
         Class<?> c = (Class<?>) clazz.asObject();
         HotSpotResolvedObjectType holderClass = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromClass(c);
-        HotSpotResolvedJavaMethod targetMethod = holderClass.createMethod(vmtarget.asLong());
+        HotSpotResolvedJavaMethod targetMethod = HotSpotResolvedJavaMethod.fromMetaspace(vmtarget.asLong());
 
-        // In lamda forms we erase signature types to avoid resolving issues
+        // In lambda forms we erase signature types to avoid resolving issues
         // involving class loaders. When we optimize a method handle invoke
         // to a direct call we must cast the receiver and arguments to its
         // actual types.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java	Fri Jan 17 16:55:59 2014 +0100
@@ -153,7 +153,7 @@
                 try (Scope s = Debug.scope("CodeInstall")) {
                     Stub stub = Stub.this;
                     HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
-                    HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult);
+                    HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(backend.getTarget().arch, stub, compResult);
 
                     CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null);
                     if (result != CodeInstallResult.OK) {
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Fri Jan 17 16:55:59 2014 +0100
@@ -44,6 +44,7 @@
  */
 public class JTTTest extends GraalCompilerTest {
 
+    protected static final Set<DeoptimizationReason> EMPTY = Collections.<DeoptimizationReason> emptySet();
     /**
      * The arguments which, if non-null, will replace the Locals in the test method's graph.
      */
@@ -94,17 +95,29 @@
     }
 
     protected void runTest(String name, Object... args) {
-        runTest(Collections.<DeoptimizationReason> emptySet(), name, args);
+        runTest(EMPTY, name, args);
     }
 
     protected void runTest(Set<DeoptimizationReason> shouldNotDeopt, String name, Object... args) {
+        runTest(shouldNotDeopt, true, false, name, args);
+    }
+
+    protected void runTest(Set<DeoptimizationReason> shouldNotDeopt, boolean bind, boolean noProfile, String name, Object... args) {
         Method method = getMethod(name);
         Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this;
 
         Result expect = executeExpected(method, receiver, args);
 
+        if (noProfile) {
+            getMetaAccess().lookupJavaMethod(method).reprofile();
+        }
+
         testAgainstExpected(method, expect, shouldNotDeopt, receiver, args);
-        if (args.length > 0) {
+        if (args.length > 0 && bind) {
+            if (noProfile) {
+                getMetaAccess().lookupJavaMethod(method).reprofile();
+            }
+
             this.argsToBind = args;
             testAgainstExpected(method, expect, shouldNotDeopt, receiver, args);
             this.argsToBind = null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/CharacterBits.java	Fri Jan 17 16:55:59 2014 +0100
@@ -0,0 +1,56 @@
+/*
+ * 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.jtt.jdk;
+
+import com.oracle.graal.jtt.*;
+import org.junit.*;
+
+public class CharacterBits extends JTTTest {
+    @SuppressWarnings("unused") private static char init = Character.reverseBytes((char) 42);
+    private static char original = 0x1708;
+
+    public static char test(char o) {
+        return Character.reverseBytes(o);
+    }
+
+    @Test
+    public void run0() {
+        runTest("test", original);
+    }
+
+    @Test
+    public void run1() {
+        runTest("test", (char) 0x1708L);
+    }
+
+    @Test
+    public void run2() {
+        runTest("test", (char) 0);
+        runTest("test", (char) 1);
+        runTest("test", (char) -1);
+        runTest("test", (char) 0x00ff);
+        runTest("test", (char) 0xff00);
+        runTest("test", (char) 0xffff);
+        runTest("test", (char) 0x3fff);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/ShortBits.java	Fri Jan 17 16:55:59 2014 +0100
@@ -0,0 +1,56 @@
+/*
+ * 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.jtt.jdk;
+
+import com.oracle.graal.jtt.*;
+import org.junit.*;
+
+public class ShortBits extends JTTTest {
+    @SuppressWarnings("unused") private static short init = Short.reverseBytes((short) 42);
+    private static short original = 0x1708;
+
+    public static short test(short o) {
+        return Short.reverseBytes(o);
+    }
+
+    @Test
+    public void run0() {
+        runTest("test", original);
+    }
+
+    @Test
+    public void run1() {
+        runTest("test", (short) 0x1708L);
+    }
+
+    @Test
+    public void run2() {
+        runTest("test", (short) 0);
+        runTest("test", (short) 1);
+        runTest("test", (short) -1);
+        runTest("test", (short) 0x00ff);
+        runTest("test", (short) 0xff00);
+        runTest("test", (short) 0xffff);
+        runTest("test", (short) 0x3fff);
+    }
+}
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/DeoptimizeNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -76,6 +76,10 @@
         return ConstantNode.forConstant(speculation, metaAccess, graph());
     }
 
+    public Constant getSpeculation() {
+        return speculation;
+    }
+
     @NodeIntrinsic
     public static native void deopt(@ConstantNodeParameter DeoptimizationAction action, @ConstantNodeParameter DeoptimizationReason reason);
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -45,7 +45,7 @@
 
     @Input private LogicNode condition;
     private final DeoptimizationReason reason;
-    private final Constant speculation;
+    private Constant speculation;
     private DeoptimizationAction action;
     private boolean negated;
 
@@ -86,6 +86,10 @@
         return speculation;
     }
 
+    public void setSpeculation(Constant speculation) {
+        this.speculation = speculation;
+    }
+
     @Override
     public String toString(Verbosity verbosity) {
         if (verbosity == Verbosity.Name && negated) {
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/FloatStamp.java	Fri Jan 17 16:55:59 2014 +0100
@@ -148,6 +148,7 @@
         final int prime = 31;
         int result = 1;
         long temp;
+        result = prime * result + kind().hashCode();
         temp = Double.doubleToLongBits(lowerBound);
         result = prime * result + (int) (temp ^ (temp >>> 32));
         result = prime * result + (nonNaN ? 1231 : 1237);
@@ -165,6 +166,9 @@
             return false;
         }
         FloatStamp other = (FloatStamp) obj;
+        if (kind() != other.kind()) {
+            return false;
+        }
         if (Double.doubleToLongBits(lowerBound) != Double.doubleToLongBits(other.lowerBound)) {
             return false;
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IntegerStamp.java	Fri Jan 17 16:55:59 2014 +0100
@@ -194,6 +194,7 @@
     public int hashCode() {
         final int prime = 31;
         int result = 1;
+        result = prime * result + kind().hashCode();
         result = prime * result + (int) (lowerBound ^ (lowerBound >>> 32));
         result = prime * result + (int) (upperBound ^ (upperBound >>> 32));
         result = prime * result + (int) (downMask ^ (downMask >>> 32));
@@ -210,7 +211,7 @@
             return false;
         }
         IntegerStamp other = (IntegerStamp) obj;
-        if (lowerBound != other.lowerBound || upperBound != other.upperBound || downMask != other.downMask || upMask != other.upMask) {
+        if (lowerBound != other.lowerBound || upperBound != other.upperBound || downMask != other.downMask || upMask != other.upMask || kind() != other.kind()) {
             return false;
         }
         return true;
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/UseTrappingNullChecksPhase.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/UseTrappingNullChecksPhase.java	Fri Jan 17 16:55:59 2014 +0100
@@ -22,6 +22,7 @@
  */
 package com.oracle.graal.phases.common;
 
+import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
@@ -46,6 +47,12 @@
     }
 
     private static void tryUseTrappingNullCheck(DeoptimizeNode deopt) {
+        if (deopt.reason() != DeoptimizationReason.NullCheckException) {
+            return;
+        }
+        if (deopt.getSpeculation() != null && deopt.getSpeculation() != Constant.NULL_OBJECT) {
+            return;
+        }
         Node predecessor = deopt.predecessor();
         Node branch = null;
         while (predecessor instanceof AbstractBeginNode) {
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Fri Jan 17 16:55:59 2014 +0100
@@ -32,12 +32,14 @@
     private final TargetDescription target;
     private final OptimisticOptimizations optimisticOpts;
     private final ProfilingInfo profilingInfo;
+    private final SpeculationLog log;
 
-    public MidTierContext(Providers copyFrom, Assumptions assumptions, TargetDescription target, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo) {
+    public MidTierContext(Providers copyFrom, Assumptions assumptions, TargetDescription target, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog log) {
         super(copyFrom, assumptions);
         this.target = target;
         this.optimisticOpts = optimisticOpts;
         this.profilingInfo = profilingInfo;
+        this.log = log;
     }
 
     public TargetDescription getTarget() {
@@ -51,4 +53,8 @@
     public ProfilingInfo getProfilingInfo() {
         return profilingInfo;
     }
+
+    public SpeculationLog getSpeculationLog() {
+        return log;
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CharacterSubstitutions.java	Fri Jan 17 16:55:59 2014 +0100
@@ -0,0 +1,34 @@
+/*
+ * 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.replacements;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.replacements.nodes.*;
+
+@ClassSubstitution(Character.class)
+public class CharacterSubstitutions {
+    @MethodSubstitution
+    public static char reverseBytes(char i) {
+        return (char) (ReverseBytesNode.reverse(i) >> 16);
+    }
+}
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/GraalMethodSubstitutions.java	Fri Jan 17 16:55:59 2014 +0100
@@ -47,6 +47,8 @@
             replacements.registerSubstitutions(FloatSubstitutions.class);
             replacements.registerSubstitutions(LongSubstitutions.class);
             replacements.registerSubstitutions(IntegerSubstitutions.class);
+            replacements.registerSubstitutions(CharacterSubstitutions.class);
+            replacements.registerSubstitutions(ShortSubstitutions.class);
             replacements.registerSubstitutions(UnsignedMathSubstitutions.class);
             replacements.registerSubstitutions(NodeClassSubstitutions.class);
             replacements.registerSubstitutions(CompositeValueClassSubstitutions.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ShortSubstitutions.java	Fri Jan 17 16:55:59 2014 +0100
@@ -0,0 +1,34 @@
+/*
+ * 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.replacements;
+
+import com.oracle.graal.api.replacements.*;
+import com.oracle.graal.replacements.nodes.*;
+
+@ClassSubstitution(Short.class)
+public class ShortSubstitutions {
+    @MethodSubstitution
+    public static short reverseBytes(short i) {
+        return (short) (ReverseBytesNode.reverse(i) >> 16);
+    }
+}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java	Fri Jan 17 16:55:59 2014 +0100
@@ -244,7 +244,7 @@
 
         InstalledCode installedCode = null;
         try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache()); TimerCloseable a = CodeInstallationTime.start()) {
-            installedCode = providers.getCodeCache().addMethod(graph.method(), result);
+            installedCode = providers.getCodeCache().addMethod(graph.method(), result, null);
         } catch (Throwable e) {
             throw Debug.handle(e);
         }
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/InstrumentationProbeNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -373,7 +373,9 @@
                 if (stepping) {
                     getContext().getDebugManager().haltedAt(astNode, frame.materialize());
                 }
-                next.internalEnter(astNode, frame);
+                if (next != null) {
+                    next.internalEnter(astNode, frame);
+                }
             }
         }
 
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/NodePhylum.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/instrument/NodePhylum.java	Fri Jan 17 16:55:59 2014 +0100
@@ -29,7 +29,7 @@
  * and other simple tool behavior. These categories (<em>phyla</em>) should correspond to program
  * structures that are meaningful to a programmer using the guest language. A Truffle node without a
  * proxy carrying some phylum should be treated as an artifact of the guest language implementation
- * and should never to the user of a guest language programming tool.
+ * and should never be visible to the user of a guest language programming tool.
  * <p>
  * Note that phyla are not intended to represent a partition of user-visible node categories, as the
  * relative categorization of nodes can change with the particular programming tasks at hand.
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceManager.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceManager.java	Fri Jan 17 16:55:59 2014 +0100
@@ -33,7 +33,7 @@
  * A representation of source code information, suitable for hash table keys with equality defined
  * in terms of content. There are three kinds of sources supported at present.
  * <ul>
- * <li><strong>File:</strong>Each file is represented as a canonical object, indexed by the
+ * <li><strong>File:</strong> Each file is represented as a canonical object, indexed by the
  * absolute, canonical path name of the file. The textual contents of the file may be supplied when
  * the object is created, or it may be read lazily. Only one lazy attempt will be made to read a
  * file, and failure will result silently in null content.</li>
@@ -43,6 +43,20 @@
  * <li><strong>Fake Files:</strong> A named text string used for testing; its contents can be
  * retrieved by name, unlike literal sources.</li>
  * </ul>
+ * <p>
+ * <strong>Cache:</strong>
+ * <ol>
+ * <li>Access to source file contents via {@link Source#getInputStream()} or
+ * {@link Source#getReader()} does <em>not</em> by itself result in the file's contents being cached
+ * in the {@link Source} object.</li>
+ * <li>Access to source file contents via {@link Source#getCode()} or any other {@link Source}
+ * methods related to file's contents <em>will</em> result in the contents being cached in the
+ * {@link Source} object.</li>
+ * <li>Once source file contents have been cached, access to source file contents via
+ * {@link Source#getInputStream()} or {@link Source#getReader()} will be provided from the cache.</li>
+ * <li>Any access to source file contents via the cache will result in a timestamp check and
+ * possible cache reload.</li>
+ * </ol>
  */
 public final class SourceManager {
 
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/KernelNodes.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/core/KernelNodes.java	Fri Jan 17 16:55:59 2014 +0100
@@ -629,13 +629,6 @@
 
         @Specialization(order = 3)
         public Object raise(VirtualFrame frame, RubyClass exceptionClass, RubyString message) {
-            final RubyContext context = getContext();
-
-            if (context.getConfiguration().getPrintRubyExceptions()) {
-                context.implementationMessage("Ruby raise: %s", message);
-                new Exception().printStackTrace();
-            }
-
             final RubyBasicObject exception = exceptionClass.newInstance();
             initialize.dispatch(frame, exception, null, message);
             throw new RaiseException(exception);
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/literal/HashLiteralNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/literal/HashLiteralNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -41,4 +41,9 @@
         return hash;
     }
 
+    @Override
+    public Object isDefined(VirtualFrame frame) {
+        return getContext().makeString("expression");
+    }
+
 }
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/methods/CatchNextNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/methods/CatchNextNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -39,4 +39,5 @@
             return e.getResult();
         }
     }
+
 }
--- a/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/methods/MethodDefinitionNode.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/methods/MethodDefinitionNode.java	Fri Jan 17 16:55:59 2014 +0100
@@ -91,4 +91,8 @@
         return name;
     }
 
+    public CallTarget getCallTarget() {
+        return callTarget;
+    }
+
 }
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/RubyContext.java	Fri Jan 17 16:55:59 2014 +0100
@@ -169,10 +169,6 @@
     }
 
     public Object execute(RubyContext context, Source source, RubyParser.ParserContext parserContext, Object self, MaterializedFrame parentFrame) {
-        if (configuration.getPrintExecutedFiles()) {
-            implementationMessage("executing: %s", source.getName());
-        }
-
         try {
             final RubyParserResult parseResult = parser.parse(context, source, parserContext, parentFrame);
             final RubyArguments arguments = new RubyArguments(parentFrame, self, null);
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/Configuration.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/Configuration.java	Fri Jan 17 16:55:59 2014 +0100
@@ -32,11 +32,8 @@
     private final boolean fullObjectSpace;
 
     private final boolean printParseTree;
-    private final boolean printExecutedFiles;
-    private final boolean printSpiltInstanceVariables;
     private final boolean printUninitializedCalls;
     private final boolean printJavaExceptions;
-    private final boolean printRubyExceptions;
 
     private final PrintStream standardOut;
     private final InputReader inputReader;
@@ -58,11 +55,8 @@
         fullObjectSpace = builder.getFullObjectSpace();
 
         printParseTree = builder.getPrintParseTree();
-        printExecutedFiles = builder.getPrintExecutedFiles();
-        printSpiltInstanceVariables = builder.getPrintSpiltInstanceVariables();
         printUninitializedCalls = builder.getPrintUninitializedCalls();
         printJavaExceptions = builder.getPrintJavaExceptions();
-        printRubyExceptions = builder.getPrintRubyExceptions();
 
         standardOut = builder.getStandardOut();
         inputReader = builder.getInputReader();
@@ -108,14 +102,6 @@
         return printParseTree;
     }
 
-    public boolean getPrintExecutedFiles() {
-        return printExecutedFiles;
-    }
-
-    public boolean getPrintSpiltInstanceVariables() {
-        return printSpiltInstanceVariables;
-    }
-
     public boolean getPrintUninitializedCalls() {
         return printUninitializedCalls;
     }
@@ -124,10 +110,6 @@
         return printJavaExceptions;
     }
 
-    public boolean getPrintRubyExceptions() {
-        return printRubyExceptions;
-    }
-
     public PrintStream getStandardOut() {
         return standardOut;
     }
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/ConfigurationBuilder.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/configuration/ConfigurationBuilder.java	Fri Jan 17 16:55:59 2014 +0100
@@ -37,11 +37,8 @@
     private boolean fullObjectSpace = false;
 
     private boolean printParseTree = false;
-    private boolean printExecutedFiles = false;
-    private boolean printSpiltInstanceVariables = false;
     private boolean printUninitializedCalls = false;
     private boolean printJavaExceptions = false;
-    private boolean printRubyExceptions = false;
 
     private PrintStream standardOut = System.out;
 
@@ -77,11 +74,8 @@
         fullObjectSpace = configuration.getFullObjectSpace();
 
         printParseTree = configuration.getPrintParseTree();
-        printExecutedFiles = configuration.getPrintExecutedFiles();
-        printSpiltInstanceVariables = configuration.getPrintSpiltInstanceVariables();
         printUninitializedCalls = configuration.getPrintUninitializedCalls();
         printJavaExceptions = configuration.getPrintJavaExceptions();
-        printRubyExceptions = configuration.getPrintRubyExceptions();
 
         standardOut = configuration.getStandardOut();
     }
@@ -169,22 +163,6 @@
         this.printParseTree = printParseTree;
     }
 
-    public boolean getPrintExecutedFiles() {
-        return printExecutedFiles;
-    }
-
-    public void setPrintExecutedFiles(boolean printExecutedFiles) {
-        this.printExecutedFiles = printExecutedFiles;
-    }
-
-    public boolean getPrintSpiltInstanceVariables() {
-        return printSpiltInstanceVariables;
-    }
-
-    public void setPrintSpiltInstanceVariables(boolean printSpiltInstanceVariables) {
-        this.printSpiltInstanceVariables = printSpiltInstanceVariables;
-    }
-
     public boolean getPrintUninitializedCalls() {
         return printUninitializedCalls;
     }
@@ -201,14 +179,6 @@
         this.printJavaExceptions = printJavaExceptions;
     }
 
-    public boolean getPrintRubyExceptions() {
-        return printRubyExceptions;
-    }
-
-    public void setPrintRubyExceptions(boolean printRubyExceptions) {
-        this.printRubyExceptions = printRubyExceptions;
-    }
-
     public PrintStream getStandardOut() {
         return standardOut;
     }
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/CoreLibrary.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/CoreLibrary.java	Fri Jan 17 16:55:59 2014 +0100
@@ -20,6 +20,8 @@
 
 public class CoreLibrary {
 
+    public static final String RUBY_VERSION = "2.1.0";
+
     private final RubyContext context;
 
     private RubyClass argumentErrorClass;
@@ -164,7 +166,7 @@
 
         // Set constants
 
-        objectClass.setConstant("RUBY_VERSION", new RubyString(stringClass, "2.1.0"));
+        objectClass.setConstant("RUBY_VERSION", new RubyString(stringClass, RUBY_VERSION));
         objectClass.setConstant("RUBY_PATCHLEVEL", 0);
         objectClass.setConstant("RUBY_ENGINE", new RubyString(stringClass, "rubytruffle"));
         objectClass.setConstant("RUBY_PLATFORM", new RubyString(stringClass, "jvm"));
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/RubyClass.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/core/RubyClass.java	Fri Jan 17 16:55:59 2014 +0100
@@ -114,7 +114,7 @@
 
         include(superclass);
 
-        objectLayoutForInstances = new ObjectLayout(getName(), getContext(), superclass.objectLayoutForInstances);
+        objectLayoutForInstances = new ObjectLayout(getName(), superclass.objectLayoutForInstances);
     }
 
     public RubyBasicObject newInstance() {
@@ -157,7 +157,7 @@
     }
 
     private void renewObjectLayoutForInstances() {
-        objectLayoutForInstances = objectLayoutForInstances.renew(getContext(), superclass.objectLayoutForInstances);
+        objectLayoutForInstances = objectLayoutForInstances.renew(superclass.objectLayoutForInstances);
 
         for (RubyClass subClass : subClasses) {
             subClass.renewObjectLayoutForInstances();
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/objects/ObjectLayout.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/objects/ObjectLayout.java	Fri Jan 17 16:55:59 2014 +0100
@@ -17,7 +17,6 @@
 
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.nodes.NodeUtil.*;
-import com.oracle.truffle.ruby.runtime.*;
 
 /**
  * Maps names of instance variables to storage locations, which are either the offset of a primitive
@@ -49,11 +48,11 @@
         objectStorageLocationsUsed = 0;
     }
 
-    public ObjectLayout(String originHint, RubyContext context, ObjectLayout parent) {
-        this(originHint, context, parent, new HashMap<String, Class>());
+    public ObjectLayout(String originHint, ObjectLayout parent) {
+        this(originHint, parent, new HashMap<String, Class>());
     }
 
-    public ObjectLayout(String originHint, RubyContext context, ObjectLayout parent, Map<String, Class> storageTypes) {
+    public ObjectLayout(String originHint, ObjectLayout parent, Map<String, Class> storageTypes) {
         this.originHint = originHint;
         this.parent = parent;
 
@@ -105,10 +104,6 @@
                     storageLocations.put(entry.getKey(), newStorageLocation);
                     primitiveStorageLocationIndex += primitivesNeeded;
                 } else {
-                    if (canStoreInPrimitive && context.getConfiguration().getPrintSpiltInstanceVariables()) {
-                        context.implementationMessage("instance variable %s of type %s spilt due to lack of space", name, type.getName());
-                    }
-
                     final ObjectStorageLocation newStorageLocation = new ObjectStorageLocation(this, objectStorageLocationIndex);
                     storageLocations.put(entry.getKey(), newStorageLocation);
                     objectStorageLocationIndex++;
@@ -125,25 +120,25 @@
      * comes from the same Ruby class as it did, but it's a new layout because layouts are
      * immutable, so modifications to the superclass yields a new layout.
      */
-    public ObjectLayout renew(RubyContext context, ObjectLayout newParent) {
-        return new ObjectLayout(originHint + ".renewed", context, newParent, getStorageTypes());
+    public ObjectLayout renew(ObjectLayout newParent) {
+        return new ObjectLayout(originHint + ".renewed", newParent, getStorageTypes());
     }
 
     /**
      * Create a new version of this layout but with a new variable.
      */
-    public ObjectLayout withNewVariable(RubyContext context, String name, Class type) {
+    public ObjectLayout withNewVariable(String name, Class type) {
         final Map<String, Class> storageTypes = getStorageTypes();
         storageTypes.put(name, type);
-        return new ObjectLayout(originHint + ".withnew", context, parent, storageTypes);
+        return new ObjectLayout(originHint + ".withnew", parent, storageTypes);
     }
 
     /**
      * Create a new version of this layout but with an existing variable generalized to support any
      * type.
      */
-    public ObjectLayout withGeneralisedVariable(RubyContext context, String name) {
-        return withNewVariable(context, name, Object.class);
+    public ObjectLayout withGeneralisedVariable(String name) {
+        return withNewVariable(name, Object.class);
     }
 
     /**
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/objects/RubyBasicObject.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/objects/RubyBasicObject.java	Fri Jan 17 16:55:59 2014 +0100
@@ -124,7 +124,7 @@
              * the layout of this object.
              */
 
-            rubyClass.setObjectLayoutForInstances(rubyClass.getObjectLayoutForInstances().withNewVariable(rubyClass.getContext(), name, value.getClass()));
+            rubyClass.setObjectLayoutForInstances(rubyClass.getObjectLayoutForInstances().withNewVariable(name, value.getClass()));
             updateLayout();
 
             storageLocation = objectLayout.findStorageLocation(name);
@@ -140,7 +140,7 @@
              * layout and update the layout of this object.
              */
 
-            rubyClass.setObjectLayoutForInstances(rubyClass.getObjectLayoutForInstances().withGeneralisedVariable(rubyClass.getContext(), name));
+            rubyClass.setObjectLayoutForInstances(rubyClass.getObjectLayoutForInstances().withGeneralisedVariable(name));
             updateLayout();
 
             storageLocation = objectLayout.findStorageLocation(name);
@@ -315,15 +315,13 @@
     }
 
     public void switchToPrivateLayout() {
-        final RubyContext context = getRubyClass().getContext();
-
         final Map<String, Object> instanceVariables = getInstanceVariables();
 
         hasPrivateLayout = true;
         objectLayout = ObjectLayout.EMPTY;
 
         for (Entry<String, Object> entry : instanceVariables.entrySet()) {
-            objectLayout = objectLayout.withNewVariable(context, entry.getKey(), entry.getValue().getClass());
+            objectLayout = objectLayout.withNewVariable(entry.getKey(), entry.getValue().getClass());
         }
 
         setInstanceVariables(instanceVariables);
--- a/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/subsystems/FeatureManager.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.runtime/src/com/oracle/truffle/ruby/runtime/subsystems/FeatureManager.java	Fri Jan 17 16:55:59 2014 +0100
@@ -35,11 +35,6 @@
     public boolean require(String feature) throws IOException {
         // Some features are handled specially
 
-        if (feature.equals("continuation")) {
-            // We always load continuations
-            return true;
-        }
-
         if (feature.equals("stringio")) {
             context.implementationMessage("stringio not yet implemented");
             return true;
--- a/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/CommandLineParser.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.shell/src/com/oracle/truffle/ruby/shell/CommandLineParser.java	Fri Jan 17 16:55:59 2014 +0100
@@ -217,21 +217,12 @@
                         case "--print-parse-tree":
                             configurationBuilder.setPrintParseTree(true);
                             break;
-                        case "--print-executed-files":
-                            configurationBuilder.setPrintExecutedFiles(true);
-                            break;
-                        case "--print-spilt-instance-variables":
-                            configurationBuilder.setPrintSpiltInstanceVariables(true);
-                            break;
                         case "--print-uninitialized-calls":
                             configurationBuilder.setPrintUninitializedCalls(true);
                             break;
                         case "--print-java-exceptions":
                             configurationBuilder.setPrintJavaExceptions(true);
                             break;
-                        case "--print-ruby-exceptions":
-                            configurationBuilder.setPrintRubyExceptions(true);
-                            break;
                         default:
                             throw new IllegalArgumentException("unknown flag " + arg);
                     }
@@ -337,12 +328,8 @@
         out.println("  --no-intrinsic-method-calls       don't turn method calls into intrinsic nodes");
         out.println("  --no-jline                        don't use JLine");
         out.println("  --print-parse-tree                print the result of parsing");
-        out.println("  --print-executed-files            print the name of files as they are executed");
-        out.println("  --print-missing-intrinsics        print method calls that don't have intrinsic nodes");
-        out.println("  --print-spilt-instance-variables  print each time a native-typed instance variable is spilt to the boxed array");
         out.println("  --print-uninitialized-calls       print each time a method call is uninitialized");
         out.println("  --print-java-exceptions           print Java exception back traces at the point of translating them to Ruby exceptions");
-        out.println("  --print-ruby-exceptions           print the Java exception back traces at the point of raising Ruby exceptions");
         out.println("Relevant environment variables:");
         out.println("  RUBYHOME                          location of the Ruby Truffle installation");
         out.println("  RUBYOPT                           extra command line arguments");
--- a/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ContinuationTests.java	Thu Jan 16 15:20:17 2014 +0100
+++ b/graal/com.oracle.truffle.ruby.test/src/com/oracle/truffle/ruby/test/core/ContinuationTests.java	Fri Jan 17 16:55:59 2014 +0100
@@ -20,23 +20,23 @@
 
     @Test
     public void testRequired() {
-        assertPrints("", "require \"continuation\"; callcc { |c| c.call }");
+        assertPrints("", "callcc { |c| c.call }");
     }
 
     @Test
     public void testOneShotGoingUpCallstack() {
-        assertPrints("1\n3\n", "require \"continuation\"; callcc { |c| puts 1; c.call; puts 2 }; puts 3");
+        assertPrints("1\n3\n", "callcc { |c| puts 1; c.call; puts 2 }; puts 3");
     }
 
     @Test
     public void testOneShotGoingUpCallstackReturnValue() {
-        assertPrints("14\n", "require \"continuation\"; puts callcc { |c| c.call 14 }");
+        assertPrints("14\n", "puts callcc { |c| c.call 14 }");
     }
 
     @Test
     public void testNestedOneShotGoingUpCallstack() {
-        assertPrints("1\n2\n4\n5\n", "require \"continuation\"; callcc { |c1| puts 1; callcc { |c2| puts 2; c2.call; puts 3 }; puts 4 }; puts 5");
-        assertPrints("1\n2\n5\n", "require \"continuation\"; callcc { |c1| puts 1; callcc { |c2| puts 2; c1.call; puts 3 }; puts 4 }; puts 5");
+        assertPrints("1\n2\n4\n5\n", "callcc { |c1| puts 1; callcc { |c2| puts 2; c2.call; puts 3 }; puts 4 }; puts 5");
+        assertPrints("1\n2\n5\n", "callcc { |c1| puts 1; callcc { |c2| puts 2; c1.call; puts 3 }; puts 4 }; puts 5");
     }
 
 }
--- a/src/gpu/ptx/vm/gpu_ptx.cpp	Thu Jan 16 15:20:17 2014 +0100
+++ b/src/gpu/ptx/vm/gpu_ptx.cpp	Fri Jan 17 16:55:59 2014 +0100
@@ -417,7 +417,6 @@
     }
     thread->set_vm_result(return_val);
   } else if (returnTypeSize > 0) {
-    jlong result;
     status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&primitiveReturnValue, device_return_value, T_LONG_BYTE_SIZE);
     if (status != GRAAL_CUDA_SUCCESS) {
       tty->print_cr("[CUDA] *** Error (%d) Failed to copy value from device argument", status);
--- a/src/share/vm/runtime/deoptimization.cpp	Thu Jan 16 15:20:17 2014 +0100
+++ b/src/share/vm/runtime/deoptimization.cpp	Fri Jan 17 16:55:59 2014 +0100
@@ -1359,7 +1359,7 @@
     ScopeDesc*      trap_scope  = cvf->scope();
     
     if (TraceDeoptimization) {
-      tty->print_cr("  bci=%d pc=%d, relative_pc=%d, method=%s" GRAAL_ONLY(", speculation=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name()->as_C_string()
+      tty->print_cr("  bci=%d pc=%d, relative_pc=%d, method=%s" GRAAL_ONLY(", debug_id=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name()->as_C_string()
 #ifdef GRAAL
           , debug_id
 #endif
@@ -1373,14 +1373,25 @@
     if (speculation != NULL) {
       oop speculation_log = nm->speculation_log();
       if (speculation_log != NULL) {
-        if (TraceUncollectedSpeculations) {
+        if (TraceDeoptimization || TraceUncollectedSpeculations) {
           if (SpeculationLog::lastFailed(speculation_log) != NULL) {
             tty->print_cr("A speculation that was not collected by the compiler is being overwritten");
           }
         }
+        if (TraceDeoptimization) {
+          tty->print_cr("Saving speculation to speculation log");
+        }
         SpeculationLog::set_lastFailed(speculation_log, speculation);
+      } else {
+        if (TraceDeoptimization) {
+          tty->print_cr("Speculation present but no speculation log");
+        }
       }
       thread->set_pending_failed_speculation(NULL);
+    } else {
+      if (TraceDeoptimization) {
+        tty->print_cr("No speculation");
+      }
     }
 
     if (trap_bci == SynchronizationEntryBCI) {
@@ -1490,7 +1501,7 @@
           tty->print(" (Graal: no installed code) ");
         }
 #endif //GRAAL
-        tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" GRAAL_ONLY(" speculation=%d"),
+        tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" GRAAL_ONLY(" debug_id=%d"),
                    fr.pc(),
                    os::current_thread_id(),
                    trap_reason_name(reason),
@@ -2025,14 +2036,14 @@
 #endif
   size_t len;
   if (unloaded_class_index < 0) {
-    len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" GRAAL_ONLY(" speculation='%d'"),
+    len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" GRAAL_ONLY(" debug_id='%d'"),
                        reason, action
 #ifdef GRAAL
                        ,debug_id
 #endif
                        );
   } else {
-    len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" GRAAL_ONLY(" speculation='%d'"),
+    len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" GRAAL_ONLY(" debug_id='%d'"),
                        reason, action, unloaded_class_index
 #ifdef GRAAL
                        ,debug_id