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

Method parsePhases

deps/v8/tools/turbolizer/src/source-resolver.ts:129–223  ·  view source on GitHub ↗
(phasesJson)

Source from the content-addressed store, hash-verified

127 }
128
129 public parsePhases(phasesJson): void {
130 const instructionsPhase = new InstructionsPhase();
131 const selectedDynamicPhases = new Array<DynamicPhase>();
132 const nodeMap = new Array<GraphNode | TurboshaftGraphOperation>();
133 let lastTurboshaftGraphPhase: TurboshaftGraphPhase = null;
134 let lastGraphPhase: GraphPhase | TurboshaftGraphPhase = null;
135 for (const [, genericPhase] of Object.entries<GenericPhase>(phasesJson)) {
136 switch (genericPhase.type) {
137 case PhaseType.Disassembly:
138 const castedDisassembly = genericPhase as DisassemblyPhase;
139 const disassemblyPhase = new DisassemblyPhase(castedDisassembly.name,
140 castedDisassembly.data, castedDisassembly?.blockIdToOffset);
141 this.disassemblyPhase = disassemblyPhase;
142 break;
143 case PhaseType.Schedule:
144 const castedSchedule = genericPhase as SchedulePhase;
145 const schedulePhase = new SchedulePhase(castedSchedule.name, castedSchedule.data);
146 this.phaseNames.set(schedulePhase.name, this.phases.length);
147 this.phases.push(schedulePhase);
148 selectedDynamicPhases.push(schedulePhase);
149 if (lastGraphPhase instanceof GraphPhase) {
150 schedulePhase.positions = lastGraphPhase.positions;
151 } else {
152 const oldIdToNewIdMap = this.getOldIdToNewIdMap(this.phases.length - 1);
153 schedulePhase.positions.merge(lastGraphPhase.data.nodes, oldIdToNewIdMap);
154 }
155 schedulePhase.instructionsPhase = instructionsPhase;
156 break;
157 case PhaseType.Sequence:
158 const castedSequence = camelize(genericPhase) as SequencePhase;
159 const sequencePhase = new SequencePhase(castedSequence.name, castedSequence.blocks,
160 castedSequence.registerAllocation);
161 const prevPhase = this.getDynamicPhase(this.phases.length - 1);
162 sequencePhase.positions = prevPhase.positions;
163 sequencePhase.instructionsPhase = prevPhase.instructionsPhase;
164 this.phaseNames.set(sequencePhase.name, this.phases.length);
165 this.phases.push(sequencePhase);
166 break;
167 case PhaseType.Instructions:
168 const castedInstructions = genericPhase as InstructionsPhase;
169 if (instructionsPhase.name === "") {
170 instructionsPhase.name = castedInstructions.name;
171 } else {
172 instructionsPhase.name += `, ${castedInstructions.name}`;
173 }
174 instructionsPhase.parseNodeIdToInstructionRangeFromJSON(castedInstructions
175 ?.nodeIdToInstructionRange);
176 instructionsPhase.parseBlockIdToInstructionRangeFromJSON(castedInstructions
177 ?.blockIdToInstructionRange);
178 instructionsPhase.parseInstructionOffsetToPCOffsetFromJSON(castedInstructions
179 ?.instructionOffsetToPCOffset);
180 instructionsPhase.parseCodeOffsetsInfoFromJSON(castedInstructions?.codeOffsetsInfo);
181 break;
182 case PhaseType.Graph:
183 const castedGraph = genericPhase as GraphPhase;
184 const graphPhase = new GraphPhase(castedGraph.name, castedGraph.data,
185 nodeMap as Array<GraphNode>, this.sources, this.inlinings);
186 this.phaseNames.set(graphPhase.name, this.phases.length);

Callers 1

loadFileFunction · 0.80

Calls 15

getOldIdToNewIdMapMethod · 0.95
getDynamicPhaseMethod · 0.95
sortSourcePositionsMethod · 0.95
camelizeFunction · 0.90
isDynamicMethod · 0.80
entriesMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected