Skip to content

Commit

Permalink
Fix GraphKit invoke source position.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstancu committed Oct 18, 2022
1 parent b03a7dc commit f65d849
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,22 @@ public ResolvedJavaMethod findMethod(Class<?> declaringClass, String name, Class
}
}

private NodeSourcePosition invokePosition(int invokeBci) {
if (graph.trackNodeSourcePosition()) {
NodeSourcePosition currentPosition = graph.currentNodeSourcePosition();
assert currentPosition.getCaller() == null : "The GraphKit currentPosition should be a top level position.";
return NodeSourcePosition.substitution(currentPosition.getMethod(), invokeBci);
}
return null;
}

/**
* Creates and appends an {@link InvokeNode} for a call to a given method with a given set of
* arguments.
*/
@SuppressWarnings("try")
public InvokeNode createInvoke(ResolvedJavaMethod method, InvokeKind invokeKind, FrameStateBuilder frameStateBuilder, int bci, ValueNode... args) {
try (DebugCloseable context = graph.withNodeSourcePosition(NodeSourcePosition.substitution(graph.currentNodeSourcePosition(), method))) {
try (DebugCloseable context = graph.withNodeSourcePosition(invokePosition(bci))) {
assert method.isStatic() == (invokeKind == InvokeKind.Static);
Signature signature = method.getSignature();
JavaType returnType = signature.getReturnType(null);
Expand Down Expand Up @@ -282,7 +291,7 @@ public InvokeNode createIntrinsicInvoke(ResolvedJavaMethod method, ValueNode...
@SuppressWarnings("try")
public InvokeWithExceptionNode createInvokeWithExceptionAndUnwind(ResolvedJavaMethod method, InvokeKind invokeKind,
FrameStateBuilder frameStateBuilder, int invokeBci, ValueNode... args) {
try (DebugCloseable context = graph.withNodeSourcePosition(NodeSourcePosition.substitution(graph.currentNodeSourcePosition(), method))) {
try (DebugCloseable context = graph.withNodeSourcePosition(invokePosition(invokeBci))) {
InvokeWithExceptionNode result = startInvokeWithException(method, invokeKind, frameStateBuilder, invokeBci, args);
exceptionPart();
ExceptionObjectNode exception = exceptionObject();
Expand All @@ -294,7 +303,7 @@ public InvokeWithExceptionNode createInvokeWithExceptionAndUnwind(ResolvedJavaMe

@SuppressWarnings("try")
public InvokeWithExceptionNode createInvokeWithExceptionAndUnwind(MethodCallTargetNode callTarget, FrameStateBuilder frameStateBuilder, int invokeBci) {
try (DebugCloseable context = graph.withNodeSourcePosition(NodeSourcePosition.substitution(graph.currentNodeSourcePosition(), callTarget.targetMethod()))) {
try (DebugCloseable context = graph.withNodeSourcePosition(invokePosition(invokeBci))) {
InvokeWithExceptionNode result = startInvokeWithException(callTarget, frameStateBuilder, invokeBci);
exceptionPart();
ExceptionObjectNode exception = exceptionObject();
Expand Down

0 comments on commit f65d849

Please sign in to comment.