// Copyright 2022 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/compiler/turboshaft/graph.h" #include <algorithm> #include <iomanip> #include "src/base/logging.h" namespace v8::internal::compiler::turboshaft { // PrintDominatorTree prints the dominator tree in a format that looks like: // // 0 // ╠ 1 // ╠ 2 // ╠ 3 // ║ ╠ 4 // ║ ║ ╠ 5 // ║ ║ ╚ 6 // ║ ╚ 7 // ║ ╠ 8 // ║ ╚ 16 // ╚ 17 // // Where the numbers are the IDs of the Blocks. // Doing so is mostly straight forward, with the subtelty that we need to know // where to put "║" symbols (eg, in from of "╠ 5" above). The logic to do this // is basically: "if the current node is not the last of its siblings, then, // when going down to print its content, we add a "║" in front of each of its // children; otherwise (current node is the last of its siblings), we add a // blank space " " in front of its children". We maintain this information // using a stack (implemented with a std::vector). void Block::PrintDominatorTree(std::vector<const char*> tree_symbols, bool has_next) const { … } std::ostream& operator<<(std::ostream& os, PrintAsBlockHeader block_header) { … } std::ostream& operator<<(std::ostream& os, const Graph& graph) { … } std::ostream& operator<<(std::ostream& os, const Block::Kind& kind) { … } } // namespace v8::internal::compiler::turboshaft