| 137 | } |
| 138 | |
| 139 | private dfsFindRankLate(visited: Array<boolean>, node: GraphNode): void { |
| 140 | if (visited[node.id]) return; |
| 141 | visited[node.id] = true; |
| 142 | const originalRank = node.rank; |
| 143 | let newRank = node.rank; |
| 144 | let isFirstInput = true; |
| 145 | for (const outputEdge of node.outputs) { |
| 146 | const output = outputEdge.target; |
| 147 | this.dfsFindRankLate(visited, output); |
| 148 | const outputRank = output.rank; |
| 149 | if (output.visible && (isFirstInput || outputRank <= newRank) && |
| 150 | (outputRank > originalRank)) { |
| 151 | newRank = outputRank - 1; |
| 152 | } |
| 153 | isFirstInput = false; |
| 154 | } |
| 155 | if (node.nodeLabel.opcode !== "Start" && node.nodeLabel.opcode !== "Phi" |
| 156 | && node.nodeLabel.opcode !== "EffectPhi" |
| 157 | && node.nodeLabel.opcode !== "InductionVariablePhi") { |
| 158 | node.rank = newRank; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | private dfsRankOrder(visited: Array<boolean>, node: GraphNode): void { |
| 163 | if (visited[node.id]) return; |