< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.graph/src/org/graalvm/compiler/graph/NodeSourcePosition.java

Print this page
rev 52509 : [mq]: graal

*** 26,35 **** --- 26,36 ---- import static org.graalvm.compiler.graph.NodeSourcePosition.Marker.None; import static org.graalvm.compiler.graph.NodeSourcePosition.Marker.Placeholder; import static org.graalvm.compiler.graph.NodeSourcePosition.Marker.Substitution; + import java.util.Iterator; import java.util.Objects; import org.graalvm.compiler.bytecode.BytecodeDisassembler; import org.graalvm.compiler.bytecode.Bytecodes;
*** 38,48 **** import jdk.vm.ci.code.CodeUtil; import jdk.vm.ci.meta.JavaMethod; import jdk.vm.ci.meta.MetaUtil; import jdk.vm.ci.meta.ResolvedJavaMethod; ! public class NodeSourcePosition extends BytecodePosition { private static final boolean STRICT_SOURCE_POSITION = Boolean.getBoolean("debug.graal.SourcePositionStrictChecks"); private static final boolean SOURCE_POSITION_BYTECODES = Boolean.getBoolean("debug.graal.SourcePositionDisassemble"); private final int hashCode; --- 39,49 ---- import jdk.vm.ci.code.CodeUtil; import jdk.vm.ci.meta.JavaMethod; import jdk.vm.ci.meta.MetaUtil; import jdk.vm.ci.meta.ResolvedJavaMethod; ! public class NodeSourcePosition extends BytecodePosition implements Iterable<NodeSourcePosition> { private static final boolean STRICT_SOURCE_POSITION = Boolean.getBoolean("debug.graal.SourcePositionStrictChecks"); private static final boolean SOURCE_POSITION_BYTECODES = Boolean.getBoolean("debug.graal.SourcePositionDisassemble"); private final int hashCode;
*** 51,72 **** /** * Remove marker frames. */ public NodeSourcePosition trim() { ! if (marker != None) { ! return null; } - NodeSourcePosition caller = getCaller(); - if (caller != null) { - caller = caller.trim(); - } - if (caller != getCaller()) { - return new NodeSourcePosition(caller, getMethod(), getBCI()); } return this; } public ResolvedJavaMethod getRootMethod() { NodeSourcePosition cur = this; while (cur.getCaller() != null) { cur = cur.getCaller(); --- 52,72 ---- /** * Remove marker frames. */ public NodeSourcePosition trim() { ! NodeSourcePosition lastMarker = null; ! for (NodeSourcePosition current = this; current != null; current = current.getCaller()) { ! if (current.marker != None) { ! lastMarker = current; } } + if (lastMarker == null) { return this; } + return lastMarker.getCaller(); + } public ResolvedJavaMethod getRootMethod() { NodeSourcePosition cur = this; while (cur.getCaller() != null) { cur = cur.getCaller();
*** 79,88 **** --- 79,107 ---- assert root.equals(currentRoot) || root.getName().equals(currentRoot.getName()) && root.getSignature().toMethodDescriptor().equals(currentRoot.getSignature().toMethodDescriptor()) && root.getDeclaringClass().getName().equals(currentRoot.getDeclaringClass().getName()) : root + " " + currentRoot; return true; } + @Override + public Iterator<NodeSourcePosition> iterator() { + return new Iterator<NodeSourcePosition>() { + private NodeSourcePosition currentPosition = NodeSourcePosition.this; + + @Override + public boolean hasNext() { + return currentPosition != null; + } + + @Override + public NodeSourcePosition next() { + NodeSourcePosition current = currentPosition; + currentPosition = currentPosition.getCaller(); + return current; + } + }; + } + enum Marker { None, Placeholder, Substitution }
*** 122,136 **** public boolean isPlaceholder() { return marker == Placeholder; } public static NodeSourcePosition substitution(ResolvedJavaMethod method) { ! return substitution(null, method); } public static NodeSourcePosition substitution(NodeSourcePosition caller, ResolvedJavaMethod method) { ! return new NodeSourcePosition(caller, method, BytecodeFrame.INVALID_FRAMESTATE_BCI, Substitution); } public boolean isSubstitution() { return marker == Substitution; } --- 141,163 ---- public boolean isPlaceholder() { return marker == Placeholder; } public static NodeSourcePosition substitution(ResolvedJavaMethod method) { ! return substitution(null, method, BytecodeFrame.INVALID_FRAMESTATE_BCI); ! } ! ! public static NodeSourcePosition substitution(ResolvedJavaMethod method, int bci) { ! return substitution(null, method, bci); } public static NodeSourcePosition substitution(NodeSourcePosition caller, ResolvedJavaMethod method) { ! return substitution(caller, method, BytecodeFrame.INVALID_FRAMESTATE_BCI); ! } ! ! public static NodeSourcePosition substitution(NodeSourcePosition caller, ResolvedJavaMethod method, int bci) { ! return new NodeSourcePosition(caller, method, bci, Substitution); } public boolean isSubstitution() { return marker == Substitution; }
*** 193,206 **** if (getCaller() == null) { if (isPlaceholder()) { return new NodeSourcePosition(newSourceLanguagePosition, link, getMethod(), 0); } assert link == null || isSubstitution || verifyCaller(this, link) : link; ! ! return new NodeSourcePosition(newSourceLanguagePosition, link, getMethod(), getBCI()); } else { ! return new NodeSourcePosition(getCaller().addCaller(newSourceLanguagePosition, link, isSubstitution), getMethod(), getBCI()); } } @Override public String toString() { --- 220,233 ---- if (getCaller() == null) { if (isPlaceholder()) { return new NodeSourcePosition(newSourceLanguagePosition, link, getMethod(), 0); } assert link == null || isSubstitution || verifyCaller(this, link) : link; ! assert !isSubstitution || marker == None; ! return new NodeSourcePosition(newSourceLanguagePosition, link, getMethod(), getBCI(), isSubstitution ? Substitution : None); } else { ! return new NodeSourcePosition(getCaller().addCaller(newSourceLanguagePosition, link, isSubstitution), getMethod(), getBCI(), marker); } } @Override public String toString() {
*** 219,228 **** --- 246,258 ---- return sb.toString(); } private static void format(StringBuilder sb, NodeSourcePosition pos) { MetaUtil.appendLocation(sb.append("at "), pos.getMethod(), pos.getBCI()); + if (pos.marker != None) { + sb.append(" " + pos.marker); + } if (SOURCE_POSITION_BYTECODES) { String disassembly = BytecodeDisassembler.disassembleOne(pos.getMethod(), pos.getBCI()); if (disassembly != null && disassembly.length() > 0) { sb.append(" // "); sb.append(disassembly);
< prev index next >