v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
all-nodes.cc
Go to the documentation of this file.
1
// Copyright 2014 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/all-nodes.h
"
6
7
#include "
src/compiler/turbofan-graph.h
"
8
9
namespace
v8
{
10
namespace
internal
{
11
namespace
compiler {
12
13
AllNodes::AllNodes
(
Zone
* local_zone,
const
TFGraph
* graph,
bool
only_inputs)
14
: reachable(local_zone),
15
is_reachable_(static_cast<int>(graph->NodeCount()), local_zone),
16
only_inputs_(only_inputs) {
17
Mark
(local_zone, graph->end(), graph);
18
}
19
20
AllNodes::AllNodes
(
Zone
* local_zone,
Node
*
end
,
const
TFGraph
* graph,
21
bool
only_inputs)
22
: reachable(local_zone),
23
is_reachable_(static_cast<int>(graph->NodeCount()), local_zone),
24
only_inputs_(only_inputs) {
25
Mark
(local_zone,
end
, graph);
26
}
27
28
void
AllNodes::Mark
(
Zone
* local_zone,
Node
*
end
,
const
TFGraph
* graph) {
29
DCHECK_LT
(
end
->id(), graph->NodeCount());
30
is_reachable_
.
Add
(
end
->id());
31
reachable
.
push_back
(
end
);
32
// Find all nodes reachable from {end}.
33
for
(
size_t
i
= 0;
i
<
reachable
.
size
();
i
++) {
34
for
(
Node
*
const
input :
reachable
[
i
]->inputs()) {
35
if
(input ==
nullptr
) {
36
// TODO(titzer): print a warning.
37
continue
;
38
}
39
if
(!
is_reachable_
.
Contains
(input->id())) {
40
is_reachable_
.
Add
(input->id());
41
reachable
.
push_back
(input);
42
}
43
}
44
if
(!
only_inputs_
) {
45
for
(
Node
* use :
reachable
[
i
]->uses()) {
46
if
(use ==
nullptr
|| use->id() >= graph->NodeCount()) {
47
continue
;
48
}
49
if
(!
is_reachable_
.
Contains
(use->id())) {
50
is_reachable_
.
Add
(use->id());
51
reachable
.
push_back
(use);
52
}
53
}
54
}
55
}
56
}
57
58
}
// namespace compiler
59
}
// namespace internal
60
}
// namespace v8
all-nodes.h
v8::internal::BitVector::Add
void Add(int i)
Definition
bit-vector.h:185
v8::internal::BitVector::Contains
bool Contains(int i) const
Definition
bit-vector.h:180
v8::internal::ZoneVector::size
size_t size() const
Definition
zone-containers.h:238
v8::internal::ZoneVector::push_back
void push_back(const T &value)
Definition
zone-containers.h:303
v8::internal::Zone
Definition
zone.h:43
v8::internal::compiler::AllNodes::only_inputs_
const bool only_inputs_
Definition
all-nodes.h:45
v8::internal::compiler::AllNodes::is_reachable_
BitVector is_reachable_
Definition
all-nodes.h:44
v8::internal::compiler::AllNodes::reachable
NodeVector reachable
Definition
all-nodes.h:39
v8::internal::compiler::AllNodes::AllNodes
AllNodes(Zone *local_zone, Node *end, const TFGraph *graph, bool only_inputs=true)
Definition
all-nodes.cc:20
v8::internal::compiler::AllNodes::Mark
void Mark(Zone *local_zone, Node *end, const TFGraph *graph)
Definition
all-nodes.cc:28
v8::internal::compiler::Node
Definition
node.h:41
v8::internal::compiler::TFGraph
Definition
turbofan-graph.h:32
end
int end
Definition
debug-coverage.cc:596
v8::internal::compiler::Mark
uint32_t Mark
Definition
node.h:26
v8::internal
Definition
api-arguments-inl.h:20
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
DCHECK_LT
#define DCHECK_LT(v1, v2)
Definition
logging.h:489
turbofan-graph.h
src
compiler
all-nodes.cc
Generated on Sun Apr 6 2025 21:08:51 for v8 by
1.12.0