v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
phase.h
Go to the documentation of this file.
1// Copyright 2023 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_PHASE_H_
6#define V8_COMPILER_PHASE_H_
7
10
11#ifdef V8_RUNTIME_CALL_STATS
12#define DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, Kind, Mode) \
13 static constexpr PhaseKind kKind = Kind; \
14 static const char* phase_name() { return "V8.TF" #Name; } \
15 static constexpr RuntimeCallCounterId kRuntimeCallCounterId = \
16 RuntimeCallCounterId::kOptimize##Name; \
17 static constexpr RuntimeCallStats::CounterMode kCounterMode = Mode;
18#else // V8_RUNTIME_CALL_STATS
19#define DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, Kind, Mode) \
20 static constexpr PhaseKind kKind = Kind; \
21 static const char* phase_name() { return "V8.TF" #Name; }
22#endif // V8_RUNTIME_CALL_STATS
23
24#define DECL_PIPELINE_PHASE_CONSTANTS(Name) \
25 DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, PhaseKind::kTurbofan, \
26 RuntimeCallStats::kThreadSpecific)
27
28#define DECL_MAIN_THREAD_PIPELINE_PHASE_CONSTANTS(Name) \
29 DECL_PIPELINE_PHASE_CONSTANTS_HELPER(Name, PhaseKind::kTurbofan, \
30 RuntimeCallStats::kExact)
31
32namespace v8::internal {
33
34class OptimizedCompilationInfo;
35
36namespace compiler {
37
38inline constexpr char kCodegenZoneName[] = "codegen-zone";
39inline constexpr char kGraphZoneName[] = "graph-zone";
40inline constexpr char kInstructionZoneName[] = "instruction-zone";
41inline constexpr char kRegisterAllocationZoneName[] =
42 "register-allocation-zone";
43inline constexpr char kRegisterAllocatorVerifierZoneName[] =
44 "register-allocator-verifier-zone";
45
46class TFPipelineData;
47class Schedule;
48void PrintCode(Isolate* isolate, DirectHandle<Code> code,
51 Schedule* schedule, const char* phase_name);
52
53enum class PhaseKind {
56};
57
61
62inline std::ostream& operator<<(std::ostream& out, InstructionStartsAsJSON s) {
63 out << ", \"instructionOffsetToPCOffset\": {";
64 bool needs_comma = false;
65 for (size_t i = 0; i < s.instr_starts->size(); ++i) {
66 if (needs_comma) out << ", ";
67 const TurbolizerInstructionStartInfo& info = (*s.instr_starts)[i];
68 out << "\"" << i << "\": {";
69 out << "\"gap\": " << info.gap_pc_offset;
70 out << ", \"arch\": " << info.arch_instr_pc_offset;
71 out << ", \"condition\": " << info.condition_pc_offset;
72 out << "}";
73 needs_comma = true;
74 }
75 out << "}";
76 return out;
77}
78
82
83inline std::ostream& operator<<(std::ostream& out,
85 out << ", \"codeOffsetsInfo\": {";
86 out << "\"codeStartRegisterCheck\": "
87 << s.offsets_info->code_start_register_check << ", ";
88 out << "\"deoptCheck\": " << s.offsets_info->deopt_check << ", ";
89 out << "\"blocksStart\": " << s.offsets_info->blocks_start << ", ";
90 out << "\"outOfLineCode\": " << s.offsets_info->out_of_line_code << ", ";
91 out << "\"deoptimizationExits\": " << s.offsets_info->deoptimization_exits
92 << ", ";
93 out << "\"pools\": " << s.offsets_info->pools << ", ";
94 out << "\"jumpTables\": " << s.offsets_info->jump_tables;
95 out << "}";
96 return out;
97}
98
102
103inline std::ostream& operator<<(std::ostream& out, BlockStartsAsJSON s) {
104 out << ", \"blockIdToOffset\": {";
105 bool needs_comma = false;
106 for (size_t i = 0; i < s.block_starts->size(); ++i) {
107 if (needs_comma) out << ", ";
108 int offset = (*s.block_starts)[i];
109 out << "\"" << i << "\":" << offset;
110 needs_comma = true;
111 }
112 out << "},";
113 return out;
114}
115
116} // namespace compiler
117} // namespace v8::internal
118
119#endif // V8_COMPILER_PHASE_H_
Schedule * schedule
int32_t offset
constexpr char kRegisterAllocatorVerifierZoneName[]
Definition phase.h:43
void PrintCode(Isolate *isolate, DirectHandle< Code > code, OptimizedCompilationInfo *info)
Definition pipeline.cc:588
constexpr char kInstructionZoneName[]
Definition phase.h:40
constexpr char kRegisterAllocationZoneName[]
Definition phase.h:41
constexpr char kGraphZoneName[]
Definition phase.h:39
void TraceSchedule(OptimizedCompilationInfo *info, TFPipelineData *data, Schedule *schedule, const char *phase_name)
Definition pipeline.cc:560
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
constexpr char kCodegenZoneName[]
Definition phase.h:38
const ZoneVector< int > * block_starts
Definition phase.h:100
const ZoneVector< TurbolizerInstructionStartInfo > * instr_starts
Definition phase.h:59
const TurbolizerCodeOffsetsInfo * offsets_info
Definition phase.h:80