changeset 4547:a3cdfa2be94e

Allow to intrinsify an invoke with a deoptimize node. Make debug output more relaxed wrt to null in FrameMap.method
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 09 Feb 2012 20:05:59 +0100
parents df329f268a05
children f55914bc1d67
files graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java
diffstat 6 files changed, 61 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java	Thu Feb 09 20:05:59 2012 +0100
@@ -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.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java	Thu Feb 09 20:05:59 2012 +0100
@@ -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:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java	Thu Feb 09 20:05:59 2012 +0100
@@ -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:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java	Thu Feb 09 20:05:59 2012 +0100
@@ -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/java/InstanceOfNode.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java	Thu Feb 09 20:05:59 2012 +0100
@@ -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.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java	Thu Feb 09 18:20:56 2012 +0100
+++ b/graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java	Thu Feb 09 20:05:59 2012 +0100
@@ -23,7 +23,6 @@
 package com.oracle.max.graal.compiler.tests;
 
 import static com.oracle.max.graal.graph.iterators.NodePredicates.*;
-import junit.framework.*;
 
 import org.junit.Test;