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

Side by Side Diff: src/compiler/generic-node-inl.h

Issue 765983002: Clean up node iteration (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comment 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
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_GENERIC_NODE_INL_H_ 5 #ifndef V8_COMPILER_GENERIC_NODE_INL_H_
6 #define V8_COMPILER_GENERIC_NODE_INL_H_ 6 #define V8_COMPILER_GENERIC_NODE_INL_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler/generic-graph.h" 10 #include "src/compiler/generic-graph.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 template <class B, class S> 44 template <class B, class S>
45 inline typename GenericNode<B, S>::Inputs::iterator 45 inline typename GenericNode<B, S>::Inputs::iterator
46 GenericNode<B, S>::Inputs::end() { 46 GenericNode<B, S>::Inputs::end() {
47 return typename GenericNode<B, S>::Inputs::iterator( 47 return typename GenericNode<B, S>::Inputs::iterator(
48 this->node_, this->node_->InputCount()); 48 this->node_, this->node_->InputCount());
49 } 49 }
50 50
51 template <class B, class S> 51 template <class B, class S>
52 inline typename GenericNode<B, S>::InputEdges::iterator
53 GenericNode<B, S>::InputEdges::begin() {
54 return typename GenericNode<B, S>::InputEdges::iterator(this->node_, 0);
55 }
56
57 template <class B, class S>
58 inline typename GenericNode<B, S>::InputEdges::iterator
59 GenericNode<B, S>::InputEdges::end() {
60 return typename GenericNode<B, S>::InputEdges::iterator(
61 this->node_, this->node_->InputCount());
62 }
63
64 template <class B, class S>
52 inline typename GenericNode<B, S>::Uses::iterator 65 inline typename GenericNode<B, S>::Uses::iterator
53 GenericNode<B, S>::Uses::begin() { 66 GenericNode<B, S>::Uses::begin() {
54 return typename GenericNode<B, S>::Uses::iterator(this->node_); 67 return typename GenericNode<B, S>::Uses::iterator(this->node_);
55 } 68 }
56 69
57 template <class B, class S> 70 template <class B, class S>
58 inline typename GenericNode<B, S>::Uses::iterator 71 inline typename GenericNode<B, S>::Uses::iterator
59 GenericNode<B, S>::Uses::end() { 72 GenericNode<B, S>::Uses::end() {
60 return typename GenericNode<B, S>::Uses::iterator(); 73 return typename GenericNode<B, S>::Uses::iterator();
61 } 74 }
62 75
63 template <class B, class S> 76 template <class B, class S>
77 inline typename GenericNode<B, S>::UseEdges::iterator
78 GenericNode<B, S>::UseEdges::begin() {
79 return typename GenericNode<B, S>::UseEdges::iterator(this->node_);
80 }
81
82 template <class B, class S>
83 inline typename GenericNode<B, S>::UseEdges::iterator
84 GenericNode<B, S>::UseEdges::end() {
85 return typename GenericNode<B, S>::UseEdges::iterator();
86 }
87
88 template <class B, class S>
64 void GenericNode<B, S>::ReplaceUses(GenericNode* replace_to) { 89 void GenericNode<B, S>::ReplaceUses(GenericNode* replace_to) {
65 for (Use* use = first_use_; use != NULL; use = use->next) { 90 for (Use* use = first_use_; use != NULL; use = use->next) {
66 use->from->GetInputRecordPtr(use->input_index)->to = replace_to; 91 use->from->GetInputRecordPtr(use->input_index)->to = replace_to;
67 } 92 }
68 if (replace_to->last_use_ == NULL) { 93 if (replace_to->last_use_ == NULL) {
69 DCHECK_EQ(NULL, replace_to->first_use_); 94 DCHECK_EQ(NULL, replace_to->first_use_);
70 replace_to->first_use_ = first_use_; 95 replace_to->first_use_ = first_use_;
71 replace_to->last_use_ = last_use_; 96 replace_to->last_use_ = last_use_;
72 } else if (first_use_ != NULL) { 97 } else if (first_use_ != NULL) {
73 DCHECK_NE(NULL, replace_to->first_use_); 98 DCHECK_NE(NULL, replace_to->first_use_);
(...skipping 17 matching lines...) Expand all
91 RemoveUse(use); 116 RemoveUse(use);
92 replace_to->AppendUse(use); 117 replace_to->AppendUse(use);
93 use->from->GetInputRecordPtr(use->input_index)->to = replace_to; 118 use->from->GetInputRecordPtr(use->input_index)->to = replace_to;
94 } 119 }
95 use = next; 120 use = next;
96 } 121 }
97 } 122 }
98 123
99 template <class B, class S> 124 template <class B, class S>
100 void GenericNode<B, S>::RemoveAllInputs() { 125 void GenericNode<B, S>::RemoveAllInputs() {
101 for (typename Inputs::iterator iter(inputs().begin()); iter != inputs().end(); 126 for (auto edge : input_edges()) {
102 ++iter) { 127 edge.UpdateTo(NULL);
103 iter.GetInput()->Update(NULL);
104 } 128 }
105 } 129 }
106 130
107 template <class B, class S> 131 template <class B, class S>
108 void GenericNode<B, S>::TrimInputCount(int new_input_count) { 132 void GenericNode<B, S>::TrimInputCount(int new_input_count) {
109 if (new_input_count == input_count_) return; // Nothing to do. 133 if (new_input_count == input_count_) return; // Nothing to do.
110 134
111 DCHECK(new_input_count < input_count_); 135 DCHECK(new_input_count < input_count_);
112 136
113 // Update inline inputs. 137 // Update inline inputs.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 ++use; 282 ++use;
259 ++input; 283 ++input;
260 } 284 }
261 return result; 285 return result;
262 } 286 }
263 } 287 }
264 } 288 }
265 } // namespace v8::internal::compiler 289 } // namespace v8::internal::compiler
266 290
267 #endif // V8_COMPILER_GENERIC_NODE_INL_H_ 291 #endif // V8_COMPILER_GENERIC_NODE_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698