changeset 4554:daba89671d29

Merge
author Christian Haeubl <christian.haeubl@oracle.com>
date Thu, 09 Feb 2012 18:36:11 -0800
parents 7d0d849abf80 (current diff) e065aa86d077 (diff)
children ce13e056d821 35ca3ade314d
files graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java graal/com.oracle.max.graal.lir.amd64/src/com/oracle/max/graal/lir/amd64/AMD64CompareToIntOpcode.java graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java
diffstat 20 files changed, 211 insertions(+), 235 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Thu Feb 09 18:36:11 2012 -0800
@@ -67,12 +67,12 @@
      *            or local class.
      * @return the simple name
      */
-    public static String getSimpleName(Class<?> clazz, boolean withEnclosingClass) {
+    public static String getSimpleName(Class< ? > clazz, boolean withEnclosingClass) {
         final String simpleName = clazz.getSimpleName();
         if (simpleName.length() != 0) {
             if (withEnclosingClass) {
                 String prefix = "";
-                Class<?> enclosingClass = clazz;
+                Class< ? > enclosingClass = clazz;
                 while ((enclosingClass = enclosingClass.getEnclosingClass()) != null) {
                     prefix = prefix + enclosingClass.getSimpleName() + ".";
                 }
@@ -95,6 +95,7 @@
 
     public static final int K = 1024;
     public static final int M = 1024 * 1024;
+
     public static boolean isOdd(int n) {
         return (n & 1) == 1;
     }
@@ -124,8 +125,8 @@
     }
 
     /**
-     * Computes the log (base 2) of the specified integer, rounding down.
-     * (E.g {@code log2(8) = 3}, {@code log2(21) = 4})
+     * Computes the log (base 2) of the specified integer, rounding down. (E.g {@code log2(8) = 3}, {@code log2(21) = 4}
+     * )
      *
      * @param val the value
      * @return the log base 2 of the value
@@ -136,8 +137,7 @@
     }
 
     /**
-     * Computes the log (base 2) of the specified long, rounding down.
-     * (E.g {@code log2(8) = 3}, {@code log2(21) = 4})
+     * Computes the log (base 2) of the specified long, rounding down. (E.g {@code log2(8) = 3}, {@code log2(21) = 4})
      *
      * @param val the value
      * @return the log base 2 of the value
@@ -154,6 +154,7 @@
 
     /**
      * Gets a word with the nth bit set.
+     *
      * @param n the nth bit to set
      * @return an integer value with the nth bit set
      */
@@ -163,6 +164,7 @@
 
     /**
      * Gets a word with the right-most n bits set.
+     *
      * @param n the number of right most bits to set
      * @return an integer value with the right-most n bits set
      */
@@ -196,6 +198,7 @@
         }
         return internalNameToJava(riType.name(), qualified);
     }
+
     /**
      * Converts a given type to its Java programming language name. The following are examples of strings returned by
      * this method:
@@ -330,6 +333,7 @@
         }
         return sb.toString();
     }
+
     /**
      * Gets a string for a given field formatted according to a given format specification. A format specification is
      * composed of characters that are to be copied verbatim to the result and specifiers that denote an attribute of
@@ -350,8 +354,8 @@
      *
      * @param format a format specification
      * @param field the field to be formatted
-     * @param kinds if {@code true} then {@code field}'s type is printed in the
-     *            {@linkplain CiKind#jniName JNI} form of its {@linkplain CiKind kind}
+     * @param kinds if {@code true} then {@code field}'s type is printed in the {@linkplain CiKind#jniName JNI} form of
+     *            its {@linkplain CiKind kind}
      * @return the result of formatting this field according to {@code format}
      * @throws IllegalFormatException if an illegal specifier is encountered in {@code format}
      */
@@ -424,8 +428,7 @@
     }
 
     /**
-     * Creates a set that uses reference-equality instead of {@link Object#equals(Object)}
-     * when comparing values.
+     * Creates a set that uses reference-equality instead of {@link Object#equals(Object)} when comparing values.
      *
      * @param <T> the type of elements in the set
      * @return a set based on reference-equality
@@ -435,8 +438,8 @@
     }
 
     /**
-     * Prepends the String {@code indentation} to every line in String {@code lines},
-     * including a possibly non-empty line following the final newline.
+     * Prepends the String {@code indentation} to every line in String {@code lines}, including a possibly non-empty
+     * line following the final newline.
      */
     public static String indent(String lines, String indentation) {
         if (lines.length() == 0) {
@@ -537,26 +540,26 @@
     }
 
     /**
-     * Convenient shortcut for calling {@link #appendLocation(StringBuilder, RiMethod, int)}
-     * without having to supply a a {@link StringBuilder} instance and convert the result
-     * to a string.
+     * Convenient shortcut for calling {@link #appendLocation(StringBuilder, RiMethod, int)} without having to supply a
+     * a {@link StringBuilder} instance and convert the result to a string.
      */
     public static String toLocation(RiResolvedMethod method, int bci) {
         return appendLocation(new StringBuilder(), method, bci).toString();
     }
 
-
     /**
-     * Appends a string representation of a location specified by a given method and bci to
-     * a given {@link StringBuilder}. If a stack trace element with a non-null file name
-     * and non-negative line number is {@linkplain RiMethod#toStackTraceElement(int) available}
-     * for the given method, then the string returned is the {@link StackTraceElement#toString()}
-     * value of the stack trace element, suffixed by the bci location. For example:
+     * Appends a string representation of a location specified by a given method and bci to a given
+     * {@link StringBuilder}. If a stack trace element with a non-null file name and non-negative line number is
+     * {@linkplain RiMethod#toStackTraceElement(int) available} for the given method, then the string returned is the
+     * {@link StackTraceElement#toString()} value of the stack trace element, suffixed by the bci location. For example:
+     *
      * <pre>
      *     java.lang.String.valueOf(String.java:2930) [bci: 12]
      * </pre>
-     * Otherwise, the string returned is the value of {@code CiUtil.format("%H.%n(%p)"}, suffixed
-     * by the bci location. For example:
+     *
+     * Otherwise, the string returned is the value of {@code CiUtil.format("%H.%n(%p)"}, suffixed by the bci location.
+     * For example:
+     *
      * <pre>
      *     java.lang.String.valueOf(int) [bci: 12]
      * </pre>
@@ -567,11 +570,13 @@
      * @return
      */
     public static StringBuilder appendLocation(StringBuilder sb, RiResolvedMethod method, int bci) {
-        StackTraceElement ste = method.toStackTraceElement(bci);
-        if (ste.getFileName() != null && ste.getLineNumber() > 0) {
-            sb.append(ste);
-        } else {
-            sb.append(CiUtil.format("%H.%n(%p)", method));
+        if (method != null) {
+            StackTraceElement ste = method.toStackTraceElement(bci);
+            if (ste.getFileName() != null && ste.getLineNumber() > 0) {
+                sb.append(ste);
+            } else {
+                sb.append(CiUtil.format("%H.%n(%p)", method));
+            }
         }
         return sb.append(" [bci: ").append(bci).append(']');
     }
@@ -629,6 +634,7 @@
      * Formats a location present in a register or frame reference map.
      */
     public static class RefMapFormatter {
+
         /**
          * The size of a stack slot.
          */
@@ -642,8 +648,8 @@
         public final CiArchitecture arch;
 
         /**
-         * The offset (in bytes) from the slot pointed to by {@link #fp} to the slot
-         * corresponding to bit 0 in the frame reference map.
+         * The offset (in bytes) from the slot pointed to by {@link #fp} to the slot corresponding to bit 0 in the frame
+         * reference map.
          */
         public final int refMapToFPOffset;
 
@@ -728,9 +734,9 @@
         return result;
     }
 
-    public static Class<?>[] signatureToTypes(RiSignature signature, RiResolvedType accessingClass) {
+    public static Class< ? >[] signatureToTypes(RiSignature signature, RiResolvedType accessingClass) {
         int count = signature.argumentCount(false);
-        Class<?>[] result = new Class<?>[count];
+        Class< ? >[] result = new Class< ? >[count];
         for (int i = 0; i < result.length; ++i) {
             result[i] = signature.argumentTypeAt(i, accessingClass).resolve(accessingClass).toJava();
         }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Thu Feb 09 18:36:11 2012 -0800
@@ -820,9 +820,6 @@
     }
 
     public Variable emitConditional(BooleanNode node, CiValue trueValue, CiValue falseValue) {
-        assert trueValue instanceof CiConstant && (trueValue.kind.stackKind() == CiKind.Int || trueValue.kind == CiKind.Long);
-        assert falseValue instanceof CiConstant && (falseValue.kind.stackKind() == CiKind.Int || trueValue.kind == CiKind.Long);
-
         if (node instanceof NullCheckNode) {
             return emitNullCheckConditional((NullCheckNode) node, trueValue, falseValue);
         } else if (node instanceof CompareNode) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/ConvertDeoptimizeToGuardPhase.java	Thu Feb 09 18:36:11 2012 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.graal.compiler.phases;
+
+import java.util.*;
+
+import com.oracle.max.graal.graph.*;
+import com.oracle.max.graal.nodes.*;
+
+public class ConvertDeoptimizeToGuardPhase extends Phase {
+
+    private static BeginNode findBeginNode(Node startNode) {
+        Node n = startNode;
+        while (true) {
+            if (n instanceof BeginNode) {
+                return (BeginNode) n;
+            } else {
+                n = n.predecessor();
+            }
+        }
+    }
+
+    @Override
+    protected void run(final StructuredGraph graph) {
+        List<DeoptimizeNode> nodes = graph.getNodes(DeoptimizeNode.class).snapshot();
+        if (nodes.size() == 0) {
+            return;
+        }
+
+        for (DeoptimizeNode d : nodes) {
+            BeginNode myBeginNode = findBeginNode(d);
+            Node controlSplit = myBeginNode.predecessor();
+
+            if (controlSplit instanceof IfNode) {
+                IfNode ifNode = (IfNode) controlSplit;
+                BeginNode otherBegin = ifNode.trueSuccessor();
+                BooleanNode conditionNode = ifNode.compare();
+                if (myBeginNode == ifNode.trueSuccessor()) {
+                    conditionNode = conditionNode.negate();
+                    otherBegin = ifNode.falseSuccessor();
+                }
+                BeginNode ifBlockBegin = findBeginNode(ifNode);
+                graph.unique(new GuardNode(conditionNode, ifBlockBegin));
+                otherBegin.replaceAtUsages(ifBlockBegin);
+                FixedNode next = otherBegin.next();
+                otherBegin.setNext(null);
+                ifNode.replaceAtPredecessors(next);
+            }
+        }
+
+        new DeadCodeEliminationPhase().apply(graph);
+    }
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Thu Feb 09 18:36:11 2012 -0800
@@ -26,7 +26,6 @@
 import static com.oracle.max.cri.ci.CiValueUtil.*;
 import static com.oracle.max.graal.lir.amd64.AMD64Arithmetic.*;
 import static com.oracle.max.graal.lir.amd64.AMD64Compare.*;
-import static com.oracle.max.graal.lir.amd64.AMD64CompareToIntOpcode.*;
 
 import java.util.*;
 
@@ -599,27 +598,4 @@
             postGCWriteBarrier(address.base, newValue);
         }
     }
-
-    // TODO The class NormalizeCompareNode should be lowered away in the front end, since the code generated is long and uses branches anyway.
-    @Override
-    public void visitNormalizeCompare(NormalizeCompareNode x) {
-        emitCompare(operand(x.x()), operand(x.y()));
-        Variable result = newVariable(x.kind());
-        switch (x.x().kind()){
-            case Float:
-            case Double:
-                if (x.isUnorderedLess) {
-                    append(CMP2INT_UL.create(result));
-                } else {
-                    append(CMP2INT_UG.create(result));
-                }
-                break;
-            case Long:
-                append(CMP2INT.create(result));
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-        setResult(x, result);
-    }
 }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotXirGenerator.java	Thu Feb 09 18:36:11 2012 -0800
@@ -762,8 +762,8 @@
             XirOperand result = asm.restart(CiKind.Int);
             XirParameter object = asm.createInputParameter("object", CiKind.Object);
             final XirOperand hub = is(EXACT_HINTS, flags) ? null : asm.createConstantInputParameter("hub", CiKind.Object);
-            XirOperand trueValue = asm.createConstantInputParameter("trueValue", CiKind.Int);
-            XirOperand falseValue = asm.createConstantInputParameter("falseValue", CiKind.Int);
+            XirOperand trueValue = asm.createInputParameter("trueValue", CiKind.Int);
+            XirOperand falseValue = asm.createInputParameter("falseValue", CiKind.Int);
 
             XirOperand objHub = asm.createTemp("objHub", CiKind.Object);
 
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderConfiguration.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderConfiguration.java	Thu Feb 09 18:36:11 2012 -0800
@@ -22,6 +22,7 @@
  */
 package com.oracle.max.graal.java;
 
+import com.oracle.max.cri.ri.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.phases.*;
 
@@ -34,6 +35,7 @@
     private final boolean useBranchPrediction;
     private final ResolvePolicy resolving;
     private final PhasePlan plan;
+    private RiResolvedType[] skippedExceptionTypes;
 
     public GraphBuilderConfiguration(boolean useBranchPrediction, ResolvePolicy resolving, PhasePlan plan) {
         this.useBranchPrediction = useBranchPrediction;
@@ -45,6 +47,15 @@
         return useBranchPrediction;
     }
 
+
+    public void setSkippedExceptionTypes(RiResolvedType[] skippedExceptionTypes) {
+        this.skippedExceptionTypes = skippedExceptionTypes;
+    }
+
+    public RiResolvedType[] getSkippedExceptionTypes() {
+        return skippedExceptionTypes;
+    }
+
     public boolean eagerResolvingForSnippets() {
         return (resolving == ResolvePolicy.EagerForSnippets || resolving == ResolvePolicy.Eager);
     }
--- a/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.java/src/com/oracle/max/graal/java/GraphBuilderPhase.java	Thu Feb 09 18:36:11 2012 -0800
@@ -1446,7 +1446,18 @@
             if (config.eagerResolving()) {
                 catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF);
             }
-            ConstantNode typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, catchType, (catchType instanceof RiResolvedType) && ((RiResolvedType) catchType).isInitialized());
+            boolean initialized = (catchType instanceof RiResolvedType) && ((RiResolvedType) catchType).isInitialized();
+            if (initialized && config.getSkippedExceptionTypes() != null) {
+                RiResolvedType resolvedCatchType = (RiResolvedType) catchType;
+                for (RiResolvedType skippedType : config.getSkippedExceptionTypes()) {
+                    initialized &= !resolvedCatchType.isSubtypeOf(skippedType);
+                    if (!initialized) {
+                        break;
+                    }
+                }
+            }
+
+            ConstantNode typeInstruction = genTypeOrDeopt(RiType.Representation.ObjectHub, catchType, initialized);
             if (typeInstruction != null) {
                 Block nextBlock = block.successors.size() == 1 ? unwindBlock(block.deoptBci) : block.successors.get(1);
                 FixedNode catchSuccessor = createTarget(block.successors.get(0), frameState);
--- a/graal/com.oracle.max.graal.lir.amd64/src/com/oracle/max/graal/lir/amd64/AMD64CompareToIntOpcode.java	Thu Feb 09 18:35:47 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.graal.lir.amd64;
-
-import static com.oracle.max.cri.ci.CiValueUtil.*;
-
-import java.util.*;
-
-import com.oracle.max.asm.*;
-import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
-import com.oracle.max.asm.target.amd64.*;
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.graph.*;
-import com.oracle.max.graal.lir.*;
-import com.oracle.max.graal.lir.asm.*;
-
-/**
- * Implementation of the Java bytecodes that compare a long, float, or double value and produce the
- * integer constants -1, 0, 1 on less, equal, or greater, respectively.  For floating point compares,
- * unordered can be either greater {@link #CMP2INT_UG} or less {@link #CMP2INT_UL}.
- */
-public enum AMD64CompareToIntOpcode {
-    CMP2INT, CMP2INT_UG, CMP2INT_UL;
-
-    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) {
-            @Override
-            public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-                emit(masm, output(0));
-            }
-
-            @Override
-            protected EnumSet<OperandFlag> flagsFor(OperandMode mode, int index) {
-                if (mode == OperandMode.Output && index == 0) {
-                    return EnumSet.of(OperandFlag.Register);
-                }
-                throw GraalInternalError.shouldNotReachHere();
-            }
-        };
-    }
-
-    private void emit(AMD64MacroAssembler masm, CiValue result) {
-        CiRegister dest = asIntReg(result);
-        Label high = new Label();
-        Label low = new Label();
-        Label done = new Label();
-
-        // comparison is done by a separate LIR instruction before
-        switch (this) {
-            case CMP2INT:
-                masm.jcc(ConditionFlag.greater, high);
-                masm.jcc(ConditionFlag.less, low);
-                break;
-            case CMP2INT_UG:
-                masm.jcc(ConditionFlag.parity, high);
-                masm.jcc(ConditionFlag.above, high);
-                masm.jcc(ConditionFlag.below, low);
-                break;
-            case CMP2INT_UL:
-                masm.jcc(ConditionFlag.parity, low);
-                masm.jcc(ConditionFlag.above, high);
-                masm.jcc(ConditionFlag.below, low);
-                break;
-            default:
-                throw GraalInternalError.shouldNotReachHere();
-        }
-
-        // equal -> 0
-        masm.xorptr(dest, dest);
-        masm.jmp(done);
-
-        // greater -> 1
-        masm.bind(high);
-        masm.xorptr(dest, dest);
-        masm.incrementl(dest, 1);
-        masm.jmp(done);
-
-        // less -> -1
-        masm.bind(low);
-        masm.xorptr(dest, dest);
-        masm.decrementl(dest, 1);
-
-        masm.bind(done);
-    }
-}
--- a/graal/com.oracle.max.graal.lir.amd64/src/com/oracle/max/graal/lir/amd64/AMD64ControlFlow.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.lir.amd64/src/com/oracle/max/graal/lir/amd64/AMD64ControlFlow.java	Thu Feb 09 18:36:11 2012 -0800
@@ -354,10 +354,10 @@
         switch (cond) {
             case EQ: return ConditionFlag.equal;
             case NE: return ConditionFlag.notEqual;
-            case BT: return ConditionFlag.below;
-            case BE: return ConditionFlag.belowEqual;
-            case AE: return ConditionFlag.aboveEqual;
-            case AT: return ConditionFlag.above;
+            case LT: return ConditionFlag.below;
+            case LE: return ConditionFlag.belowEqual;
+            case GE: return ConditionFlag.aboveEqual;
+            case GT: return ConditionFlag.above;
             default: throw GraalInternalError.shouldNotReachHere();
         }
     }
--- a/graal/com.oracle.max.graal.lir/src/com/oracle/max/graal/lir/cfg/Block.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.lir/src/com/oracle/max/graal/lir/cfg/Block.java	Thu Feb 09 18:36:11 2012 -0800
@@ -98,6 +98,19 @@
         return dominator;
     }
 
+    public Block getEarliestPostDominated() {
+        Block b = this;
+        while (true) {
+            Block dom = b.getDominator();
+            if (dom != null && dom.getPostdominator() == b) {
+                b = dom;
+            } else {
+                break;
+            }
+        }
+        return b;
+    }
+
     public List<Block> getDominated() {
         if (dominated == null) {
             return Collections.emptyList();
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -40,6 +40,10 @@
     @Data private String message;
     @Data private final DeoptAction action;
 
+    public DeoptimizeNode() {
+        this(DeoptAction.InvalidateReprofile);
+    }
+
     public DeoptimizeNode(DeoptAction action) {
         super(StampFactory.illegal());
         this.action = action;
@@ -61,4 +65,9 @@
     public void generate(LIRGeneratorTool gen) {
         gen.emitDeoptimizeOn(null, action, message);
     }
+
+    @NodeIntrinsic
+    public static void deopt() {
+        throw new UnsupportedOperationException();
+    }
 }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java	Thu Feb 09 18:36:11 2012 -0800
@@ -590,7 +590,9 @@
     public Map<Object, Object> getDebugProperties() {
         Map<Object, Object> properties = super.getDebugProperties();
         properties.put("bci", bci);
-        properties.put("method", CiUtil.format("%H.%n(%p):%r", method));
+        if (method != null) {
+            properties.put("method", CiUtil.format("%H.%n(%p):%r", method));
+        }
         StringBuilder str = new StringBuilder();
         for (int i = 0; i < localsSize(); i++) {
             str.append(i == 0 ? "" : ", ").append(localAt(i) == null ? "_" : localAt(i).toString(Verbosity.Id));
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -29,6 +29,7 @@
 import com.oracle.max.graal.nodes.extended.*;
 import com.oracle.max.graal.nodes.java.*;
 import com.oracle.max.graal.nodes.spi.*;
+import com.oracle.max.graal.nodes.util.*;
 
 /**
  * The {@code InvokeNode} represents all kinds of method calls.
@@ -117,7 +118,15 @@
             assert kind() == CiKind.Void && usages().isEmpty();
             ((StructuredGraph) graph()).removeFixed(this);
         } else {
-            ((StructuredGraph) graph()).replaceFixed(this, node);
+            if (node instanceof FixedWithNextNode) {
+                ((StructuredGraph) graph()).replaceFixedWithFixed(this, (FixedWithNextNode) node);
+            } else if (node instanceof DeoptimizeNode) {
+                this.replaceAtPredecessors(node);
+                this.replaceAtUsages(null);
+                GraphUtil.killCFG(this);
+            } else {
+                ((StructuredGraph) graph()).replaceFixed(this, node);
+            }
         }
         call.safeDelete();
         if (stateAfter.usages().isEmpty()) {
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MaterializeNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/MaterializeNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -31,7 +31,7 @@
         super(condition, trueValue, falseValue);
     }
 
-    public static MaterializeNode create(BooleanNode condition, Graph graph, ConstantNode trueValue, ConstantNode falseValue) {
+    public static MaterializeNode create(BooleanNode condition, Graph graph, ValueNode trueValue, ValueNode falseValue) {
         MaterializeNode result = new MaterializeNode(condition, trueValue, falseValue);
         return graph.unique(result);
 
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/CompareNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/CompareNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -146,17 +146,6 @@
     private ValueNode optimizeNormalizeCmp(CiConstant constant, NormalizeCompareNode normalizeNode) {
         if (constant.kind == CiKind.Int && constant.asInt() == 0) {
             Condition cond = condition();
-            if (normalizeNode.x().kind().isFloatOrDouble()) {
-                switch (cond) {
-                    case LT: cond = Condition.BT; break;
-                    case LE: cond = Condition.BE; break;
-                    case GE: cond = Condition.AE; break;
-                    case GT: cond = Condition.AT; break;
-                }
-            }
-            if (normalizeNode == y()) {
-                cond = cond.mirror();
-            }
             boolean isLess = cond == Condition.LE || cond == Condition.LT || cond == Condition.BE || cond == Condition.BT;
             boolean canonUnorderedIsTrue = cond != Condition.EQ && (cond == Condition.NE || !(isLess ^ normalizeNode.isUnorderedLess));
             CompareNode result = graph().unique(new CompareNode(normalizeNode.x(), cond, canonUnorderedIsTrue, normalizeNode.y()));
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/Condition.java	Thu Feb 09 18:36:11 2012 -0800
@@ -227,13 +227,9 @@
                 switch (this) {
                     case EQ: return x == y;
                     case NE: return x != y;
-                    case BT:
                     case LT: return x < y;
-                    case BE:
                     case LE: return x <= y;
-                    case AT:
                     case GT: return x > y;
-                    case AE:
                     case GE: return x >= y;
                 }
             }
@@ -246,13 +242,9 @@
                 switch (this) {
                     case EQ: return x == y;
                     case NE: return x != y;
-                    case BT:
                     case LT: return x < y;
-                    case BE:
                     case LE: return x <= y;
-                    case AT:
                     case GT: return x > y;
-                    case AE:
                     case GE: return x >= y;
                 }
             }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/calc/NormalizeCompareNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -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
@@ -22,21 +22,15 @@
  */
 package com.oracle.max.graal.nodes.calc;
 
-import java.util.*;
-
 import com.oracle.max.cri.ci.*;
+import com.oracle.max.graal.cri.*;
 import com.oracle.max.graal.nodes.*;
 import com.oracle.max.graal.nodes.spi.*;
 
 /**
- * Returns -1, 0, or 1 if either x > y, x == y, or x < y.
+ * Returns -1, 0, or 1 if either x < y, x == y, or x > y.
  */
-// TODO(cwi): Since the machine code representation of this node uses branches and individual constant assignemnts anyway,
-// it should be lowered to explicit control flow nodes.  This removes AMD64CompareToIntOpcode.
-// For code generated by javac, the opcodes are followed by a branch instruction immediately, so in all cases that matter
-// this node is canonicalized away.
-// Consider moving this node and the code that does the lowering / canonicalization in a Java-specific project.
-public final class NormalizeCompareNode extends BinaryNode implements LIRLowerable {
+public final class NormalizeCompareNode extends BinaryNode implements Lowerable {
     @Data public final boolean isUnorderedLess;
 
     /**
@@ -51,14 +45,15 @@
     }
 
     @Override
-    public void generate(LIRGeneratorTool gen) {
-        gen.visitNormalizeCompare(this);
-    }
+    public void lower(CiLoweringTool tool) {
+        StructuredGraph graph = (StructuredGraph) graph();
 
-    @Override
-    public Map<Object, Object> getDebugProperties() {
-        Map<Object, Object> properties = super.getDebugProperties();
-        properties.put("isUnorderedLess", isUnorderedLess);
-        return properties;
+        CompareNode equalComp = graph.unique(new CompareNode(x(), Condition.EQ, false, y()));
+        MaterializeNode equalValue = MaterializeNode.create(equalComp, graph, ConstantNode.forInt(0, graph), ConstantNode.forInt(1, graph));
+
+        CompareNode lessComp = graph.unique(new CompareNode(x(), Condition.LT, isUnorderedLess, y()));
+        MaterializeNode value =  MaterializeNode.create(lessComp, graph, ConstantNode.forInt(-1, graph), equalValue);
+
+        graph.replaceFloating(this, value);
     }
 }
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/UnboxNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/extended/UnboxNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -62,25 +62,27 @@
         if (source.isConstant()) {
             CiConstant constant = source.asConstant();
             Object o = constant.asObject();
-            switch (kind()) {
-                case Boolean:
-                    return ConstantNode.forBoolean((Boolean) o, graph());
-                case Byte:
-                    return ConstantNode.forByte((Byte) o, graph());
-                case Char:
-                    return ConstantNode.forChar((Character) o, graph());
-                case Short:
-                    return ConstantNode.forShort((Short) o, graph());
-                case Int:
-                    return ConstantNode.forInt((Integer) o, graph());
-                case Long:
-                    return ConstantNode.forLong((Long) o, graph());
-                case Float:
-                    return ConstantNode.forFloat((Long) o, graph());
-                case Double:
-                    return ConstantNode.forDouble((Long) o, graph());
-                default:
-                    assert false;
+            if (o != null) {
+                switch (kind()) {
+                    case Boolean:
+                        return ConstantNode.forBoolean((Boolean) o, graph());
+                    case Byte:
+                        return ConstantNode.forByte((Byte) o, graph());
+                    case Char:
+                        return ConstantNode.forChar((Character) o, graph());
+                    case Short:
+                        return ConstantNode.forShort((Short) o, graph());
+                    case Int:
+                        return ConstantNode.forInt((Integer) o, graph());
+                    case Long:
+                        return ConstantNode.forLong((Long) o, graph());
+                    case Float:
+                        return ConstantNode.forFloat((Long) o, graph());
+                    case Double:
+                        return ConstantNode.forDouble((Long) o, graph());
+                    default:
+                        assert false;
+                }
             }
         }
         return this;
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java	Thu Feb 09 18:36:11 2012 -0800
@@ -63,6 +63,7 @@
 
     @Override
     public ValueNode canonical(CanonicalizerTool tool) {
+        assert object() != null : this;
         RiResolvedType exact = object().exactType();
         if (exact != null) {
             boolean result = exact.isSubtypeOf(targetClass());
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java	Thu Feb 09 18:35:47 2012 -0800
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java	Thu Feb 09 18:36:11 2012 -0800
@@ -103,9 +103,6 @@
     // * The actual compare-and-swap
     public abstract void visitCompareAndSwap(CompareAndSwapNode i);
 
-    // The class NormalizeCompareNode should be lowered away in the front end, since the code generated is long and uses branches anyway.
-    public abstract void visitNormalizeCompare(NormalizeCompareNode i);
-
     // Functionality that is currently implemented in XIR.
     // These methods will go away eventually when lowering is done via snippets in the front end.
     public abstract void visitArrayLength(ArrayLengthNode i);