changeset 12505:0b0e60214f49

Merge.
author Doug Simon <doug.simon@oracle.com>
date Mon, 21 Oct 2013 18:37:19 +0200
parents 1d68b3962a10 (diff) 249c54db0276 (current diff)
children 1be3cb11f88e
files
diffstat 39 files changed, 314 insertions(+), 185 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ExternalCompilationResult.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ExternalCompilationResult.java	Mon Oct 21 18:37:19 2013 +0200
@@ -23,12 +23,12 @@
 package com.oracle.graal.api.code;
 
 /**
- * Represents the output from compiling a method generated by graal, but executing 
- * in a memory and computational subsystem outside the graal host system.
+ * Represents the output from compiling a method generated by Graal, but executing in a memory and
+ * computational subsystem outside the Graal host system.
  * 
- * Output may include the compiled machine code, associated
- * data and references, relocation information, deoptimization information,
- * as this result is generated from a structure graph on the graal host system.
+ * Output may include the compiled machine code, associated data and references, relocation
+ * information, deoptimization information, as this result is generated from a structure graph on
+ * the Graal host system.
  */
 public class ExternalCompilationResult extends CompilationResult {
 
@@ -45,7 +45,8 @@
 
     /**
      * Set the address for the point of entry to the external compilation result.
-     * @param addr    The address of the entry point.
+     * 
+     * @param addr the address of the entry point
      */
     public void setEntryPoint(long addr) {
         entryPoint = addr;
@@ -53,9 +54,10 @@
 
     /**
      * Return the address for the point of entry to the external compilation result.
+     * 
      * @return address value
      */
     public long getEntryPoint() {
-      return entryPoint;
+        return entryPoint;
     }
 }
--- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java	Mon Oct 21 18:37:19 2013 +0200
@@ -918,9 +918,8 @@
         public void emit(PTXAssembler asm) {
 
             if (booleanOperator != null) {
-                asm.emitString("setp." + operator.getOperator() + "." + booleanOperator.getOperator() + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ", %r;"); // Predicates
-// need to be objects
-
+                // Predicates need to be objects
+                asm.emitString("setp." + operator.getOperator() + "." + booleanOperator.getOperator() + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ", %r;");
             } else {
                 asm.emitString("setp." + operator.getOperator() + "." + typeForKind(kind) + " %p" + predicate + emitValue(first) + emitValue(second) + ";");
             }
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ArrayPTXTest.java	Mon Oct 21 18:37:19 2013 +0200
@@ -35,15 +35,9 @@
 
     @Test
     public void testArray() {
-        int[] array1 = {
-            1, 2, 3, 4, 5, 6, 7, 8, 9
-        };
-        int[] array2 = {
-            1, 2, 3, 4, 5, 6, 7, 8, 9
-        };
-        int[] array3 = {
-            1, 2, 3, 4, 5, 6, 7, 8, 9
-        };
+        int[] array1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+        int[] array2 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+        int[] array3 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
 
         invoke(compile("testStoreArray1I"), array1, 2);
         printReport("testStoreArray1I: " + Arrays.toString(array1));
@@ -60,17 +54,14 @@
         array[i] = 42;
     }
 
-    public static void testStoreArrayWarp0(int[] array,
-                                           @Warp(dimension = X) int i) {
+    public static void testStoreArrayWarp0(int[] array, @Warp(dimension = X) int i) {
         array[i] = 42;
     }
 
-    public static void testStoreArrayWarp1I(@ParallelOver(dimension = X) int[] array,
-                                            @Warp(dimension = X) int i) {
+    public static void testStoreArrayWarp1I(@ParallelOver(dimension = X) int[] array, @Warp(dimension = X) int i) {
         array[i] = 42;
     }
 
-
     public static void main(String[] args) {
         ArrayPTXTest test = new ArrayPTXTest();
         for (Method m : ArrayPTXTest.class.getMethods()) {
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/ControlPTXTest.java	Mon Oct 21 18:37:19 2013 +0200
@@ -60,12 +60,10 @@
         } else {
             printReport("testIfElse2I: no VALUE");
         }
-        Boolean bret = (Boolean) invoke(compile("testIntegerTestBranch2I"),
-                                        0xff00, 0x00ff);
+        Boolean bret = (Boolean) invoke(compile("testIntegerTestBranch2I"), 0xff00, 0x00ff);
         if (bret != null) {
             printReport("testIntegerTestBranch2I: " + bret);
-            printReport("testIntegerTestBranch2I: actual: " +
-                                testIntegerTestBranch2I(0xff00, 0x00ff));
+            printReport("testIntegerTestBranch2I: actual: " + testIntegerTestBranch2I(0xff00, 0x00ff));
         } else {
             printReport("testIntegerTestBranch2I: no VALUE");
         }
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/IntegerPTXTest.java	Mon Oct 21 18:37:19 2013 +0200
@@ -31,6 +31,7 @@
     @Test
     public void testAdd() {
 
+        // @formatter:off
         /* Integer r4 = (Integer) invoke(compile("testAdd2B"), (byte) 6, (byte) 4);
         if (r4 == null) {
             printReport("testAdd2B FAILED");
@@ -39,6 +40,7 @@
         } else {
             printReport("testAdd2B FAILED");
         } */
+        // @formatter:on
 
         Integer r4 = (Integer) invoke(compile("testAdd2I"), 18, 24);
         if (r4 == null) {
@@ -346,7 +348,6 @@
         return (int) a;
     }
 
-
     public static void main(String[] args) {
         IntegerPTXTest test = new IntegerPTXTest();
         for (Method m : IntegerPTXTest.class.getMethods()) {
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Mon Oct 21 18:37:19 2013 +0200
@@ -242,14 +242,14 @@
             case Object:
                 append(new BranchOp(finalCondition, label, kind));
                 break;
-// case Float:
-// append(new CompareOp(FCMP, x, y));
-// append(new BranchOp(condition, label));
-// break;
-// case Double:
-// append(new CompareOp(DCMP, x, y));
-// append(new BranchOp(condition, label));
-// break;
+            // case Float:
+            // append(new CompareOp(FCMP, x, y));
+            // append(new BranchOp(condition, label));
+            // break;
+            // case Double:
+            // append(new CompareOp(DCMP, x, y));
+            // append(new BranchOp(condition, label));
+            // break;
             default:
                 throw GraalInternalError.shouldNotReachHere("" + left.getKind());
         }
@@ -631,7 +631,7 @@
 
     @Override
     public Value emitUDiv(Value a, Value b, DeoptimizingNode deopting) {
-// LIRFrameState state = state(deopting);
+        // LIRFrameState state = state(deopting);
         switch (a.getKind().getStackKind()) {
             case Int:
                 // emitDivRem(IUDIV, a, b, state);
@@ -646,7 +646,7 @@
 
     @Override
     public Value emitURem(Value a, Value b, DeoptimizingNode deopting) {
-// LIRFrameState state = state(deopting);
+        // LIRFrameState state = state(deopting);
         switch (a.getKind().getStackKind()) {
             case Int:
                 // emitDivRem(IUREM, a, b, state);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Mon Oct 21 18:37:19 2013 +0200
@@ -553,8 +553,7 @@
             @Override
             public SchedulePhase call() throws Exception {
                 Assumptions assumptions = new Assumptions(false);
-                HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultPhasePlan(),
-                                OptimisticOptimizations.ALL);
+                HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL);
                 new CanonicalizerPhase(true).apply(graph, context);
                 if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
                     new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
@@ -576,8 +575,7 @@
                 new FloatingReadPhase().apply(graph);
                 new RemoveValueProxyPhase().apply(graph);
 
-                MidTierContext midContext = new MidTierContext(getProviders(), assumptions, getCodeCache().getTarget(),
-                                OptimisticOptimizations.ALL);
+                MidTierContext midContext = new MidTierContext(getProviders(), assumptions, getCodeCache().getTarget(), OptimisticOptimizations.ALL);
                 new GuardLoweringPhase().apply(graph, midContext);
                 new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext);
                 new LoweringPhase(new CanonicalizerPhase(true)).apply(graph, midContext);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java	Mon Oct 21 18:37:19 2013 +0200
@@ -39,6 +39,7 @@
 import com.oracle.graal.asm.amd64.*;
 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag;
 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.*;
@@ -239,6 +240,19 @@
         Label verifiedStub = new Label();
 
         // Emit the prefix
+        emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub);
+
+        // Emit code for the LIR
+        emitCodeBody(installedCodeOwner, tasm, lirGen);
+
+        // Emit the suffix
+        emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap);
+    }
+
+    /**
+     * @param installedCodeOwner see {@link Backend#emitCode}
+     */
+    protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) {
         HotSpotProviders providers = getProviders();
         if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) {
             tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY);
@@ -263,10 +277,20 @@
         tasm.recordMark(Marks.MARK_OSR_ENTRY);
         asm.bind(verifiedStub);
         tasm.recordMark(Marks.MARK_VERIFIED_ENTRY);
+    }
 
-        // Emit code for the LIR
+    /**
+     * @param installedCodeOwner see {@link Backend#emitCode}
+     */
+    protected void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) {
         lirGen.lir.emitCode(tasm);
+    }
 
+    /**
+     * @param installedCodeOwner see {@link Backend#emitCode}
+     */
+    protected void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) {
+        HotSpotProviders providers = getProviders();
         HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext;
         if (frameContext != null && !frameContext.isStub) {
             HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls();
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java	Mon Oct 21 18:37:19 2013 +0200
@@ -55,10 +55,7 @@
     private final Register[] nativeGeneralParameterRegisters;
 
     private static Register[] initAllocatable() {
-        Register[] registers = new Register[] {
-            r0,  r1,  r2,  r3,  r4,  r5,  r6,  r7,
-            r8,  r9,  r10, r11, r12, r13, r14, r15,
-        };
+        Register[] registers = new Register[]{r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15};
 
         return registers;
     }
@@ -94,9 +91,8 @@
         throw GraalInternalError.unimplemented("PTXHotSpotRegisterConfig.getRegisterForRole()");
     }
 
-    private static CallingConvention callingConvention(@SuppressWarnings("unused") Register[] generalParameterRegisters,
-                                                JavaType returnType, JavaType[] parameterTypes,
-                                                Type type, TargetDescription target, boolean stackOnly) {
+    private static CallingConvention callingConvention(@SuppressWarnings("unused") Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type,
+                    TargetDescription target, boolean stackOnly) {
 
         assert stackOnly == false;
 
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java	Mon Oct 21 18:37:19 2013 +0200
@@ -41,13 +41,13 @@
     @Override
     public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
         // TODO the patched call address looks odd (and is invalid) compared to other runtime calls:
-// 0xffffffff749bb5fc: call 0xffffffff415a720c ; {runtime_call}
-// [Exception Handler]
-// 0xffffffff749bb604: call 0xffffffff749bb220 ; {runtime_call}
-// 0xffffffff749bb608: nop
-// [Deopt Handler Code]
-// 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call}
-// 0xffffffff749bb610: nop
+        // 0xffffffff749bb5fc: call 0xffffffff415a720c ; {runtime_call}
+        // [Exception Handler]
+        // 0xffffffff749bb604: call 0xffffffff749bb220 ; {runtime_call}
+        // 0xffffffff749bb608: nop
+        // [Deopt Handler Code]
+        // 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call}
+        // 0xffffffff749bb610: nop
         SPARCCall.directCall(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java	Mon Oct 21 18:37:19 2013 +0200
@@ -41,14 +41,14 @@
     public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) {
         leaveFrame(tasm);
 
-// SPARCHotSpotBackend backend = (SPARCHotSpotBackend)
-// HotSpotGraalRuntime.runtime().getBackend();
-// final boolean isStub = true;
-// HotSpotFrameContext frameContext = backend.new HotSpotFrameContext(isStub);
-// frameContext.enter(tasm);
+        // SPARCHotSpotBackend backend = (SPARCHotSpotBackend)
+        // HotSpotGraalRuntime.runtime().getBackend();
+        // final boolean isStub = true;
+        // HotSpotFrameContext frameContext = backend.new HotSpotFrameContext(isStub);
+        // frameContext.enter(tasm);
         Register scratch = g3;
         SPARCCall.indirectJmp(tasm, masm, scratch, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP));
 
-// frameContext.leave(tasm);
+        // frameContext.leave(tasm);
     }
 }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java	Mon Oct 21 18:37:19 2013 +0200
@@ -154,7 +154,7 @@
 
     @Override
     public void emitTailcall(Value[] args, Value address) {
-// append(new AMD64TailcallOp(args, address));
+        // append(new AMD64TailcallOp(args, address));
         throw GraalInternalError.unimplemented();
     }
 
@@ -242,14 +242,16 @@
         assert access == null || access instanceof HeapAccess;
         if (isCompressCandidate(access)) {
             if (config.useCompressedOops && kind == Kind.Object) {
-// append(new LoadCompressedPointer(kind, result, loadAddress, access != null ? state(access) :
-// null, config.narrowOopBase, config.narrowOopShift,
-// config.logMinObjAlignment));
+                // append(new LoadCompressedPointer(kind, result, loadAddress, access != null ?
+                // state(access) :
+                // null, config.narrowOopBase, config.narrowOopShift,
+                // config.logMinObjAlignment));
                 throw GraalInternalError.unimplemented();
             } else if (config.useCompressedClassPointers && kind == Kind.Long) {
-// append(new LoadCompressedPointer(kind, result, loadAddress, access != null ? state(access) :
-// null, config.narrowKlassBase, config.narrowKlassShift,
-// config.logKlassAlignment));
+                // append(new LoadCompressedPointer(kind, result, loadAddress, access != null ?
+                // state(access) :
+                // null, config.narrowKlassBase, config.narrowKlassShift,
+                // config.logKlassAlignment));
                 throw GraalInternalError.unimplemented();
             } else {
                 append(new LoadOp(kind, result, loadAddress, access != null ? state(access) : null));
@@ -280,21 +282,21 @@
         Variable input = load(inputVal);
         if (isCompressCandidate(access)) {
             if (config.useCompressedOops && kind == Kind.Object) {
-// if (input.getKind() == Kind.Object) {
-// Variable scratch = newVariable(Kind.Long);
-// append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state,
-// config.narrowOopBase, config.narrowOopShift,
-// config.logMinObjAlignment));
-// } else {
-// // the input oop is already compressed
-// append(new StoreOp(input.getKind(), storeAddress, input, state));
-// }
+                // if (input.getKind() == Kind.Object) {
+                // Variable scratch = newVariable(Kind.Long);
+                // append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state,
+                // config.narrowOopBase, config.narrowOopShift,
+                // config.logMinObjAlignment));
+                // } else {
+                // // the input oop is already compressed
+                // append(new StoreOp(input.getKind(), storeAddress, input, state));
+                // }
                 throw GraalInternalError.unimplemented();
             } else if (config.useCompressedClassPointers && kind == Kind.Long) {
-// Variable scratch = newVariable(Kind.Long);
-// append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state,
-// config.narrowKlassBase, config.narrowKlassShift,
-// config.logKlassAlignment));
+                // Variable scratch = newVariable(Kind.Long);
+                // append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state,
+                // config.narrowKlassBase, config.narrowKlassShift,
+                // config.logKlassAlignment));
                 throw GraalInternalError.unimplemented();
             } else {
                 append(new StoreOp(kind, storeAddress, input, state));
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java	Mon Oct 21 18:37:19 2013 +0200
@@ -105,11 +105,11 @@
         for (HotSpotBackendFactory factory : ServiceLoader.loadInstalled(HotSpotBackendFactory.class)) {
             if (factory.getArchitecture().equalsIgnoreCase(architecture)) {
                 if (factory.getGraalRuntimeName().equals(GraalRuntime.getValue())) {
-                    assert selected == null;
+                    assert selected == null || checkFactoryOverriding(selected, factory);
                     selected = factory;
                 }
                 if (factory.getGraalRuntimeName().equals("basic")) {
-                    assert basic == null;
+                    assert basic == null || checkFactoryOverriding(basic, factory);
                     basic = factory;
                 } else {
                     nonBasic = factory;
@@ -135,6 +135,18 @@
     }
 
     /**
+     * Checks that a factory overriding is valid. A factory B can only override/replace a factory A
+     * if the B.getClass() is a subclass of A.getClass(). This models the assumption that B is
+     * extends the behavior of A and has therefore understood the behavior expected of A.
+     * 
+     * @param baseFactory
+     * @param overridingFactory
+     */
+    private static boolean checkFactoryOverriding(HotSpotBackendFactory baseFactory, HotSpotBackendFactory overridingFactory) {
+        return baseFactory.getClass().isAssignableFrom(overridingFactory.getClass());
+    }
+
+    /**
      * Gets the kind of a word value on the {@linkplain #getHostBackend() host} backend.
      */
     public static Kind getHostWordKind() {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Mon Oct 21 18:37:19 2013 +0200
@@ -93,7 +93,8 @@
         }
         // the canonicalization before loop unrolling is needed to propagate the length into
         // additions, etc.
-        PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getForeignCalls(), tool.getLowerer(), tool.assumptions(), tool.getReplacements());
+        PhaseContext context = new PhaseContext(tool.getMetaAccess(), tool.getCodeCache(), tool.getConstantReflection(), tool.getForeignCalls(), tool.getLowerer(), tool.assumptions(),
+                        tool.getReplacements());
         new CanonicalizerPhase(true).apply(snippetGraph, context);
         new LoopFullUnrollPhase(new CanonicalizerPhase(true)).apply(snippetGraph, context);
         new CanonicalizerPhase(true).apply(snippetGraph, context);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java	Mon Oct 21 18:37:19 2013 +0200
@@ -795,7 +795,7 @@
         eagerResolvingForSnippets(cpi, opcode);
         JavaMethod result = constantPool.lookupMethod(cpi, opcode);
         // assert !graphBuilderConfig.unresolvedIsError() || ((result instanceof ResolvedJavaMethod)
-// && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result;
+        // && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result;
         return result;
     }
 
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java	Mon Oct 21 18:37:19 2013 +0200
@@ -53,7 +53,6 @@
         }
     }
 
-
     public static class ForeignCallNoArgOp extends HSAILLIRInstruction {
 
         @Def({REG}) protected Value out;
@@ -80,7 +79,6 @@
         }
     }
 
-
     public static class CompareBranchOp extends HSAILLIRInstruction implements StandardOp.BranchOp {
 
         @Opcode protected final HSAILCompare opcode;
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java	Mon Oct 21 18:37:19 2013 +0200
@@ -129,7 +129,6 @@
         }
     }
 
-
     public abstract static class MemOp extends HSAILLIRInstruction {
 
         protected final Kind kind;
@@ -268,8 +267,6 @@
         masm.emitCompressedOopDecode(result, narrowOopBase, narrowOopShift);
     }
 
-
-
     public static class LeaOp extends HSAILLIRInstruction {
 
         @Def({REG}) protected AllocatableValue result;
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java	Mon Oct 21 18:37:19 2013 +0200
@@ -67,8 +67,7 @@
         }
     }
 
-    public static void emit(PTXAssembler masm, PTXCompare opcode,
-                            Condition condition, Value x, Value y, int p) {
+    public static void emit(PTXAssembler masm, PTXCompare opcode, Condition condition, Value x, Value y, int p) {
         if (isConstant(x)) {
             new Setp(condition, x, y, p).emit(masm);
         } else if (isConstant(y)) {
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java	Mon Oct 21 18:37:19 2013 +0200
@@ -43,8 +43,7 @@
         @Use({COMPOSITE}) protected PTXAddressValue address;
         @State protected LIRFrameState state;
 
-        public LoadOp(Kind kind, Variable result, PTXAddressValue address,
-                      LIRFrameState state) {
+        public LoadOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
             this.kind = kind;
             this.result = result;
             this.address = address;
@@ -63,8 +62,7 @@
                 case Float:
                 case Double:
                 case Object:
-                    new Ld(Global, result, addr.getBase(),
-                           Constant.forLong(addr.getDisplacement())).emit(masm);
+                    new Ld(Global, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
@@ -99,8 +97,7 @@
                 case Float:
                 case Double:
                 case Object:
-                    new St(Global, input, addr.getBase(),
-                           Constant.forLong(addr.getDisplacement())).emit(masm);
+                    new St(Global, input, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind());
@@ -117,8 +114,7 @@
         @Use({COMPOSITE}) protected PTXAddressValue address;
         @State protected LIRFrameState state;
 
-        public LoadParamOp(Kind kind, Variable result, PTXAddressValue address,
-                           LIRFrameState state) {
+        public LoadParamOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
             this.kind = kind;
             this.result = result;
             this.address = address;
@@ -137,8 +133,7 @@
                 case Float:
                 case Double:
                 case Object:
-                    new Ld(Parameter, result, addr.getBase(),
-                           Constant.forLong(addr.getDisplacement())).emit(masm);
+                    new Ld(Parameter, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
@@ -156,8 +151,7 @@
         @Use({COMPOSITE}) protected PTXAddressValue address;
         @State protected LIRFrameState state;
 
-        public LoadReturnAddrOp(Kind kind, Variable result,
-                                PTXAddressValue address, LIRFrameState state) {
+        public LoadReturnAddrOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) {
             this.kind = kind;
             this.result = result;
             this.address = address;
@@ -172,8 +166,7 @@
                 case Long:
                 case Float:
                 case Double:
-                    new Ld(Parameter, result, addr.getBase(),
-                           Constant.forLong(addr.getDisplacement())).emit(masm);
+                    new Ld(Parameter, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere();
@@ -190,8 +183,7 @@
         @Use({REG}) protected Variable input;
         @State protected LIRFrameState state;
 
-        public StoreReturnValOp(Kind kind, PTXAddressValue address,
-                                Variable input, LIRFrameState state) {
+        public StoreReturnValOp(Kind kind, PTXAddressValue address, Variable input, LIRFrameState state) {
             this.kind = kind;
             this.address = address;
             this.input = input;
@@ -210,8 +202,7 @@
                 case Float:
                 case Double:
                 case Object:
-                    new St(Global, input, addr.getBase(),
-                           Constant.forLong(addr.getDisplacement())).emit(masm);
+                    new St(Global, input, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm);
                     break;
                 default:
                     throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind());
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ParallelOver.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ParallelOver.java	Mon Oct 21 18:37:19 2013 +0200
@@ -25,6 +25,7 @@
 import static com.oracle.graal.lir.ptx.ThreadDimension.*;
 
 import java.lang.annotation.*;
+
 @Retention(RetentionPolicy.RUNTIME)
 @Target({ElementType.PARAMETER})
 public @interface ParallelOver {
@@ -33,4 +34,3 @@
 
     ThreadDimension dimension() default X;
 }
-
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ThreadDimension.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/ThreadDimension.java	Mon Oct 21 18:37:19 2013 +0200
@@ -23,8 +23,5 @@
 package com.oracle.graal.lir.ptx;
 
 public enum ThreadDimension {
-X,
-Y,
-Z
+    X, Y, Z
 }
-
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/Warp.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/Warp.java	Mon Oct 21 18:37:19 2013 +0200
@@ -34,4 +34,3 @@
 
     ThreadDimension dimension() default X;
 }
-
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java	Mon Oct 21 18:37:19 2013 +0200
@@ -143,45 +143,45 @@
             }
         } else {
             throw GraalInternalError.shouldNotReachHere();
-// SPARCAddress src = (SPARCAddress) tasm.asAddress(input);
-// switch (opcode) {
-// case IPOPCNT:
-// new Ldsw(src, tmp).emit(masm);
-// // clear upper word for 64 bit POPC
-// new Srl(tmp, g0, dst).emit(masm);
-// new Popc(tmp, dst).emit(masm);
-// break;
-// case LPOPCNT:
-// new Ldx(src, tmp).emit(masm);
-// new Popc(tmp, dst).emit(masm);
-// break;
-// case BSF:
-// assert input.getKind() == Kind.Int;
-// new Ldsw(src, tmp).emit(masm);
-// new Srl(tmp, 1, tmp).emit(masm);
-// new Srl(tmp, 0, dst).emit(masm);
-// new Or(tmp, tmp, dst).emit(masm);
-// new Srl(dst, 2, tmp).emit(masm);
-// new Or(dst, tmp, dst).emit(masm);
-// new Srl(dst, 4, tmp).emit(masm);
-// new Or(dst, tmp, dst).emit(masm);
-// new Srl(dst, 8, tmp).emit(masm);
-// new Or(dst, tmp, dst).emit(masm);
-// new Srl(dst, 16, tmp).emit(masm);
-// new Or(dst, tmp, dst).emit(masm);
-// new Popc(dst, dst).emit(masm);
-// new Mov(Kind.Int.getBitCount(), tmp).emit(masm);
-// new Sub(tmp, dst, dst).emit(masm);
-// break;
-// case IBSR:
-// // masm.bsrl(dst, src);
-// // countLeadingZerosI_bsr masm.bsrq(dst, src);
-// // masm.bsrl(dst, src);
-// case LBSR:
-// // masm.bsrq(dst, src);
-// default:
-// throw GraalInternalError.shouldNotReachHere("missing: " + opcode);
-// }
+            // SPARCAddress src = (SPARCAddress) tasm.asAddress(input);
+            // switch (opcode) {
+            // case IPOPCNT:
+            // new Ldsw(src, tmp).emit(masm);
+            // // clear upper word for 64 bit POPC
+            // new Srl(tmp, g0, dst).emit(masm);
+            // new Popc(tmp, dst).emit(masm);
+            // break;
+            // case LPOPCNT:
+            // new Ldx(src, tmp).emit(masm);
+            // new Popc(tmp, dst).emit(masm);
+            // break;
+            // case BSF:
+            // assert input.getKind() == Kind.Int;
+            // new Ldsw(src, tmp).emit(masm);
+            // new Srl(tmp, 1, tmp).emit(masm);
+            // new Srl(tmp, 0, dst).emit(masm);
+            // new Or(tmp, tmp, dst).emit(masm);
+            // new Srl(dst, 2, tmp).emit(masm);
+            // new Or(dst, tmp, dst).emit(masm);
+            // new Srl(dst, 4, tmp).emit(masm);
+            // new Or(dst, tmp, dst).emit(masm);
+            // new Srl(dst, 8, tmp).emit(masm);
+            // new Or(dst, tmp, dst).emit(masm);
+            // new Srl(dst, 16, tmp).emit(masm);
+            // new Or(dst, tmp, dst).emit(masm);
+            // new Popc(dst, dst).emit(masm);
+            // new Mov(Kind.Int.getBitCount(), tmp).emit(masm);
+            // new Sub(tmp, dst, dst).emit(masm);
+            // break;
+            // case IBSR:
+            // // masm.bsrl(dst, src);
+            // // countLeadingZerosI_bsr masm.bsrq(dst, src);
+            // // masm.bsrl(dst, src);
+            // case LBSR:
+            // // masm.bsrq(dst, src);
+            // default:
+            // throw GraalInternalError.shouldNotReachHere("missing: " + opcode);
+            // }
         }
     }
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java	Mon Oct 21 18:37:19 2013 +0200
@@ -446,8 +446,8 @@
         }
 
         // Load jump table entry into scratch and jump to it
-// masm.movslq(value, new AMD64Address(scratch, value, Scale.Times4, 0));
-// masm.addq(scratch, value);
+        // masm.movslq(value, new AMD64Address(scratch, value, Scale.Times4, 0));
+        // masm.addq(scratch, value);
         new Jmp(new SPARCAddress(scratch, 0)).emit(masm);
         new Nop().emit(masm);  // delay slot
 
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Mon Oct 21 18:37:19 2013 +0200
@@ -213,7 +213,7 @@
     @Opcode("CAS")
     public static class CompareAndSwapOp extends SPARCLIRInstruction {
 
-// @Def protected AllocatableValue result;
+        // @Def protected AllocatableValue result;
         @Use protected AllocatableValue address;
         @Use protected AllocatableValue cmpValue;
         @Use protected AllocatableValue newValue;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRIntrospection.java	Mon Oct 21 18:37:19 2013 +0200
@@ -107,8 +107,7 @@
 
         private static boolean verifyFlags(Field field, Class<?> type, EnumSet<OperandFlag> flags) {
             if (flags.contains(REG)) {
-                assert type.isAssignableFrom(REGISTER_VALUE_CLASS) ||
-                       type.isAssignableFrom(VARIABLE_CLASS) : "Cannot assign RegisterValue / Variable to field with REG flag:" + field;
+                assert type.isAssignableFrom(REGISTER_VALUE_CLASS) || type.isAssignableFrom(VARIABLE_CLASS) : "Cannot assign RegisterValue / Variable to field with REG flag:" + field;
             }
             if (flags.contains(STACK)) {
                 assert type.isAssignableFrom(STACK_SLOT_CLASS) : "Cannot assign StackSlot to field with STACK flag:" + field;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Mon Oct 21 18:37:19 2013 +0200
@@ -63,7 +63,8 @@
 
     private List<ExceptionInfo> exceptionInfoList;
 
-    public TargetMethodAssembler(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, CompilationResult compilationResult) {
+    public TargetMethodAssembler(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext,
+                    CompilationResult compilationResult) {
         this.target = codeCache.getTarget();
         this.codeCache = codeCache;
         this.foreignCalls = foreignCalls;
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/BeginStateSplitNode.java	Mon Oct 21 18:37:19 2013 +0200
@@ -25,9 +25,11 @@
 import com.oracle.graal.nodes.type.*;
 
 /**
- * Base class for {@link AbstractBeginNode}s that are associated with a frame state. TODO (dnsimon) this not
- * needed until {@link AbstractBeginNode} no longer implements {@link StateSplit} which is not possible
- * until loop peeling works without requiring begin nodes to have frames states
+ * Base class for {@link AbstractBeginNode}s that are associated with a frame state.
+ * 
+ * TODO (dnsimon) this not needed until {@link AbstractBeginNode} no longer implements
+ * {@link StateSplit} which is not possible until loop peeling works without requiring begin nodes
+ * to have frames states.
  */
 public abstract class BeginStateSplitNode extends AbstractBeginNode implements StateSplit {
 
--- a/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java	Mon Oct 21 18:37:19 2013 +0200
@@ -35,10 +35,9 @@
  */
 public class PTX extends Architecture {
 
-    public static final RegisterCategory REG    = new RegisterCategory("REG");
-    public static final RegisterCategory SREG   = new RegisterCategory("SREG");
-    public static final RegisterCategory PARAM  = new RegisterCategory("PARAM");
-
+    public static final RegisterCategory REG = new RegisterCategory("REG");
+    public static final RegisterCategory SREG = new RegisterCategory("SREG");
+    public static final RegisterCategory PARAM = new RegisterCategory("PARAM");
 
     // @formatter:off
 
@@ -194,8 +193,7 @@
     // @formatter:on
 
     public PTX() {
-        super("PTX", 8, ByteOrder.LITTLE_ENDIAN, false, allRegisters,
-              LOAD_STORE | STORE_STORE, 0, r15.encoding + 1, 8);
+        super("PTX", 8, ByteOrder.LITTLE_ENDIAN, false, allRegisters, LOAD_STORE | STORE_STORE, 0, r15.encoding + 1, 8);
     }
 
     @Override
@@ -232,5 +230,4 @@
         }
     }
 
-
 }
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java	Mon Oct 21 18:37:19 2013 +0200
@@ -51,8 +51,7 @@
                 StructuredGraph graph = parse(snippet);
                 PhasePlan phasePlan = getDefaultPhasePlan();
                 Assumptions assumptions = new Assumptions(true);
-                HighTierContext context = new HighTierContext(getProviders(), assumptions, null, phasePlan,
-                                OptimisticOptimizations.ALL);
+                HighTierContext context = new HighTierContext(getProviders(), assumptions, null, phasePlan, OptimisticOptimizations.ALL);
                 Debug.dump(graph, "Graph");
                 new InliningPhase(new CanonicalizerPhase(true)).apply(graph, context);
                 Debug.dump(graph, "Graph");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java	Mon Oct 21 18:37:19 2013 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013, 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.truffle.hotspot.amd64;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.*;
+import com.oracle.graal.asm.amd64.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.amd64.*;
+import com.oracle.graal.hotspot.meta.*;
+import com.oracle.graal.lir.asm.*;
+import com.oracle.graal.truffle.*;
+import com.oracle.truffle.api.*;
+import com.oracle.truffle.api.frame.*;
+
+/**
+ * Subclass of {@link AMD64HotSpotBackend} that injects special code into
+ * {@link OptimizedCallTarget#call(PackedFrame, Arguments)} for making a tail-call to the entry
+ * point of the target callee.
+ */
+class AMD64HotSpotTruffleBackend extends AMD64HotSpotBackend {
+
+    private ResolvedJavaMethod optimizedCallTargetCall;
+
+    public AMD64HotSpotTruffleBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
+        super(runtime, providers);
+    }
+
+    private ResolvedJavaMethod getInstrumentedMethod() throws GraalInternalError {
+        if (optimizedCallTargetCall == null) {
+            try {
+                optimizedCallTargetCall = getProviders().getMetaAccess().lookupJavaMethod(OptimizedCallTarget.class.getDeclaredMethod("call", PackedFrame.class, Arguments.class));
+            } catch (NoSuchMethodException | SecurityException e) {
+                throw new GraalInternalError(e);
+            }
+        }
+        return optimizedCallTargetCall;
+    }
+
+    @Override
+    protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) {
+        super.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub);
+        if (getInstrumentedMethod().equals(installedCodeOwner)) {
+            // TODO emit tailcall code
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java	Mon Oct 21 18:37:19 2013 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, 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.truffle.hotspot.amd64;
+
+import com.oracle.graal.api.runtime.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.hotspot.amd64.*;
+import com.oracle.graal.hotspot.meta.*;
+
+/**
+ * Factory to create a Truffle-specialized AMD64 HotSpot backend.
+ */
+@ServiceProvider(HotSpotBackendFactory.class)
+public class AMD64HotSpotTruffleBackendFactory extends AMD64HotSpotBackendFactory {
+
+    @Override
+    protected AMD64HotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
+        return new AMD64HotSpotTruffleBackend(runtime, providers);
+    }
+}
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Mon Oct 21 18:37:19 2013 +0200
@@ -976,7 +976,7 @@
 
         private List<CodeExecutableElement> createImplicitChildrenAccessors() {
             NodeData node = getModel().getNode();
-// Map<NodeChildData, Set<TypeData>> expectTypes = new HashMap<>();
+            // Map<NodeChildData, Set<TypeData>> expectTypes = new HashMap<>();
             @SuppressWarnings("unchecked")
             List<Set<TypeData>> expectTypes = Arrays.<Set<TypeData>> asList(new Set[node.getGenericSpecialization().getParameters().size()]);
 
@@ -2688,8 +2688,8 @@
             final SpecializationData polymorphic = node.getGenericPolymorphicSpecialization();
 
             ExecutableElement executeCached = nodeGen.getMethod(executeCachedName(polymorphic));
-// ExecutableTypeData execType = new ExecutableTypeData(polymorphic, executeCached,
-// node.getTypeSystem(), polymorphic.getReturnType().getTypeSystemType());
+            // ExecutableTypeData execType = new ExecutableTypeData(polymorphic, executeCached,
+            // node.getTypeSystem(), polymorphic.getReturnType().getTypeSystemType());
 
             ExecutableTypeMethodParser parser = new ExecutableTypeMethodParser(getContext(), node);
             ExecutableTypeData execType = parser.parse(Arrays.asList(executeCached)).get(0);
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java	Mon Oct 21 18:37:19 2013 +0200
@@ -227,7 +227,7 @@
 
         List<TypeData> polymorphicSignature = new ArrayList<>();
         // TODO we should support more optimized for boxing
-// List<ActualParameter> updatePolymorphic = generic.getReturnTypeAndParameters();
+        // List<ActualParameter> updatePolymorphic = generic.getReturnTypeAndParameters();
         List<ActualParameter> updatePolymorphic = Arrays.asList();
         for (ActualParameter genericParameter : updatePolymorphic) {
             if (!genericParameter.getSpecification().isSignature()) {
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Parser.java	Mon Oct 21 18:37:19 2013 +0200
@@ -21,9 +21,10 @@
  * questions.
  */
 
- // The content of this file is automatically generated. DO NOT EDIT.
+// The content of this file is automatically generated. DO NOT EDIT.
 
 package com.oracle.truffle.sl.parser;
+
 import java.util.*;
 
 import com.oracle.truffle.sl.*;
--- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Mon Oct 21 17:36:41 2013 +0200
+++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/parser/Scanner.java	Mon Oct 21 18:37:19 2013 +0200
@@ -21,7 +21,7 @@
  * questions.
  */
 
- // The content of this file is automatically generated. DO NOT EDIT.
+// The content of this file is automatically generated. DO NOT EDIT.
 
 package com.oracle.truffle.sl.parser;
 
--- a/make/bsd/makefiles/gcc.make	Mon Oct 21 17:36:41 2013 +0200
+++ b/make/bsd/makefiles/gcc.make	Mon Oct 21 18:37:19 2013 +0200
@@ -313,6 +313,14 @@
     OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT)
     OPT_CFLAGS/unsafe.o += -O1
   endif
+  # Clang 5.0
+  ifeq ($(shell expr $(CC_VER_MAJOR) = 5 \& $(CC_VER_MINOR) = 0), 1)
+    OPT_CFLAGS/graalCompilerToVM.o += -O1
+    OPT_CFLAGS/unsafe.o += -O1
+    # Specific optimization level plus precompiled headers produces:
+    #     error: __OPTIMIZE_SIZE__ predefined macro was enabled in PCH file but is currently disabled
+    USE_PRECOMPILED_HEADER = 0
+  endif
 else
   # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
   ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)
--- a/mx/projects	Mon Oct 21 17:36:41 2013 +0200
+++ b/mx/projects	Mon Oct 21 18:37:19 2013 +0200
@@ -32,6 +32,7 @@
 com.oracle.graal.hotspot.amd64,\
 com.oracle.graal.hotspot.ptx,\
 com.oracle.graal.truffle,\
+com.oracle.graal.truffle.hotspot.amd64,\
 com.oracle.graal.hotspot.sparc,\
 com.oracle.graal.hotspot,\
 com.oracle.graal.hotspot.hsail
@@ -649,4 +650,11 @@
 project@com.oracle.graal.truffle.test@javaCompliance=1.7
 project@com.oracle.graal.truffle.test@workingSets=Graal,Truffle,Test
 
-
+# graal.truffle.hotspot.amd64
+project@com.oracle.graal.truffle.hotspot.amd64@subDir=graal
+project@com.oracle.graal.truffle.hotspot.amd64@sourceDirs=src
+project@com.oracle.graal.truffle.hotspot.amd64@dependencies=com.oracle.graal.truffle,com.oracle.graal.hotspot.amd64
+project@com.oracle.graal.truffle.hotspot.amd64@checkstyle=com.oracle.graal.graph
+project@com.oracle.graal.truffle.hotspot.amd64@javaCompliance=1.7
+project@com.oracle.graal.truffle.hotspot.amd64@annotationProcessors=com.oracle.graal.service.processor
+project@com.oracle.graal.truffle.hotspot.amd64@workingSets=Graal,Truffle
--- a/mxtool/mx.py	Mon Oct 21 17:36:41 2013 +0200
+++ b/mxtool/mx.py	Mon Oct 21 18:37:19 2013 +0200
@@ -890,7 +890,7 @@
         suite.imports.append(suite_import)
         imported_suite = _loadSuite(importMxDir, False)
         if imported_suite.version != suite.version:
-            warn('import version of ' + imported_suite.name +' does not match tip of ' + suite.version)
+            warn('import version of ' + imported_suite.name + ' does not match tip of ' + suite.version)
 
     def _load_imports(self):
         self._visit_imports(self._find_and_loadsuite)
@@ -4118,7 +4118,7 @@
     try:
         version = subprocess.check_output(['hg', 'tip', '-R', s.dir, '--template', '{node}'])
         if s.version is not None and s.version != version:
-            abort('version of suite ' + s.name +' has changed during run')
+            abort('version of suite ' + s.name + ' has changed during run')
         return version
     except subprocess.CalledProcessError:
         if abortOnError: