#include "src/compiler/graph-visualizer.h"
#include <memory>
#include <optional>
#include <sstream>
#include <string>
#include "src/base/vector.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/codegen/source-position.h"
#include "src/compiler/all-nodes.h"
#include "src/compiler/backend/register-allocation.h"
#include "src/compiler/backend/register-allocator.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/graph.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/node.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator-properties.h"
#include "src/compiler/operator.h"
#include "src/compiler/schedule.h"
#include "src/objects/script-inl.h"
#include "src/objects/shared-function-info.h"
#include "src/utils/ostreams.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-disassembler.h"
#endif
namespace v8 {
namespace internal {
namespace compiler {
const char* get_cached_trace_turbo_filename(OptimizedCompilationInfo* info) { … }
TurboJsonFile::TurboJsonFile(OptimizedCompilationInfo* info,
std::ios_base::openmode mode)
: … { … }
TurboJsonFile::~TurboJsonFile() { … }
TurboCfgFile::TurboCfgFile(Isolate* isolate)
: … { … }
TurboCfgFile::~TurboCfgFile() { … }
std::ostream& operator<<(std::ostream& out,
const SourcePositionAsJSON& asJSON) { … }
std::ostream& operator<<(std::ostream& out, const NodeOriginAsJSON& asJSON) { … }
void JsonPrintBytecodeSource(std::ostream& os, int source_id,
std::unique_ptr<char[]> function_name,
DirectHandle<BytecodeArray> bytecode_array) { … }
void JsonPrintFunctionSource(std::ostream& os, int source_id,
std::unique_ptr<char[]> function_name,
Handle<Script> script, Isolate* isolate,
Handle<SharedFunctionInfo> shared, bool with_key) { … }
int SourceIdAssigner::GetIdFor(Handle<SharedFunctionInfo> shared) { … }
namespace {
void JsonPrintInlinedFunctionInfo(
std::ostream& os, int source_id, int inlining_id,
const OptimizedCompilationInfo::InlinedFunctionHolder& h) { … }
}
void JsonPrintAllBytecodeSources(std::ostream& os,
OptimizedCompilationInfo* info) { … }
void JsonPrintAllSourceWithPositions(std::ostream& os,
OptimizedCompilationInfo* info,
Isolate* isolate) { … }
#if V8_ENABLE_WEBASSEMBLY
void JsonPrintAllSourceWithPositionsWasm(
std::ostream& os, const wasm::WasmModule* module,
const wasm::WireBytesStorage* wire_bytes,
base::Vector<WasmInliningPosition> positions) { … }
#endif
std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
const char* optional_base_dir,
const char* phase,
const char* suffix) { … }
static int SafeId(Node* node) { … }
static const char* SafeMnemonic(Node* node) { … }
JSONGraphWriter::JSONGraphWriter(std::ostream& os, const Graph* graph,
const SourcePositionTable* positions,
const NodeOriginTable* origins)
: … { … }
void JSONGraphWriter::PrintPhase(const char* phase_name) { … }
void JSONGraphWriter::Print() { … }
void JSONGraphWriter::PrintNode(Node* node, bool is_live) { … }
void JSONGraphWriter::PrintEdges(Node* node) { … }
void JSONGraphWriter::PrintEdge(Node* from, int index, Node* to) { … }
std::optional<Type> JSONGraphWriter::GetType(Node* node) { … }
std::ostream& operator<<(std::ostream& os, const GraphAsJSON& ad) { … }
class GraphC1Visualizer { … };
void GraphC1Visualizer::PrintIndent() { … }
GraphC1Visualizer::GraphC1Visualizer(std::ostream& os, Zone* zone)
: … { … }
void GraphC1Visualizer::PrintStringProperty(const char* name,
const char* value) { … }
void GraphC1Visualizer::PrintLongProperty(const char* name, int64_t value) { … }
void GraphC1Visualizer::PrintBlockProperty(const char* name, int rpo_number) { … }
void GraphC1Visualizer::PrintIntProperty(const char* name, int value) { … }
void GraphC1Visualizer::PrintCompilation(const OptimizedCompilationInfo* info) { … }
void GraphC1Visualizer::PrintNodeId(Node* n) { … }
void GraphC1Visualizer::PrintNode(Node* n) { … }
template <typename InputIterator>
void GraphC1Visualizer::PrintInputs(InputIterator* i, int count,
const char* prefix) { … }
void GraphC1Visualizer::PrintInputs(Node* node) { … }
void GraphC1Visualizer::PrintType(Node* node) { … }
void GraphC1Visualizer::PrintSchedule(const char* phase,
const Schedule* schedule,
const SourcePositionTable* positions,
const InstructionSequence* instructions) { … }
void GraphC1Visualizer::PrintLiveRanges(const char* phase,
const RegisterAllocationData* data) { … }
void GraphC1Visualizer::PrintLiveRangeChain(const TopLevelLiveRange* range,
const char* type) { … }
void GraphC1Visualizer::PrintLiveRange(const LiveRange* range, const char* type,
int vreg) { … }
std::ostream& operator<<(std::ostream& os, const AsC1VCompilation& ac) { … }
std::ostream& operator<<(std::ostream& os, const AsC1V& ac) { … }
std::ostream& operator<<(std::ostream& os,
const AsC1VRegisterAllocationData& ac) { … }
const int kUnvisited = …;
const int kOnStack = …;
const int kVisited = …;
std::ostream& operator<<(std::ostream& os, const AsRPO& ar) { … }
namespace {
void PrintIndent(std::ostream& os, int indent) { … }
void PrintScheduledNode(std::ostream& os, int indent, Node* n) { … }
void PrintScheduledGraph(std::ostream& os, const Schedule* schedule) { … }
}
std::ostream& operator<<(std::ostream& os,
const LiveRangeAsJSON& live_range_json) { … }
std::ostream& operator<<(
std::ostream& os,
const TopLevelLiveRangeAsJSON& top_level_live_range_json) { … }
void PrintTopLevelLiveRanges(std::ostream& os,
const ZoneVector<TopLevelLiveRange*> ranges,
const InstructionSequence& code) { … }
std::ostream& operator<<(std::ostream& os,
const RegisterAllocationDataAsJSON& ac) { … }
std::ostream& operator<<(std::ostream& os, const AsScheduledGraph& scheduled) { … }
std::ostream& operator<<(std::ostream& os, const InstructionOperandAsJSON& o) { … }
std::ostream& operator<<(std::ostream& os, const InstructionAsJSON& i_json) { … }
std::ostream& operator<<(std::ostream& os, const InstructionBlockAsJSON& b) { … }
std::ostream& operator<<(std::ostream& os, const InstructionSequenceAsJSON& s) { … }
}
}
}