// Copyright 2013 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/graph-visualizer.h" #include #include #include #include "src/code-stubs.h" #include "src/compiler/all-nodes.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/register-allocator.h" #include "src/compiler/schedule.h" #include "src/compiler/scheduler.h" #include "src/interpreter/bytecodes.h" #include "src/objects/script-inl.h" #include "src/objects/shared-function-info.h" #include "src/optimized-compilation-info.h" #include "src/ostreams.h" #include "src/source-position.h" namespace v8 { namespace internal { namespace compiler { const char* get_cached_trace_turbo_filename(OptimizedCompilationInfo* info) { if (!info->trace_turbo_filename()) { info->set_trace_turbo_filename( GetVisualizerLogFileName(info, FLAG_trace_turbo_path, nullptr, "json")); } return info->trace_turbo_filename(); } TurboJsonFile::TurboJsonFile(OptimizedCompilationInfo* info, std::ios_base::openmode mode) : std::ofstream(get_cached_trace_turbo_filename(info), mode) {} TurboJsonFile::~TurboJsonFile() { flush(); } std::ostream& operator<<(std::ostream& out, const SourcePositionAsJSON& asJSON) { asJSON.sp.PrintJson(out); return out; } std::ostream& operator<<(std::ostream& out, const NodeOriginAsJSON& asJSON) { asJSON.no.PrintJson(out); return out; } void JsonPrintFunctionSource(std::ostream& os, int source_id, std::unique_ptr function_name, Handle