| Index: src/compiler/node.h
|
| diff --git a/src/compiler/node.h b/src/compiler/node.h
|
| index a475fee21af8c655547790c2a16a141bf15a5534..7c9f3ad26f1b8bf6706f67e324aa63de339e7c0f 100644
|
| --- a/src/compiler/node.h
|
| +++ b/src/compiler/node.h
|
| @@ -46,7 +46,7 @@ class V8_EXPORT_PRIVATE Node final {
|
| Node* const* inputs, bool has_extensible_inputs);
|
| static Node* Clone(Zone* zone, NodeId id, const Node* node);
|
|
|
| - bool IsDead() const { return InputCount() > 0 && !InputAt(0); }
|
| + inline bool IsDead() const;
|
| void Kill();
|
|
|
| const Operator* op() const { return op_; }
|
| @@ -109,41 +109,11 @@ class V8_EXPORT_PRIVATE Node final {
|
| int UseCount() const;
|
| void ReplaceUses(Node* replace_to);
|
|
|
| - class InputEdges final {
|
| - public:
|
| - typedef Edge value_type;
|
| -
|
| - class iterator;
|
| - inline iterator begin() const;
|
| - inline iterator end() const;
|
| -
|
| - bool empty() const;
|
| -
|
| - explicit InputEdges(Node* node) : node_(node) {}
|
| -
|
| - private:
|
| - Node* node_;
|
| - };
|
| -
|
| - InputEdges input_edges() { return InputEdges(this); }
|
| -
|
| - class V8_EXPORT_PRIVATE Inputs final {
|
| - public:
|
| - typedef Node* value_type;
|
| -
|
| - class const_iterator;
|
| - inline const_iterator begin() const;
|
| - inline const_iterator end() const;
|
| -
|
| - bool empty() const;
|
| -
|
| - explicit Inputs(Node* node) : node_(node) {}
|
| + class InputEdges;
|
| + inline InputEdges input_edges();
|
|
|
| - private:
|
| - Node* node_;
|
| - };
|
| -
|
| - Inputs inputs() { return Inputs(this); }
|
| + class Inputs;
|
| + inline Inputs inputs() const;
|
|
|
| class UseEdges final {
|
| public:
|
| @@ -345,6 +315,48 @@ static inline const T& OpParameter(const Node* node) {
|
| return OpParameter<T>(node->op());
|
| }
|
|
|
| +class Node::InputEdges final {
|
| + public:
|
| + typedef Edge value_type;
|
| +
|
| + class iterator;
|
| + inline iterator begin() const;
|
| + inline iterator end() const;
|
| +
|
| + bool empty() const { return count_ == 0; }
|
| + int count() const { return count_; }
|
| +
|
| + inline value_type operator[](int index) const;
|
| +
|
| + InputEdges(Node** input_root, Use* use_root, int count)
|
| + : input_root_(input_root), use_root_(use_root), count_(count) {}
|
| +
|
| + private:
|
| + Node** input_root_;
|
| + Use* use_root_;
|
| + int count_;
|
| +};
|
| +
|
| +class V8_EXPORT_PRIVATE Node::Inputs final {
|
| + public:
|
| + typedef Node* value_type;
|
| +
|
| + class const_iterator;
|
| + inline const_iterator begin() const;
|
| + inline const_iterator end() const;
|
| +
|
| + bool empty() const { return count_ == 0; }
|
| + int count() const { return count_; }
|
| +
|
| + inline value_type operator[](int index) const;
|
| +
|
| + explicit Inputs(Node* const* input_root, int count)
|
| + : input_root_(input_root), count_(count) {}
|
| +
|
| + private:
|
| + Node* const* input_root_;
|
| + int count_;
|
| +};
|
|
|
| // An encapsulation for information associated with a single use of node as a
|
| // input from another node, allowing access to both the defining node and
|
| @@ -373,6 +385,7 @@ class Edge final {
|
|
|
| private:
|
| friend class Node::UseEdges::iterator;
|
| + friend class Node::InputEdges;
|
| friend class Node::InputEdges::iterator;
|
|
|
| Edge(Node::Use* use, Node** input_ptr) : use_(use), input_ptr_(input_ptr) {
|
| @@ -385,12 +398,37 @@ class Edge final {
|
| Node** input_ptr_;
|
| };
|
|
|
| +bool Node::IsDead() const {
|
| + Node::Inputs inputs = this->inputs();
|
| + return inputs.count() > 0 && inputs[0] == nullptr;
|
| +}
|
| +
|
| +Node::InputEdges Node::input_edges() {
|
| + int inline_count = InlineCountField::decode(bit_field_);
|
| + if (inline_count != kOutlineMarker) {
|
| + return InputEdges(inputs_.inline_, reinterpret_cast<Use*>(this) - 1,
|
| + inline_count);
|
| + } else {
|
| + return InputEdges(inputs_.outline_->inputs_,
|
| + reinterpret_cast<Use*>(inputs_.outline_) - 1,
|
| + inputs_.outline_->count_);
|
| + }
|
| +}
|
| +
|
| +Node::Inputs Node::inputs() const {
|
| + int inline_count = InlineCountField::decode(bit_field_);
|
| + if (inline_count != kOutlineMarker) {
|
| + return Inputs(inputs_.inline_, inline_count);
|
| + } else {
|
| + return Inputs(inputs_.outline_->inputs_, inputs_.outline_->count_);
|
| + }
|
| +}
|
|
|
| // A forward iterator to visit the edges for the input dependencies of a node.
|
| class Node::InputEdges::iterator final {
|
| public:
|
| typedef std::forward_iterator_tag iterator_category;
|
| - typedef int difference_type;
|
| + typedef std::ptrdiff_t difference_type;
|
| typedef Edge value_type;
|
| typedef Edge* pointer;
|
| typedef Edge& reference;
|
| @@ -419,15 +457,12 @@ class Node::InputEdges::iterator final {
|
| return iterator(use_ - offset, input_ptr_ + offset);
|
| }
|
| difference_type operator-(const iterator& other) const {
|
| - return static_cast<difference_type>(input_ptr_ - other.input_ptr_);
|
| + return input_ptr_ - other.input_ptr_;
|
| }
|
|
|
| private:
|
| friend class Node;
|
|
|
| - explicit iterator(Node* from, int index = 0)
|
| - : use_(from->GetUsePtr(index)), input_ptr_(from->GetInputPtr(index)) {}
|
| -
|
| explicit iterator(Use* use, Node** input_ptr)
|
| : use_(use), input_ptr_(input_ptr) {}
|
|
|
| @@ -437,69 +472,71 @@ class Node::InputEdges::iterator final {
|
|
|
|
|
| Node::InputEdges::iterator Node::InputEdges::begin() const {
|
| - return Node::InputEdges::iterator(this->node_, 0);
|
| + return Node::InputEdges::iterator(use_root_, input_root_);
|
| }
|
|
|
|
|
| Node::InputEdges::iterator Node::InputEdges::end() const {
|
| - return Node::InputEdges::iterator(this->node_, this->node_->InputCount());
|
| + return Node::InputEdges::iterator(use_root_ - count_, input_root_ + count_);
|
| }
|
|
|
| +Edge Node::InputEdges::operator[](int index) const {
|
| + return Edge(use_root_ + index, input_root_ + index);
|
| +}
|
|
|
| // A forward iterator to visit the inputs of a node.
|
| class Node::Inputs::const_iterator final {
|
| public:
|
| typedef std::forward_iterator_tag iterator_category;
|
| - typedef int difference_type;
|
| + typedef std::ptrdiff_t difference_type;
|
| typedef Node* value_type;
|
| - typedef Node** pointer;
|
| - typedef Node*& reference;
|
| + typedef const value_type* pointer;
|
| + typedef value_type& reference;
|
|
|
| - const_iterator(const const_iterator& other) : iter_(other.iter_) {}
|
| + const_iterator(const const_iterator& other) : input_ptr_(other.input_ptr_) {}
|
|
|
| - Node* operator*() const { return (*iter_).to(); }
|
| + Node* operator*() const { return *input_ptr_; }
|
| bool operator==(const const_iterator& other) const {
|
| - return iter_ == other.iter_;
|
| + return input_ptr_ == other.input_ptr_;
|
| }
|
| bool operator!=(const const_iterator& other) const {
|
| return !(*this == other);
|
| }
|
| const_iterator& operator++() {
|
| - ++iter_;
|
| + ++input_ptr_;
|
| return *this;
|
| }
|
| const_iterator operator++(int);
|
| const_iterator& operator+=(difference_type offset) {
|
| - iter_ += offset;
|
| + input_ptr_ += offset;
|
| return *this;
|
| }
|
| const_iterator operator+(difference_type offset) const {
|
| - return const_iterator(iter_ + offset);
|
| + return const_iterator(input_ptr_ + offset);
|
| }
|
| difference_type operator-(const const_iterator& other) const {
|
| - return iter_ - other.iter_;
|
| + return input_ptr_ - other.input_ptr_;
|
| }
|
|
|
| private:
|
| friend class Node::Inputs;
|
|
|
| - const_iterator(Node* node, int index) : iter_(node, index) {}
|
| -
|
| - explicit const_iterator(Node::InputEdges::iterator iter) : iter_(iter) {}
|
| + explicit const_iterator(Node* const* input_ptr) : input_ptr_(input_ptr) {}
|
|
|
| - Node::InputEdges::iterator iter_;
|
| + Node* const* input_ptr_;
|
| };
|
|
|
|
|
| Node::Inputs::const_iterator Node::Inputs::begin() const {
|
| - return const_iterator(this->node_, 0);
|
| + return const_iterator(input_root_);
|
| }
|
|
|
|
|
| Node::Inputs::const_iterator Node::Inputs::end() const {
|
| - return const_iterator(this->node_, this->node_->InputCount());
|
| + return const_iterator(input_root_ + count_);
|
| }
|
|
|
| +Node* Node::Inputs::operator[](int index) const { return input_root_[index]; }
|
|
|
| // A forward iterator to visit the uses edges of a node.
|
| class Node::UseEdges::iterator final {
|
|
|