v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
maglev-pipeline-statistics.cc
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
6
10
11namespace v8 {
12namespace internal {
13namespace maglev {
14
15constexpr char MaglevPipelineStatistics::kTraceCategory[];
16
17MaglevPipelineStatistics::MaglevPipelineStatistics(
18 maglev::MaglevCompilationInfo* info,
19 std::shared_ptr<CompilationStatistics> compilation_stats,
20 compiler::ZoneStats* zone_stats)
21 : Base(info->zone(), zone_stats, compilation_stats, CodeKind::MAGLEV) {
22 set_function_name(info->toplevel_function()->shared()->DebugNameCStr().get());
23}
24
25MaglevPipelineStatistics::~MaglevPipelineStatistics() {
26 if (Base::InPhaseKind()) EndPhaseKind();
27}
28
29void MaglevPipelineStatistics::BeginPhaseKind(const char* name) {
30 if (Base::InPhaseKind()) EndPhaseKind();
31 Base::BeginPhaseKind(name);
32 TRACE_EVENT_BEGIN1(kTraceCategory, name, "kind",
33 CodeKindToString(code_kind()));
34}
35
36void MaglevPipelineStatistics::EndPhaseKind() {
37 CompilationStatistics::BasicStats diff;
38 Base::EndPhaseKind(&diff);
39 TRACE_EVENT_END2(kTraceCategory, phase_kind_name(), "kind",
40 CodeKindToString(code_kind()), "stats",
41 TRACE_STR_COPY(diff.AsJSON().c_str()));
42}
43
44void MaglevPipelineStatistics::BeginPhase(const char* name) {
45 Base::BeginPhase(name);
46 TRACE_EVENT_BEGIN1(kTraceCategory, phase_name(), "kind",
47 CodeKindToString(code_kind()));
48}
49
50void MaglevPipelineStatistics::EndPhase() {
51 CompilationStatistics::BasicStats diff;
52 Base::EndPhase(&diff);
53 TRACE_EVENT_END2(kTraceCategory, phase_name(), "kind",
54 CodeKindToString(code_kind()), "stats",
55 TRACE_STR_COPY(diff.AsJSON().c_str()));
56}
57
58} // namespace maglev
59} // namespace internal
60} // namespace v8
const char * CodeKindToString(CodeKind kind)
Definition code-kind.cc:10
#define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
#define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val)
#define TRACE_STR_COPY(str)
Definition trace-event.h:50