# HG changeset patch # User Thomas Wuerthinger # Date 1328814359 -3600 # Node ID a3cdfa2be94e70fa3de90a0b792b1245a6b514df # Parent df329f268a054519519baa1ca5e04766f679d9df Allow to intrinsify an invoke with a deoptimize node. Make debug output more relaxed wrt to null in FrameMap.method diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiUtil.java --- 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 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: + * *
      *     java.lang.String.valueOf(String.java:2930) [bci: 12]
      * 
- * 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: + * *
      *     java.lang.String.valueOf(int) [bci: 12]
      * 
@@ -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(); } diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/DeoptimizeNode.java --- 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(); + } } diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/FrameState.java --- 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 getDebugProperties() { Map 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)); diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/InvokeNode.java --- 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()) { diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/java/InstanceOfNode.java --- 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()); diff -r df329f268a05 -r a3cdfa2be94e graal/com.oracle.max.graal.tests/src/com/oracle/max/graal/compiler/tests/DegeneratedLoopsTest.java --- 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;