v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
graph-trimmer.cc
Go to the documentation of this file.
1
// Copyright 2015 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
#include "
src/compiler/graph-trimmer.h
"
6
7
#include "
src/compiler/turbofan-graph.h
"
8
9
namespace
v8
{
10
namespace
internal
{
11
namespace
compiler {
12
13
GraphTrimmer::GraphTrimmer
(
Zone
* zone,
TFGraph
* graph)
14
:
graph_
(graph), is_live_(graph, 2), live_(zone) {
15
live_
.
reserve
(graph->NodeCount());
16
}
17
18
GraphTrimmer::~GraphTrimmer
() =
default
;
19
20
21
void
GraphTrimmer::TrimGraph
() {
22
// Mark end node as live.
23
MarkAsLive
(
graph
()->
end
());
24
// Compute transitive closure of live nodes.
25
for
(
size_t
i
= 0;
i
<
live_
.
size
(); ++
i
) {
26
Node
*
const
live =
live_
[
i
];
27
for
(
Node
*
const
input : live->
inputs
())
MarkAsLive
(input);
28
}
29
// Remove dead->live edges.
30
for
(
Node
*
const
live :
live_
) {
31
DCHECK
(
IsLive
(live));
32
for
(
Edge
edge : live->use_edges()) {
33
Node
*
const
user = edge.from();
34
if
(!
IsLive
(user)) {
35
if
(
v8_flags
.trace_turbo_trimming) {
36
StdoutStream
{} <<
"DeadLink: "
<< *user <<
"("
<< edge.index()
37
<<
") -> "
<< *live << std::endl;
38
}
39
edge.UpdateTo(
nullptr
);
40
}
41
}
42
}
43
}
44
45
}
// namespace compiler
46
}
// namespace internal
47
}
// namespace v8
v8::internal::StdoutStream
Definition
ostreams.h:91
v8::internal::ZoneVector::reserve
void reserve(size_t new_cap)
Definition
zone-containers.h:241
v8::internal::ZoneVector::size
size_t size() const
Definition
zone-containers.h:238
v8::internal::Zone
Definition
zone.h:43
v8::internal::compiler::Edge
Definition
node.h:423
v8::internal::compiler::GraphTrimmer::live_
NodeVector live_
Definition
graph-trimmer.h:53
v8::internal::compiler::GraphTrimmer::~GraphTrimmer
~GraphTrimmer()
v8::internal::compiler::GraphTrimmer::IsLive
V8_INLINE bool IsLive(Node *const node)
Definition
graph-trimmer.h:40
v8::internal::compiler::GraphTrimmer::graph
TFGraph * graph() const
Definition
graph-trimmer.h:49
v8::internal::compiler::GraphTrimmer::MarkAsLive
V8_INLINE void MarkAsLive(Node *const node)
Definition
graph-trimmer.h:41
v8::internal::compiler::GraphTrimmer::GraphTrimmer
GraphTrimmer(Zone *zone, TFGraph *graph)
Definition
graph-trimmer.cc:13
v8::internal::compiler::GraphTrimmer::TrimGraph
void TrimGraph()
Definition
graph-trimmer.cc:21
v8::internal::compiler::Node
Definition
node.h:41
v8::internal::compiler::Node::inputs
Inputs inputs() const
Definition
node.h:478
v8::internal::compiler::TFGraph
Definition
turbofan-graph.h:32
end
int end
Definition
debug-coverage.cc:596
graph-trimmer.h
v8::internal
Definition
api-arguments-inl.h:20
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::v8_flags
V8_EXPORT_PRIVATE FlagValues v8_flags
v8
Definition
api-arguments-inl.h:19
DCHECK
#define DCHECK(condition)
Definition
logging.h:482
turbofan-graph.h
graph_
TFGraph * graph_
Definition
wasm-inlining-into-js.cc:372
src
compiler
graph-trimmer.cc
Generated on Sun Apr 6 2025 21:08:51 for v8 by
1.12.0