changeset 4266:e2499e6d8aa7

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 11 Jan 2012 16:31:46 +0100
parents 4643ccd37dac (current diff) 8d2c14f722ac (diff)
children ba5f95c3d6f5
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/RegisterVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java 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/AMD64LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java
diffstat 44 files changed, 552 insertions(+), 433 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java	Wed Jan 11 16:31:46 2012 +0100
@@ -79,7 +79,7 @@
     /**
      * Constants for X86 prefix bytes.
      */
-    private class Prefix {
+    private static class Prefix {
         private static final int REX = 0x40;
         private static final int REXB = 0x41;
         private static final int REXX = 0x42;
--- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/X86InstructionDecoder.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/X86InstructionDecoder.java	Wed Jan 11 16:31:46 2012 +0100
@@ -30,7 +30,7 @@
     private int currentEndOfInstruction;
     private int currentDisplacementPosition;
 
-    private class Prefix {
+    private static class Prefix {
 
         // segment overrides
         public static final int CSSegment = 0x2e;
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java	Wed Jan 11 16:31:46 2012 +0100
@@ -98,4 +98,27 @@
         assert value.kind == CiKind.Double;
         return asRegister(value);
     }
+
+
+    public static boolean sameRegister(CiValue...values) {
+        for (int i = 0; i < values.length; i++) {
+            for (int j = i + 1; j < values.length; j++) {
+                if (isRegister(values[i]) && isRegister(values[j]) && asRegister(values[i]) != asRegister(values[j])) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    public static boolean differentRegisters(CiValue...values) {
+        for (int i = 0; i < values.length; i++) {
+            for (int j = i + 1; j < values.length; j++) {
+                if (isRegister(values[i]) && isRegister(values[j]) && asRegister(values[i]) == asRegister(values[j])) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
 }
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java	Wed Jan 11 16:31:46 2012 +0100
@@ -67,7 +67,7 @@
                 return false;
             }
             if (arg.constant != null) {
-                if (arg.constant != null && arg.constant.kind != param.kind) {
+                if (arg.constant.kind != param.kind) {
                     return false;
                 }
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/AssignRegisters.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/AssignRegisters.java	Wed Jan 11 16:31:46 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
@@ -48,10 +48,10 @@
         ValueProcedure defProc =          new ValueProcedure() { @Override public CiValue doValue(CiValue value) { return def(value); } };
         ValueProcedure setReferenceProc = new ValueProcedure() { @Override public CiValue doValue(CiValue value) { return setReference(value); } };
 
-        trace(1, "==== start assign registers ====");
+        assert trace("==== start assign registers ====");
         for (int i = lir.linearScanOrder().size() - 1; i >= 0; i--) {
             LIRBlock block = lir.linearScanOrder().get(i);
-            trace(1, "start block %s", block);
+            assert trace("start block %s", block);
             assert block.phis == null : "Register assignment must run after phi functions have been replaced by moves";
 
             curRegisterRefMap = frameMap.initRegisterRefMap();
@@ -62,7 +62,7 @@
 
             for (int j = block.lir().size() - 1; j >= 0; j--) {
                 LIRInstruction op = block.lir().get(j);
-                trace(1, "  op %d %s", op.id(), op);
+                assert trace("  op %d %s", op.id(), op);
 
                 op.forEachOutput(defProc);
                 op.forEachTemp(defProc);
@@ -70,7 +70,7 @@
                 op.forEachAlive(useProc);
 
                 if (op.info != null) {
-                    trace(3, "    registerRefMap: %s  frameRefMap: %s", curRegisterRefMap, curFrameRefMap);
+                    assert trace("    registerRefMap: %s  frameRefMap: %s", curRegisterRefMap, curFrameRefMap);
                     op.info.finish(new CiBitMap(curRegisterRefMap), new CiBitMap(curFrameRefMap), frameMap);
 
                     if (op instanceof LIRXirInstruction) {
@@ -85,13 +85,13 @@
                 // for the last time at this instruction are not part of the reference map.
                 op.forEachInput(useProc);
             }
-            trace(1, "end block %s", block);
+            assert trace("end block %s", block);
         }
-        trace(1, "==== end assign registers ====");
+        assert trace("==== end assign registers ====");
     }
 
     private CiValue use(CiValue value) {
-        trace(3, "    use %s", value);
+        assert trace("    use %s", value);
         if (isLocation(value)) {
             CiValue location = asLocation(value).location;
             frameMap.setReference(location, curRegisterRefMap, curFrameRefMap);
@@ -103,7 +103,7 @@
     }
 
     private CiValue def(CiValue value) {
-        trace(3, "    def %s", value);
+        assert trace("    def %s", value);
         if (isLocation(value)) {
             CiValue location = asLocation(value).location;
             frameMap.clearReference(location, curRegisterRefMap, curFrameRefMap);
@@ -115,16 +115,17 @@
     }
 
     private CiValue setReference(CiValue value) {
-        trace(3, "    setReference %s", value);
+        assert trace("    setReference %s", value);
         frameMap.setReference(asLocation(value).location, curRegisterRefMap, curFrameRefMap);
         return value;
     }
 
     protected abstract LocationMap locationsForBlockEnd(LIRBlock block);
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Wed Jan 11 16:31:46 2012 +0100
@@ -171,22 +171,22 @@
         blockLiveIn = new BitSet[blocks().size()];
         registerLive = new BitSet();
 
-        trace(1, "==== start backward data flow analysis ====");
+        assert trace("==== start backward data flow analysis ====");
         for (int i = blocks().size() - 1; i >= 0; i--) {
             LIRBlock block = blocks().get(i);
-            trace(1, "start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
+            assert trace("start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
 
             variableLive = new BitSet();
             for (LIRBlock sux : block.getLIRSuccessors()) {
                 BitSet suxLive = liveIn(sux);
                 if (suxLive != null) {
-                    trace(1, "  sux %s  suxLive: %s", sux, suxLive);
+                    assert trace("  sux %s  suxLive: %s", sux, suxLive);
                     variableLive.or(suxLive);
                 }
 
                 if (sux.phis != null) {
                     curOpId = block.lastLirInstructionId();
-                    trace(1, "  phis %d  variableLive: %s", curOpId, variableLive);
+                    assert trace("  phis %d  variableLive: %s", curOpId, variableLive);
                     sux.phis.forEachInput(block, phiInputProc);
                 }
             }
@@ -196,7 +196,7 @@
             for (int j = block.lir().size() - 1; j >= 0; j--) {
                 LIRInstruction op = block.lir().get(j);
                 curOpId = op.id();
-                trace(1, "  op %d %s  variableLive: %s  registerLive: %s", curOpId, op, variableLive, registerLive);
+                assert trace("  op %d %s  variableLive: %s  registerLive: %s", curOpId, op, variableLive, registerLive);
 
                 op.forEachOutput(outputProc);
                 op.forEachTemp(tempProc);
@@ -207,7 +207,7 @@
 
             if (block.phis != null) {
                 curOpId = block.firstLirInstructionId();
-                trace(1, "  phis %d  variableLive: %s  registerLive: %s", curOpId, variableLive, registerLive);
+                assert trace("  phis %d  variableLive: %s  registerLive: %s", curOpId, variableLive, registerLive);
                 block.phis.forEachOutput(outputProc);
             }
 
@@ -216,29 +216,29 @@
             setLiveIn(block, variableLive);
 
             if (block.isLoopHeader()) {
-                trace(1, "  loop header, propagating live set to loop blocks  variableLive: %s", variableLive);
+                assert trace("  loop header, propagating live set to loop blocks  variableLive: %s", variableLive);
                 // All variables that are live at the beginning of a loop are also live the whole loop.
                 // This is guaranteed by the SSA form.
                 for (Block loop : block.loopBlocks) {
                     BitSet loopLiveIn = liveIn(loop);
                     assert loopLiveIn != null : "All loop blocks must have been processed before the loop header";
                     loopLiveIn.or(variableLive);
-                    trace(3, "    block %s  loopLiveIn %s", loop, loopLiveIn);
+                    assert trace("    block %s  loopLiveIn %s", loop, loopLiveIn);
                 }
             }
 
-            trace(1, "end block %s  variableLive: %s", block, variableLive);
+            assert trace("end block %s  variableLive: %s", block, variableLive);
         }
-        trace(1, "==== end backward data flow analysis ====");
+        assert trace("==== end backward data flow analysis ====");
     }
 
     private CiValue use(CiValue value, int killOpId) {
-        trace(3, "    use %s", value);
+        assert trace("    use %s", value);
         if (isVariable(value)) {
             int variableIdx = asVariable(value).index;
             assert definitions[variableIdx] < curOpId;
             if (!variableLive.get(variableIdx)) {
-                trace(3, "      set live variable %d", variableIdx);
+                assert trace("      set live variable %d", variableIdx);
                 variableLive.set(variableIdx);
                 kill(value, killOpId);
             }
@@ -246,7 +246,7 @@
         } else if (isAllocatableRegister(value)) {
             int regNum = asRegister(value).number;
             if (!registerLive.get(regNum)) {
-                trace(3, "      set live register %d", regNum);
+                assert trace("      set live register %d", regNum);
                 registerLive.set(regNum);
                 kill(value, killOpId);
             }
@@ -255,12 +255,12 @@
     }
 
     private CiValue def(CiValue value, boolean isTemp) {
-        trace(3, "    def %s", value);
+        assert trace("    def %s", value);
         if (isVariable(value)) {
             int variableIdx = asVariable(value).index;
             assert definitions[variableIdx] == curOpId;
             if (variableLive.get(variableIdx)) {
-                trace(3, "      clear live variable %d", variableIdx);
+                assert trace("      clear live variable %d", variableIdx);
                 assert !isTemp : "temp variable cannot be used after the operation";
                 variableLive.clear(variableIdx);
             } else {
@@ -271,7 +271,7 @@
         } else if (isAllocatableRegister(value)) {
             int regNum = asRegister(value).number;
             if (registerLive.get(regNum)) {
-                trace(3, "      clear live register %d", regNum);
+                assert trace("      clear live register %d", regNum);
                 assert !isTemp : "temp variable cannot be used after the operation";
                 registerLive.clear(regNum);
             } else {
@@ -296,11 +296,11 @@
             if (useBlock.loopDepth() > 0 && useBlock.loopIndex() != defBlock.loopIndex()) {
                 // This is a value defined outside of the loop it is currently used in.  Therefore, it is live the whole loop
                 // and is not killed by the current instruction.
-                trace(3, "      no kill because use in loop %d, definition in loop %d", useBlock.loopIndex(), defBlock.loopIndex());
+                assert trace("      no kill because use in loop %d, definition in loop %d", useBlock.loopIndex(), defBlock.loopIndex());
                 return;
             }
         }
-        trace(3, "      kill %s at %d", value, opId);
+        assert trace("      kill %s at %d", value, opId);
 
         Object entry = killedValues(opId);
         if (entry == null) {
@@ -322,9 +322,10 @@
         }
     }
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/ResolveDataFlow.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/ResolveDataFlow.java	Wed Jan 11 16:31:46 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
@@ -50,11 +50,11 @@
         ValueProcedure locMappingProc =    new ValueProcedure() {    @Override public CiValue doValue(CiValue value) { return locMapping(value); } };
         PhiValueProcedure phiMappingProc = new PhiValueProcedure() { @Override public CiValue doValue(CiValue input, CiValue output) { return phiMapping(input, output); } };
 
-        trace(1, "==== start resolve data flow ====");
+        assert trace("==== start resolve data flow ====");
         for (LIRBlock toBlock : lir.linearScanOrder()) {
 
             for (LIRBlock fromBlock : toBlock.getLIRPredecessors()) {
-                trace(1, "start edge %s -> %s", fromBlock, toBlock);
+                assert trace("start edge %s -> %s", fromBlock, toBlock);
                 findInsertPos(fromBlock, toBlock);
 
                 LocationMap toLocations = locationsForBlockBegin(toBlock);
@@ -68,14 +68,14 @@
                 }
 
                 moveResolver.resolve();
-                trace(1, "end edge %s -> %s", fromBlock, toBlock);
+                assert trace("end edge %s -> %s", fromBlock, toBlock);
             }
 
             // Phi functions are resolved with moves now, so delete them.
             toBlock.phis = null;
         }
         moveResolver.finish();
-        trace(1, "==== end resolve data flow ====");
+        assert trace("==== end resolve data flow ====");
     }
 
     private CiValue locMapping(CiValue value) {
@@ -102,11 +102,11 @@
             LIRInstruction instr = instructions.get(instructions.size() - 1);
             assert instr instanceof LIRBranch && instr.code == StandardOpcode.JUMP : "block does not end with an unconditional jump";
             moveResolver.init(instructions, instructions.size() - 1);
-            trace(1, "  insert at end of %s before %d", fromBlock, instructions.size() - 1);
+            assert trace("  insert at end of %s before %d", fromBlock, instructions.size() - 1);
 
         } else if (toBlock.numberOfPreds() == 1) {
             moveResolver.init(toBlock.lir(), 1);
-            trace(1, "  insert at beginning of %s before %d", toBlock, 1);
+            assert trace("  insert at beginning of %s before %d", toBlock, 1);
 
         } else {
             Util.shouldNotReachHere("Critical edge not split");
@@ -117,9 +117,10 @@
     protected abstract LocationMap locationsForBlockEnd(LIRBlock block);
 
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Wed Jan 11 16:31:46 2012 +0100
@@ -163,12 +163,12 @@
         PhiValueProcedure useSlotProc =   new PhiValueProcedure() { @Override public CiValue doValue(CiValue value) { return useSlot(value); } };
         ValueProcedure defSlotProc =      new ValueProcedure() {    @Override public CiValue doValue(CiValue value) { return defSlot(value); } };
 
-        trace(1, "==== start spill all allocation ====");
+        assert trace("==== start spill all allocation ====");
         curInRegisterState = new Object[maxRegisterNum()];
         curOutRegisterState = new Object[maxRegisterNum()];
         curRegisterLocations = new LocationMap(lir.numVariables());
         for (LIRBlock block : lir.linearScanOrder()) {
-            trace(1, "start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
+            assert trace("start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
             assert checkEmpty(curOutRegisterState);
 
             if (block.dominator() != null) {
@@ -181,17 +181,17 @@
             } else {
                 curStackLocations = new LocationMap(lir.numVariables());
             }
-            traceState();
+            assert traceState();
 
             if (block.phis != null) {
-                trace(1, "  phis");
+                assert trace("  phis");
                 block.phis.forEachOutput(defSlotProc);
             }
 
             for (int opIdx = 0; opIdx < block.lir().size(); opIdx++) {
                 LIRInstruction op = block.lir().get(opIdx);
                 curInstruction = op;
-                trace(1, "  op %d %s", op.id(), op);
+                assert trace("  op %d %s", op.id(), op);
 
                 assert curRegisterLocations.checkEmpty();
 
@@ -226,7 +226,7 @@
 
             for (LIRBlock sux : block.getLIRSuccessors()) {
                 if (sux.phis != null) {
-                    trace(1, "  phis of successor %s", sux);
+                    assert trace("  phis of successor %s", sux);
                     sux.phis.forEachInput(block, useSlotProc);
                 }
             }
@@ -236,11 +236,11 @@
             setLocationsFor(block, curStackLocations);
 
             traceState();
-            trace(1, "end block %s", block);
+            assert trace("end block %s", block);
         }
 
         moveResolver.finish();
-        trace(1, "==== end spill all allocation ====");
+        assert trace("==== end spill all allocation ====");
     }
 
     private CiValue killNonLive(CiValue value) {
@@ -253,7 +253,7 @@
 
     private CiValue kill(CiValue value, boolean end) {
         if (isVariable(value)) {
-            trace(3, "    kill variable %s", value);
+            assert trace("    kill variable %s", value);
 
             Variable variable = asVariable(value);
             curStackLocations.clear(variable);
@@ -263,7 +263,7 @@
                 killLocation(loc);
                 curRegisterLocations.clear(variable);
 
-                trace(3, "      location %s", loc);
+                assert trace("      location %s", loc);
                 assert isAllocatableRegister(loc.location);
 
                 int regNum = asRegister(loc.location).number;
@@ -273,7 +273,7 @@
             }
 
         } else if (isAllocatableRegister(value)) {
-            trace(3, "    kill register %s", value);
+            assert trace("    kill register %s", value);
             int regNum = asRegister(value).number;
             assert curOutRegisterState[regNum] == null || curOutRegisterState[regNum] instanceof LIRInstruction && curInstruction != null;
 
@@ -288,7 +288,7 @@
     }
 
     private CiValue killLocation(CiValue value) {
-        trace(3, "    kill location %s", value);
+        assert trace("    kill location %s", value);
         assert isAllocatableRegister(asLocation(value).location);
 
         int regNum = asRegister(asLocation(value).location).number;
@@ -300,7 +300,7 @@
 
     private CiValue block(CiValue value) {
         if (isAllocatableRegister(value)) {
-            trace(3, "    block %s", value);
+            assert trace("    block %s", value);
             int regNum = asRegister(value).number;
             assert curInstruction != null;
             assert curOutRegisterState[regNum] == null || curOutRegisterState[regNum] instanceof LIRInstruction;
@@ -315,11 +315,11 @@
             return useSlot(value);
         }
         if (isVariable(value)) {
-            trace(3, "    load %s", value);
+            assert trace("    load %s", value);
             Location regLoc = curRegisterLocations.get(asVariable(value));
             if (regLoc != null) {
                 // This variable has already been processed before.
-                trace(3, "      found location %s", regLoc);
+                assert trace("      found location %s", regLoc);
             } else {
                 regLoc = allocateRegister(asVariable(value), curInRegisterState, mode == OperandMode.Alive ? curOutRegisterState : null, mode, flags);
                 Location stackLoc = curStackLocations.get(asVariable(value));
@@ -339,7 +339,7 @@
             return defSlot(value);
         }
         if (isVariable(value)) {
-            trace(3, "    spill %s", value);
+            assert trace("    spill %s", value);
             assert curStackLocations.get(asVariable(value)) == null;
             Location regLoc = allocateRegister(asVariable(value), null, curOutRegisterState, mode, flags);
             if (mode == OperandMode.Output) {
@@ -356,10 +356,10 @@
 
     private CiValue useSlot(CiValue value) {
         if (isVariable(value)) {
-            trace(3, "    useSlot %s", value);
+            assert trace("    useSlot %s", value);
             Location stackLoc = curStackLocations.get(asVariable(value));
             assert stackLoc != null;
-            trace(3, "      slot %s", stackLoc);
+            assert trace("      slot %s", stackLoc);
             return stackLoc;
         } else {
             return value;
@@ -368,11 +368,11 @@
 
     private CiValue defSlot(CiValue value) {
         if (isVariable(value)) {
-            trace(3, "    assignSlot %s", value);
+            assert trace("    assignSlot %s", value);
             Location stackLoc = new Location(asVariable(value), frameMap.allocateSpillSlot(value.kind));
             assert curStackLocations.get(asVariable(value)) == null;
             curStackLocations.put(stackLoc);
-            trace(3, "      slot %s", stackLoc);
+            assert trace("      slot %s", stackLoc);
             return stackLoc;
         } else {
             return value;
@@ -384,7 +384,7 @@
             CiValue result = curInstruction.forEachRegisterHint(variable, mode, new ValueProcedure() {
                 @Override
                 public CiValue doValue(CiValue registerHint) {
-                    trace(3, "      registerHint %s", registerHint);
+                    assert trace("      registerHint %s", registerHint);
                     CiRegister hint = null;
                     if (isRegister(registerHint)) {
                         hint = asRegister(registerHint);
@@ -429,7 +429,7 @@
         }
         assert curRegisterLocations.get(variable) == null;
         curRegisterLocations.put(loc);
-        trace(3, "      selected register %s", loc);
+        assert trace("      selected register %s", loc);
         return loc;
     }
 
@@ -470,8 +470,8 @@
     }
 
 
-    private void traceState() {
-        if (GraalOptions.TraceRegisterAllocationLevel >= 3) {
+    private boolean traceState() {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.print("  curVariableLocations: ");
             curStackLocations.forEachLocation(new ValueProcedure() {
                 @Override
@@ -482,11 +482,13 @@
             });
             TTY.println();
         }
+        return true;
     }
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java	Wed Jan 11 16:31:46 2012 +0100
@@ -74,7 +74,7 @@
         assert isLocation(from) || isConstant(from);
         assert from != to;
 
-        trace(3, "mr    add mapping from %s to %s", from, to);
+        assert trace("mr    add mapping from %s to %s", from, to);
         mappingFrom.add(from);
         mappingTo.add(to);
 
@@ -86,12 +86,12 @@
 
         if (mappingFrom.size() == 1) {
             // If there is only one mapping, it is trivial that this mapping is safe to resolve.
-            trace(3, "mr    resolve  mappings: %d", mappingFrom.size());
+            assert trace("mr    resolve  mappings: %d", mappingFrom.size());
             insertMove(mappingFrom.get(0), mappingTo.get(0));
             mappingFrom.remove(0);
             mappingTo.remove(0);
         } else if (mappingFrom.size() > 1) {
-            trace(3, "mr    resolve  mappings: %d", mappingFrom.size());
+            assert trace("mr    resolve  mappings: %d", mappingFrom.size());
             doResolve();
         }
         insertPos = -1;
@@ -258,7 +258,7 @@
     }
 
     private void insertExchange(Location from, Location to) {
-        trace(3, "mr      XCHG %s, %s", from, to);
+        assert trace("mr      XCHG %s, %s", from, to);
         // TODO create XCHG instruction and use it here
         insertionBuffer.append(insertPos, null);
         throw Util.unimplemented();
@@ -291,7 +291,7 @@
             }
 
         } else {
-            trace(3, "mr      MOV %s -> %s", src, dst);
+            assert trace("mr      MOV %s -> %s", src, dst);
             insertionBuffer.append(insertPos, StandardOpcode.SPILL_MOVE.create(dst,  src));
         }
     }
@@ -337,9 +337,10 @@
     }
 
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/RegisterVerifier.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/RegisterVerifier.java	Wed Jan 11 16:31:46 2012 +0100
@@ -93,18 +93,18 @@
         setStateFor(startBlock, curInputState);
         addToWorkList(startBlock);
 
-        trace(1, "==== start verify register allocation ====");
+        assert trace("==== start verify register allocation ====");
         do {
             LIRBlock block = workList.remove(0);
             assert block.phis == null : "phi functions must have been resolved with moves";
 
             // Must copy state because it is modified.
             curInputState = copy(stateFor(block));
-            trace(1, "start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
-            traceState();
+            assert trace("start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
+            assert traceState();
 
             for (LIRInstruction op : block.lir()) {
-                trace(2, "  op %d %s", op.id(), op);
+                assert trace("  op %d %s", op.id(), op);
 
                 op.forEachInput(useProc);
                 if (op.hasCall()) {
@@ -120,23 +120,23 @@
                 processSuccessor(succ);
             }
 
-            trace(1, "end block %s", block);
+            assert trace("end block %s", block);
         } while (!workList.isEmpty());
-        trace(1, "==== end verify register allocation ====");
+        assert trace("==== end verify register allocation ====");
     }
 
     private void processSuccessor(LIRBlock succ) {
         Map<Object, CiValue> savedState = stateFor(succ);
         if (savedState == null) {
             // Block was not processed before, so set initial inputState.
-            trace(2, "  successor %s: initial visit", succ);
+            assert trace("  successor %s: initial visit", succ);
             setStateFor(succ, copy(curInputState));
             addToWorkList(succ);
 
         } else {
             // This block was already processed before.
             // Check if new inputState is consistent with savedState.
-            trace(2, "  successor %s: state present", succ);
+            assert trace("  successor %s: state present", succ);
             Iterator<Map.Entry<Object, CiValue>> iter = savedState.entrySet().iterator();
             while (iter.hasNext()) {
                 Map.Entry<Object, CiValue> entry = iter.next();
@@ -146,7 +146,7 @@
                 if (savedValue != inputValue) {
                     // Current inputState and previous savedState assume a different value in this register.
                     // Assume that this register is invalid and remove it from the saved state.
-                    trace(2, "    invalididating %s because it is inconsistent with %s", savedValue, inputValue);
+                    assert trace("    invalididating %s because it is inconsistent with %s", savedValue, inputValue);
                     iter.remove();
                     // Must re-visit this block.
                     addToWorkList(succ);
@@ -161,7 +161,7 @@
         while (iter.hasNext()) {
             Object value1 = iter.next();
             if (value1 instanceof CiRegister && frameMap.registerConfig.getAttributesMap()[((CiRegister) value1).number].isCallerSave) {
-                trace(2, "    remove caller save register %s", value1);
+                assert trace("    remove caller save register %s", value1);
                 iter.remove();
             }
         }
@@ -201,20 +201,20 @@
     }
 
     private CiValue temp(CiValue value) {
-        trace(2, "    temp %s -> remove key %s", value, key(value));
+        assert trace("    temp %s -> remove key %s", value, key(value));
         curInputState.remove(key(value));
         return value;
     }
 
     private CiValue output(CiValue value) {
-        trace(2, "    output %s -> set key %s", value, key(value));
+        assert trace("    output %s -> set key %s", value, key(value));
         curInputState.put(key(value), value);
         return value;
     }
 
 
-    private void traceState() {
-        if (GraalOptions.TraceRegisterAllocationLevel >= 2) {
+    private boolean traceState() {
+        if (GraalOptions.TraceRegisterAllocation) {
             ArrayList<Object> keys = new ArrayList<>(curInputState.keySet());
             Collections.sort(keys, new Comparator<Object>() {
                 @Override
@@ -241,11 +241,13 @@
             }
             TTY.println();
         }
+        return true;
     }
 
-    private static void trace(int level, String format, Object...args) {
-        if (GraalOptions.TraceRegisterAllocationLevel >= level) {
+    private static boolean trace(String format, Object...args) {
+        if (GraalOptions.TraceRegisterAllocation) {
             TTY.println(format, args);
         }
+        return true;
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jan 11 16:31:46 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
@@ -105,7 +105,7 @@
     public static boolean PrintCodeBytes                     = ____;
     public static int     PrintAssemblyBytesPerLine          = 16;
     public static int     TraceLinearScanLevel               = 0;
-    public static int     TraceRegisterAllocationLevel       = 0;
+    public static boolean TraceRegisterAllocation            = false;
     public static int     TraceLIRGeneratorLevel             = 0;
     public static boolean TraceRelocation                    = ____;
     public static boolean TraceLIRVisit                      = ____;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/PostOrderNodeIterator.java	Wed Jan 11 16:31:46 2012 +0100
@@ -102,8 +102,8 @@
         nodeStates.put(x, state);
         if (successors != null) {
             for (Node node : successors) {
-                nodeStates.put((FixedNode) node.predecessor(), state);
                 if (node != null) {
+                    nodeStates.put((FixedNode) node.predecessor(), state);
                     nodeQueue.addFirst((FixedNode) node);
                 }
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRCall.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRCall.java	Wed Jan 11 16:31:46 2012 +0100
@@ -78,14 +78,6 @@
         this.target = target;
     }
 
-    public RiMethod method() {
-        return (RiMethod) target;
-    }
-
-    public CiRuntimeCall runtimeCall() {
-        return (CiRuntimeCall) target;
-    }
-
     public CiValue targetAddress() {
         if (targetAddressIndex >= 0) {
             return input(targetAddressIndex);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/EscapeAnalysisPhase.java	Wed Jan 11 16:31:46 2012 +0100
@@ -207,7 +207,7 @@
     }
 
 
-    public class EscapementFixup {
+    public static class EscapementFixup {
 
         private final Map<Object, Integer> fields = new HashMap<>();
         private final EscapeOp op;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/FloatingReadPhase.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/FloatingReadPhase.java	Wed Jan 11 16:31:46 2012 +0100
@@ -124,7 +124,6 @@
                 }
                 assert phi.valueCount() <= phi.merge().endCount() : phi.merge();
             } else {
-                assert m != null;
                 PhiNode phi = m.graph().unique(new PhiNode(CiKind.Illegal, m, PhiType.Memory));
                 for (int i = 0; i < mergeOperationCount + 1; ++i) {
                     phi.addInput((ValueNode) original);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jan 11 16:31:46 2012 +0100
@@ -68,7 +68,7 @@
 
         this.currentContext = context;
         try {
-            assert graph != null && !shouldVerify || graph.verify();
+            assert graph != null && (!shouldVerify || graph.verify());
         } catch (GraalInternalError e) {
             throw e.addContext("start of phase", getDetailedName());
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Wed Jan 11 16:31:46 2012 +0100
@@ -93,7 +93,6 @@
                         ok = false;
                         break;
                     }
-                    assert unmarkedDominated == null : "b=" + b + ", unmarkedDominated=" + unmarkedDominated + ", dominated=" + dominated;
                     unmarkedDominated = dominated;
                 }
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -38,22 +38,20 @@
     FADD, FSUB, FMUL, FDIV,
     DADD, DSUB, DMUL, DDIV;
 
-    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
-        assert (name().startsWith("I") && result.kind == CiKind.Int && left.kind.stackKind() == CiKind.Int && right.kind.stackKind() == CiKind.Int)
-            || (name().startsWith("L") && result.kind == CiKind.Long && left.kind == CiKind.Long && right.kind == CiKind.Long)
-            || (name().startsWith("F") && result.kind == CiKind.Float && left.kind == CiKind.Float && right.kind == CiKind.Float)
-            || (name().startsWith("D") && result.kind == CiKind.Double && left.kind == CiKind.Double && right.kind == CiKind.Double);
+    public LIRInstruction create(CiValue result, CiValue x, CiValue y) {
+        assert (name().startsWith("I") && result.kind == CiKind.Int && x.kind.stackKind() == CiKind.Int && y.kind.stackKind() == CiKind.Int)
+            || (name().startsWith("L") && result.kind == CiKind.Long && x.kind == CiKind.Long && y.kind == CiKind.Long)
+            || (name().startsWith("F") && result.kind == CiKind.Float && x.kind == CiKind.Float && y.kind == CiKind.Float)
+            || (name().startsWith("D") && result.kind == CiKind.Double && x.kind == CiKind.Double && y.kind == CiKind.Double);
 
-        CiValue[] inputs = new CiValue[] {left};
-        CiValue[] alives = new CiValue[] {right};
+        CiValue[] inputs = new CiValue[] {x};
+        CiValue[] alives = new CiValue[] {y};
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, null, inputs, alives, LIRInstruction.NO_OPERANDS) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                assert !(alive(0) instanceof CiRegisterValue) || asRegister(output(0)) != asRegister(alive(0)) : "result and right must be different registers";
-                AMD64MoveOpcode.move(tasm, masm, output(0), input(0));
-                emit(tasm, masm, output(0), alive(0));
+                emit(tasm, masm, output(0), input(0), alive(0));
             }
 
             @Override
@@ -70,10 +68,13 @@
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) {
-        CiRegister dst = asRegister(leftAndResult);
-        if (isRegister(right)) {
-            CiRegister rreg = asRegister(right);
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue y) {
+        assert sameRegister(x, y) || differentRegisters(result, y);
+        AMD64MoveOpcode.move(tasm, masm, result, x);
+
+        CiRegister dst = asRegister(result);
+        if (isRegister(y)) {
+            CiRegister rreg = asRegister(y);
             switch (this) {
                 case IADD: masm.addl(dst,  rreg); break;
                 case ISUB: masm.subl(dst,  rreg); break;
@@ -95,30 +96,30 @@
                 case DDIV: masm.divsd(dst, rreg); break;
                 default:   throw Util.shouldNotReachHere();
             }
-        } else if (isConstant(right)) {
+        } else if (isConstant(y)) {
             switch (this) {
-                case IADD: masm.incrementl(dst, tasm.asIntConst(right)); break;
-                case ISUB: masm.decrementl(dst, tasm.asIntConst(right)); break;
-                case IAND: masm.andl(dst,  tasm.asIntConst(right)); break;
-                case IOR:  masm.orl(dst,   tasm.asIntConst(right)); break;
-                case IXOR: masm.xorl(dst,  tasm.asIntConst(right)); break;
-                case LADD: masm.addq(dst,  tasm.asIntConst(right)); break;
-                case LSUB: masm.subq(dst,  tasm.asIntConst(right)); break;
-                case LAND: masm.andq(dst,  tasm.asIntConst(right)); break;
-                case LOR:  masm.orq(dst,   tasm.asIntConst(right)); break;
-                case LXOR: masm.xorq(dst,  tasm.asIntConst(right)); break;
-                case FADD: masm.addss(dst, tasm.asFloatConstRef(right)); break;
-                case FSUB: masm.subss(dst, tasm.asFloatConstRef(right)); break;
-                case FMUL: masm.mulss(dst, tasm.asFloatConstRef(right)); break;
-                case FDIV: masm.divss(dst, tasm.asFloatConstRef(right)); break;
-                case DADD: masm.addsd(dst, tasm.asDoubleConstRef(right)); break;
-                case DSUB: masm.subsd(dst, tasm.asDoubleConstRef(right)); break;
-                case DMUL: masm.mulsd(dst, tasm.asDoubleConstRef(right)); break;
-                case DDIV: masm.divsd(dst, tasm.asDoubleConstRef(right)); break;
+                case IADD: masm.incrementl(dst, tasm.asIntConst(y)); break;
+                case ISUB: masm.decrementl(dst, tasm.asIntConst(y)); break;
+                case IAND: masm.andl(dst,  tasm.asIntConst(y)); break;
+                case IOR:  masm.orl(dst,   tasm.asIntConst(y)); break;
+                case IXOR: masm.xorl(dst,  tasm.asIntConst(y)); break;
+                case LADD: masm.addq(dst,  tasm.asIntConst(y)); break;
+                case LSUB: masm.subq(dst,  tasm.asIntConst(y)); break;
+                case LAND: masm.andq(dst,  tasm.asIntConst(y)); break;
+                case LOR:  masm.orq(dst,   tasm.asIntConst(y)); break;
+                case LXOR: masm.xorq(dst,  tasm.asIntConst(y)); break;
+                case FADD: masm.addss(dst, tasm.asFloatConstRef(y)); break;
+                case FSUB: masm.subss(dst, tasm.asFloatConstRef(y)); break;
+                case FMUL: masm.mulss(dst, tasm.asFloatConstRef(y)); break;
+                case FDIV: masm.divss(dst, tasm.asFloatConstRef(y)); break;
+                case DADD: masm.addsd(dst, tasm.asDoubleConstRef(y)); break;
+                case DSUB: masm.subsd(dst, tasm.asDoubleConstRef(y)); break;
+                case DMUL: masm.mulsd(dst, tasm.asDoubleConstRef(y)); break;
+                case DDIV: masm.divsd(dst, tasm.asDoubleConstRef(y)); break;
                 default:   throw Util.shouldNotReachHere();
             }
         } else {
-            CiAddress raddr = tasm.asAddress(right);
+            CiAddress raddr = tasm.asAddress(y);
             switch (this) {
                 case IADD: masm.addl(dst,  raddr); break;
                 case ISUB: masm.subl(dst,  raddr); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -35,14 +35,14 @@
 public enum AMD64CompareOpcode implements LIROpcode {
     ICMP, LCMP, ACMP, FCMP, DCMP;
 
-    public LIRInstruction create(Variable left, CiValue right) {
-        assert (name().startsWith("I") && left.kind == CiKind.Int && right.kind.stackKind() == CiKind.Int)
-            || (name().startsWith("I") && left.kind == CiKind.Jsr && right.kind == CiKind.Jsr)
-            || (name().startsWith("L") && left.kind == CiKind.Long && right.kind == CiKind.Long)
-            || (name().startsWith("A") && left.kind == CiKind.Object && right.kind == CiKind.Object)
-            || (name().startsWith("F") && left.kind == CiKind.Float && right.kind == CiKind.Float)
-            || (name().startsWith("D") && left.kind == CiKind.Double && right.kind == CiKind.Double) : "left.kind=" + left.kind + ", right.kind=" + right.kind;
-        CiValue[] inputs = new CiValue[] {left, right};
+    public LIRInstruction create(CiValue x, CiValue y) {
+        assert (name().startsWith("I") && x.kind == CiKind.Int && y.kind.stackKind() == CiKind.Int)
+            || (name().startsWith("I") && x.kind == CiKind.Jsr && y.kind == CiKind.Jsr)
+            || (name().startsWith("L") && x.kind == CiKind.Long && y.kind == CiKind.Long)
+            || (name().startsWith("A") && x.kind == CiKind.Object && y.kind == CiKind.Object)
+            || (name().startsWith("F") && x.kind == CiKind.Float && y.kind == CiKind.Float)
+            || (name().startsWith("D") && x.kind == CiKind.Double && y.kind == CiKind.Double);
+        CiValue[] inputs = new CiValue[] {x, y};
 
         return new AMD64LIRInstruction(this, LIRInstruction.NO_OPERANDS, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
             @Override
@@ -60,10 +60,10 @@
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue left, CiValue right) {
-        CiRegister lreg = asRegister(left);
-        if (isRegister(right)) {
-            CiRegister rreg = asRegister(right);
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue x, CiValue y) {
+        CiRegister lreg = asRegister(x);
+        if (isRegister(y)) {
+            CiRegister rreg = asRegister(y);
             switch (this) {
                 case ICMP: masm.cmpl(lreg, rreg); break;
                 case LCMP: masm.cmpq(lreg, rreg); break;
@@ -72,22 +72,22 @@
                 case DCMP: masm.ucomisd(lreg, rreg); break;
                 default:   throw Util.shouldNotReachHere();
             }
-        } else if (isConstant(right)) {
+        } else if (isConstant(y)) {
             switch (this) {
-                case ICMP: masm.cmpl(lreg, tasm.asIntConst(right)); break;
-                case LCMP: masm.cmpq(lreg, tasm.asIntConst(right)); break;
+                case ICMP: masm.cmpl(lreg, tasm.asIntConst(y)); break;
+                case LCMP: masm.cmpq(lreg, tasm.asIntConst(y)); break;
                 case ACMP:
-                    if (((CiConstant) right).isNull()) {
+                    if (((CiConstant) y).isNull()) {
                         masm.cmpq(lreg, 0); break;
                     } else {
                         throw Util.shouldNotReachHere("Only null object constants are allowed in comparisons");
                     }
-                case FCMP: masm.ucomiss(lreg, tasm.asFloatConstRef(right)); break;
-                case DCMP: masm.ucomisd(lreg, tasm.asDoubleConstRef(right)); break;
+                case FCMP: masm.ucomiss(lreg, tasm.asFloatConstRef(y)); break;
+                case DCMP: masm.ucomisd(lreg, tasm.asDoubleConstRef(y)); break;
                 default:   throw Util.shouldNotReachHere();
             }
         } else {
-            CiAddress raddr = tasm.asAddress(right);
+            CiAddress raddr = tasm.asAddress(y);
             switch (this) {
                 case ICMP: masm.cmpl(lreg, raddr); break;
                 case LCMP: masm.cmpq(lreg, raddr); break;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -40,7 +40,7 @@
 public enum AMD64CompareToIntOpcode implements LIROpcode {
     CMP2INT, CMP2INT_UG, CMP2INT_UL;
 
-    public LIRInstruction create(Variable result) {
+    public LIRInstruction create(CiValue result) {
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, null, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -34,8 +34,8 @@
 public enum AMD64ConvertFIOpcode implements LIROpcode {
     F2I, D2I;
 
-    public LIRInstruction create(Variable result, Variable input) {
-        CiValue[] inputs = new CiValue[] {input};
+    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) {
@@ -46,16 +46,16 @@
         };
     }
 
-    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) {
+    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x) {
         AMD64ConvertFSlowPath slowPath;
         switch (this) {
             case F2I:
-                masm.cvttss2sil(asIntReg(result), asFloatReg(input));
-                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asFloatReg(input), false, false);
+                masm.cvttss2sil(asIntReg(result), asFloatReg(x));
+                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asFloatReg(x), false, false);
                 break;
             case D2I:
-                masm.cvttsd2sil(asIntReg(result), asDoubleReg(input));
-                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asDoubleReg(input), true, false);
+                masm.cvttsd2sil(asIntReg(result), asDoubleReg(x));
+                slowPath = new AMD64ConvertFSlowPath(masm, asIntReg(result), asDoubleReg(x), true, false);
                 break;
             default:
                 throw Util.shouldNotReachHere();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -34,8 +34,8 @@
 public enum AMD64ConvertFLOpcode implements LIROpcode {
     F2L, D2L;
 
-    public LIRInstruction create(Variable result, Variable input, Variable scratch) {
-        CiValue[] inputs = new CiValue[] {input};
+    public LIRInstruction create(CiValue result, CiValue x, CiValue scratch) {
+        CiValue[] inputs = new CiValue[] {x};
         CiValue[] temps = new CiValue[] {scratch};
         CiValue[] outputs = new CiValue[] {result};
 
@@ -47,16 +47,16 @@
         };
     }
 
-    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input, CiValue scratch) {
+    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue scratch) {
         AMD64ConvertFSlowPath slowPath;
         switch (this) {
             case F2L:
-                masm.cvttss2siq(asLongReg(result), asFloatReg(input));
-                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asFloatReg(input), false, true);
+                masm.cvttss2siq(asLongReg(result), asFloatReg(x));
+                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asFloatReg(x), false, true);
                 break;
             case D2L:
-                masm.cvttsd2siq(asLongReg(result), asDoubleReg(input));
-                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asDoubleReg(input), true, true);
+                masm.cvttsd2siq(asLongReg(result), asDoubleReg(x));
+                slowPath = new AMD64ConvertFSlowPath(masm, asLongReg(result), asDoubleReg(x), true, true);
                 break;
             default:
                 throw Util.shouldNotReachHere();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -39,8 +39,8 @@
     L2F, L2D,
     MOV_I2F, MOV_L2D, MOV_F2I, MOV_D2L;
 
-    public LIRInstruction create(Variable result, Variable input) {
-        CiValue[] inputs = new CiValue[] {input};
+    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) {
@@ -59,35 +59,35 @@
         };
     }
 
-    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue input) {
+    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x) {
         switch (this) {
             case L2I:
-                AMD64MoveOpcode.move(tasm, masm, result, input);
+                AMD64MoveOpcode.move(tasm, masm, result, x);
                 masm.andl(asIntReg(result), 0xFFFFFFFF);
                 break;
             case I2B:
-                AMD64MoveOpcode.move(tasm, masm, result, input);
+                AMD64MoveOpcode.move(tasm, masm, result, x);
                 masm.signExtendByte(asIntReg(result));
                 break;
             case I2C:
-                AMD64MoveOpcode.move(tasm, masm, result, input);
+                AMD64MoveOpcode.move(tasm, masm, result, x);
                 masm.andl(asIntReg(result), 0xFFFF);
                 break;
             case I2S:
-                AMD64MoveOpcode.move(tasm, masm, result, input);
+                AMD64MoveOpcode.move(tasm, masm, result, x);
                 masm.signExtendShort(asIntReg(result));
                 break;
-            case I2L: masm.movslq(asLongReg(result), asIntReg(input)); break;
-            case F2D: masm.cvtss2sd(asDoubleReg(result), asFloatReg(input)); break;
-            case D2F: masm.cvtsd2ss(asFloatReg(result), asDoubleReg(input)); break;
-            case I2F: masm.cvtsi2ssl(asFloatReg(result), asIntReg(input)); break;
-            case I2D: masm.cvtsi2sdl(asDoubleReg(result), asIntReg(input)); break;
-            case L2F: masm.cvtsi2ssq(asFloatReg(result), asLongReg(input)); break;
-            case L2D: masm.cvtsi2sdq(asDoubleReg(result), asLongReg(input)); break;
-            case MOV_I2F: masm.movdl(asFloatReg(result), asIntReg(input)); break;
-            case MOV_L2D: masm.movdq(asDoubleReg(result), asLongReg(input)); break;
-            case MOV_F2I: masm.movdl(asIntReg(result), asFloatReg(input)); break;
-            case MOV_D2L: masm.movdq(asLongReg(result), asDoubleReg(input)); break;
+            case I2L: masm.movslq(asLongReg(result), asIntReg(x)); break;
+            case F2D: masm.cvtss2sd(asDoubleReg(result), asFloatReg(x)); break;
+            case D2F: masm.cvtsd2ss(asFloatReg(result), asDoubleReg(x)); break;
+            case I2F: masm.cvtsi2ssl(asFloatReg(result), asIntReg(x)); break;
+            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 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;
+            case MOV_D2L: masm.movdq(asLongReg(result), asDoubleReg(x)); break;
             default: throw Util.shouldNotReachHere();
         }
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -33,28 +33,28 @@
 import com.oracle.max.graal.compiler.util.*;
 
 public enum AMD64DivOpcode implements LIROpcode {
-    IDIV, IREM, UIDIV, UIREM,
-    LDIV, LREM, ULDIV, ULREM;
+    IDIV, IREM, IUDIV, IUREM,
+    LDIV, LREM, LUDIV, LUREM;
 
-    public LIRInstruction create(CiRegisterValue result, LIRDebugInfo info, CiRegisterValue left, Variable right) {
-        CiValue[] inputs = new CiValue[] {left};
-        CiValue[] alives = new CiValue[] {right};
-        CiValue[] temps = new CiValue[] {result.reg == AMD64.rax ? AMD64.rdx.asValue(result.kind) : AMD64.rax.asValue(result.kind)};
+    public LIRInstruction create(CiValue result, LIRDebugInfo info, CiValue x, CiValue y) {
+        CiValue[] inputs = new CiValue[] {x};
+        CiValue[] alives = new CiValue[] {y};
+        CiValue[] temps = new CiValue[] {asRegister(result) == AMD64.rax ? AMD64.rdx.asValue(result.kind) : AMD64.rax.asValue(result.kind)};
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, info, inputs, alives, temps) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                emit(tasm, masm, asRegister(output(0)), info, asRegister(input(0)), asRegister(alive(0)));
+                emit(tasm, masm, output(0), info, input(0), alive(0));
             }
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiRegister result, LIRDebugInfo info, CiRegister left, CiRegister right) {
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, LIRDebugInfo info, CiValue x, CiValue y) {
         // left input in rax, right input in any register but rax and rdx, result quotient in rax, result remainder in rdx
-        assert left == AMD64.rax;
-        assert right != AMD64.rax && right != AMD64.rdx;
-        assert (name().endsWith("DIV") && result == AMD64.rax) || (name().endsWith("REM") && result == AMD64.rdx);
+        assert asRegister(x) == AMD64.rax;
+        assert differentRegisters(y, AMD64.rax.asValue(), AMD64.rdx.asValue());
+        assert (name().endsWith("DIV") && asRegister(result) == AMD64.rax) || (name().endsWith("REM") && asRegister(result) == AMD64.rdx);
 
         int exceptionOffset;
         switch (this) {
@@ -62,7 +62,7 @@
             case IREM:
                 masm.cdql();
                 exceptionOffset = masm.codeBuffer.position();
-                masm.idivl(right);
+                masm.idivl(asRegister(y));
                 break;
 
             case LDIV:
@@ -74,31 +74,31 @@
                     masm.movq(AMD64.rdx, java.lang.Long.MIN_VALUE);
                     masm.cmpq(AMD64.rax, AMD64.rdx);
                     masm.jcc(ConditionFlag.notEqual, normalCase);
-                    masm.cmpl(right, -1);
+                    masm.cmpl(asRegister(y), -1);
                     masm.jcc(ConditionFlag.equal, continuation);
                     masm.bind(normalCase);
                 }
 
                 masm.cdqq();
                 exceptionOffset = masm.codeBuffer.position();
-                masm.idivq(right);
+                masm.idivq(asRegister(y));
                 masm.bind(continuation);
                 break;
 
-            case UIDIV:
-            case UIREM:
+            case IUDIV:
+            case IUREM:
                 // Must zero the high 64-bit word (in RDX) of the dividend
                 masm.xorq(AMD64.rdx, AMD64.rdx);
                 exceptionOffset = masm.codeBuffer.position();
-                masm.divl(right);
+                masm.divl(asRegister(y));
                 break;
 
-            case ULDIV:
-            case ULREM:
+            case LUDIV:
+            case LUREM:
                 // Must zero the high 64-bit word (in RDX) of the dividend
                 masm.xorq(AMD64.rdx, AMD64.rdx);
                 exceptionOffset = masm.codeBuffer.position();
-                masm.divq(right);
+                masm.divq(asRegister(y));
                 break;
 
             default:
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Wed Jan 11 16:31:46 2012 +0100
@@ -306,11 +306,11 @@
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, load(a)));
-                append(UIDIV.create(RAX_I, state(), RAX_I, load(b)));
+                append(IUDIV.create(RAX_I, state(), RAX_I, load(b)));
                 return emitMove(RAX_I);
             case Long:
                 append(MOVE.create(RAX_L, load(a)));
-                append(ULDIV.create(RAX_L, state(), RAX_L, load(b)));
+                append(LUDIV.create(RAX_L, state(), RAX_L, load(b)));
                 return emitMove(RAX_L);
             default:
                 throw Util.shouldNotReachHere();
@@ -322,11 +322,11 @@
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, load(a)));
-                append(UIREM.create(RDX_I, state(), RAX_I, load(b)));
+                append(IUREM.create(RDX_I, state(), RAX_I, load(b)));
                 return emitMove(RDX_I);
             case Long:
                 append(MOVE.create(RAX_L, load(a)));
-                append(ULREM.create(RDX_L, state(), RAX_L, load(b)));
+                append(LUREM.create(RDX_L, state(), RAX_L, load(b)));
                 return emitMove(RDX_L);
             default:
                 throw Util.shouldNotReachHere();
@@ -394,8 +394,8 @@
     public Variable emitUShr(CiValue a, CiValue b) {
         Variable result = newVariable(a.kind);
         switch (a.kind) {
-            case Int:    append(UISHR.create(result, a, loadShiftCount(b))); break;
-            case Long:   append(ULSHR.create(result, a, loadShiftCount(b))); break;
+            case Int:    append(IUSHR.create(result, a, loadShiftCount(b))); break;
+            case Long:   append(LUSHR.create(result, a, loadShiftCount(b))); break;
             default: Util.shouldNotReachHere();
         }
         return result;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -36,20 +36,18 @@
     FAND, FOR, FXOR,
     DAND, DOR, DXOR;
 
-    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
-        assert (name().startsWith("F") && result.kind == CiKind.Float && left.kind == CiKind.Float && right.kind == CiKind.Float)
-            || (name().startsWith("D") && result.kind == CiKind.Double && left.kind == CiKind.Double && right.kind == CiKind.Double);
+    public LIRInstruction create(CiValue result, CiValue x, CiValue y) {
+        assert (name().startsWith("F") && result.kind == CiKind.Float && x.kind == CiKind.Float && y.kind == CiKind.Float)
+            || (name().startsWith("D") && result.kind == CiKind.Double && x.kind == CiKind.Double && y.kind == CiKind.Double);
 
-        CiValue[] inputs = new CiValue[] {left};
-        CiValue[] alives = new CiValue[] {right};
+        CiValue[] inputs = new CiValue[] {x};
+        CiValue[] alives = new CiValue[] {y};
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, null, inputs, alives, LIRInstruction.NO_OPERANDS) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                assert !(alive(0) instanceof CiRegisterValue) || asRegister(output(0)) != asRegister(alive(0)) : "result and right must be different registers";
-                AMD64MoveOpcode.move(tasm, masm, output(0), input(0));
-                emit(tasm, masm, output(0), alive(0));
+                emit(tasm, masm, output(0), input(0), alive(0));
             }
 
             @Override
@@ -66,10 +64,13 @@
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) {
-        CiRegister dst = asRegister(leftAndResult);
-        if (isRegister(right)) {
-            CiRegister rreg = asRegister(right);
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue y) {
+        assert sameRegister(x, y) || differentRegisters(result, y);
+        AMD64MoveOpcode.move(tasm, masm, result, x);
+
+        CiRegister dst = asRegister(result);
+        if (isRegister(y)) {
+            CiRegister rreg = asRegister(y);
             switch (this) {
                 case FAND: masm.andps(dst, rreg); break;
                 case FOR:  masm.orps(dst,  rreg); break;
@@ -79,18 +80,16 @@
                 case DXOR: masm.xorpd(dst, rreg); break;
                 default:   throw Util.shouldNotReachHere();
             }
-        } else if (isConstant(right)) {
+        } else {
             switch (this) {
-                case FAND: masm.andps(dst, tasm.asFloatConstRef(right, 16)); break;
-                case FOR:  masm.orps(dst,  tasm.asFloatConstRef(right, 16)); break;
-                case FXOR: masm.xorps(dst, tasm.asFloatConstRef(right, 16)); break;
-                case DAND: masm.andpd(dst, tasm.asDoubleConstRef(right, 16)); break;
-                case DOR:  masm.orpd(dst,  tasm.asDoubleConstRef(right, 16)); break;
-                case DXOR: masm.xorpd(dst, tasm.asDoubleConstRef(right, 16)); break;
+                case FAND: masm.andps(dst, tasm.asFloatConstRef(y, 16)); break;
+                case FOR:  masm.orps(dst,  tasm.asFloatConstRef(y, 16)); break;
+                case FXOR: masm.xorps(dst, tasm.asFloatConstRef(y, 16)); break;
+                case DAND: masm.andpd(dst, tasm.asDoubleConstRef(y, 16)); break;
+                case DOR:  masm.orpd(dst,  tasm.asDoubleConstRef(y, 16)); break;
+                case DXOR: masm.xorpd(dst, tasm.asDoubleConstRef(y, 16)); break;
                 default:   throw Util.shouldNotReachHere();
             }
-        } else {
-            throw Util.shouldNotReachHere();
         }
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -35,17 +35,15 @@
 public enum AMD64MulOpcode implements LIROpcode {
     IMUL, LMUL;
 
-    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
-        CiValue[] inputs = new CiValue[] {left};
-        CiValue[] alives = new CiValue[] {right};
+    public LIRInstruction create(CiValue result, CiValue x, CiValue y) {
+        CiValue[] inputs = new CiValue[] {x};
+        CiValue[] alives = new CiValue[] {y};
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, null, inputs, alives, LIRInstruction.NO_OPERANDS) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                assert !(alive(0) instanceof CiRegisterValue) || asRegister(output(0)) != asRegister(alive(0)) : "result and right must be different registers";
-                AMD64MoveOpcode.move(tasm, masm, output(0), input(0));
-                emit(tasm, masm, output(0), alive(0));
+                emit(tasm, masm, output(0), input(0), alive(0));
             }
 
             @Override
@@ -62,22 +60,23 @@
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) {
-        CiRegister dst = asRegister(leftAndResult);
-        if (isRegister(right)) {
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue y) {
+        assert sameRegister(x, y) || differentRegisters(result, y);
+        AMD64MoveOpcode.move(tasm, masm, result, x);
+
+        CiRegister dst = asRegister(result);
+        if (isRegister(y)) {
             switch (this) {
-                case IMUL: masm.imull(dst, asRegister(right)); break;
-                case LMUL: masm.imulq(dst, asRegister(right)); break;
-                default:   throw Util.shouldNotReachHere();
-            }
-        } else if (isConstant(right)) {
-            switch (this) {
-                case IMUL: masm.imull(dst, dst, tasm.asIntConst(right)); break;
-                case LMUL: masm.imulq(dst, dst, tasm.asIntConst(right)); break;
+                case IMUL: masm.imull(dst, asRegister(y)); break;
+                case LMUL: masm.imulq(dst, asRegister(y)); break;
                 default:   throw Util.shouldNotReachHere();
             }
         } else {
-            throw Util.shouldNotReachHere();
+            switch (this) {
+                case IMUL: masm.imull(dst, dst, tasm.asIntConst(y)); break;
+                case LMUL: masm.imulq(dst, dst, tasm.asIntConst(y)); break;
+                default:   throw Util.shouldNotReachHere();
+            }
         }
     }
 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -35,15 +35,14 @@
 public enum AMD64Op1Opcode implements LIROpcode {
     INEG, LNEG;
 
-    public LIRInstruction create(Variable result, CiValue input) {
-        CiValue[] inputs = new CiValue[] {input};
+    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) {
-                AMD64MoveOpcode.move(tasm, masm, output(0), input(0));
-                emit(masm, output(0));
+                emit(tasm, masm, output(0), input(0));
             }
 
             @Override
@@ -58,10 +57,11 @@
         };
     }
 
-    private void emit(AMD64MacroAssembler masm, CiValue inputAndResult) {
+    private void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x) {
+        AMD64MoveOpcode.move(tasm, masm, result, x);
         switch (this) {
-            case INEG: masm.negl(asIntReg(inputAndResult)); break;
-            case LNEG: masm.negq(asLongReg(inputAndResult)); break;
+            case INEG: masm.negl(asIntReg(result)); break;
+            case LNEG: masm.negq(asLongReg(result)); break;
             default:   throw Util.shouldNotReachHere();
         }
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -33,20 +33,18 @@
 import com.oracle.max.graal.compiler.util.*;
 
 public enum AMD64ShiftOpcode implements LIROpcode {
-    ISHL, ISHR, UISHR,
-    LSHL, LSHR, ULSHR;
+    ISHL, ISHR, IUSHR,
+    LSHL, LSHR, LUSHR;
 
-    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
-        CiValue[] inputs = new CiValue[] {left};
-        CiValue[] alives = new CiValue[] {right};
+    public LIRInstruction create(CiValue result, CiValue x, CiValue y) {
+        CiValue[] inputs = new CiValue[] {x};
+        CiValue[] alives = new CiValue[] {y};
         CiValue[] outputs = new CiValue[] {result};
 
         return new AMD64LIRInstruction(this, outputs, null, inputs, alives, LIRInstruction.NO_OPERANDS) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                assert !(alive(0) instanceof CiRegisterValue) || asRegister(output(0)) != asRegister(alive(0)) : "result and right must be different registers";
-                AMD64MoveOpcode.move(tasm, masm, output(0), input(0));
-                emit(tasm, masm, output(0), alive(0));
+                emit(tasm, masm, output(0), input(0), alive(0));
             }
 
             @Override
@@ -63,27 +61,30 @@
         };
     }
 
-    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue leftAndResult, CiValue right) {
-        CiRegister dst = asRegister(leftAndResult);
-        if (isRegister(right)) {
-            assert asRegister(right) == AMD64.rcx;
+    protected void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, CiValue result, CiValue x, CiValue y) {
+        assert sameRegister(x, y) || differentRegisters(result, y);
+        AMD64MoveOpcode.move(tasm, masm, result, x);
+
+        CiRegister dst = asRegister(result);
+        if (isRegister(y)) {
+            assert asRegister(y) == AMD64.rcx;
             switch (this) {
                 case ISHL:  masm.shll(dst); break;
                 case ISHR:  masm.sarl(dst); break;
-                case UISHR: masm.shrl(dst); break;
+                case IUSHR: masm.shrl(dst); break;
                 case LSHL:  masm.shlq(dst); break;
                 case LSHR:  masm.sarq(dst); break;
-                case ULSHR: masm.shrq(dst); break;
+                case LUSHR: masm.shrq(dst); break;
                 default:    throw Util.shouldNotReachHere();
             }
-        } else if (isConstant(right)) {
+        } else if (isConstant(y)) {
             switch (this) {
-                case ISHL:  masm.shll(dst, tasm.asIntConst(right) & 31); break;
-                case ISHR:  masm.sarl(dst, tasm.asIntConst(right) & 31); break;
-                case UISHR: masm.shrl(dst, tasm.asIntConst(right) & 31); break;
-                case LSHL:  masm.shlq(dst, tasm.asIntConst(right) & 63); break;
-                case LSHR:  masm.sarq(dst, tasm.asIntConst(right) & 63); break;
-                case ULSHR: masm.shrq(dst, tasm.asIntConst(right) & 63); break;
+                case ISHL:  masm.shll(dst, tasm.asIntConst(y) & 31); break;
+                case ISHR:  masm.sarl(dst, tasm.asIntConst(y) & 31); break;
+                case IUSHR: masm.shrl(dst, tasm.asIntConst(y) & 31); break;
+                case LSHL:  masm.shlq(dst, tasm.asIntConst(y) & 63); break;
+                case LSHR:  masm.sarq(dst, tasm.asIntConst(y) & 63); break;
+                case LUSHR: masm.shrq(dst, tasm.asIntConst(y) & 63); break;
                 default:   throw Util.shouldNotReachHere();
             }
         } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64XirOpcode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -154,7 +154,7 @@
                     break;
 
                 case Shr:
-                    emitXirViaLir(tasm, masm, AMD64ShiftOpcode.UISHR, AMD64ShiftOpcode.ULSHR, null, null, operands[inst.x().index], operands[inst.y().index], operands[inst.result.index]);
+                    emitXirViaLir(tasm, masm, AMD64ShiftOpcode.IUSHR, AMD64ShiftOpcode.LUSHR, null, null, operands[inst.x().index], operands[inst.y().index], operands[inst.result.index]);
                     break;
 
                 case And:
@@ -518,13 +518,13 @@
         }
 
         if (code instanceof AMD64ArithmeticOpcode) {
-            ((AMD64ArithmeticOpcode) code).emit(tasm, masm, left, right);
+            ((AMD64ArithmeticOpcode) code).emit(tasm, masm, result, left, right);
         } else if (code instanceof AMD64MulOpcode) {
-            ((AMD64MulOpcode) code).emit(tasm, masm, left, right);
+            ((AMD64MulOpcode) code).emit(tasm, masm, result, left, right);
         } else if (code instanceof AMD64DivOpcode) {
-            ((AMD64DivOpcode) code).emit(tasm, masm, asRegister(result), null, asRegister(left), asRegister(right));
+            ((AMD64DivOpcode) code).emit(tasm, masm, result, null, left, right);
         } else if (code instanceof AMD64ShiftOpcode) {
-            ((AMD64ShiftOpcode) code).emit(tasm, masm, left, right);
+            ((AMD64ShiftOpcode) code).emit(tasm, masm, result, left, right);
         }
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/util/InliningUtil.java	Wed Jan 11 16:31:46 2012 +0100
@@ -244,11 +244,11 @@
         RiResolvedType holder = callTarget.targetMethod().holder();
 
         if (callTarget.receiver().declaredType() != null) {
-            RiType declared = callTarget.receiver().declaredType();
+            RiResolvedType declared = callTarget.receiver().declaredType();
             // the invoke target might be more specific than the holder (happens after inlining: locals lose their declared type...)
             // TODO (ls) fix this
-            if (declared instanceof RiResolvedType && ((RiResolvedType) declared).isSubtypeOf(holder)) {
-                holder = (RiResolvedType) declared;
+            if (declared != null && declared.isSubtypeOf(holder)) {
+                holder = declared;
             }
         }
         // TODO (tw) fix this
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/FrameStateBuilder.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/FrameStateBuilder.java	Wed Jan 11 16:31:46 2012 +0100
@@ -349,7 +349,7 @@
      * @param x the instruction which produces the value for the local
      */
     public void storeLocal(int i, ValueNode x) {
-        assert x == null || (x.kind() != CiKind.Void && x.kind() != CiKind.Illegal) : "unexpected value: " + x;
+        assert x.kind() != CiKind.Void && x.kind() != CiKind.Illegal : "unexpected value: " + x;
         locals[i] = x;
         if (isTwoSlot(x.kind())) {
             // (tw) if this was a double word then kill i+1
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Wed Jan 11 16:31:46 2012 +0100
@@ -124,7 +124,6 @@
         returnBlock = null;
         methodSynchronizedObject = null;
         exceptionHandlers = null;
-        assert graph != null;
         this.currentGraph = graph;
         this.frameState = new FrameStateBuilder(method, method.maxLocals(), method.maxStackSize(), graph);
         build();
@@ -1056,9 +1055,9 @@
                     exact = runtime.getTypeOf(receiver.asConstant());
                 }
                 if (exact == null) {
-                    RiType declared = receiver.declaredType();
-                    if (declared instanceof RiResolvedType) {
-                        exact = ((RiResolvedType) declared).exactType();
+                    RiResolvedType declared = receiver.declaredType();
+                    if (declared != null) {
+                        exact = declared.exactType();
                     }
                 }
             }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -49,7 +49,6 @@
      */
     public InvokeNode(MethodCallTargetNode callTarget, int bci) {
         super(callTarget.returnStamp());
-        assert callTarget != null;
         this.callTarget = callTarget;
         this.bci = bci;
     }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeWithExceptionNode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeWithExceptionNode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -47,7 +47,6 @@
      */
     public InvokeWithExceptionNode(MethodCallTargetNode callTarget, BeginNode exceptionEdge, int bci) {
         super(callTarget.returnStamp(), new BeginNode[]{null, exceptionEdge}, new double[]{1.0, 0.0});
-        assert callTarget != null;
         this.bci = bci;
         this.callTarget = callTarget;
     }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/RegisterFinalizerNode.java	Wed Jan 11 16:31:46 2012 +0100
@@ -52,10 +52,10 @@
 
     @Override
     public Node canonical(CanonicalizerTool tool) {
-        RiType declaredType = object.declaredType();
+        RiResolvedType declaredType = object.declaredType();
         RiResolvedType exactType = object.exactType();
-        if (exactType == null && declaredType instanceof RiResolvedType) {
-            exactType = ((RiResolvedType) declaredType).exactType();
+        if (exactType == null && declaredType != null) {
+            exactType = declaredType.exactType();
         }
 
         boolean needsCheck = true;
@@ -64,8 +64,8 @@
             needsCheck = exactType.hasFinalizer();
         } else {
             // if either the declared type of receiver or the holder can be assumed to have no finalizers
-            if (declaredType instanceof RiResolvedType && !((RiResolvedType) declaredType).hasFinalizableSubclass()) {
-                if (tool.assumptions() != null && tool.assumptions().recordNoFinalizableSubclassAssumption((RiResolvedType) declaredType)) {
+            if (declaredType != null && !declaredType.hasFinalizableSubclass()) {
+                if (tool.assumptions() != null && tool.assumptions().recordNoFinalizableSubclassAssumption(declaredType)) {
                     needsCheck = false;
                 }
             }
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/ArrayCopySnippets.java	Wed Jan 11 16:17:51 2012 +0100
+++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/ArrayCopySnippets.java	Wed Jan 11 16:31:46 2012 +0100
@@ -79,22 +79,22 @@
         if (src == dest && srcPos < destPos) { // bad aliased case
             if ((length & 0x01) == 0) {
                 if ((length & 0x02) == 0) {
-                    copyLongsDown(src, srcPos * 2, dest, destPos * 2, length >> 2);
+                    copyLongsDown(src, srcPos * 2L, dest, destPos * 2L, length >> 2);
                 } else {
-                    copyIntsDown(src, srcPos * 2, dest, destPos * 2, length >> 1);
+                    copyIntsDown(src, srcPos * 2L, dest, destPos * 2L, length >> 1);
                 }
             } else {
-                copyShortsDown(src, srcPos * 2, dest, destPos * 2, length);
+                copyShortsDown(src, srcPos * 2L, dest, destPos * 2L, length);
             }
         } else {
             if ((length & 0x01) == 0) {
                 if ((length & 0x02) == 0) {
-                    copyLongsUp(src, srcPos * 2, dest, destPos * 2, length >> 2);
+                    copyLongsUp(src, srcPos * 2L, dest, destPos * 2L, length >> 2);
                 } else {
-                    copyIntsUp(src, srcPos * 2, dest, destPos * 2, length >> 1);
+                    copyIntsUp(src, srcPos * 2L, dest, destPos * 2L, length >> 1);
                 }
             } else {
-                copyShortsUp(src, srcPos * 2, dest, destPos * 2, length);
+                copyShortsUp(src, srcPos * 2L, dest, destPos * 2L, length);
             }
         }
     }
@@ -110,22 +110,22 @@
         if (src == dest && srcPos < destPos) { // bad aliased case
             if ((length & 0x01) == 0) {
                 if ((length & 0x02) == 0) {
-                    copyLongsDown(src, srcPos * 2, dest, destPos * 2, length >> 2);
+                    copyLongsDown(src, srcPos * 2L, dest, destPos * 2L, length >> 2);
                 } else {
-                    copyIntsDown(src, srcPos * 2, dest, destPos * 2, length >> 1);
+                    copyIntsDown(src, srcPos * 2L, dest, destPos * 2L, length >> 1);
                 }
             } else {
-                copyShortsDown(src, srcPos * 2, dest, destPos * 2, length);
+                copyShortsDown(src, srcPos * 2L, dest, destPos * 2L, length);
             }
         } else {
             if ((length & 0x01) == 0) {
                 if ((length & 0x02) == 0) {
-                    copyLongsUp(src, srcPos * 2, dest, destPos * 2, length >> 2);
+                    copyLongsUp(src, srcPos * 2L, dest, destPos * 2L, length >> 2);
                 } else {
-                    copyIntsUp(src, srcPos * 2, dest, destPos * 2, length >> 1);
+                    copyIntsUp(src, srcPos * 2L, dest, destPos * 2L, length >> 1);
                 }
             } else {
-                copyShortsUp(src, srcPos * 2, dest, destPos * 2, length);
+                copyShortsUp(src, srcPos * 2L, dest, destPos * 2L, length);
             }
         }
     }
@@ -140,15 +140,15 @@
         }
         if (src == dest && srcPos < destPos) { // bad aliased case
             if ((length & 0x01) == 0) {
-                copyLongsDown(src, srcPos * 4, dest, destPos * 4, length >> 1);
+                copyLongsDown(src, srcPos * 4L, dest, destPos * 4L, length >> 1);
             } else {
-                copyIntsDown(src, srcPos * 4, dest, destPos * 4, length);
+                copyIntsDown(src, srcPos * 4L, dest, destPos * 4L, length);
             }
         } else {
             if ((length & 0x01) == 0) {
-                copyLongsUp(src, srcPos * 4, dest, destPos * 4, length >> 1);
+                copyLongsUp(src, srcPos * 4L, dest, destPos * 4L, length >> 1);
             } else {
-                copyIntsUp(src, srcPos * 4, dest, destPos * 4, length);
+                copyIntsUp(src, srcPos * 4L, dest, destPos * 4L, length);
             }
         }
     }
@@ -162,9 +162,9 @@
             throw new IndexOutOfBoundsException();
         }
         if (src == dest && srcPos < destPos) { // bad aliased case
-            copyLongsDown(src, srcPos * 8, dest, destPos * 8, length);
+            copyLongsDown(src, srcPos * 8L, dest, destPos * 8L, length);
         } else {
-            copyLongsUp(src, srcPos * 8, dest, destPos * 8, length);
+            copyLongsUp(src, srcPos * 8L, dest, destPos * 8L, length);
         }
     }
 
@@ -232,7 +232,7 @@
     @Snippet
     public static void copyShortsUp(Object src, long srcOffset, Object dest, long destOffset, int length)  {
         long header = ArrayHeaderSizeNode.sizeFor(CiKind.Short);
-        for (long i = 0; i < length * 2; i += 2) {
+        for (long i = 0; i < length * 2L; i += 2) {
             Character a = UnsafeLoadNode.load(src, i + (srcOffset + header), CiKind.Short);
             UnsafeStoreNode.store(dest, i + (destOffset + header), a.charValue(), CiKind.Short);
         }
@@ -241,7 +241,7 @@
     @Snippet
     public static void copyIntsUp(Object src, long srcOffset, Object dest, long destOffset, int length)  {
         long header = ArrayHeaderSizeNode.sizeFor(CiKind.Int);
-        for (long i = 0; i < length * 4; i += 4) {
+        for (long i = 0; i < length * 4L; i += 4) {
             Integer a = UnsafeLoadNode.load(src, i + (srcOffset + header), CiKind.Int);
             UnsafeStoreNode.store(dest, i + (destOffset + header), a.intValue(), CiKind.Int);
         }
@@ -250,7 +250,7 @@
     @Snippet
     public static void copyLongsUp(Object src, long srcOffset, Object dest, long destOffset, int length)  {
         long header = ArrayHeaderSizeNode.sizeFor(CiKind.Long);
-        for (long i = 0; i < length * 8; i += 8) {
+        for (long i = 0; i < length * 8L; i += 8) {
             Long a = UnsafeLoadNode.load(src, i + (srcOffset + header), CiKind.Long);
             UnsafeStoreNode.store(dest, i + (destOffset + header), a.longValue(), CiKind.Long);
         }
--- a/mx/commands.py	Wed Jan 11 16:17:51 2012 +0100
+++ b/mx/commands.py	Wed Jan 11 16:31:46 2012 +0100
@@ -35,12 +35,10 @@
 _graal_home = dirname(dirname(__file__))
 _vmSourcesAvailable = exists(join(_graal_home, 'make')) and exists(join(_graal_home, 'src')) 
 _vmbuild = 'product'
-_winSDK = 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\'
-_mksHome = 'C:\\cygwin\\bin'
 
 def clean(args):
     """cleans the GraalVM source tree"""
-    opts = mx.clean(args)
+    opts = mx.clean(args, parser=ArgumentParser(prog='mx clean'))
     if opts.native:
         os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
         mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make'))
@@ -191,11 +189,14 @@
     Get the JDK into which Graal is installed, creating it first if necessary.
     """
     jdk = join(_graal_home, 'jdk' + mx.java().version)
+    jdkContents = ['bin', 'db', 'include', 'jre', 'lib']
+    if mx.get_os() != 'windows':
+        jdkContents.append('man')
     if not exists(jdk):
         srcJdk = mx.java().jdk
         mx.log('Creating ' + jdk + ' from ' + srcJdk)
         os.mkdir(jdk)
-        for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']:
+        for d in jdkContents:
             src = join(srcJdk, d)
             dst = join(jdk, d)
             if not exists(src):
@@ -226,7 +227,7 @@
                 mx.abort('The ' + build + ' VM has not been created - run \'mx clean; mx make ' + build + '\'') 
             mx.log('Creating ' + res)
             os.mkdir(res)
-            for d in ['bin', 'db', 'include', 'jre', 'lib', 'man']:
+            for d in jdkContents:
                 shutil.copytree(join(jdk, d), join(res, d))
         return res
     else:
@@ -237,8 +238,11 @@
     newLine = os.linesep
     STARTTOKEN = 'RUNINDEBUGSHELL_STARTSEQUENCE'
     ENDTOKEN = 'RUNINDEBUGSHELL_ENDSEQUENCE'
-    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + _winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
-            shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    
+    winSDK = mx.get_env('WIN_SDK', 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\')
+
+    p = subprocess.Popen('cmd.exe /E:ON /V:ON /K ""' + winSDK + '/Bin/SetEnv.cmd" & echo ' + STARTTOKEN + '"', \
+            shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
     output = p.stdout
     input = p.stdin
     if logFile:
@@ -302,8 +306,10 @@
                 
         if platform.system() == 'Windows':
             compilelogfile = _graal_home + '/graalCompile.log'
+            mksHome = mx.get_env('MKS_HOME', 'C:\\cygwin\\bin')
+
             _runInDebugShell('msbuild ' + _graal_home + r'\build\vs-amd64\jvm.vcproj /p:Configuration=compiler1_product /target:clean', _graal_home)
-            winCompileCmd = r'set HotSpotMksHome=' + _mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + ''
+            winCompileCmd = r'set HotSpotMksHome=' + mksHome + r'& set OUT_DIR=' + jdk + r'& set JAVA_HOME=' + jdk + r'& set path=%JAVA_HOME%\bin;%path%;%HotSpotMksHome%& cd /D "' +_graal_home + r'\make\windows"& call create.bat ' + _graal_home + ''
             print(winCompileCmd)
             winCompileSuccess = re.compile(r"^Writing \.vcxproj file:")
             if not _runInDebugShell(winCompileCmd, _graal_home, compilelogfile, winCompileSuccess):
@@ -371,10 +377,11 @@
                 else:
                     path = dep.path
                     if dep.mustExist:
+                        dep.get_path(resolve=True)
                         if isabs(path):
                             println(out, '\t<classpathentry exported="true" kind="lib" path="' + path + '"/>')
                         else:
-                            println(out, '\t<classpathentry exported="true" kind="lib" path="/' + path + '"/>')
+                            println(out, '\t<classpathentry exported="true" kind="lib" path="' + join(_graal_home, path) + '"/>')
             else:
                 println(out, '\t<classpathentry combineaccessrules="false" exported="true" kind="src" path="/' + dep.name + '"/>')
                         
@@ -585,7 +592,12 @@
                 if not test.test('-graal'):
                     t.abort(test.group + ' ' + test.name + ' Failed')
                 t.stop()
+    except KeyboardInterrupt:
+        total.abort(1)
+    
     except Exception as e:
+        import traceback
+        traceback.print_exc()
         total.abort(str(e))
 
     total.stop()
--- a/mxtool/mx.py	Wed Jan 11 16:17:51 2012 +0100
+++ b/mxtool/mx.py	Wed Jan 11 16:31:46 2012 +0100
@@ -45,12 +45,9 @@
 #   projects    - Defines the projects and libraries in the suite and the dependencies between them
 #   commands.py - Suite specific extensions to the commands available to mx. This is only processed
 #                 for the primary suite.
-#   includes    - Other suites to be loaded. This is a recursive. 
+#   includes    - Other suites to be loaded. This is recursive. 
 #   env         - A set of environment variable definitions.
 #
-# The MX_INCLUDES environment variable can also be used to specify other suites.
-# This value of this variable has the same format as a Java class path.
-#
 # The includes and env files are typically not put under version control
 # as they usually contain local file-system paths.
 #
@@ -547,7 +544,6 @@
         remaining = end - time.time()
         if remaining <= 0:
             abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args)))
-            _kill_process_group(process.pid)
         delay = min(delay * 2, remaining, .05)
         time.sleep(delay)
 
@@ -571,7 +567,7 @@
     if _opts.verbose:
         log(' '.join(args))
         
-    if timeout is None and _opts.ptimeout != 0:
+    if timeout is None and hasattr(_opts, 'ptimeout') and _opts.ptimeout != 0:
         timeout = _opts.ptimeout
 
     global _currentSubprocess    
@@ -579,11 +575,16 @@
     try:
         # On Unix, the new subprocess should be in a separate group so that a timeout alarm
         # can use os.killpg() to kill the whole subprocess group
-        preexec_fn = os.setsid if get_os() != 'windows' else None
+        preexec_fn = None
+        creationflags = 0
+        if get_os() == 'windows':
+            creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
+        else:
+            preexec_fn = os.setsid  
         
         if not callable(out) and not callable(err) and timeout is None:
             # The preexec_fn=os.setsid
-            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             retcode = p.wait()
         else:
@@ -593,7 +594,7 @@
                 stream.close()
             stdout=out if not callable(out) else subprocess.PIPE
             stderr=err if not callable(err) else subprocess.PIPE
-            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             if callable(out):
                 t = Thread(target=redirect, args=(p.stdout, out))
@@ -630,7 +631,7 @@
     """
     Gets the platform specific suffix for an executable 
     """
-    if os == 'windows':
+    if get_os() == 'windows':
         return name + '.exe'
     return name
 
@@ -645,6 +646,9 @@
         self.javac = exe_suffix(join(self.jdk, 'bin', 'javac'))
         self.javap = exe_suffix(join(self.jdk, 'bin', 'javap'))
 
+        if not exists(self.java):
+            abort('Java launcher derived from JAVA_HOME does not exist: ' + self.java)
+
         def delAtAndSplit(s):
             return shlex.split(s.lstrip('@'))
         
@@ -747,7 +751,10 @@
     currentSubprocess = _currentSubprocess
     if currentSubprocess is not None:
         p, _ = currentSubprocess
-        _kill_process_group(p.pid)
+        if get_os() == 'windows':
+            p.kill()
+        else:
+            _kill_process_group(p.pid)
     
     raise SystemExit(codeOrMessage)
 
@@ -902,13 +909,20 @@
                 if dep.name in built:
                     mustBuild = True
             
+        javafilelist = []
+        nonjavafilelistdst = []
         for sourceDir in sourceDirs:
-            javafilelist = []
-            nonjavafilelist = []
             for root, _, files in os.walk(sourceDir):
                 javafiles = [join(root, name) for name in files if name.endswith('.java') and name != 'package-info.java']
                 javafilelist += javafiles
-                nonjavafilelist += [join(root, name) for name in files if not name.endswith('.java')]
+                
+                # Copy all non Java resources
+                nonjavafilelist = [join(root, name) for name in files if not name.endswith('.java')]
+                for src in nonjavafilelist:
+                    dst = join(outputDir, src[len(sourceDir) + 1:])
+                    if exists(dirname(dst)) and (not exists(dst) or os.path.getmtime(dst) != os.path.getmtime(src)):
+                        shutil.copyfile(src, dst)
+                
                 if not mustBuild:
                     for javafile in javafiles:
                         classfile = outputDir + javafile[len(sourceDir):-len('java')] + 'class'
@@ -916,65 +930,62 @@
                             mustBuild = True
                             break
                 
-            if not mustBuild:
-                log('[all class files in {0} are up to date - skipping]'.format(sourceDir))
-                continue
-                
-            if len(javafilelist) == 0:
-                log('[no Java sources in {0} - skipping]'.format(sourceDir))
-                continue
-
-            built.add(p.name)
-
-            argfileName = join(p.dir, 'javafilelist.txt')
-            argfile = open(argfileName, 'wb')
-            argfile.write('\n'.join(javafilelist))
-            argfile.close()
+        if not mustBuild:
+            log('[all class files for {0} are up to date - skipping]'.format(p.name))
+            continue
             
-            try:
-                if jdtJar is None:
-                    log('Compiling Java sources in {0} with javac...'.format(sourceDir))
-                    errFilt = None
-                    if not args.warnAPI:
-                        class Filter:
-                            """
-                            Class to errFilt the 'is Sun proprietary API and may be removed in a future release'
-                            warning when compiling the VM classes.
-                            
-                            """
-                            def __init__(self):
-                                self.c = 0
-                            
-                            def eat(self, line):
-                                if 'proprietary API' in line:
-                                    self.c = 2
-                                elif self.c != 0:
-                                    self.c -= 1
-                                else:
-                                    log(line.rstrip())
-                        errFilt=Filter().eat
+        if len(javafilelist) == 0:
+            log('[no Java sources for {0} - skipping]'.format(p.name))
+            continue
+
+        built.add(p.name)
+
+        argfileName = join(p.dir, 'javafilelist.txt')
+        argfile = open(argfileName, 'wb')
+        argfile.write('\n'.join(javafilelist))
+        argfile.close()
+        
+        try:
+            if jdtJar is None:
+                log('Compiling Java sources for {0} with javac...'.format(p.name))
+                errFilt = None
+                if not args.warnAPI:
+                    class Filter:
+                        """
+                        Class to errFilt the 'is Sun proprietary API and may be removed in a future release'
+                        warning when compiling the VM classes.
+                        
+                        """
+                        def __init__(self):
+                            self.c = 0
                         
-                    run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt)
-                else:
-                    log('Compiling Java sources in {0} with JDT...'.format(sourceDir))
-                    jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
-                    if not exists(jdtProperties):
-                        raise SystemError('JDT properties file {0} not found'.format(jdtProperties))
-                    run([java().java, '-Xmx1g', '-jar', jdtJar,
-                             '-properties', jdtProperties,
-                             '-' + args.compliance,
-                             '-cp', cp, '-g',
-                             '-warn:-unusedImport,-unchecked',
-                             '-d', outputDir, '@' + argfile.name])
-            finally:
-                os.remove(argfileName)
-                        
-                
-            for name in nonjavafilelist:
-                dst = join(outputDir, name[len(sourceDir) + 1:])
-                if exists(dirname(dst)):
-                    shutil.copyfile(name, dst)
-    return args
+                        def eat(self, line):
+                            if 'proprietary API' in line:
+                                self.c = 2
+                            elif self.c != 0:
+                                self.c -= 1
+                            else:
+                                log(line.rstrip())
+                    errFilt=Filter().eat
+                    
+                run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt)
+            else:
+                log('Compiling Java sources for {0} with JDT...'.format(p.name))
+                jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
+                if not exists(jdtProperties):
+                    raise SystemError('JDT properties file {0} not found'.format(jdtProperties))
+                run([java().java, '-Xmx1g', '-jar', jdtJar,
+                         '-properties', jdtProperties,
+                         '-' + args.compliance,
+                         '-cp', cp, '-g',
+                         '-warn:-unusedImport,-unchecked',
+                         '-d', outputDir, '@' + argfile.name])
+        finally:
+            os.remove(argfileName)
+                    
+    if suppliedParser:
+        return args
+    return None
 
 def canonicalizeprojects(args):
     """process all project files to canonicalize the dependencies
@@ -1122,8 +1133,10 @@
     Removes all files created by a build, including Java class files, executables, and
     generated images.
     """
+
+    suppliedParser = parser is not None
     
-    parser = parser if parser is not None else ArgumentParser(prog='mx build');
+    parser = parser if suppliedParser else ArgumentParser(prog='mx build');
     parser.add_argument('--no-native', action='store_false', dest='native', help='do not clean native projects')
     parser.add_argument('--no-java', action='store_false', dest='java', help='do not clean Java projects')
 
@@ -1139,7 +1152,9 @@
                 if outputDir != '' and exists(outputDir):
                     log('Removing {0}...'.format(outputDir))
                     shutil.rmtree(outputDir)
-    return args
+                    
+    if suppliedParser:
+        return args
     
 def help_(args):
     """show help for a given command
@@ -1219,13 +1234,6 @@
 _argParser = ArgParser()
 
 def main():
-    MX_INCLUDES = os.environ.get('MX_INCLUDES', None)
-    if MX_INCLUDES is not None:
-        for path in MX_INCLUDES.split(os.pathsep):
-            d = join(path, 'mx')
-            if exists(d) and isdir(d):
-                _loadSuite(path)
-                
     cwdMxDir = join(os.getcwd(), 'mx')
     if exists(cwdMxDir) and isdir(cwdMxDir):
         _loadSuite(os.getcwd(), True)
@@ -1251,7 +1259,7 @@
         
     c, _ = commands[command][:2]
     try:
-        if opts.timeout != 0:
+        if hasattr(opts, 'timeout') and opts.timeout != 0:
             def alarm_handler(signum, frame):
                 abort('Command timed out after ' + str(opts.timeout) + ' seconds: ' + ' '.join(commandAndArgs))
             signal.signal(signal.SIGALRM, alarm_handler)
--- a/src/share/tools/IdealGraphVisualizer/nbproject/build-impl.xml	Wed Jan 11 16:17:51 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/build-impl.xml	Wed Jan 11 16:31:46 2012 +0100
@@ -38,10 +38,11 @@
             </not>
         </condition>
     </fail>
-    <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly.">
+    <ant antfile="nbproject/platform.xml"/>
+    <fail message="Cannot find NetBeans build harness. ${line.separator}Check that nbplatform.${nbplatform.active}.netbeans.dest.dir and nbplatform.${nbplatform.active}.harness.dir are defined. ${line.separator}On a developer machine these are normally defined in ${user.properties.file}=${netbeans.user}/build.properties ${line.separator}but for automated builds you should pass these properties to Ant explicitly. ${line.separator}You may instead download the harness and platform: -Dbootstrap.url=.../tasks.jar -Dautoupdate.catalog.url=.../updates.xml">
         <condition>
             <not>
-                <available type="dir" file="${harness.dir}"/>
+                <available file="${harness.dir}/suite.xml"/>
             </not>
         </condition>
     </fail>
--- a/src/share/tools/IdealGraphVisualizer/nbproject/genfiles.properties	Wed Jan 11 16:17:51 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/genfiles.properties	Wed Jan 11 16:31:46 2012 +0100
@@ -4,5 +4,8 @@
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=3c2c6126
-nbproject/build-impl.xml.script.CRC32=5a29eb53
-nbproject/build-impl.xml.stylesheet.CRC32=183e6ef3@1.45.1
+nbproject/build-impl.xml.script.CRC32=b26e57e5
+nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.47.1
+nbproject/platform.xml.data.CRC32=3c2c6126
+nbproject/platform.xml.script.CRC32=db9e1f43
+nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.47.1
--- a/src/share/tools/IdealGraphVisualizer/nbproject/platform.properties	Wed Jan 11 16:17:51 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/platform.properties	Wed Jan 11 16:31:46 2012 +0100
@@ -2,7 +2,32 @@
     ${nbplatform.active.dir}/ide:\
     ${nbplatform.active.dir}/platform
 disabled.modules=\
+    com.jcraft.jsch,\
+    com.jcraft.jzlib,\
+    org.apache.commons.codec,\
+    org.apache.commons.httpclient,\
+    org.apache.commons.io,\
+    org.apache.commons.lang,\
+    org.apache.commons.logging,\
+    org.apache.ws.commons.util,\
     org.apache.xml.resolver,\
+    org.apache.xmlrpc,\
+    org.eclipse.core.contenttype,\
+    org.eclipse.core.jobs,\
+    org.eclipse.core.net,\
+    org.eclipse.core.runtime,\
+    org.eclipse.core.runtime.compatibility.auth,\
+    org.eclipse.equinox.app,\
+    org.eclipse.equinox.common,\
+    org.eclipse.equinox.preferences,\
+    org.eclipse.equinox.registry,\
+    org.eclipse.equinox.security,\
+    org.eclipse.jgit,\
+    org.eclipse.mylyn.bugzilla.core,\
+    org.eclipse.mylyn.commons.core,\
+    org.eclipse.mylyn.commons.net,\
+    org.eclipse.mylyn.commons.xmlrpc,\
+    org.eclipse.mylyn.tasks.core,\
     org.mozilla.rhino.patched,\
     org.netbeans.api.debugger,\
     org.netbeans.api.java.classpath,\
@@ -10,24 +35,22 @@
     org.netbeans.core.browser,\
     org.netbeans.core.execution,\
     org.netbeans.core.ide,\
+    org.netbeans.core.io.ui,\
     org.netbeans.core.multiview,\
+    org.netbeans.core.nativeaccess,\
+    org.netbeans.core.osgi,\
     org.netbeans.lib.cvsclient,\
     org.netbeans.lib.terminalemulator,\
     org.netbeans.libs.antlr3.runtime,\
-    org.netbeans.libs.bugtracking,\
-    org.netbeans.libs.bugzilla,\
     org.netbeans.libs.bytelist,\
-    org.netbeans.libs.commons_codec,\
-    org.netbeans.libs.commons_logging,\
     org.netbeans.libs.commons_net,\
     org.netbeans.libs.freemarker,\
+    org.netbeans.libs.git,\
     org.netbeans.libs.ini4j,\
-    org.netbeans.libs.jakarta_oro,\
     org.netbeans.libs.jaxb,\
-    org.netbeans.libs.jsch,\
     org.netbeans.libs.jsr223,\
+    org.netbeans.libs.junit4,\
     org.netbeans.libs.jvyamlb,\
-    org.netbeans.libs.jzlib,\
     org.netbeans.libs.lucene,\
     org.netbeans.libs.smack,\
     org.netbeans.libs.svnClientAdapter,\
@@ -43,6 +66,7 @@
     org.netbeans.modules.core.kit,\
     org.netbeans.modules.csl.api,\
     org.netbeans.modules.css.editor,\
+    org.netbeans.modules.css.lib,\
     org.netbeans.modules.css.visual,\
     org.netbeans.modules.db,\
     org.netbeans.modules.db.core,\
@@ -71,6 +95,7 @@
     org.netbeans.modules.extexecution,\
     org.netbeans.modules.extexecution.destroy,\
     org.netbeans.modules.favorites,\
+    org.netbeans.modules.git,\
     org.netbeans.modules.glassfish.common,\
     org.netbeans.modules.gototest,\
     org.netbeans.modules.gsf.codecoverage,\
@@ -83,8 +108,10 @@
     org.netbeans.modules.html.validation,\
     org.netbeans.modules.httpserver,\
     org.netbeans.modules.hudson,\
+    org.netbeans.modules.hudson.git,\
     org.netbeans.modules.hudson.mercurial,\
     org.netbeans.modules.hudson.subversion,\
+    org.netbeans.modules.hudson.tasklist,\
     org.netbeans.modules.ide.kit,\
     org.netbeans.modules.image,\
     org.netbeans.modules.javascript.editing,\
@@ -93,6 +120,7 @@
     org.netbeans.modules.javascript.refactoring,\
     org.netbeans.modules.jellytools.ide,\
     org.netbeans.modules.jumpto,\
+    org.netbeans.modules.keyring.impl,\
     org.netbeans.modules.languages,\
     org.netbeans.modules.languages.diff,\
     org.netbeans.modules.languages.manifest,\
@@ -100,6 +128,7 @@
     org.netbeans.modules.lexer.nbbridge,\
     org.netbeans.modules.localhistory,\
     org.netbeans.modules.mercurial,\
+    org.netbeans.modules.netbinox,\
     org.netbeans.modules.parsing.api,\
     org.netbeans.modules.parsing.lucene,\
     org.netbeans.modules.print.editor,\
@@ -120,6 +149,7 @@
     org.netbeans.modules.spellchecker.bindings.properties,\
     org.netbeans.modules.spellchecker.dictionary_en,\
     org.netbeans.modules.spellchecker.kit,\
+    org.netbeans.modules.spi.actions,\
     org.netbeans.modules.subversion,\
     org.netbeans.modules.swing.validation,\
     org.netbeans.modules.target.iterator,\
@@ -133,10 +163,11 @@
     org.netbeans.modules.utilities.project,\
     org.netbeans.modules.versioning,\
     org.netbeans.modules.versioning.indexingbridge,\
-    org.netbeans.modules.versioning.system.cvss,\
+    org.netbeans.modules.versioning.system.cvss.installer,\
     org.netbeans.modules.versioning.util,\
     org.netbeans.modules.web.client.tools.api,\
     org.netbeans.modules.web.common,\
+    org.netbeans.modules.web.indent,\
     org.netbeans.modules.xml,\
     org.netbeans.modules.xml.axi,\
     org.netbeans.modules.xml.catalog,\
@@ -165,4 +196,9 @@
     org.openide.execution,\
     org.openide.options,\
     org.openide.util.enumerations
+## Not disabled because of NetBeans bug 206347:
+## Applications not using OSGi don't start on NbP 7.1
+#   org.netbeans.core.netigso,\
+#   org.netbeans.libs.felix,\
+#   org.netbeans.libs.osgi,\
 nbplatform.active=default
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/platform.xml	Wed Jan 11 16:31:46 2012 +0100
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="platform" default="download" basedir="..">
+    <condition property="download.required">
+        <and>
+            <not>
+                <available file="${harness.dir}/suite.xml"/>
+            </not>
+            <isset property="bootstrap.url"/>
+            <isset property="autoupdate.catalog.url"/>
+        </and>
+    </condition>
+    <target name="download" if="download.required">
+        <mkdir dir="${harness.dir}"/>
+        <pathconvert pathsep="|" property="download.clusters">
+            <mapper type="flatten"/>
+            <path path="${cluster.path}"/>
+        </pathconvert>
+        <property name="disabled.modules" value=""/>
+        <pathconvert property="module.includes" pathsep="">
+            <mapper type="glob" from="${basedir}${file.separator}*" to="(?!\Q*\E)"/>
+            <path>
+                <filelist files="${disabled.modules}" dir="."/>
+            </path>
+        </pathconvert>
+        <echo message="Downloading clusters ${download.clusters}"/>
+        <property name="tasks.jar" location="${java.io.tmpdir}/tasks.jar"/>
+        <get src="${bootstrap.url}" dest="${tasks.jar}" usetimestamp="true" verbose="true"/>
+        <taskdef name="autoupdate" classname="org.netbeans.nbbuild.AutoUpdate" classpath="${tasks.jar}"/>
+        <autoupdate installdir="${nbplatform.active.dir}" updatecenter="${autoupdate.catalog.url}">
+            <modules includes="${module.includes}.*" clusters="${download.clusters}"/>
+            <modules includes="org[.]netbeans[.]modules[.]apisupport[.]harness" clusters="harness"/>
+        </autoupdate>
+    </target>
+</project>
--- a/src/share/vm/runtime/arguments.cpp	Wed Jan 11 16:17:51 2012 +0100
+++ b/src/share/vm/runtime/arguments.cpp	Wed Jan 11 16:31:46 2012 +0100
@@ -2015,7 +2015,8 @@
   const int BUFFER_SIZE = 1024;
   char path[BUFFER_SIZE];
 
-  sprintf(path, "%s/%s/bin", graal_dir, project);
+  const char fileSep = *os::file_separator();
+  sprintf(path, "%s%c%s%cbin", graal_dir, fileSep, project, fileSep);
   DIR* dir = os::opendir(path);
   if (dir == NULL) {
     jio_fprintf(defaultStream::output_stream(), "Error while starting Graal VM: The Graal class directory %s could not be opened.\n", path);
@@ -2031,8 +2032,14 @@
 static bool find_graal_dir(char* graal_dir) {
   strcpy(graal_dir, Arguments::get_java_home());
   char* end = graal_dir + strlen(graal_dir);
+  const char fileSep = *os::file_separator();
   while (end != graal_dir) {
-    strcat(graal_dir, "/graal");
+    if (fileSep == '/') 
+      strcat(graal_dir, "/graal");
+    else {
+      assert(fileSep == '\\', "unexpected separator char");
+      strcat(graal_dir, "\\graal");
+    }
     DIR* dir = os::opendir(graal_dir);
     if (dir != NULL) {
       os::closedir(dir);
@@ -2040,7 +2047,7 @@
     }
     *end = 0;
     while (end != graal_dir) {
-      if (*end == '/') {
+      if (*end == fileSep) {
         *end = 0;
         break;
       }