private void verifySourcePosition(NodeSourcePosition originalPosition, NodeSourcePosition decodedSourcePosition) { if (originalPosition == null) { assert decodedSourcePosition == null; return; } assert originalPosition.getBCI() == decodedSourcePosition.getBCI(); assert originalPosition.getMethod().equals(decodedSourcePosition.getMethod()); verifySourcePosition(originalPosition.getCaller(), decodedSourcePosition.getCaller()); } }
public NodeSourcePosition addCaller(SourceLanguagePosition newSourceLanguagePosition, NodeSourcePosition link, boolean isSubstitution) { 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 boolean equals(Object obj) { if (obj instanceof SourceMapping) { SourceMapping other = (SourceMapping) obj; return other.startOffset == startOffset && other.endOffset == endOffset && other.sourcePosition.equals(sourcePosition); } return false; }
public boolean verify() { NodeSourcePosition current = this; NodeSourcePosition caller = getCaller(); while (caller != null) { assert verifyCaller(current, caller) : current; current = caller; caller = caller.getCaller(); } return true; }
@Override public NodeSourcePosition getCallerBytecodePosition(NodeSourcePosition position) { if (caller == null) { return position; } if (callerBytecodePosition == null) { NodeSourcePosition invokePosition = invokeData.invoke.asNode().getNodeSourcePosition(); if (invokePosition == null) { assert position == null : "should only happen when tracking is disabled"; return null; } callerBytecodePosition = invokePosition; } if (position != null) { return position.addCaller(caller.resolveSourceLanguagePosition(), callerBytecodePosition); } final SourceLanguagePosition pos = caller.resolveSourceLanguagePosition(); if (pos != null && callerBytecodePosition != null) { return new NodeSourcePosition(pos, callerBytecodePosition.getCaller(), callerBytecodePosition.getMethod(), callerBytecodePosition.getBCI()); } return callerBytecodePosition; }
public InlineCacheGuardPosition(NodeSourcePosition callStack, ResolvedJavaType dispatchedType, ResolvedJavaMethod targetMethod) { super(callStack.getCaller(), callStack.getMethod(), callStack.getBCI()); this.concreteMethod = targetMethod; this.dispatchedType = dispatchedType; this.hashCode = super.hashCode() + 7 * ((dispatchedType == null) ? 0 : dispatchedType.hashCode()) + 31 * targetMethod.hashCode(); }
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); } } }
default void addCallerToNoDeoptSuccessorPosition(NodeSourcePosition caller) { NodeSourcePosition noDeoptSuccessorPosition = getNoDeoptSuccessorPosition(); if (noDeoptSuccessorPosition == null) { return; } setNoDeoptSuccessorPosition(new NodeSourcePosition(caller, noDeoptSuccessorPosition.getMethod(), noDeoptSuccessorPosition.getBCI())); } }
NodeSourcePosition survivingSuccessorPosition = null; if (graph.trackNodeSourcePosition()) { survivingSuccessorPosition = new NodeSourcePosition(currentPosition.getCaller(), currentPosition.getMethod(), noDeoptBlock.startBci);
/** * This method returns a unique key for the given node. Unless the node comes from a * substitution, the unique key is the BCI of the node. Every * newinstance/newarray/newmultiarray/instanceof/checkcast node coming from a substitution * method cannot have a BCI. If one substitution has multiple nodes of the same type, then the * BCI would not be unique. In the later case the key is a unique object. */ protected static Object uniqueKey(Node node) { NodeSourcePosition position = node.getNodeSourcePosition(); // If the 'position' has a 'caller' then it is inlined, case in which the BCI is // probably not unique. if (position != null && position.getCaller() == null) { if (position.getBCI() >= 0) { return position.getBCI(); } } return new Object(); }
@Override public int nodeSourcePositionBCI(NodeSourcePosition pos) { return pos.getBCI(); }
public int depth() { int d = 0; NodeSourcePosition pos = this; while (pos != null) { d++; pos = pos.getCaller(); } return d; }
if (pos != null) { if (inlineeRoot == null) { assert (inlineeRoot = pos.getRootMethod()) != null; } else { assert pos.verifyRootMethod(inlineeRoot); callerPos = pos.addCaller(invokePos, isSubstitution); posMap.put(pos, callerPos); ((DeoptimizingGuard) value).addCallerToNoDeoptSuccessorPosition(callerPos.getCaller());
private static void reportPrunedTypeFlows(BufferedWriter out) { doWrite(out, String.format("%-35s\n", "Summary")); doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Removed Count")); typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).collect(Collectors.groupingBy(TypeFlowBuilder::getFlowClass)).forEach((flowClass, providers) -> { doWrite(out, String.format("%-35s\t%-10d\n", flowClass.getSimpleName(), providers.size())); }); doWrite(out, String.format("\n%-35s\n", "Removed flows")); doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Location")); typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).forEach((provider) -> { Object source = provider.getSource(); String sourceStr; if (source instanceof ValueNode) { ValueNode value = (ValueNode) source; NodeSourcePosition srcPosition = value.getNodeSourcePosition(); if (srcPosition != null) { sourceStr = srcPosition.toString(); } else { sourceStr = value.toString() + " @ " + value.graph().method().format("%H.%n(%p)"); } } else { sourceStr = source.toString(); } doWrite(out, String.format("%-35s\t%-10s\n", provider.getFlowClass().getSimpleName(), sourceStr)); }); }
public static NodeSourcePosition placeholder(ResolvedJavaMethod method, int bci) { return new NodeSourcePosition(null, method, bci, Placeholder); }
@Override public String toString() { StringBuilder sb = new StringBuilder(100); NodeSourcePosition pos = this; while (pos != null) { format(sb, pos); if (pos.sourceLanguagePosition != null) { sb.append(" source=" + pos.sourceLanguagePosition.toShortString()); } pos = pos.getCaller(); if (pos != null) { sb.append(CodeUtil.NEW_LINE); } } return sb.toString(); }
NodeSourcePosition at = pos; while (at != null) { SourceLanguagePosition cur = at.getSourceLanguage(); if (cur != null) { arr.add(cur); at = at.getCaller();
@Override public ResolvedJavaMethod nodeSourcePositionMethod(NodeSourcePosition pos) { return pos.getMethod(); }
private NodeSourcePosition create(int bci, BytecodeParser parent) { if (outerSourcePosition == null && parent != null) { outerSourcePosition = parent.getFrameStateBuilder().createBytecodePosition(parent.bci()); } if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI && parent != null) { return FrameState.toSourcePosition(outerFrameState); } if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) { throw shouldNotReachHere(); } if (parser.intrinsicContext != null && (parent == null || parent.intrinsicContext != parser.intrinsicContext)) { // When parsing an intrinsic put in a substitution marker showing the original method as // the caller. This keeps the relationship between the method and the method // substitution clear in resulting NodeSourcePosition. NodeSourcePosition original = new NodeSourcePosition(outerSourcePosition, parser.intrinsicContext.getOriginalMethod(), -1); return NodeSourcePosition.substitution(original, code.getMethod(), bci); } else { return new NodeSourcePosition(outerSourcePosition, code.getMethod(), bci); } }