public static NodeSourcePosition substitution(NodeSourcePosition caller, ResolvedJavaMethod method) { return substitution(caller, method, BytecodeFrame.INVALID_FRAMESTATE_BCI); }
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 GraphKit(DebugContext debug, ResolvedJavaMethod stubMethod, Providers providers, WordTypes wordTypes, Plugins graphBuilderPlugins, CompilationIdentifier compilationId, String name) { this.providers = providers; StructuredGraph.Builder builder = new StructuredGraph.Builder(debug.getOptions(), debug).compilationId(compilationId); if (name != null) { builder.name(name); } else { builder.method(stubMethod); } this.graph = builder.build(); graph.disableUnsafeAccessTracking(); if (graph.trackNodeSourcePosition()) { // Set up a default value that everything constructed by GraphKit will use. graph.withNodeSourcePosition(NodeSourcePosition.substitution(stubMethod)); } this.wordTypes = wordTypes; this.graphBuilderPlugins = graphBuilderPlugins; this.lastFixedNode = graph.start(); structures = new ArrayList<>(); /* * Add a dummy element, so that the access of the last element never leads to an exception. */ structures.add(new Structure() { }); }
@SuppressWarnings("try") public InvokeWithExceptionNode createInvokeWithExceptionAndUnwind(ResolvedJavaMethod method, InvokeKind invokeKind, FrameStateBuilder frameStateBuilder, int invokeBci, int exceptionEdgeBci, ValueNode... args) { try (DebugCloseable context = graph.withNodeSourcePosition(NodeSourcePosition.substitution(graph.currentNodeSourcePosition(), method))) { InvokeWithExceptionNode result = startInvokeWithException(method, invokeKind, frameStateBuilder, invokeBci, exceptionEdgeBci, args); exceptionPart(); ExceptionObjectNode exception = exceptionObject(); append(new UnwindNode(exception)); endInvokeWithException(); return result; } }
@SuppressWarnings("try") public InvokeWithExceptionNode createInvokeWithExceptionAndUnwind(MethodCallTargetNode callTarget, FrameStateBuilder frameStateBuilder, int invokeBci, int exceptionEdgeBci) { try (DebugCloseable context = graph.withNodeSourcePosition(NodeSourcePosition.substitution(graph.currentNodeSourcePosition(), callTarget.targetMethod()))) { InvokeWithExceptionNode result = startInvokeWithException(callTarget, frameStateBuilder, invokeBci, exceptionEdgeBci); exceptionPart(); ExceptionObjectNode exception = exceptionObject(); append(new UnwindNode(exception)); endInvokeWithException(); return result; } }
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); } }
/** * 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))) { assert method.isStatic() == (invokeKind == InvokeKind.Static); Signature signature = method.getSignature(); JavaType returnType = signature.getReturnType(null); assert checkArgs(method, args); StampPair returnStamp = graphBuilderPlugins.getOverridingStamp(this, returnType, false); if (returnStamp == null) { returnStamp = StampFactory.forDeclaredType(graph.getAssumptions(), returnType, false); } MethodCallTargetNode callTarget = graph.add(createMethodCallTarget(invokeKind, method, args, returnStamp, bci)); InvokeNode invoke = append(new InvokeNode(callTarget, bci)); if (frameStateBuilder != null) { if (invoke.getStackKind() != JavaKind.Void) { frameStateBuilder.push(invoke.getStackKind(), invoke); } invoke.setStateAfter(frameStateBuilder.create(bci, invoke)); if (invoke.getStackKind() != JavaKind.Void) { frameStateBuilder.pop(invoke.getStackKind()); } } return invoke; } }