Skip to content

Commit 67b4ac3

Browse files
committed
Formatting cleanup
1 parent 5975f9f commit 67b4ac3

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/GraphDecoder.java

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public NodeSourcePosition getNodeSourcePosition(NodeSourcePosition position) {
217217
* Sets the {@link #inliningLog} and {@link #optimizationLog} as the logs of the
218218
* {@link #graph} if they are non-null.
219219
*/
220-
public void replaceLogsForDecodedGraph() {
220+
public final void replaceLogsForDecodedGraph() {
221221
if (inliningLog != null) {
222222
graph.setInliningLog(inliningLog);
223223
}
@@ -267,7 +267,7 @@ public enum LoopScopeTrigger {
267267
}
268268

269269
/** Decoding state maintained for each loop in the encoded graph. */
270-
protected static class LoopScope {
270+
protected static final class LoopScope {
271271
public final MethodScope methodScope;
272272
public final LoopScope outer;
273273
public final int loopDepth;
@@ -333,18 +333,18 @@ protected static class LoopScope {
333333
protected LoopScope(MethodScope methodScope) {
334334
this.methodScope = methodScope;
335335
this.outer = null;
336+
this.loopDepth = 0;
337+
this.loopIteration = 0;
338+
this.trigger = LoopScopeTrigger.START;
336339
this.nextIterationFromLoopExitDuplication = methodScope.loopExplosion.duplicateLoopExits() || methodScope.loopExplosion.mergeLoops() ? new ArrayDeque<>(2) : null;
337340
this.nextIterationFromLoopEndDuplication = methodScope.loopExplosion.duplicateLoopEnds() ? new ArrayDeque<>(2) : null;
338341
this.nextIterationsFromUnrolling = methodScope.loopExplosion.unrollLoops() ? new ArrayDeque<>(2) : null;
339-
this.loopDepth = 0;
340-
this.loopIteration = 0;
341342
this.iterationStates = null;
342343
this.loopBeginOrderId = -1;
343344
int nodeCount = methodScope.encodedGraph.nodeStartOffsets.length;
344345
this.nodesToProcess = new BitSet(methodScope.maxFixedNodeOrderId);
345346
this.createdNodes = new Node[nodeCount];
346347
this.initialCreatedNodes = null;
347-
this.trigger = LoopScopeTrigger.START;
348348
this.writtenNodes = null;
349349
}
350350

@@ -358,7 +358,8 @@ protected LoopScope(MethodScope methodScope) {
358358
protected LoopScope(MethodScope methodScope, LoopScope outer, int loopDepth, int loopIteration, int loopBeginOrderId, LoopScopeTrigger trigger, Node[] initialCreatedNodes, Node[] createdNodes,
359359
Deque<LoopScope> nextIterationFromLoopExitDuplication,
360360
Deque<LoopScope> nextIterationFromLoopEndDuplication,
361-
Deque<LoopScope> nextIterationsFromUnrolling, EconomicMap<LoopExplosionState, LoopExplosionState> iterationStates) {
361+
Deque<LoopScope> nextIterationsFromUnrolling,
362+
EconomicMap<LoopExplosionState, LoopExplosionState> iterationStates) {
362363
this(methodScope, outer, loopDepth, loopIteration, loopBeginOrderId, trigger, initialCreatedNodes, createdNodes, nextIterationFromLoopExitDuplication, nextIterationFromLoopEndDuplication,
363364
nextIterationsFromUnrolling, iterationStates, true);
364365
}
@@ -375,7 +376,8 @@ protected LoopScope(MethodScope methodScope, LoopScope outer, int loopDepth, int
375376
protected LoopScope(MethodScope methodScope, LoopScope outer, int loopDepth, int loopIteration, int loopBeginOrderId, LoopScopeTrigger trigger, Node[] initialCreatedNodes, Node[] createdNodes,
376377
Deque<LoopScope> nextIterationFromLoopExitDuplication,
377378
Deque<LoopScope> nextIterationFromLoopEndDuplication,
378-
Deque<LoopScope> nextIterationsFromUnrolling, EconomicMap<LoopExplosionState, LoopExplosionState> iterationStates,
379+
Deque<LoopScope> nextIterationsFromUnrolling,
380+
EconomicMap<LoopExplosionState, LoopExplosionState> iterationStates,
379381
boolean reuseInitialNodes) {
380382
this.methodScope = methodScope;
381383
this.outer = outer;
@@ -507,8 +509,8 @@ public boolean hasIterationsToProcess() {
507509
* @param remove determines if the query of the next iteration should remove it from the
508510
* list of iterations to be processed
509511
* @return the next {@link LoopScope} to be processed that has been created in the context
510-
* of decoding this loop scope. Note that the order is not necessarily reflecting
511-
* the number of loop iterations.
512+
* of decoding this loop scope, or null if there is none. Note that the order is not
513+
* necessarily reflecting the number of loop iterations.
512514
*/
513515
public LoopScope getNextIterationToProcess(boolean remove) {
514516
if (nextIterationFromLoopEndDuplication != null && !nextIterationFromLoopEndDuplication.isEmpty()) {
@@ -652,6 +654,8 @@ public GraphDecoder(Architecture architecture, StructuredGraph graph) {
652654
reusableFloatingNodes = EconomicMap.create(Equivalence.IDENTITY);
653655
}
654656

657+
// #region Main decoder loop
658+
655659
public final void decode(EncodedGraph encodedGraph) {
656660
decode(encodedGraph, null);
657661
}
@@ -797,6 +801,8 @@ private static void propagateCreatedNodes(LoopScope loopScope) {
797801
}
798802
}
799803

804+
// #endregion
805+
800806
public static final boolean DUMP_DURING_FIXED_NODE_PROCESSING = false;
801807

802808
protected LoopScope processNextNode(MethodScope methodScope, LoopScope loopScope) {
@@ -907,14 +913,12 @@ protected LoopScope processNextNode(MethodScope methodScope, LoopScope loopScope
907913
if (methodScope.loopExplosion.useExplosion()) {
908914
handleLoopExplosionBegin(methodScope, loopScope, (LoopBeginNode) node);
909915
}
910-
911916
} else if (node instanceof LoopExitNode) {
912917
if (methodScope.loopExplosion.useExplosion()) {
913918
handleLoopExplosionProxyNodes(methodScope, loopScope, successorAddScope, (LoopExitNode) node, nodeOrderId);
914919
} else {
915920
handleProxyNodes(methodScope, loopScope, (LoopExitNode) node);
916921
}
917-
918922
} else if (node instanceof MergeNode) {
919923
handleMergeNode(((MergeNode) node));
920924
} else if (node instanceof AbstractEndNode) {
@@ -1772,6 +1776,8 @@ protected Node handleFloatingNodeAfterAdd(MethodScope methodScope, LoopScope loo
17721776
return node;
17731777
}
17741778

1779+
// #region Reading from encoded graph
1780+
17751781
/**
17761782
* Process successor edges of a node. We create the successor nodes so that we can fill the
17771783
* successor list, but no properties or edges are loaded yet. That is done when the successor is
@@ -1905,6 +1911,10 @@ protected Object readObject(MethodScope methodScope) {
19051911
return methodScope.encodedGraph.getObject(methodScope.reader.getUVInt());
19061912
}
19071913

1914+
// #endregion
1915+
1916+
// #region Cleanup
1917+
19081918
/**
19091919
* Removes unnecessary nodes from the graph after decoding.
19101920
*
@@ -1914,7 +1924,7 @@ protected void cleanupGraph(MethodScope rootMethodScope) {
19141924
assert verifyEdges();
19151925
}
19161926

1917-
protected boolean verifyEdges() {
1927+
private boolean verifyEdges() {
19181928
for (Node node : graph.getNodes()) {
19191929
assert node.isAlive();
19201930
for (Node i : node.inputs()) {
@@ -1937,6 +1947,8 @@ protected boolean verifyEdges() {
19371947
}
19381948
return true;
19391949
}
1950+
1951+
// #endregion
19401952
}
19411953

19421954
class LoopDetector implements Runnable {
@@ -2256,7 +2268,7 @@ private void findLoopExits(Loop loop) {
22562268
* // outerLoopContinueCode that uses values proxied inside the loop
22572269
* </pre>
22582270
*
2259-
* We would produce two loop exits that merge booth on the outerLoopContinueCode.
2271+
* We would produce two loop exits that merge both on the outerLoopContinueCode.
22602272
* This would require the generation of complex phi and proxy constructs, thus we include the merge inside the
22612273
* loop if we find a subsequent loop explosion merge.
22622274
*/
@@ -2286,27 +2298,22 @@ private void findLoopExits(Loop loop) {
22862298
// we found a shared merge as outlined above
22872299
if (mergesToRemove.size() > 0) {
22882300
assert merges.size() < loop.exits.size() : Assertions.errorMessage(merges, loop, loop.exits);
2289-
outer: for (MergeNode merge : mergesToRemove) {
2301+
for (MergeNode merge : mergesToRemove) {
22902302
FixedNode current = merge;
2291-
while (current != null) {
2292-
if (current instanceof FixedWithNextNode) {
2293-
current = ((FixedWithNextNode) current).next();
2294-
continue;
2295-
}
2296-
if (current instanceof EndNode && methodScope.loopExplosionMerges.contains(((EndNode) current).merge())) {
2297-
// we found the place for the loop exit introduction since the subsequent
2298-
// merge has a frame state
2299-
loop.exits.removeIf(x -> x.merge() == merge);
2300-
loop.exits.add((EndNode) current);
2301-
break;
2302-
}
2303-
/*
2304-
* No next merge was found, this can only mean no immediate unroll happend next,
2305-
* i.e., there is no subsequent iteration of any loop exploded directly after,
2306-
* thus no loop exit possible.
2307-
*/
2308-
continue outer;
2303+
while (current instanceof FixedWithNextNode c) {
2304+
current = c.next();
2305+
}
2306+
if (current instanceof EndNode end && methodScope.loopExplosionMerges.contains(end.merge())) {
2307+
// we found the place for the loop exit introduction since the subsequent
2308+
// merge has a frame state
2309+
loop.exits.removeIf(x -> x.merge() == merge);
2310+
loop.exits.add(end);
23092311
}
2312+
/*
2313+
* Else, no next merge was found, this can only mean no immediate unroll happend
2314+
* next, i.e., there is no subsequent iteration of any loop exploded directly after,
2315+
* thus no loop exit possible.
2316+
*/
23102317
}
23112318
}
23122319
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/InliningLogCodec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,10 @@ private InliningLog decode(Object encodedObject) {
206206
* @param orderId the order ID of the registered node
207207
*/
208208
public void registerNode(InliningLog inliningLog, Node node, int orderId) {
209-
if (!(node instanceof Invokable)) {
209+
if (!(node instanceof Invokable invokable)) {
210210
return;
211211
}
212212
assert orderIdToCallsite != null : "registerNode should be called after decode";
213-
Invokable invokable = (Invokable) node;
214213
if (inliningLog.containsLeafCallsite(invokable)) {
215214
return;
216215
}

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/TruffleTierContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ public static TruffleTierContext createInitialContext(PartialEvaluator partialEv
109109
DebugContext debug,
110110
TruffleCompilable compilable,
111111
CompilationIdentifier compilationId, SpeculationLog log,
112-
TruffleCompilationTask task, PerformanceInformationHandler handler) {
112+
TruffleCompilationTask task,
113+
PerformanceInformationHandler handler) {
113114

114115
boolean readyForCompilation = compilable.prepareForCompilation(true, task.tier(), !task.hasNextTier());
115116
if (!readyForCompilation) {

truffle/src/com.oracle.truffle.compiler/src/com/oracle/truffle/compiler/TruffleCompilable.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ default int getSuccessfulCompilationCount() {
227227
* mean it will always be inlined, as inlining is a complex process that takes many factors into
228228
* account. If this method returns <code>false</code>, it will never be inlined. This typically
229229
* means that compilation with this compilable as the root has failed.
230-
*
231-
*
232230
*/
233231
default boolean canBeInlined() {
234232
return true;

0 commit comments

Comments
 (0)