Commit df98f6f4 authored by Danylo Boiko's avatar Danylo Boiko Committed by V8 LUCI CQ

[turboshaft][turbolizer] Changed type of blocks Ids in JSON output

Bug: v8:12783
Change-Id: I718ba43c63d8010f9a512e6bd47ea58fbb4970ce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3756142
Commit-Queue: Danylo Boiko <danielboyko02@gmail.com>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81661}
parent 1895e44d
......@@ -31,7 +31,7 @@ void JSONTurboshaftGraphWriter::PrintNodes() {
first = false;
os_ << "{\"id\":" << turboshaft_graph_.Index(op).id() << ",";
os_ << "\"title\":\"" << OpcodeName(op.opcode) << "\",";
os_ << "\"block_id\":\"" << block.index() << "\",";
os_ << "\"block_id\":" << block.index().id() << ",";
os_ << "\"op_properties_type\":\"" << op.properties() << "\",";
os_ << "\"properties\":\"";
op.PrintOptions(os_);
......@@ -60,7 +60,7 @@ void JSONTurboshaftGraphWriter::PrintBlocks() {
for (const Block& block : turboshaft_graph_.blocks()) {
if (!first_block) os_ << ",\n";
first_block = false;
os_ << "{\"id\":\"" << block.index() << "\",";
os_ << "{\"id\":" << block.index().id() << ",";
os_ << "\"type\":\"" << block.kind() << "\",";
os_ << "\"deferred\":" << std::boolalpha << block.IsDeferred() << ",";
os_ << "\"predecessors\":[";
......@@ -68,7 +68,7 @@ void JSONTurboshaftGraphWriter::PrintBlocks() {
for (const Block* pred : block.Predecessors()) {
if (!first_predecessor) os_ << ", ";
first_predecessor = false;
os_ << "\"" << pred->index() << "\"";
os_ << pred->index().id();
}
os_ << "]}";
}
......
......@@ -39,16 +39,14 @@ export class TurboshaftGraphPhase extends Phase {
private parseBlocksFromJSON(blocksJson): void {
for (const blockJson of blocksJson) {
// TODO (danylo boiko) Change type of block id in JSON output
const numId = Number(blockJson.id.substring(1));
const block = new TurboshaftGraphBlock(numId, blockJson.type,
const block = new TurboshaftGraphBlock(blockJson.id, blockJson.type,
blockJson.deferred, blockJson.predecessors);
this.data.blocks.push(block);
this.blockIdToBlockMap[block.id] = block;
}
for (const block of this.blockIdToBlockMap) {
for (const predecessor of block.predecessors) {
const source = this.blockIdToBlockMap[Number(predecessor.substring(1))];
const source = this.blockIdToBlockMap[predecessor];
const edge = new TurboshaftGraphEdge(block, source);
block.inputs.push(edge);
source.outputs.push(edge);
......@@ -58,8 +56,7 @@ export class TurboshaftGraphPhase extends Phase {
private parseNodesFromJSON(nodesJson): void {
for (const nodeJson of nodesJson) {
const numId = Number(nodeJson.block_id.substring(1));
const block = this.blockIdToBlockMap[numId];
const block = this.blockIdToBlockMap[nodeJson.block_id];
const node = new TurboshaftGraphNode(nodeJson.id, nodeJson.title,
block, nodeJson.op_properties_type, nodeJson.properties);
block.nodes.push(node);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment