changeset 4302:b3c3d1b1ddfa

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 13 Jan 2012 15:23:40 +0100
parents fad6f1ebeb44 (current diff) 62cb0e636094 (diff)
children dd67881406c2
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFSlowPath.java
diffstat 18 files changed, 201 insertions(+), 281 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java	Fri Jan 13 15:23:40 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -305,7 +305,7 @@
                 }
 
                 if (context.isObserved()) {
-                    context.observable.fireCompilationEvent("After LIR generation", graph, lir);
+                    context.observable.fireCompilationEvent("After LIR generation", graph, lir, lirGenerator);
                 }
                 if (GraalOptions.PrintLIR && !TTY.isSuppressed()) {
                     LIR.printLIR(lir.linearScanOrder());
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/asm/TargetMethodAssembler.java	Fri Jan 13 15:23:40 2012 +0100
@@ -234,7 +234,19 @@
         return recordDataReferenceInCode((CiConstant) value, alignment);
     }
 
+    /**
+     * Returns the address of a long constant that is embedded as a data references into the code.
+     */
+    public CiAddress asLongConstRef(CiValue value) {
+        assert value.kind == CiKind.Long && isConstant(value);
+        return recordDataReferenceInCode((CiConstant) value, 8);
+    }
+
     public CiAddress asAddress(CiValue value) {
-        return frameMap.asAddress(value);
+        if (isStackSlot(value)) {
+            CiStackSlot slot = (CiStackSlot) value;
+            return new CiAddress(slot.kind, frameMap.registerConfig.getFrameRegister().asValue(), frameMap.offsetForStackSlot(slot));
+        }
+        return (CiAddress) value;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Fri Jan 13 15:23:40 2012 +0100
@@ -154,7 +154,7 @@
 
         } else if (value != null) {
             CiValue operand = nodeOperands.get(value);
-            assert operand != null && operand instanceof Variable || operand instanceof CiConstant;
+            assert operand != null && (operand instanceof Variable || operand instanceof CiConstant);
             return operand;
 
         } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/FrameMap.java	Fri Jan 13 15:23:40 2012 +0100
@@ -339,12 +339,4 @@
             }
         }
     }
