Mercurial > hg > truffle
changeset 20819:42a9e77c68be
Truffle: add performance warnings (non-inlinable call, non-leaf type cast/instanceof)
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 09 Apr 2015 01:26:59 +0200 |
parents | 79d212bfee22 |
children | ca57c045b1e8 |
files | graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java |
diffstat | 1 files changed, 36 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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<ValueNode> 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) {