private static void printPath(Element start, PrintStream out) { Element cur = start; out.print("\tat " + cur.method.asStackTraceElement(0)); while (cur.parent != null) { out.print("\n\tat " + cur.parent.method.asStackTraceElement(cur.invoke.getSource().invoke().bci())); cur = cur.parent; } }
@Override public void simplify(SimplifierTool tool) { if (invoke().getContextMethod() == null) { assert (invoke().stateAfter() != null && BytecodeFrame.isPlaceholderBci(invoke().stateAfter().bci)) || BytecodeFrame.isPlaceholderBci(invoke().stateDuring().bci); return; ResolvedJavaType contextType = (invoke().stateAfter() == null && invoke().stateDuring() == null) ? null : invoke().getContextType(); ResolvedJavaMethod specialCallTarget = findSpecialCallTarget(invokeKind, receiver(), targetMethod, contextType); if (specialCallTarget != null) {
private static SourceReference[] sourceReference(InvokeTypeFlow invoke) { List<SourceReference> sourceReference = new ArrayList<>(); FrameState state = invoke.getSource().invoke().stateAfter(); while (state != null) { if (state.getCode() != null) { sourceReference.add(new SourceReference(state.bci, state.getCode().asStackTraceElement(state.bci))); } else { sourceReference.add(UNKNOWN_SOURCE_REFERENCE); } state = state.outerFrameState(); } return sourceReference.toArray(new SourceReference[sourceReference.size()]); }
assert singleReturn.result() == null || singleReturn.result() == singleCallTarget.invoke(); ResolvedJavaMethod resolvedTarget = lookup(singleCallTarget.targetMethod());
/** * Gets an approximate source code location for a node if possible. * * @return the StackTraceElements if an approximate source location is found, null otherwise */ public static StackTraceElement[] approxSourceStackTraceElement(Node node) { NodeSourcePosition position = node.getNodeSourcePosition(); if (position != null) { // use GraphBuilderConfiguration and enable trackNodeSourcePosition to get better source // positions. return approxSourceStackTraceElement(position); } ArrayList<StackTraceElement> elements = new ArrayList<>(); Node n = node; while (n != null) { if (n instanceof MethodCallTargetNode) { elements.add(((MethodCallTargetNode) n).targetMethod().asStackTraceElement(-1)); n = ((MethodCallTargetNode) n).invoke().asNode(); } if (n instanceof StateSplit) { FrameState state = ((StateSplit) n).stateAfter(); elements.addAll(Arrays.asList(approxSourceStackTraceElement(state))); break; } n = n.predecessor(); } return elements.toArray(new StackTraceElement[elements.size()]); }
@Override protected void run(StructuredGraph graph) { for (NewFrameNode virtualFrame : graph.getNodes(NewFrameNode.TYPE)) { for (MethodCallTargetNode callTarget : virtualFrame.usages().filter(MethodCallTargetNode.class)) { if (callTarget.invoke() != null) { String properties = callTarget.getDebugProperties().toString(); String arguments = callTarget.arguments().toString(); Throwable exception = new VerificationError("Frame escapes at: %s#%s\nproperties:%s\narguments: %s", callTarget, callTarget.targetMethod(), properties, arguments); throw GraphUtil.approxSourceException(callTarget, exception); } } } } }
protected void replaceSnippetInvokes(StructuredGraph snippetGraph) { for (MethodCallTargetNode call : snippetGraph.getNodes(MethodCallTargetNode.TYPE)) { Invoke invoke = call.invoke(); if (!call.targetMethod().equals(getTargetMethod())) { throw new GraalError("unexpected invoke %s in snippet", getClass().getSimpleName()); } assert invoke.stateAfter().bci == BytecodeFrame.AFTER_BCI; // Here we need to fix the bci of the invoke InvokeNode newInvoke = snippetGraph.add(new InvokeNode(invoke.callTarget(), bci(), invoke.getLocationIdentity())); newInvoke.setStateAfter(invoke.stateAfter()); snippetGraph.replaceFixedWithFixed((InvokeNode) invoke.asNode(), newInvoke); } } }
for (MethodCallTargetNode methodCallTarget : loadMethodCallTargetUsages) { if (isInvokeTo(methodCallTarget.invoke(), integerNumberOfLeadingZerosMethod)) { Invoke numberOfLeadingZerosInvoke = methodCallTarget.invoke(); NodeIterable<SubNode> numberOfLeadingZerosInvokeSubUsages = numberOfLeadingZerosInvoke.asNode().usages().filter(SubNode.class); if (numberOfLeadingZerosInvokeSubUsages.count() == 1) {
callTargets.sort((t1, t2) -> Integer.compare(t1.invoke().bci(), t2.invoke().bci())); AnalysisMethod callerMethod = (AnalysisMethod) targetNode.invoke().stateAfter().getMethod(); InvokeTypeFlow invokeFlow = callerMethod.getTypeFlow().getOriginalMethodFlows().getInvoke(targetNode.invoke().bci()); node.unreachableInvokes.add(targetNode.invoke()); } else { node.unreachableInvokes.remove(targetNode.invoke()); String sourceReference = buildSourceReference(targetNode.invoke().stateAfter()); for (AnalysisMethod implementationMethod : implementationMethods) { CallTreeNode calleeNode = new CallTreeNode(implementationMethod, targetMethod, node, node.level + 1, sourceReference);
if (methodCallTargetNode.invoke().useForInlining()) { StructuredGraph inlineGraph = providers.getReplacements().getSubstitution(methodCallTargetNode.targetMethod(), methodCallTargetNode.invoke().bci(), graph.trackNodeSourcePosition(), methodCallTargetNode.asNode().getNodeSourcePosition()); if (inlineGraph != null) { InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, true, methodCallTargetNode.targetMethod());
private boolean tryCheckCastSingleImplementor(ValueNode receiver, TypeReference speculatedType) { ResolvedJavaType singleImplementor = speculatedType.getType(); if (singleImplementor != null) { ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveConcreteMethod(targetMethod(), invoke().getContextType()); if (singleImplementorMethod != null) { if (anchor != null) { graph().add(anchor); graph().addBeforeFixed(invoke().asNode(), anchor); graph().addBeforeFixed(invoke().asNode(), guard); ValueNode valueNode = graph().addOrUnique(new PiNode(receiver, StampFactory.objectNonNull(speculatedType), guard)); arguments().set(0, valueNode);
AnalysisType type = toi.nextType(); AnalysisMethod method = type.resolveConcreteMethod(getTargetMethod(), getSource().invoke().getContextType()); if (method == null || Modifier.isAbstract(method.getModifiers())) {
AnalysisMethod method = type.resolveConcreteMethod(getTargetMethod(), getSource().invoke().getContextType()); if (method == null || Modifier.isAbstract(method.getModifiers())) {
private static void postPartialEvaluation(final StructuredGraph graph) { NeverPartOfCompilationNode.verifyNotFoundIn(graph); for (AllowMaterializeNode materializeNode : graph.getNodes(AllowMaterializeNode.TYPE).snapshot()) { materializeNode.replaceAtUsages(materializeNode.getFrame()); graph.removeFixed(materializeNode); } TruffleCompilerRuntime rt = TruffleCompilerRuntime.getRuntime(); for (VirtualObjectNode virtualObjectNode : graph.getNodes(VirtualObjectNode.TYPE)) { if (virtualObjectNode instanceof VirtualInstanceNode) { VirtualInstanceNode virtualInstanceNode = (VirtualInstanceNode) virtualObjectNode; ResolvedJavaType type = virtualInstanceNode.type(); if (rt.isValueType(type)) { virtualInstanceNode.setIdentity(false); } } } if (!TruffleCompilerOptions.getValue(TruffleInlineAcrossTruffleBoundary)) { // Do not inline across Truffle boundaries. for (MethodCallTargetNode mct : graph.getNodes(MethodCallTargetNode.TYPE)) { TruffleCompilerRuntime.InlineKind inlineKind = rt.getInlineKind(mct.targetMethod(), false); if (!inlineKind.allowsInlining()) { mct.invoke().setUseForInlining(false); } } } }