# HG changeset patch # User Andreas Woess # Date 1428535619 -7200 # Node ID 42a9e77c68bee9510e2f467561b2807aed994926 # Parent 79d212bfee220223c6b6caa7c226425eeec62b44 Truffle: add performance warnings (non-inlinable call, non-leaf type cast/instanceof) diff -r 79d212bfee22 -r 42a9e77c68be graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Apr 09 01:26:46 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Apr 09 01:26:59 2015 +0200 @@ -268,6 +268,42 @@ // recompute loop frequencies now that BranchProbabilities have had time to canonicalize ComputeLoopFrequenciesClosure.compute(graph); + + if (TruffleCompilerOptions.TraceTrufflePerformanceWarnings.getValue()) { + reportPerformanceWarnings(graph); + } + } + + private static void reportPerformanceWarnings(StructuredGraph graph) { + ArrayList warnings = new ArrayList<>(); + for (MethodCallTargetNode call : graph.getNodes(MethodCallTargetNode.TYPE)) { + if (call.targetMethod().getAnnotation(TruffleBoundary.class) == null && call.targetMethod().getAnnotation(TruffleCallBoundary.class) == null) { + TracePerformanceWarningsListener.logPerformanceWarning(String.format("not inlined %s call to %s (%s)", call.invokeKind(), call.targetMethod(), call), null); + warnings.add(call); + } + } + + for (CheckCastNode cast : graph.getNodes().filter(CheckCastNode.class)) { + if (cast.type().findLeafConcreteSubtype() == null) { + TracePerformanceWarningsListener.logPerformanceWarning(String.format("non-leaf type checkcast: %s (%s)", cast.type().getName(), cast), null); + warnings.add(cast); + } + } + + for (InstanceOfNode instanceOf : graph.getNodes().filter(InstanceOfNode.class)) { + if (instanceOf.type().findLeafConcreteSubtype() == null) { + TracePerformanceWarningsListener.logPerformanceWarning(String.format("non-leaf type instanceof: %s (%s)", instanceOf.type().getName(), instanceOf), null); + warnings.add(instanceOf); + } + } + + if (Debug.isEnabled() && !warnings.isEmpty()) { + try (Scope s = Debug.scope("TrufflePerformanceWarnings", graph)) { + Debug.dump(graph, "performance warnings %s", warnings); + } catch (Throwable t) { + Debug.handle(t); + } + } } public StructuredGraph createRootGraph(StructuredGraph graph) {