Skip to content

Commit 3c46c03

Browse files
committed
[GR-55711] Use notifyAfterInline for marking inlining in TrivialInline.
PullRequest: graal/18381
2 parents c81f44c + c448565 commit 3c46c03

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ public boolean isTrivialMethod() {
144144
return isTrivialMethod;
145145
}
146146

147-
public void setTrivialMethod(boolean trivial) {
148-
isTrivialMethod = trivial;
147+
public void setTrivialMethod() {
148+
isTrivialMethod = true;
149149
}
150150

151151
public boolean isTrivialInliningDisabled() {
152152
return trivialInliningDisabled;
153153
}
154154

155-
public void setTrivialInliningDisabled(boolean trivialInliningDisabled) {
156-
this.trivialInliningDisabled = trivialInliningDisabled;
155+
public void setTrivialInliningDisabled() {
156+
trivialInliningDisabled = true;
157157
}
158158

159159
public void setCustomParseFunction(ParseFunction parseFunction) {

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompileQueue.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected PhaseSuite<HighTierContext> getAfterParseSuite() {
184184
private final boolean printMethodHistogram = NativeImageOptions.PrintMethodHistogram.getValue();
185185
private final boolean optionAOTTrivialInline = SubstrateOptions.AOTTrivialInline.getValue();
186186

187-
public record UnpublishedTrivialMethods(CompilationGraph unpublishedGraph, boolean isTrivial) {
187+
public record UnpublishedTrivialMethods(CompilationGraph unpublishedGraph, boolean newlyTrivial) {
188188
}
189189

190190
private final ConcurrentMap<HostedMethod, UnpublishedTrivialMethods> unpublishedTrivialMethods = new ConcurrentHashMap<>();
@@ -701,12 +701,8 @@ private void parseDeoptimizationTargetMethods() {
701701
});
702702
}
703703

704-
private static boolean checkTrivial(HostedMethod method, StructuredGraph graph) {
705-
if (!method.compilationInfo.isTrivialMethod() && method.canBeInlined() && InliningUtilities.isTrivialMethod(graph)) {
706-
return true;
707-
} else {
708-
return false;
709-
}
704+
private static boolean checkNewlyTrivial(HostedMethod method, StructuredGraph graph) {
705+
return !method.compilationInfo.isTrivialMethod() && method.canBeInlined() && InliningUtilities.isTrivialMethod(graph);
710706
}
711707

712708
@SuppressWarnings("try")
@@ -731,8 +727,9 @@ protected void inlineTrivialMethods(DebugContext debug) throws InterruptedExcept
731727
}
732728
for (Map.Entry<HostedMethod, UnpublishedTrivialMethods> entry : unpublishedTrivialMethods.entrySet()) {
733729
entry.getKey().compilationInfo.setCompilationGraph(entry.getValue().unpublishedGraph);
734-
if (entry.getValue().isTrivial) {
735-
entry.getKey().compilationInfo.setTrivialMethod(true);
730+
if (entry.getValue().newlyTrivial) {
731+
inliningProgress = true;
732+
entry.getKey().compilationInfo.setTrivialMethod();
736733
}
737734
}
738735
unpublishedTrivialMethods.clear();
@@ -746,12 +743,16 @@ class TrivialInliningPlugin implements InlineInvokePlugin {
746743
@Override
747744
public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
748745
if (makeInlineDecision((HostedMethod) b.getMethod(), (HostedMethod) method) && b.recursiveInliningDepth(method) == 0) {
749-
inlinedDuringDecoding = true;
750746
return InlineInfo.createStandardInlineInfo(method);
751747
} else {
752748
return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION;
753749
}
754750
}
751+
752+
@Override
753+
public void notifyAfterInline(ResolvedJavaMethod methodToInline) {
754+
inlinedDuringDecoding = true;
755+
}
755756
}
756757

757758
class InliningGraphDecoder extends PEGraphDecoder {
@@ -839,7 +840,7 @@ private void doInlineTrivial(DebugContext debug, HostedMethod method) {
839840
* that there was inlining progress, which triggers another round of inlining
840841
* where only "always inline" methods are inlined.
841842
*/
842-
method.compilationInfo.setTrivialInliningDisabled(true);
843+
method.compilationInfo.setTrivialInliningDisabled();
843844
inliningProgress = true;
844845

845846
} else {
@@ -849,12 +850,7 @@ private void doInlineTrivial(DebugContext debug, HostedMethod method) {
849850
* non-deterministic. This is why we are saving graphs to be published at the
850851
* end of each round.
851852
*/
852-
if (checkTrivial(method, graph)) {
853-
unpublishedTrivialMethods.put(method, new UnpublishedTrivialMethods(CompilationGraph.encode(graph), true));
854-
inliningProgress = true;
855-
} else {
856-
unpublishedTrivialMethods.put(method, new UnpublishedTrivialMethods(CompilationGraph.encode(graph), false));
857-
}
853+
unpublishedTrivialMethods.put(method, new UnpublishedTrivialMethods(CompilationGraph.encode(graph), checkNewlyTrivial(method, graph)));
858854
}
859855
}
860856
} catch (Throwable ex) {
@@ -1056,8 +1052,8 @@ private void defaultParseFunction(DebugContext debug, HostedMethod method, Compi
10561052
notifyBeforeEncode(method, graph);
10571053
assert GraphOrder.assertSchedulableGraph(graph);
10581054
method.compilationInfo.encodeGraph(graph);
1059-
if (checkTrivial(method, graph)) {
1060-
method.compilationInfo.setTrivialMethod(true);
1055+
if (checkNewlyTrivial(method, graph)) {
1056+
method.compilationInfo.setTrivialMethod();
10611057
}
10621058
} catch (Throwable ex) {
10631059
GraalError error = ex instanceof GraalError ? (GraalError) ex : new GraalError(ex);

0 commit comments

Comments
 (0)