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
6
8
9namespace v8 {
10namespace internal {
11namespace compiler {
12
14 : graph_(graph), is_live_(graph, 2), live_(zone) {
15 live_.reserve(graph->NodeCount());
16}
17
19
20
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
void reserve(size_t new_cap)
V8_INLINE bool IsLive(Node *const node)
V8_INLINE void MarkAsLive(Node *const node)
GraphTrimmer(Zone *zone, TFGraph *graph)
Inputs inputs() const
Definition node.h:478
int end
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK(condition)
Definition logging.h:482
TFGraph * graph_