Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: src/compiler/node.h

Issue 807693003: [turbofan] Unify custom node matchers. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_NODE_H_ 5 #ifndef V8_COMPILER_NODE_H_
6 #define V8_COMPILER_NODE_H_ 6 #define V8_COMPILER_NODE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 friend class Node::UseEdges::iterator; 271 friend class Node::UseEdges::iterator;
272 friend class Node::InputEdges::iterator; 272 friend class Node::InputEdges::iterator;
273 273
274 explicit Edge(Node::Input* input) : input_(input) {} 274 explicit Edge(Node::Input* input) : input_(input) {}
275 275
276 Node::Input* input_; 276 Node::Input* input_;
277 }; 277 };
278 278
279 279
280 // A forward iterator to visit the edges for the input dependencies of a node.. 280 // A forward iterator to visit the edges for the input dependencies of a node..
281 class Node::InputEdges::iterator { 281 class Node::InputEdges::iterator FINAL {
282 public: 282 public:
283 typedef std::forward_iterator_tag iterator_category; 283 typedef std::forward_iterator_tag iterator_category;
284 typedef int difference_type; 284 typedef ptrdiff_t difference_type;
285 typedef Edge value_type; 285 typedef Edge value_type;
286 typedef Edge* pointer; 286 typedef Edge* pointer;
287 typedef Edge& reference; 287 typedef Edge& reference;
288 iterator(const Node::InputEdges::iterator& other) // NOLINT 288 iterator(const Node::InputEdges::iterator& other) // NOLINT
289 : input_(other.input_) {} 289 : input_(other.input_) {}
290 iterator() : input_(NULL) {} 290 iterator() : input_(nullptr) {}
291 291
292 Edge operator*() const { return Edge(input_); } 292 Edge operator*() const { return Edge(input_); }
293 bool operator==(const iterator& other) const { return Equals(other); } 293 bool operator==(const iterator& other) const { return Equals(other); }
294 bool operator!=(const iterator& other) const { return !Equals(other); } 294 bool operator!=(const iterator& other) const { return !Equals(other); }
295 iterator& operator+=(difference_type n) {
296 DCHECK_NOT_NULL(input_);
297 Edge const edge(input_);
298 SetInput(edge.from(), input_->use->input_index + n);
299 return *this;
300 }
295 iterator& operator++() { 301 iterator& operator++() {
296 DCHECK(input_ != NULL); 302 (*this) += 1;
297 Edge edge(input_);
298 Node* from = edge.from();
299 SetInput(from, input_->use->input_index + 1);
300 return *this; 303 return *this;
301 } 304 }
305 iterator operator+(difference_type n) const {
306 iterator result(*this);
307 result += n;
308 return result;
309 }
302 iterator operator++(int) { 310 iterator operator++(int) {
303 iterator result(*this); 311 iterator result(*this);
304 ++(*this); 312 ++(*this);
305 return result; 313 return result;
306 } 314 }
307 315
308 private: 316 private:
309 friend class Node; 317 friend class Node;
310 318
311 explicit iterator(Node* from, int index = 0) : input_(NULL) { 319 explicit iterator(Node* from, difference_type index = 0) {
312 SetInput(from, index); 320 SetInput(from, index);
313 } 321 }
314 322
315 bool Equals(const iterator& other) const { return other.input_ == input_; } 323 bool Equals(const iterator& other) const { return other.input_ == input_; }
316 void SetInput(Node* from, int index) { 324 void SetInput(Node* from, difference_type index) {
317 DCHECK(index >= 0 && index <= from->InputCount()); 325 DCHECK(index >= 0 && index <= from->InputCount());
318 if (index < from->InputCount()) { 326 if (index < from->InputCount()) {
319 input_ = from->GetInputRecordPtr(index); 327 input_ = from->GetInputRecordPtr(static_cast<int>(index));
320 } else { 328 } else {
321 input_ = NULL; 329 input_ = nullptr;
322 } 330 }
323 } 331 }
324 332
325 Input* input_; 333 Input* input_;
326 }; 334 };
327 335
328 336
329 // A forward iterator to visit the inputs of a node. 337 // A forward iterator to visit the inputs of a node.
330 class Node::Inputs::iterator { 338 class Node::Inputs::iterator FINAL {
331 public: 339 public:
332 typedef std::forward_iterator_tag iterator_category; 340 typedef std::forward_iterator_tag iterator_category;
333 typedef int difference_type; 341 typedef ptrdiff_t difference_type;
334 typedef Node* value_type; 342 typedef Node* value_type;
335 typedef Node** pointer; 343 typedef Node** pointer;
336 typedef Node*& reference; 344 typedef Node*& reference;
337 345
338 iterator(const Node::Inputs::iterator& other) // NOLINT 346 iterator(const Node::Inputs::iterator& other) // NOLINT
339 : iter_(other.iter_) {} 347 : iter_(other.iter_) {}
340 348
341 Node* operator*() const { return (*iter_).to(); } 349 Node* operator*() const { return (*iter_).to(); }
342 bool operator==(const iterator& other) const { return Equals(other); } 350 bool operator==(const iterator& other) const { return Equals(other); }
343 bool operator!=(const iterator& other) const { return !Equals(other); } 351 bool operator!=(const iterator& other) const { return !Equals(other); }
352 iterator& operator+=(difference_type n) {
353 iter_ += n;
354 return *this;
355 }
344 iterator& operator++() { 356 iterator& operator++() {
345 ++iter_; 357 ++iter_;
346 return *this; 358 return *this;
347 } 359 }
360 iterator operator+(difference_type n) const {
361 iterator result(*this);
362 result += n;
363 return result;
364 }
348 iterator operator++(int) { 365 iterator operator++(int) {
349 iterator result(*this); 366 iterator result(*this);
350 ++(*this); 367 ++(*this);
351 return result; 368 return result;
352 } 369 }
353 370
354 371
355 private: 372 private:
356 friend class Node::Inputs; 373 friend class Node::Inputs;
357 374
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 inline bool Node::OwnedBy(Node* owner) const { 669 inline bool Node::OwnedBy(Node* owner) const {
653 return first_use_ != NULL && first_use_->from == owner && 670 return first_use_ != NULL && first_use_->from == owner &&
654 first_use_->next == NULL; 671 first_use_->next == NULL;
655 } 672 }
656 673
657 } // namespace compiler 674 } // namespace compiler
658 } // namespace internal 675 } // namespace internal
659 } // namespace v8 676 } // namespace v8
660 677
661 #endif // V8_COMPILER_NODE_H_ 678 #endif // V8_COMPILER_NODE_H_
OLDNEW
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698