-
-    public CiAddress asAddress(CiValue value) {
-        if (isStackSlot(value)) {
-            CiStackSlot slot = (CiStackSlot) value;
-            return new CiAddress(slot.kind, registerConfig.getFrameRegister().asValue(), offsetForStackSlot(slot));
-        }
-        return (CiAddress) value;
-    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java	Thu Jan 12 17:30:11 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.compiler.target.amd64;
-
-import static com.oracle.max.cri.ci.CiValueUtil.*;
-
-import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
-import com.oracle.max.asm.target.amd64.*;
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.compiler.asm.*;
-import com.oracle.max.graal.compiler.lir.*;
-import com.oracle.max.graal.compiler.util.*;
-
-public enum AMD64ConvertFIOpcode implements LIROpcode {
-    F2I, D2I;
-
-    public LIRInstruction create(CiValue result, CiValue x) {
-        CiValue[] inputs = new CiValue[] {x};
-        CiValue[] outputs = new CiValue[] {result};
-
-        return new AMD64LIRInstruction(this, outputs, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
-            @Override
-            public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                emit(tasm, masm, output(0), input(0));
-            }
-        };
-    }
-
-    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x) {
-        AMD64ConvertFSlowPath slowPath;
-        switch (this) {
-            case F2I:
-                masm.cvttss2sil(asIntReg(result), asFloatReg(x));
-                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asFloatReg(x), false, false);
-                break;
-            case D2I:
-                masm.cvttsd2sil(asIntReg(result), asDoubleReg(x));
-                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asDoubleReg(x), true, false);
-                break;
-            default:
-                throw Util.shouldNotReachHere();
-        }
-        tasm.slowPaths.add(slowPath);
-
-        masm.cmp32(asIntReg(result), Integer.MIN_VALUE);
-        masm.jcc(ConditionFlag.equal, slowPath.start);
-        masm.bind(slowPath.continuation);
-    }
-}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java	Thu Jan 12 17:30:11 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.compiler.target.amd64;
-
-import static com.oracle.max.cri.ci.CiValueUtil.*;
-
-import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
-import com.oracle.max.asm.target.amd64.*;
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.compiler.asm.*;
-import com.oracle.max.graal.compiler.lir.*;
-import com.oracle.max.graal.compiler.util.*;
-
-public enum AMD64ConvertFLOpcode implements LIROpcode {
-    F2L, D2L;
-
-    public LIRInstruction create(CiValue result, CiValue x, CiValue scratch) {
-        CiValue[] inputs = new CiValue[] {x};
-        CiValue[] temps = new CiValue[] {scratch};
-        CiValue[] outputs = new CiValue[] {result};
-
-        return new AMD64LIRInstruction(this, outputs, null, inputs, LIRInstruction.NO_OPERANDS, temps) {
-            @Override
-            public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                emit(tasm, masm, output(0), input(0), temp(0));
-            }
-        };
-    }
-
-    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue scratch) {
-        AMD64ConvertFSlowPath slowPath;
-        switch (this) {
-            case F2L:
-                masm.cvttss2siq(asLongReg(result), asFloatReg(x));
-                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asFloatReg(x), false, true);
-                break;
-            case D2L:
-                masm.cvttsd2siq(asLongReg(result), asDoubleReg(x));
-                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asDoubleReg(x), true, true);
-                break;
-            default:
-                throw Util.shouldNotReachHere();
-        }
-        tasm.slowPaths.add(slowPath);
-
-        CiRegister tmp = asLongReg(scratch);
-        masm.movq(tmp, java.lang.Long.MIN_VALUE);
-        masm.cmpq(asLongReg(result), tmp);
-        masm.jcc(ConditionFlag.equal, slowPath.start);
-        masm.bind(slowPath.continuation);
-    }
-}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFSlowPath.java	Thu Jan 12 17:30:11 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.compiler.target.amd64;
-
-import com.oracle.max.asm.*;
-import com.oracle.max.asm.target.amd64.*;
-import com.oracle.max.asm.target.amd64.AMD64Assembler.*;
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.compiler.asm.*;
-import com.oracle.max.graal.compiler.lir.*;
-
-class AMD64ConvertFSlowPath implements LIR.SlowPath {
-
-    public final Label start = new Label();
-    public final Label continuation = new Label();
-
-    private final CiRegister result;
-    private final CiRegister input;
-    private final AMD64MacroAssembler masm;
-    private final boolean inputIsDouble;
-    private final boolean resultIsLong;
-
-    public AMD64ConvertFSlowPath(AMD64MacroAssembler masm, CiRegister result, CiRegister input, boolean inputIsDouble, boolean resultIsLong) {
-        this.masm = masm;
-        this.result = result;
-        this.input = input;
-        this.inputIsDouble = inputIsDouble;
-        this.resultIsLong = resultIsLong;
-    }
-
-    @Override
-    public void emitCode(TargetMethodAssembler tasm) {
-        masm.bind(start);
-        if (inputIsDouble) {
-            masm.ucomisd(input, tasm.asDoubleConstRef(CiConstant.DOUBLE_0));
-        } else {
-            masm.ucomiss(input, tasm.asFloatConstRef(CiConstant.FLOAT_0));
-        }
-        Label nan = new Label();
-        masm.jcc(ConditionFlag.parity, nan);
-        masm.jcc(ConditionFlag.below, continuation);
-
-        // input is > 0 -> return maxInt
-        // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
-        if (resultIsLong) {
-            masm.decrementq(result, 1);
-        } else {
-            masm.decrementl(result, 1);
-        }
-        masm.jmp(continuation);
-
-        // input is NaN -> return 0
-        masm.bind(nan);
-        masm.xorptr(result, result);
-        masm.jmp(continuation);
-    }
-}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Fri Jan 13 15:23:40 2012 +0100
@@ -26,7 +26,9 @@
 
 import java.util.*;
 
+import com.oracle.max.asm.*;
 import com.oracle.max.asm.target.amd64.*;
+import com.oracle.max.asm.target.amd64.AMD64Assembler.*;
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.graal.compiler.asm.*;
 import com.oracle.max.graal.compiler.lir.*;
@@ -35,8 +37,8 @@
 public enum AMD64ConvertOpcode implements LIROpcode {
     I2L, L2I, I2B, I2C, I2S,
     F2D, D2F,
-    I2F, I2D,
-    L2F, L2D,
+    I2F, I2D, F2I, D2I,
+    L2F, L2D, F2L, D2L,
     MOV_I2F, MOV_L2D, MOV_F2I, MOV_D2L;
 
     public LIRInstruction create(CiValue result, CiValue x) {
@@ -84,6 +86,22 @@
             case I2D: masm.cvtsi2sdl(asDoubleReg(result), asIntReg(x)); break;
             case L2F: masm.cvtsi2ssq(asFloatReg(result), asLongReg(x)); break;
             case L2D: masm.cvtsi2sdq(asDoubleReg(result), asLongReg(x)); break;
+            case F2I:
+                masm.cvttss2sil(asIntReg(result), asFloatReg(x));
+                emitFixup(tasm, masm, result, x);
+                break;
+            case D2I:
+                masm.cvttsd2sil(asIntReg(result), asDoubleReg(x));
+                emitFixup(tasm, masm, result, x);
+                break;
+            case F2L:
+                masm.cvttss2siq(asLongReg(result), asFloatReg(x));
+                emitFixup(tasm, masm, result, x);
+                break;
+            case D2L:
+                masm.cvttsd2siq(asLongReg(result), asDoubleReg(x));
+                emitFixup(tasm, masm, result, x);
+                break;
             case MOV_I2F: masm.movdl(asFloatReg(result), asIntReg(x)); break;
             case MOV_L2D: masm.movdq(asDoubleReg(result), asLongReg(x)); break;
             case MOV_F2I: masm.movdl(asIntReg(result), asFloatReg(x)); break;
@@ -91,4 +109,55 @@
             default: throw Util.shouldNotReachHere();
         }
     }
+
+    private static void emitFixup(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x) {
+        FixupSlowPath slowPath = new FixupSlowPath(result, x);
+        tasm.slowPaths.add(slowPath);
+        switch (result.kind) {
+            case Int:  masm.cmpl(asIntReg(result),  Integer.MIN_VALUE); break;
+            case Long: masm.cmpq(asLongReg(result), tasm.asLongConstRef(CiConstant.forLong(java.lang.Long.MIN_VALUE))); break;
+            default:   throw Util.shouldNotReachHere();
+        }
+        masm.jcc(ConditionFlag.equal, slowPath.start);
+        masm.bind(slowPath.continuation);
+    }
+
+    private static class FixupSlowPath extends AMD64SlowPath {
+        public final Label start = new Label();
+        public final Label continuation = new Label();
+        private final CiValue result;
+        private final CiValue x;
+
+        public FixupSlowPath(CiValue result, CiValue x) {
+            this.result = result;
+            this.x = x;
+        }
+
+        @Override
+        public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
+            masm.bind(start);
+            switch (x.kind) {
+                case Float:  masm.ucomiss(asFloatReg(x),  tasm.asFloatConstRef(CiConstant.FLOAT_0)); break;
+                case Double: masm.ucomisd(asDoubleReg(x), tasm.asDoubleConstRef(CiConstant.DOUBLE_0)); break;
+                default:     throw Util.shouldNotReachHere();
+            }
+            Label nan = new Label();
+            masm.jcc(ConditionFlag.parity, nan);
+            masm.jcc(ConditionFlag.below, continuation);
+
+            // input is > 0 -> return maxInt
+            // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
+            switch (result.kind) {
+                case Int:  masm.decrementl(asIntReg(result),  1); break;
+                case Long: masm.decrementq(asLongReg(result), 1); break;
+                default:   throw Util.shouldNotReachHere();
+            }
+            masm.jmp(continuation);
+
+            // input is NaN -> return 0
+            masm.bind(nan);
+            masm.xorptr(asRegister(result), asRegister(result));
+            masm.jmp(continuation);
+        }
+    }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DeoptimizationStub.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DeoptimizationStub.java	Fri Jan 13 15:23:40 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.nodes.DeoptimizeNode.DeoptAction;
 
