# HG changeset patch # User Christian Wirth # Date 1405590058 -7200 # Node ID c667378e4699be7b80db9e969d3ad67a3564c48f # Parent 1e8b758800fbfa6782b4a0e4f541ba3777e493f0 extract methods in PartialEvaluator diff -r 1e8b758800fb -r c667378e4699 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 Jul 17 11:25:56 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Jul 17 11:40:58 2014 +0200 @@ -122,20 +122,7 @@ new VerifyFrameDoesNotEscapePhase().apply(graph, false); if (TraceTruffleCompilationHistogram.getValue() && constantReceivers != null) { - DebugHistogram histogram = Debug.createHistogram("Expanded Truffle Nodes"); - for (Constant c : constantReceivers) { - String javaName = providers.getMetaAccess().lookupJavaType(c).toJavaName(false); - - // The DSL uses nested classes with redundant names - only show the inner class - int index = javaName.indexOf('$'); - if (index != -1) { - javaName = javaName.substring(index + 1); - } - - histogram.add(javaName); - - } - new DebugHistogramAsciiPrinter(TTY.out().out()).print(histogram); + createHistogram(); } canonicalizer.apply(graph, baseContext); @@ -176,6 +163,23 @@ return graph; } + private void createHistogram() { + DebugHistogram histogram = Debug.createHistogram("Expanded Truffle Nodes"); + for (Constant c : constantReceivers) { + String javaName = providers.getMetaAccess().lookupJavaType(c).toJavaName(false); + + // The DSL uses nested classes with redundant names - only show the inner class + int index = javaName.indexOf('$'); + if (index != -1) { + javaName = javaName.substring(index + 1); + } + + histogram.add(javaName); + + } + new DebugHistogramAsciiPrinter(TTY.out().out()).print(histogram); + } + private void expandTree(StructuredGraph graph, Assumptions assumptions) { PhaseContext phaseContext = new PhaseContext(providers, assumptions); TruffleExpansionLogger expansionLogger = null; @@ -207,26 +211,7 @@ } if (inlineGraph != null) { - try (Indent indent = Debug.logAndIndent("inline graph %s", methodCallTargetNode.targetMethod())) { - - int nodeCountBefore = graph.getNodeCount(); - if (TraceTruffleExpansion.getValue()) { - expansionLogger.preExpand(methodCallTargetNode, inlineGraph); - } - List canonicalizedNodes = methodCallTargetNode.invoke().asNode().usages().snapshot(); - Map inlined = InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, false, canonicalizedNodes); - if (TraceTruffleExpansion.getValue()) { - expansionLogger.postExpand(inlined); - } - if (Debug.isDumpEnabled()) { - int nodeCountAfter = graph.getNodeCount(); - Debug.dump(graph, "After inlining %s %+d (%d)", methodCallTargetNode.targetMethod().toString(), nodeCountAfter - nodeCountBefore, nodeCountAfter); - } - AbstractInlineInfo.getInlinedParameterUsages(canonicalizedNodes, inlineGraph, inlined); - canonicalizer.applyIncremental(graph, phaseContext, canonicalizedNodes); - - changed = true; - } + changed = expandTreeInline(graph, phaseContext, expansionLogger, methodCallTargetNode, inlineGraph); } } } @@ -242,6 +227,28 @@ } } + private boolean expandTreeInline(StructuredGraph graph, PhaseContext phaseContext, TruffleExpansionLogger expansionLogger, MethodCallTargetNode methodCallTargetNode, StructuredGraph inlineGraph) { + try (Indent indent = Debug.logAndIndent("inline graph %s", methodCallTargetNode.targetMethod())) { + int nodeCountBefore = graph.getNodeCount(); + if (TraceTruffleExpansion.getValue()) { + expansionLogger.preExpand(methodCallTargetNode, inlineGraph); + } + List canonicalizedNodes = methodCallTargetNode.invoke().asNode().usages().snapshot(); + Map inlined = InliningUtil.inline(methodCallTargetNode.invoke(), inlineGraph, false, canonicalizedNodes); + if (TraceTruffleExpansion.getValue()) { + expansionLogger.postExpand(inlined); + } + if (Debug.isDumpEnabled()) { + int nodeCountAfter = graph.getNodeCount(); + Debug.dump(graph, "After inlining %s %+d (%d)", methodCallTargetNode.targetMethod().toString(), nodeCountAfter - nodeCountBefore, nodeCountAfter); + } + AbstractInlineInfo.getInlinedParameterUsages(canonicalizedNodes, inlineGraph, inlined); + canonicalizer.applyIncremental(graph, phaseContext, canonicalizedNodes); + + return true; + } + } + private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList arguments, final Assumptions assumptions, final PhaseContext phaseContext, boolean ignoreSlowPath) {