Commit 64aeb085 authored by Nico Hartmann's avatar Nico Hartmann Committed by V8 LUCI CQ

Reland "[turboshaft] Print operator properties as custom data for turbolizer"

This is a reland of commit 6e0251f9

No changes since revert. Was reverted on suspicion of breaking node integration, but was not the culprit.

Original change's description:
> [turboshaft] Print operator properties as custom data for turbolizer
>
> Bug: v8:12783
> Change-Id: Ie5812217b3e858d94174087fc492887b00dd2e9a
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3820581
> Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
> Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
> Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#82401}

Bug: v8:12783
Change-Id: I3d220e031d89f960b8cd23860f82ec0a8f147aa2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3827665
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82412}
parent 6033256a
......@@ -2594,12 +2594,22 @@ struct PrintTurboshaftGraphPhase {
UnparkedScopeIfNeeded scope(data->broker());
AllowHandleDereference allow_deref;
TurboJsonFile json_of(data->info(), std::ios_base::app);
json_of << "{\"name\":\"" << phase
<< "\",\"type\":\"turboshaft_graph\",\"data\":"
<< AsJSON(data->turboshaft_graph(), data->node_origins(),
temp_zone)
<< "},\n";
{
TurboJsonFile json_of(data->info(), std::ios_base::app);
json_of << "{\"name\":\"" << phase
<< "\",\"type\":\"turboshaft_graph\",\"data\":"
<< AsJSON(data->turboshaft_graph(), data->node_origins(),
temp_zone)
<< "},\n";
}
PrintTurboshaftCustomDataPerOperation(
data->info(), "Properties", data->turboshaft_graph(),
[](std::ostream& stream, const turboshaft::Graph& graph,
turboshaft::OpIndex index) -> bool {
const auto& op = graph.Get(index);
op.PrintOptions(stream);
return true;
});
}
if (data->info()->trace_turbo_graph()) {
......
......@@ -37,10 +37,7 @@ void JSONTurboshaftGraphWriter::PrintNodes() {
os_ << "{\"id\":" << turboshaft_graph_.Index(op).id() << ",";
os_ << "\"title\":\"" << OpcodeName(op.opcode) << "\",";
os_ << "\"block_id\":" << block.index().id() << ",";
os_ << "\"op_properties_type\":\"" << op.properties() << "\",";
os_ << "\"properties\":\"";
op.PrintOptions(os_);
os_ << "\"";
os_ << "\"op_properties_type\":\"" << op.properties() << "\"";
if (origins_) {
NodeOrigin origin = origins_->GetNodeOrigin(index.id());
if (origin.IsKnown()) {
......@@ -97,4 +94,25 @@ std::ostream& operator<<(std::ostream& os, const TurboshaftGraphAsJSON& ad) {
return os;
}
void PrintTurboshaftCustomDataPerOperation(
OptimizedCompilationInfo* info, const char* data_name, const Graph& graph,
std::function<bool(std::ostream&, const Graph&, OpIndex)> printer) {
DCHECK(printer);
TurboJsonFile json_of(info, std::ios_base::app);
json_of << "{\"name\":\"" << data_name
<< "\", \"type\":\"turboshaft_custom_data\", "
"\"data_target\":\"operations\", \"data\":[";
bool first = true;
for (auto index : graph.AllOperationIndices()) {
std::stringstream stream;
if (printer(stream, graph, index)) {
json_of << (first ? "\n" : ",\n") << "{\"key\":" << index.id()
<< ", \"value\":\"" << stream.str() << "\"}";
first = false;
}
}
json_of << "]},\n";
}
} // namespace v8::internal::compiler::turboshaft
......@@ -48,6 +48,10 @@ class JSONTurboshaftGraphWriter {
NodeOriginTable* origins_;
};
void PrintTurboshaftCustomDataPerOperation(
OptimizedCompilationInfo* info, const char* data_name, const Graph& graph,
std::function<bool(std::ostream&, const Graph&, OpIndex)> printer);
} // namespace v8::internal::compiler::turboshaft
#endif // V8_COMPILER_TURBOSHAFT_GRAPH_VISUALIZER_H_
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