blob: 8525fa0b019b56afbafdafe3e1693631759d1200 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2013 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/node.h"
6
Ben Murdochb8a8cc12014-11-26 15:28:44 +00007namespace v8 {
8namespace internal {
9namespace compiler {
10
Ben Murdoch014dc512016-03-22 12:00:34 +000011Node::OutOfLineInputs* Node::OutOfLineInputs::New(Zone* zone, int capacity) {
12 size_t size =
13 sizeof(OutOfLineInputs) + capacity * (sizeof(Node*) + sizeof(Use));
Rubin Xu7bc1b612021-02-16 09:38:50 +000014 intptr_t raw_buffer =
15 reinterpret_cast<intptr_t>(zone->Allocate<Node::OutOfLineInputs>(size));
Ben Murdoch014dc512016-03-22 12:00:34 +000016 Node::OutOfLineInputs* outline =
17 reinterpret_cast<OutOfLineInputs*>(raw_buffer + capacity * sizeof(Use));
18 outline->capacity_ = capacity;
19 outline->count_ = 0;
20 return outline;
Emily Bernier958fae72015-03-24 16:35:39 -040021}
22
Rubin Xu7bc1b612021-02-16 09:38:50 +000023void Node::OutOfLineInputs::ExtractFrom(Use* old_use_ptr,
24 ZoneNodePtr* old_input_ptr, int count) {
25 DCHECK_GE(count, 0);
Ben Murdoch014dc512016-03-22 12:00:34 +000026 // Extract the inputs from the old use and input pointers and copy them
27 // to this out-of-line-storage.
28 Use* new_use_ptr = reinterpret_cast<Use*>(this) - 1;
Rubin Xu7bc1b612021-02-16 09:38:50 +000029 ZoneNodePtr* new_input_ptr = inputs();
30 CHECK_IMPLIES(count > 0, Use::InputIndexField::is_valid(count - 1));
Ben Murdoch014dc512016-03-22 12:00:34 +000031 for (int current = 0; current < count; current++) {
32 new_use_ptr->bit_field_ =
33 Use::InputIndexField::encode(current) | Use::InlineField::encode(false);
34 DCHECK_EQ(old_input_ptr, old_use_ptr->input_ptr());
35 DCHECK_EQ(new_input_ptr, new_use_ptr->input_ptr());
36 Node* old_to = *old_input_ptr;
37 if (old_to) {
38 *old_input_ptr = nullptr;
39 old_to->RemoveUse(old_use_ptr);
40 *new_input_ptr = old_to;
41 old_to->AppendUse(new_use_ptr);
42 } else {
43 *new_input_ptr = nullptr;
44 }
45 old_input_ptr++;
46 new_input_ptr++;
47 old_use_ptr--;
48 new_use_ptr--;
49 }
50 this->count_ = count;
51}
Emily Bernier958fae72015-03-24 16:35:39 -040052
Rubin Xu7bc1b612021-02-16 09:38:50 +000053// These structs are just type tags for Zone::Allocate<T>(size_t) calls.
54struct NodeWithOutOfLineInputs {};
55struct NodeWithInLineInputs {};
Ben Murdoch014dc512016-03-22 12:00:34 +000056
Rubin Xu7bc1b612021-02-16 09:38:50 +000057template <typename NodePtrT>
58Node* Node::NewImpl(Zone* zone, NodeId id, const Operator* op, int input_count,
59 NodePtrT const* inputs, bool has_extensible_inputs) {
60 // Node uses compressed pointers, so zone must support pointer compression.
61 DCHECK_IMPLIES(kCompressGraphZone, zone->supports_compression());
62 DCHECK_GE(input_count, 0);
63
64 ZoneNodePtr* input_ptr;
Ben Murdoch014dc512016-03-22 12:00:34 +000065 Use* use_ptr;
66 Node* node;
67 bool is_inline;
68
Ben Murdoch014dc512016-03-22 12:00:34 +000069 // Verify that none of the inputs are {nullptr}.
70 for (int i = 0; i < input_count; i++) {
71 if (inputs[i] == nullptr) {
Rubin Xu7bc1b612021-02-16 09:38:50 +000072 FATAL("Node::New() Error: #%d:%s[%d] is nullptr", static_cast<int>(id),
73 op->mnemonic(), i);
Ben Murdoch014dc512016-03-22 12:00:34 +000074 }
75 }
Ben Murdoch014dc512016-03-22 12:00:34 +000076
77 if (input_count > kMaxInlineCapacity) {
78 // Allocate out-of-line inputs.
79 int capacity =
80 has_extensible_inputs ? input_count + kMaxInlineCapacity : input_count;
81 OutOfLineInputs* outline = OutOfLineInputs::New(zone, capacity);
82
Rubin Xu7bc1b612021-02-16 09:38:50 +000083 // Allocate node, with space for OutOfLineInputs pointer.
84 void* node_buffer = zone->Allocate<NodeWithOutOfLineInputs>(
85 sizeof(Node) + sizeof(ZoneOutOfLineInputsPtr));
Ben Murdoch014dc512016-03-22 12:00:34 +000086 node = new (node_buffer) Node(id, op, kOutlineMarker, 0);
Rubin Xu7bc1b612021-02-16 09:38:50 +000087 node->set_outline_inputs(outline);
Ben Murdoch014dc512016-03-22 12:00:34 +000088
89 outline->node_ = node;
90 outline->count_ = input_count;
91
Rubin Xu7bc1b612021-02-16 09:38:50 +000092 input_ptr = outline->inputs();
Ben Murdoch014dc512016-03-22 12:00:34 +000093 use_ptr = reinterpret_cast<Use*>(outline);
94 is_inline = false;
95 } else {
Rubin Xu7bc1b612021-02-16 09:38:50 +000096 // Allocate node with inline inputs. Capacity must be at least 1 so that
97 // an OutOfLineInputs pointer can be stored when inputs are added later.
98 int capacity = std::max(1, input_count);
Ben Murdoch014dc512016-03-22 12:00:34 +000099 if (has_extensible_inputs) {
100 const int max = kMaxInlineCapacity;
101 capacity = std::min(input_count + 3, max);
102 }
103
Rubin Xu7bc1b612021-02-16 09:38:50 +0000104 size_t size = sizeof(Node) + capacity * (sizeof(ZoneNodePtr) + sizeof(Use));
105 intptr_t raw_buffer =
106 reinterpret_cast<intptr_t>(zone->Allocate<NodeWithInLineInputs>(size));
Ben Murdoch014dc512016-03-22 12:00:34 +0000107 void* node_buffer =
108 reinterpret_cast<void*>(raw_buffer + capacity * sizeof(Use));
109
110 node = new (node_buffer) Node(id, op, input_count, capacity);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000111 input_ptr = node->inline_inputs();
Ben Murdoch014dc512016-03-22 12:00:34 +0000112 use_ptr = reinterpret_cast<Use*>(node);
113 is_inline = true;
114 }
115
116 // Initialize the input pointers and the uses.
Rubin Xu7bc1b612021-02-16 09:38:50 +0000117 CHECK_IMPLIES(input_count > 0,
118 Use::InputIndexField::is_valid(input_count - 1));
Emily Bernier958fae72015-03-24 16:35:39 -0400119 for (int current = 0; current < input_count; ++current) {
120 Node* to = *inputs++;
Ben Murdoch014dc512016-03-22 12:00:34 +0000121 input_ptr[current] = to;
122 Use* use = use_ptr - 1 - current;
123 use->bit_field_ = Use::InputIndexField::encode(current) |
124 Use::InlineField::encode(is_inline);
Emily Bernier958fae72015-03-24 16:35:39 -0400125 to->AppendUse(use);
Emily Bernier958fae72015-03-24 16:35:39 -0400126 }
Ben Murdoch014dc512016-03-22 12:00:34 +0000127 node->Verify();
128 return node;
129}
130
Rubin Xu7bc1b612021-02-16 09:38:50 +0000131Node* Node::New(Zone* zone, NodeId id, const Operator* op, int input_count,
132 Node* const* inputs, bool has_extensible_inputs) {
133 return NewImpl(zone, id, op, input_count, inputs, has_extensible_inputs);
134}
Ben Murdoch014dc512016-03-22 12:00:34 +0000135
136Node* Node::Clone(Zone* zone, NodeId id, const Node* node) {
137 int const input_count = node->InputCount();
Rubin Xu7bc1b612021-02-16 09:38:50 +0000138 ZoneNodePtr const* const inputs = node->has_inline_inputs()
139 ? node->inline_inputs()
140 : node->outline_inputs()->inputs();
141 Node* const clone = NewImpl(zone, id, node->op(), input_count, inputs, false);
Ben Murdoch014dc512016-03-22 12:00:34 +0000142 clone->set_type(node->type());
143 return clone;
Emily Bernier958fae72015-03-24 16:35:39 -0400144}
145
146
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000147void Node::Kill() {
148 DCHECK_NOT_NULL(op());
Ben Murdoch014dc512016-03-22 12:00:34 +0000149 NullAllInputs();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000150 DCHECK(uses().empty());
151}
152
153
Ben Murdoch014dc512016-03-22 12:00:34 +0000154void Node::AppendInput(Zone* zone, Node* new_to) {
155 DCHECK_NOT_NULL(zone);
156 DCHECK_NOT_NULL(new_to);
157
Rubin Xu7bc1b612021-02-16 09:38:50 +0000158 int const inline_count = InlineCountField::decode(bit_field_);
159 int const inline_capacity = InlineCapacityField::decode(bit_field_);
Ben Murdoch014dc512016-03-22 12:00:34 +0000160 if (inline_count < inline_capacity) {
161 // Append inline input.
162 bit_field_ = InlineCountField::update(bit_field_, inline_count + 1);
163 *GetInputPtr(inline_count) = new_to;
164 Use* use = GetUsePtr(inline_count);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000165 STATIC_ASSERT(InlineCapacityField::kMax <= Use::InputIndexField::kMax);
Ben Murdoch014dc512016-03-22 12:00:34 +0000166 use->bit_field_ = Use::InputIndexField::encode(inline_count) |
167 Use::InlineField::encode(true);
168 new_to->AppendUse(use);
169 } else {
170 // Append out-of-line input.
Rubin Xu7bc1b612021-02-16 09:38:50 +0000171 int const input_count = InputCount();
Ben Murdoch014dc512016-03-22 12:00:34 +0000172 OutOfLineInputs* outline = nullptr;
173 if (inline_count != kOutlineMarker) {
174 // switch to out of line inputs.
175 outline = OutOfLineInputs::New(zone, input_count * 2 + 3);
176 outline->node_ = this;
177 outline->ExtractFrom(GetUsePtr(0), GetInputPtr(0), input_count);
178 bit_field_ = InlineCountField::update(bit_field_, kOutlineMarker);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000179 set_outline_inputs(outline);
Ben Murdoch014dc512016-03-22 12:00:34 +0000180 } else {
181 // use current out of line inputs.
Rubin Xu7bc1b612021-02-16 09:38:50 +0000182 outline = outline_inputs();
Ben Murdoch014dc512016-03-22 12:00:34 +0000183 if (input_count >= outline->capacity_) {
184 // out of space in out-of-line inputs.
185 outline = OutOfLineInputs::New(zone, input_count * 2 + 3);
186 outline->node_ = this;
187 outline->ExtractFrom(GetUsePtr(0), GetInputPtr(0), input_count);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000188 set_outline_inputs(outline);
Ben Murdoch014dc512016-03-22 12:00:34 +0000189 }
190 }
191 outline->count_++;
192 *GetInputPtr(input_count) = new_to;
193 Use* use = GetUsePtr(input_count);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000194 CHECK(Use::InputIndexField::is_valid(input_count));
Ben Murdoch014dc512016-03-22 12:00:34 +0000195 use->bit_field_ = Use::InputIndexField::encode(input_count) |
196 Use::InlineField::encode(false);
197 new_to->AppendUse(use);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000198 }
Ben Murdoch014dc512016-03-22 12:00:34 +0000199 Verify();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000200}
201
202
Ben Murdoch014dc512016-03-22 12:00:34 +0000203void Node::InsertInput(Zone* zone, int index, Node* new_to) {
204 DCHECK_NOT_NULL(zone);
205 DCHECK_LE(0, index);
206 DCHECK_LT(index, InputCount());
207 AppendInput(zone, InputAt(InputCount() - 1));
208 for (int i = InputCount() - 1; i > index; --i) {
209 ReplaceInput(i, InputAt(i - 1));
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000210 }
Ben Murdoch014dc512016-03-22 12:00:34 +0000211 ReplaceInput(index, new_to);
212 Verify();
213}
214
Ben Murdochf91f0612016-11-29 16:50:11 +0000215void Node::InsertInputs(Zone* zone, int index, int count) {
216 DCHECK_NOT_NULL(zone);
217 DCHECK_LE(0, index);
218 DCHECK_LT(0, count);
219 DCHECK_LT(index, InputCount());
220 for (int i = 0; i < count; i++) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000221 AppendInput(zone, InputAt(std::max(InputCount() - count, 0)));
Ben Murdochf91f0612016-11-29 16:50:11 +0000222 }
Rubin Xu7bc1b612021-02-16 09:38:50 +0000223 for (int i = InputCount() - count - 1; i >= std::max(index, count); --i) {
Ben Murdochf91f0612016-11-29 16:50:11 +0000224 ReplaceInput(i, InputAt(i - count));
225 }
226 for (int i = 0; i < count; i++) {
227 ReplaceInput(index + i, nullptr);
228 }
229 Verify();
230}
Ben Murdoch014dc512016-03-22 12:00:34 +0000231
Rubin Xu7bc1b612021-02-16 09:38:50 +0000232Node* Node::RemoveInput(int index) {
Ben Murdoch014dc512016-03-22 12:00:34 +0000233 DCHECK_LE(0, index);
234 DCHECK_LT(index, InputCount());
Rubin Xu7bc1b612021-02-16 09:38:50 +0000235 Node* result = InputAt(index);
Ben Murdoch014dc512016-03-22 12:00:34 +0000236 for (; index < InputCount() - 1; ++index) {
237 ReplaceInput(index, InputAt(index + 1));
238 }
239 TrimInputCount(InputCount() - 1);
240 Verify();
Rubin Xu7bc1b612021-02-16 09:38:50 +0000241 return result;
Ben Murdoch014dc512016-03-22 12:00:34 +0000242}
243
Ben Murdoch014dc512016-03-22 12:00:34 +0000244void Node::ClearInputs(int start, int count) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000245 ZoneNodePtr* input_ptr = GetInputPtr(start);
Ben Murdoch014dc512016-03-22 12:00:34 +0000246 Use* use_ptr = GetUsePtr(start);
247 while (count-- > 0) {
248 DCHECK_EQ(input_ptr, use_ptr->input_ptr());
249 Node* input = *input_ptr;
250 *input_ptr = nullptr;
251 if (input) input->RemoveUse(use_ptr);
252 input_ptr++;
253 use_ptr--;
254 }
255 Verify();
256}
257
258
259void Node::NullAllInputs() { ClearInputs(0, InputCount()); }
260
261
262void Node::TrimInputCount(int new_input_count) {
263 int current_count = InputCount();
264 DCHECK_LE(new_input_count, current_count);
265 if (new_input_count == current_count) return; // Nothing to do.
266 ClearInputs(new_input_count, current_count - new_input_count);
267 if (has_inline_inputs()) {
268 bit_field_ = InlineCountField::update(bit_field_, new_input_count);
269 } else {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000270 outline_inputs()->count_ = new_input_count;
Ben Murdoch014dc512016-03-22 12:00:34 +0000271 }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000272}
273
Rubin Xu7bc1b612021-02-16 09:38:50 +0000274void Node::EnsureInputCount(Zone* zone, int new_input_count) {
275 int current_count = InputCount();
276 DCHECK_NE(current_count, 0);
277 if (current_count > new_input_count) {
278 TrimInputCount(new_input_count);
279 } else if (current_count < new_input_count) {
280 Node* dummy = InputAt(current_count - 1);
281 do {
282 AppendInput(zone, dummy);
283 current_count++;
284 } while (current_count < new_input_count);
285 }
286}
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000287
Emily Bernier958fae72015-03-24 16:35:39 -0400288int Node::UseCount() const {
289 int use_count = 0;
290 for (const Use* use = first_use_; use; use = use->next) {
291 ++use_count;
292 }
293 return use_count;
294}
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000295
296
Ben Murdoch014dc512016-03-22 12:00:34 +0000297void Node::ReplaceUses(Node* that) {
298 DCHECK(this->first_use_ == nullptr || this->first_use_->prev == nullptr);
299 DCHECK(that->first_use_ == nullptr || that->first_use_->prev == nullptr);
300
301 // Update the pointers to {this} to point to {that}.
302 Use* last_use = nullptr;
303 for (Use* use = this->first_use_; use; use = use->next) {
304 *use->input_ptr() = that;
305 last_use = use;
Emily Bernier958fae72015-03-24 16:35:39 -0400306 }
Ben Murdoch014dc512016-03-22 12:00:34 +0000307 if (last_use) {
308 // Concat the use list of {this} and {that}.
309 last_use->next = that->first_use_;
310 if (that->first_use_) that->first_use_->prev = last_use;
311 that->first_use_ = this->first_use_;
312 }
313 first_use_ = nullptr;
Emily Bernier958fae72015-03-24 16:35:39 -0400314}
315
Rubin Xu7bc1b612021-02-16 09:38:50 +0000316bool Node::OwnedBy(Node const* owner) const {
317 unsigned mask = 0;
318 for (Use* use = first_use_; use; use = use->next) {
319 if (use->from() == owner) {
320 mask |= 1;
321 } else {
322 return false;
323 }
324 }
325 return mask == 1;
326}
Emily Bernier958fae72015-03-24 16:35:39 -0400327
Ben Murdoch014dc512016-03-22 12:00:34 +0000328bool Node::OwnedBy(Node const* owner1, Node const* owner2) const {
329 unsigned mask = 0;
330 for (Use* use = first_use_; use; use = use->next) {
331 Node* from = use->from();
332 if (from == owner1) {
333 mask |= 1;
334 } else if (from == owner2) {
335 mask |= 2;
336 } else {
337 return false;
338 }
339 }
340 return mask == 3;
341}
342
Rubin Xu7bc1b612021-02-16 09:38:50 +0000343void Node::Print(int depth) const {
344 StdoutStream os;
345 Print(os, depth);
Ben Murdoch62ed6312017-06-06 11:06:27 +0100346}
Ben Murdoch014dc512016-03-22 12:00:34 +0000347
Rubin Xu7bc1b612021-02-16 09:38:50 +0000348namespace {
349void PrintNode(const Node* node, std::ostream& os, int depth,
350 int indentation = 0) {
351 for (int i = 0; i < indentation; ++i) {
352 os << " ";
Ben Murdoch62ed6312017-06-06 11:06:27 +0100353 }
Rubin Xu7bc1b612021-02-16 09:38:50 +0000354 if (node) {
355 os << *node;
356 } else {
357 os << "(NULL)";
358 }
359 os << std::endl;
360 if (depth <= 0) return;
361 for (Node* input : node->inputs()) {
362 PrintNode(input, os, depth - 1, indentation + 1);
363 }
364}
365} // namespace
366
367void Node::Print(std::ostream& os, int depth) const {
368 PrintNode(this, os, depth);
Ben Murdoch014dc512016-03-22 12:00:34 +0000369}
370
Ben Murdoch62ed6312017-06-06 11:06:27 +0100371std::ostream& operator<<(std::ostream& os, const Node& n) {
372 os << n.id() << ": " << *n.op();
373 if (n.InputCount() > 0) {
374 os << "(";
375 for (int i = 0; i < n.InputCount(); ++i) {
376 if (i != 0) os << ", ";
377 if (n.InputAt(i)) {
378 os << n.InputAt(i)->id();
379 } else {
380 os << "null";
381 }
382 }
383 os << ")";
384 }
385 return os;
386}
Ben Murdoch014dc512016-03-22 12:00:34 +0000387
388Node::Node(NodeId id, const Operator* op, int inline_count, int inline_capacity)
389 : op_(op),
Ben Murdoch014dc512016-03-22 12:00:34 +0000390 mark_(0),
391 bit_field_(IdField::encode(id) | InlineCountField::encode(inline_count) |
392 InlineCapacityField::encode(inline_capacity)),
393 first_use_(nullptr) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000394 // Check that the id didn't overflow.
395 STATIC_ASSERT(IdField::kMax < std::numeric_limits<NodeId>::max());
396 CHECK(IdField::is_valid(id));
397
Ben Murdoch014dc512016-03-22 12:00:34 +0000398 // Inputs must either be out of line or within the inline capacity.
Ben Murdoch014dc512016-03-22 12:00:34 +0000399 DCHECK(inline_count == kOutlineMarker || inline_count <= inline_capacity);
Rubin Xu7bc1b612021-02-16 09:38:50 +0000400 DCHECK_LE(inline_capacity, kMaxInlineCapacity);
Ben Murdoch014dc512016-03-22 12:00:34 +0000401}
402
403
404void Node::AppendUse(Use* use) {
405 DCHECK(first_use_ == nullptr || first_use_->prev == nullptr);
406 DCHECK_EQ(this, *use->input_ptr());
407 use->next = first_use_;
408 use->prev = nullptr;
409 if (first_use_) first_use_->prev = use;
410 first_use_ = use;
411}
412
413
414void Node::RemoveUse(Use* use) {
415 DCHECK(first_use_ == nullptr || first_use_->prev == nullptr);
416 if (use->prev) {
417 DCHECK_NE(first_use_, use);
418 use->prev->next = use->next;
419 } else {
420 DCHECK_EQ(first_use_, use);
421 first_use_ = use->next;
422 }
423 if (use->next) {
424 use->next->prev = use->prev;
425 }
426}
427
428
429#if DEBUG
430void Node::Verify() {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000431 // Check basic validity of input data structures.
Ben Murdoch014dc512016-03-22 12:00:34 +0000432 fflush(stdout);
433 int count = this->InputCount();
434 // Avoid quadratic explosion for mega nodes; only verify if the input
435 // count is less than 200 or is a round number of 100s.
436 if (count > 200 && count % 100) return;
437
438 for (int i = 0; i < count; i++) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000439 DCHECK_EQ(i, this->GetUsePtr(i)->input_index());
440 DCHECK_EQ(this->GetInputPtr(i), this->GetUsePtr(i)->input_ptr());
441 DCHECK_EQ(count, this->InputCount());
Ben Murdoch014dc512016-03-22 12:00:34 +0000442 }
443 { // Direct input iteration.
444 int index = 0;
445 for (Node* input : this->inputs()) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000446 DCHECK_EQ(this->InputAt(index), input);
Ben Murdoch014dc512016-03-22 12:00:34 +0000447 index++;
448 }
Rubin Xu7bc1b612021-02-16 09:38:50 +0000449 DCHECK_EQ(count, index);
450 DCHECK_EQ(this->InputCount(), index);
Ben Murdoch014dc512016-03-22 12:00:34 +0000451 }
452 { // Input edge iteration.
453 int index = 0;
454 for (Edge edge : this->input_edges()) {
Rubin Xu7bc1b612021-02-16 09:38:50 +0000455 DCHECK_EQ(edge.from(), this);
456 DCHECK_EQ(index, edge.index());
457 DCHECK_EQ(this->InputAt(index), edge.to());
Ben Murdoch014dc512016-03-22 12:00:34 +0000458 index++;
459 }
Rubin Xu7bc1b612021-02-16 09:38:50 +0000460 DCHECK_EQ(count, index);
461 DCHECK_EQ(this->InputCount(), index);
Ben Murdoch014dc512016-03-22 12:00:34 +0000462 }
463}
464#endif
465
Ben Murdoch014dc512016-03-22 12:00:34 +0000466Node::InputEdges::iterator Node::InputEdges::iterator::operator++(int n) {
467 iterator result(*this);
468 ++(*this);
469 return result;
470}
471
472
Ben Murdoch014dc512016-03-22 12:00:34 +0000473Node::Inputs::const_iterator Node::Inputs::const_iterator::operator++(int n) {
474 const_iterator result(*this);
475 ++(*this);
476 return result;
477}
478
479
Ben Murdoch014dc512016-03-22 12:00:34 +0000480Node::UseEdges::iterator Node::UseEdges::iterator::operator++(int n) {
481 iterator result(*this);
482 ++(*this);
483 return result;
484}
485
486
487bool Node::UseEdges::empty() const { return begin() == end(); }
488
489
490Node::Uses::const_iterator Node::Uses::const_iterator::operator++(int n) {
491 const_iterator result(*this);
492 ++(*this);
493 return result;
494}
495
496
497bool Node::Uses::empty() const { return begin() == end(); }
498
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000499} // namespace compiler
500} // namespace internal
501} // namespace v8