diff graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java @ 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 14a00ee82980
children e43d36482d12
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();
         }