Skip to content

Commit f9a1e76

Browse files
committed
Extract pe method in GraphManager
1 parent e978b74 commit f9a1e76

File tree

1 file changed

+18
-20
lines changed
  • compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/inlining

1 file changed

+18
-20
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/phases/inlining/GraphManager.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,21 @@ final class GraphManager {
7272
this.useSize = TruffleCompilerOptions.InliningUseSize.getValue(rootContext.compilerOptions);
7373
}
7474

75+
TruffleTierContext rootContext() {
76+
return rootContext;
77+
}
78+
7579
@SuppressWarnings("try")
7680
Entry pe(TruffleCompilable truffleAST) {
7781
Entry entry = irCache.get(truffleAST);
7882
if (entry == null) {
7983
// the guest scope represents the guest language method of truffle
8084
try (AutoCloseable guestScope = rootContext.debug.scope("Truffle", new TruffleDebugJavaMethod(rootContext.task, truffleAST))) {
81-
final PEAgnosticInlineInvokePlugin plugin = newPlugin();
8285
final TruffleTierContext context = rootContext.createInlineContext(truffleAST);
8386
try (Scope hostScope = context.debug.scope("CreateGraph", context.graph);
8487
Indent indent = context.debug.logAndIndent("evaluate %s", context.graph);) {
85-
partialEvaluator.doGraphPE(context, plugin, graphCacheForInlining);
86-
context.graph.getAssumptions().record(new TruffleAssumption(context.getNodeRewritingAssumption(partialEvaluator.getProviders())));
87-
StructuredGraph graphAfterPE = copyGraphForDebugDump(context);
88-
postPartialEvaluationSuite.apply(context.graph, context);
89-
entry = new Entry(context.graph, plugin, graphAfterPE, useSize ? NodeCostUtil.computeGraphSize(context.graph) : -1);
90-
context.debug.dump(DebugContext.INFO_LEVEL, context.graph, "After PE Tier");
88+
TruffleAssumption nodeRewritingAssumption = new TruffleAssumption(context.getNodeRewritingAssumption(partialEvaluator.getProviders()));
89+
entry = pe(context, nodeRewritingAssumption, DebugContext.INFO_LEVEL);
9190
} catch (Throwable e) {
9291
throw context.debug.handle(e);
9392
}
@@ -99,21 +98,20 @@ Entry pe(TruffleCompilable truffleAST) {
9998
return entry;
10099
}
101100

102-
private PEAgnosticInlineInvokePlugin newPlugin() {
103-
return new PEAgnosticInlineInvokePlugin(partialEvaluator);
104-
}
105-
106-
TruffleTierContext rootContext() {
107-
return rootContext;
101+
Entry peRoot() {
102+
return pe(rootContext, null, DebugContext.BASIC_LEVEL);
108103
}
109104

110-
Entry peRoot() {
111-
final PEAgnosticInlineInvokePlugin plugin = newPlugin();
112-
partialEvaluator.doGraphPE(rootContext, plugin, graphCacheForInlining);
113-
StructuredGraph graphAfterPE = copyGraphForDebugDump(rootContext);
114-
postPartialEvaluationSuite.apply(rootContext.graph, rootContext);
115-
rootContext.debug.dump(DebugContext.BASIC_LEVEL, rootContext.graph, "After PE Tier");
116-
return new Entry(rootContext.graph, plugin, graphAfterPE, useSize ? NodeCostUtil.computeGraphSize(rootContext.graph) : -1);
105+
private Entry pe(TruffleTierContext context, TruffleAssumption nodeRewritingAssumption, int dumpLevel) {
106+
final PEAgnosticInlineInvokePlugin plugin = new PEAgnosticInlineInvokePlugin(partialEvaluator);
107+
partialEvaluator.doGraphPE(context, plugin, graphCacheForInlining);
108+
if (nodeRewritingAssumption != null) {
109+
context.graph.getAssumptions().record(nodeRewritingAssumption);
110+
}
111+
final StructuredGraph graphAfterPE = copyGraphForDebugDump(context);
112+
postPartialEvaluationSuite.apply(context.graph, context);
113+
context.debug.dump(dumpLevel, context.graph, "After PE Tier");
114+
return new Entry(context.graph, plugin, graphAfterPE, useSize ? NodeCostUtil.computeGraphSize(context.graph) : -1);
117115
}
118116

119117
UnmodifiableEconomicMap<Node, Node> doInline(Invoke invoke, StructuredGraph ir, TruffleCompilable truffleAST, InliningUtil.InlineeReturnAction returnAction) {

0 commit comments

Comments
 (0)