MCPcopy Create free account
hub / github.com/nodejs/node / initWorkList

Method initWorkList

deps/v8/tools/turbolizer/src/graph-layout.ts:98–137  ·  view source on GitHub ↗
(startNodes: Array<GraphNode>)

Source from the content-addressed store, hash-verified

96 }
97
98 private initWorkList(startNodes: Array<GraphNode>): void {
99 const workList = startNodes.slice();
100 while (workList.length != 0) {
101 const node = workList.pop();
102 let changed = false;
103 if (node.rank == C.MAX_RANK_SENTINEL) {
104 node.rank = 1;
105 changed = true;
106 }
107 let begin = 0;
108 let end = node.inputs.length;
109 if (node.nodeLabel.opcode === "Phi" ||
110 node.nodeLabel.opcode === "EffectPhi" ||
111 node.nodeLabel.opcode === "InductionVariablePhi") {
112 // Keep with merge or loop node
113 begin = node.inputs.length - 1;
114 } else if (node.hasBackEdges()) {
115 end = 1;
116 }
117 for (let l = begin; l < end; ++l) {
118 const input = node.inputs[l].source;
119 if (input.visible && input.rank >= node.rank) {
120 node.rank = input.rank + 1;
121 changed = true;
122 }
123 }
124 if (changed) {
125 const hasBackEdges = node.hasBackEdges();
126 for (let l = node.outputs.length - 1; l >= 0; --l) {
127 if (hasBackEdges && (l != 0)) {
128 workList.unshift(node.outputs[l].target);
129 } else {
130 workList.push(node.outputs[l].target);
131 }
132 }
133 }
134 this.maxRank = Math.max(node.rank, this.maxRank);
135 }
136 this.trace("layoutGraph work list");
137 }
138
139 private dfsFindRankLate(visited: Array<boolean>, node: GraphNode): void {
140 if (visited[node.id]) return;

Callers 1

fullRebuildMethod · 0.95

Calls 7

traceMethod · 0.95
popMethod · 0.80
unshiftMethod · 0.80
sliceMethod · 0.65
hasBackEdgesMethod · 0.45
pushMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected