v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
analyzer-iterator.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
8
10 while (!stack_.empty()) {
11 if (IsOutdated(stack_.back())) {
12 stack_.pop_back();
13 } else {
14 return;
15 }
16 }
17}
18
20 DCHECK(HasNext());
21 DCHECK(!IsOutdated(stack_.back()));
22 curr_ = stack_.back();
23 stack_.pop_back();
24
25 const Block* curr_header = curr_.block->IsLoop()
26 ? curr_.block
27 : loop_finder_.GetLoopHeader(curr_.block);
28
29 // Pushing on the stack the children that are not in the same loop as Next
30 // (remember that since we're doing a DFS with a Last-In-First-Out stack,
31 // pushing them first on the stack means that they will be visited last).
32 for (const Block* child = curr_.block->LastChild(); child != nullptr;
33 child = child->NeighboringChild()) {
34 if (loop_finder_.GetLoopHeader(child) != curr_header) {
35 stack_.push_back({child, current_generation_});
36 }
37 }
38
39 // Pushing on the stack the children that are in the same loop as Next (they
40 // are pushed last, so that they will be visited first).
41 for (const Block* child = curr_.block->LastChild(); child != nullptr;
42 child = child->NeighboringChild()) {
43 if (loop_finder_.GetLoopHeader(child) == curr_header) {
44 stack_.push_back({child, current_generation_});
45 }
46 }
47
49
50 // Note that PopOutdated must be called after updating {visited_}, because
51 // this way, if the stack contained initially [{Bx, 1}, {Bx, 2}] (where `Bx`
52 // is the same block both time and it hasn't been visited before), then we
53 // popped the second entry at the begining of this function, but if we call
54 // PopOutdate before updating {visited_}, then it won't pop the first entry.
56
57 return curr_.block;
58}
59
63 DCHECK(curr_.block->HasBackedge(graph_));
64 const Block* header =
65 curr_.block->LastOperation(graph_).Cast<GotoOp>().destination;
66 stack_.push_back({header, ++current_generation_});
67}
68
72 DCHECK(curr_.block->HasBackedge(graph_));
73 const Block* header =
74 curr_.block->LastOperation(graph_).Cast<GotoOp>().destination;
75 for (const Block* child = header->LastChild(); child != nullptr;
76 child = child->NeighboringChild()) {
77 stack_.push_back({child, ++current_generation_});
78 }
79}
80
81} // namespace v8::internal::compiler::turboshaft
InstructionOperand destination
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482