-public class AMD64DeoptimizationStub implements LIR.SlowPath {
+public class AMD64DeoptimizationStub extends AMD64SlowPath {
     public final Label label = new Label();
     public final LIRDebugInfo info;
     public final DeoptAction action;
@@ -49,9 +49,7 @@
     private static ArrayList<Object> keepAlive = new ArrayList<>();
 
     @Override
-    public void emitCode(TargetMethodAssembler tasm) {
-        AMD64MacroAssembler masm = (AMD64MacroAssembler) tasm.asm;
-
+    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
         // TODO(cwi): we want to get rid of a generally reserved scratch register.
         CiRegister scratch = tasm.frameMap.registerConfig.getScratchRegister();
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Fri Jan 13 15:23:40 2012 +0100
@@ -27,8 +27,6 @@
 import static com.oracle.max.graal.compiler.target.amd64.AMD64ArithmeticOpcode.*;
 import static com.oracle.max.graal.compiler.target.amd64.AMD64CompareOpcode.*;
 import static com.oracle.max.graal.compiler.target.amd64.AMD64CompareToIntOpcode.*;
-import static com.oracle.max.graal.compiler.target.amd64.AMD64ConvertFIOpcode.*;
-import static com.oracle.max.graal.compiler.target.amd64.AMD64ConvertFLOpcode.*;
 import static com.oracle.max.graal.compiler.target.amd64.AMD64ConvertOpcode.*;
 import static com.oracle.max.graal.compiler.target.amd64.AMD64DivOpcode.*;
 import static com.oracle.max.graal.compiler.target.amd64.AMD64LogicFloatOpcode.*;
@@ -429,8 +427,8 @@
             case D2I: append(D2I.create(result, input)); break;
             case L2F: append(L2F.create(result, input)); break;
             case L2D: append(L2D.create(result, input)); break;
-            case F2L: append(F2L.create(result, input, newVariable(CiKind.Long))); break;
-            case D2L: append(D2L.create(result, input, newVariable(CiKind.Long))); break;
+            case F2L: append(F2L.create(result, input)); break;
+            case D2L: append(D2L.create(result, input)); break;
             case MOV_I2F: append(MOV_I2F.create(result, input)); break;
             case MOV_L2D: append(MOV_L2D.create(result, input)); break;
             case MOV_F2I: append(MOV_F2I.create(result, input)); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRInstruction.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRInstruction.java	Fri Jan 13 15:23:40 2012 +0100
@@ -28,7 +28,7 @@
 import com.oracle.max.graal.compiler.lir.*;
 
 /**
- * Convenience class to cast AbstractAssembler to AMD64MacroAssembler for the {@link #emitCode} method.
+ * Convenience class to provide AMD64MacroAssembler for the {@link #emitCode} method.
  */
 public abstract class AMD64LIRInstruction extends LIRInstruction {
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MethodEndStub.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MethodEndStub.java	Fri Jan 13 15:23:40 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,10 @@
 import com.oracle.max.asm.target.amd64.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.asm.*;
-import com.oracle.max.graal.compiler.lir.*;
 
-public class AMD64MethodEndStub implements LIR.SlowPath {
+public class AMD64MethodEndStub extends AMD64SlowPath {
     @Override
-    public void emitCode(TargetMethodAssembler tasm) {
-        AMD64MacroAssembler masm = (AMD64MacroAssembler) tasm.asm;
-
+    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
         for (int i = 0; i < GraalOptions.MethodEndBreakpointGuards; ++i) {
             masm.int3();
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64SlowPath.java	Fri Jan 13 15:23:40 2012 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.compiler.target.amd64;
+
+import com.oracle.max.asm.target.amd64.*;
+import com.oracle.max.graal.compiler.asm.*;
+import com.oracle.max.graal.compiler.lir.*;
+
+/**
+ * Convenience class to provide AMD64MacroAssembler for the {@link #emitCode} method.
+ */
+public abstract class AMD64SlowPath implements LIR.SlowPath {
+    @Override
+    public final void emitCode(TargetMethodAssembler tasm) {
+        emitCode(tasm, (AMD64MacroAssembler) tasm.asm);
+    }
+
+    public abstract void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm);
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java	Fri Jan 13 15:23:40 2012 +0100
@@ -89,7 +89,7 @@
         }
     }
 
-    private static class SlowPath implements LIR.SlowPath {
+    private static class SlowPath extends AMD64SlowPath {
         public final LIRXirInstruction instruction;
         public final Label[] labels;
         public final Map<XirMark, Mark> marks;
@@ -100,8 +100,9 @@
             this.marks = marks;
         }
 
-        public void emitCode(TargetMethodAssembler tasm) {
-            emitSlowPath(tasm, (AMD64MacroAssembler) tasm.asm, this);
+        @Override
+        public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
+            emitSlowPath(tasm, masm, this);
         }
     }
 
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinter.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinter.java	Fri Jan 13 15:23:40 2012 +0100
@@ -51,8 +51,8 @@
     public final ByteArrayOutputStream buffer;
     public final CiTarget target;
     public final RiRuntime runtime;
-    private LIR lir;
-    private LIRGenerator lirGenerator;
+    public LIR lir;
+    public LIRGenerator lirGenerator;
 
     /**
      * Creates a control flow graph printer.
@@ -66,11 +66,6 @@
         this.runtime = runtime;
     }
 
-    public void setLIR(LIR lir, LIRGenerator lirGenerator) {
-        this.lir = lir;
-        this.lirGenerator = lirGenerator;
-    }
-
     /**
      * Prints the control flow graph denoted by a given block map.
      *
@@ -129,18 +124,17 @@
      *
      * @param label A label describing the compilation phase that produced the control flow graph.
      * @param blocks The list of blocks to be printed.
-     * @param printNodes If {@code true} the nodes in the block will be printed.
      */
-    public void printCFG(String label, List<? extends Block> blocks, boolean printNodes) {
+    public void printCFG(String label, List<? extends Block> blocks) {
         begin("cfg");
         out.print("name \"").print(label).println('"');
         for (Block block : blocks) {
-            printBlock(block, printNodes);
+            printBlock(block);
         }
         end("cfg");
     }
 
-    private void printBlock(Block block, boolean printNodes) {
+    private void printBlock(Block block) {
         begin("block");
 
         out.print("name \"").print(blockToString(block)).println('"');
@@ -184,9 +178,7 @@
         out.print("loop_index ").println(block.loopIndex());
         out.print("loop_depth ").println(block.loopDepth());
 
-        if (printNodes) {
-            printNodes(block);
-        }
+        printNodes(block);
 
         if (block instanceof LIRBlock) {
             printLIR((LIRBlock) block);
@@ -228,13 +220,14 @@
         } else if (node instanceof FloatingNode) {
             out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
         }
-        if (lirGenerator != null && lirGenerator.nodeOperands != null && node instanceof ValueNode) {
+        out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
+
+        if (lirGenerator != null) {
             CiValue operand = lirGenerator.nodeOperands.get(node);
             if (operand != null) {
                 out.print("result ").print(operand.toString()).println(COLUMN_END);
             }
         }
-        out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
 
         if (node instanceof StateSplit) {
             StateSplit stateSplit = (StateSplit) node;
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java	Thu Jan 12 17:30:11 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java	Fri Jan 13 15:23:40 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,11 +77,16 @@
         }
 
         RiRuntime runtime = cfgPrinter.runtime;
-        cfgPrinter.setLIR(event.debugObject(LIR.class), event.debugObject(LIRGenerator.class));
+        if (event.debugObject(LIR.class) != null) {
+            cfgPrinter.lir = event.debugObject(LIR.class);
+        }
+        if (event.debugObject(LIRGenerator.class) != null) {
+            cfgPrinter.lirGenerator = event.debugObject(LIRGenerator.class);
+        }
+
         BlockMap blockMap = event.debugObject(BlockMap.class);
         Graph graph = event.debugObject(Graph.class);
         IdentifyBlocksPhase schedule = event.debugObject(IdentifyBlocksPhase.class);
-        LIR lir = event.debugObject(LIR.class);
         LinearScan allocator = event.debugObject(LinearScan.class);
         Interval[] intervals = event.debugObject(Interval[].class);
         CiTargetMethod targetMethod = event.debugObject(CiTargetMethod.class);
@@ -90,8 +95,8 @@
             cfgPrinter.printCFG(event.label, blockMap);
             cfgPrinter.printBytecodes(runtime.disassemble(blockMap.method));
         }
-        if (lir != null) {
-            cfgPrinter.printCFG(event.label, lir.codeEmittingOrder(), graph != null);
+        if (cfgPrinter.lir != null) {
+            cfgPrinter.printCFG(event.label, cfgPrinter.lir.codeEmittingOrder());
             if (targetMethod != null) {
                 cfgPrinter.printMachineCode(runtime.disassemble(targetMethod), null);
             }
@@ -110,7 +115,7 @@
                 }
             }
             if (blocks != null) {
-                cfgPrinter.printCFG(event.label, blocks, true);
+                cfgPrinter.printCFG(event.label, blocks);
             }
         }
         if (allocator != null && intervals != null) {
--- a/mx/commands.py	Thu Jan 12 17:30:11 2012 +0100
+++ b/mx/commands.py	Fri Jan 13 15:23:40 2012 +0100
@@ -26,7 +26,7 @@
 #
 # ----------------------------------------------------------------------------------------------------
 
-import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess
+import os, sys, shutil, zipfile, tempfile, re, time, datetime, platform, subprocess, StringIO
 from os.path import join, exists, dirname, basename
 from argparse import ArgumentParser, REMAINDER
 import mx
@@ -36,6 +36,31 @@
 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 
 _vmbuild = 'product'
 
+_copyrightTemplate = """/*
+ * Copyright (c) {0}, 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.
+ */
+ 
+"""
+
 def clean(args):
     """cleans the GraalVM source tree"""
     opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
@@ -304,6 +329,16 @@
             if not 'Xusage.txt' in line:
                 sys.stderr.write(line + os.linesep)
                 
+        # Update graal_paths.hpp
+        out = StringIO.StringIO()
+        out.write(_copyrightTemplate.format(time.strftime('%Y')))
+        for p in mx.project('com.oracle.max.graal.hotspot').all_deps([], False):
+            out.write('    prepend_to_graal_classpath(scp_compiler, graal_dir, "' + p.name + '");\n')
+        graalPaths = join(_graal_home, 'src', 'share', 'vm', 'graal', 'graal_paths.hpp')
+        assert exists(graalPaths), 'File does not exist: ' + graalPaths
+        mx.update_file(graalPaths, out.getvalue())
+        out.close()
+                
         if platform.system() == 'Windows':
             compilelogfile = _graal_home + '/graalCompile.log'
             mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
--- a/src/share/vm/graal/graal_paths.hpp	Thu Jan 12 17:30:11 2012 +0100
+++ b/src/share/vm/graal/graal_paths.hpp	Fri Jan 13 15:23:40 2012 +0100
@@ -20,17 +20,16 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
+ 
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.cri");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.criutils");
-    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.base");
-    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asmdis");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asm");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.graph");
+    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.nodes");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.compiler");
-    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.nodes");
+    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.java");
+    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.printer");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.snippets");
+    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.base");
+    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.asmdis");
     prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.hotspot");
-    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.printer");
-    prepend_to_graal_classpath(scp_compiler, graal_dir, "com.oracle.max.graal.java");
-