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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-inlining.cc ('k') | src/compiler/node-matchers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/node.h
diff --git a/src/compiler/node.h b/src/compiler/node.h
index 2295b7b5e3e9dfba6a161ca8b9c6b768bf26ee16..804281e226b4ed1e7a506c52077afbed0fb1982d 100644
--- a/src/compiler/node.h
+++ b/src/compiler/node.h
@@ -278,27 +278,35 @@ class Edge {
// A forward iterator to visit the edges for the input dependencies of a node..
-class Node::InputEdges::iterator {
+class Node::InputEdges::iterator FINAL {
public:
typedef std::forward_iterator_tag iterator_category;
- typedef int difference_type;
+ typedef ptrdiff_t difference_type;
typedef Edge value_type;
typedef Edge* pointer;
typedef Edge& reference;
iterator(const Node::InputEdges::iterator& other) // NOLINT
: input_(other.input_) {}
- iterator() : input_(NULL) {}
+ iterator() : input_(nullptr) {}
Edge operator*() const { return Edge(input_); }
bool operator==(const iterator& other) const { return Equals(other); }
bool operator!=(const iterator& other) const { return !Equals(other); }
+ iterator& operator+=(difference_type n) {
+ DCHECK_NOT_NULL(input_);
+ Edge const edge(input_);
+ SetInput(edge.from(), input_->use->input_index + n);
+ return *this;
+ }
iterator& operator++() {
- DCHECK(input_ != NULL);
- Edge edge(input_);
- Node* from = edge.from();
- SetInput(from, input_->use->input_index + 1);
+ (*this) += 1;
return *this;
}
+ iterator operator+(difference_type n) const {
+ iterator result(*this);
+ result += n;
+ return result;
+ }
iterator operator++(int) {
iterator result(*this);
++(*this);
@@ -308,17 +316,17 @@ class Node::InputEdges::iterator {
private:
friend class Node;
- explicit iterator(Node* from, int index = 0) : input_(NULL) {
+ explicit iterator(Node* from, difference_type index = 0) {
SetInput(from, index);
}
bool Equals(const iterator& other) const { return other.input_ == input_; }
- void SetInput(Node* from, int index) {
+ void SetInput(Node* from, difference_type index) {
DCHECK(index >= 0 && index <= from->InputCount());
if (index < from->InputCount()) {
- input_ = from->GetInputRecordPtr(index);
+ input_ = from->GetInputRecordPtr(static_cast<int>(index));
} else {
- input_ = NULL;
+ input_ = nullptr;
}
}
@@ -327,10 +335,10 @@ class Node::InputEdges::iterator {
// A forward iterator to visit the inputs of a node.
-class Node::Inputs::iterator {
+class Node::Inputs::iterator FINAL {
public:
typedef std::forward_iterator_tag iterator_category;
- typedef int difference_type;
+ typedef ptrdiff_t difference_type;
typedef Node* value_type;
typedef Node** pointer;
typedef Node*& reference;
@@ -341,10 +349,19 @@ class Node::Inputs::iterator {
Node* operator*() const { return (*iter_).to(); }
bool operator==(const iterator& other) const { return Equals(other); }
bool operator!=(const iterator& other) const { return !Equals(other); }
+ iterator& operator+=(difference_type n) {
+ iter_ += n;
+ return *this;
+ }
iterator& operator++() {
++iter_;
return *this;
}
+ iterator operator+(difference_type n) const {
+ iterator result(*this);
+ result += n;
+ return result;
+ }
iterator operator++(int) {
iterator result(*this);
++(*this);
« 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