diff options
Diffstat (limited to 'deps/v8/tools/turbolizer/src/phases/instructions-phase.ts')
-rw-r--r-- | deps/v8/tools/turbolizer/src/phases/instructions-phase.ts | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/deps/v8/tools/turbolizer/src/phases/instructions-phase.ts b/deps/v8/tools/turbolizer/src/phases/instructions-phase.ts index 5e0d94dc48..b48f917879 100644 --- a/deps/v8/tools/turbolizer/src/phases/instructions-phase.ts +++ b/deps/v8/tools/turbolizer/src/phases/instructions-phase.ts @@ -62,28 +62,35 @@ export class InstructionsPhase extends Phase { return keyPcOffsets; } - public nodesForPCOffset(offset: number): Array<string> { - if (this.pcOffsets.length === 0) return new Array<string>(); + public instructionsForPCOffset(offset: number): Array<number> { + if (this.pcOffsets.length === 0) return new Array<number>(); for (const key of this.pcOffsets) { if (key <= offset) { - const instructions = this.pcOffsetToInstructions.get(key); - const nodes = new Array<string>(); - for (const instruction of instructions) { - for (const [nodeId, range] of this.nodeIdToInstructionRange.entries()) { - if (!range) continue; - const [start, end] = range; - if (start == end && instruction == start) { - nodes.push(String(nodeId)); - } - if (start <= instruction && instruction < end) { - nodes.push(String(nodeId)); - } - } + return this.pcOffsetToInstructions.get(key); + } + } + return new Array<number>(); + } + + public nodesForInstructions(instructionIds: Iterable<number>): Array<string> { + const nodes = new Array<string>(); + for (const instruction of instructionIds) { + for (const [nodeId, range] of this.nodeIdToInstructionRange.entries()) { + if (!range) continue; + const [start, end] = range; + if (start == end && instruction == start) { + nodes.push(String(nodeId)); + } + if (start <= instruction && instruction < end) { + nodes.push(String(nodeId)); } - return nodes; } } - return new Array<string>(); + return nodes; + } + + public nodesForPCOffset(offset: number): Array<string> { + return this.nodesForInstructions(this.instructionsForPCOffset(offset)); } public nodesToKeyPcOffsets(nodeIds: Set<string>): Array<TurbolizerInstructionStartInfo> { |