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

Side by Side Diff: src/compiler/node-properties.cc

Issue 883613006: [turbofan] Cleanup the NodeProperties. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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/node-properties.h ('k') | src/compiler/node-properties-inl.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/compiler/node-properties.h"
6
5 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
6 #include "src/compiler/node-properties.h" 8 #include "src/compiler/operator-properties.h"
7 9
8 namespace v8 { 10 namespace v8 {
9 namespace internal { 11 namespace internal {
10 namespace compiler { 12 namespace compiler {
11 13
14 // static
15 int NodeProperties::PastValueIndex(Node* node) {
16 return FirstValueIndex(node) + node->op()->ValueInputCount();
17 }
18
19
20 // static
21 int NodeProperties::PastContextIndex(Node* node) {
22 return FirstContextIndex(node) +
23 OperatorProperties::GetContextInputCount(node->op());
24 }
25
26
27 // static
28 int NodeProperties::PastFrameStateIndex(Node* node) {
29 return FirstFrameStateIndex(node) +
30 OperatorProperties::GetFrameStateInputCount(node->op());
31 }
32
33
34 // static
35 int NodeProperties::PastEffectIndex(Node* node) {
36 return FirstEffectIndex(node) + node->op()->EffectInputCount();
37 }
38
39
40 // static
41 int NodeProperties::PastControlIndex(Node* node) {
42 return FirstControlIndex(node) + node->op()->ControlInputCount();
43 }
44
45
46 // static
47 Node* NodeProperties::GetValueInput(Node* node, int index) {
48 DCHECK(0 <= index && index < node->op()->ValueInputCount());
49 return node->InputAt(FirstValueIndex(node) + index);
50 }
51
52
53 // static
54 Node* NodeProperties::GetContextInput(Node* node) {
55 DCHECK(OperatorProperties::HasContextInput(node->op()));
56 return node->InputAt(FirstContextIndex(node));
57 }
58
59
60 // static
61 Node* NodeProperties::GetFrameStateInput(Node* node) {
62 DCHECK(OperatorProperties::HasFrameStateInput(node->op()));
63 return node->InputAt(FirstFrameStateIndex(node));
64 }
65
66
67 // static
68 Node* NodeProperties::GetEffectInput(Node* node, int index) {
69 DCHECK(0 <= index && index < node->op()->EffectInputCount());
70 return node->InputAt(FirstEffectIndex(node) + index);
71 }
72
73
74 // static
75 Node* NodeProperties::GetControlInput(Node* node, int index) {
76 DCHECK(0 <= index && index < node->op()->ControlInputCount());
77 return node->InputAt(FirstControlIndex(node) + index);
78 }
79
80
81 // static
82 bool NodeProperties::IsValueEdge(Edge edge) {
83 Node* const node = edge.from();
84 return IsInputRange(edge, FirstValueIndex(node),
85 node->op()->ValueInputCount());
86 }
87
88
89 // static
90 bool NodeProperties::IsContextEdge(Edge edge) {
91 Node* const node = edge.from();
92 return IsInputRange(edge, FirstContextIndex(node),
93 OperatorProperties::GetContextInputCount(node->op()));
94 }
95
96
97 // static
98 bool NodeProperties::IsFrameStateEdge(Edge edge) {
99 Node* const node = edge.from();
100 return IsInputRange(edge, FirstFrameStateIndex(node),
101 OperatorProperties::GetFrameStateInputCount(node->op()));
102 }
103
104
105 // static
106 bool NodeProperties::IsEffectEdge(Edge edge) {
107 Node* const node = edge.from();
108 return IsInputRange(edge, FirstEffectIndex(node),
109 node->op()->EffectInputCount());
110 }
111
112
113 // static
114 bool NodeProperties::IsControlEdge(Edge edge) {
115 Node* const node = edge.from();
116 return IsInputRange(edge, FirstControlIndex(node),
117 node->op()->ControlInputCount());
118 }
119
120
121 // static
122 void NodeProperties::ReplaceContextInput(Node* node, Node* context) {
123 node->ReplaceInput(FirstContextIndex(node), context);
124 }
125
126
127 // static
128 void NodeProperties::ReplaceControlInput(Node* node, Node* control) {
129 node->ReplaceInput(FirstControlIndex(node), control);
130 }
131
132
133 // static
134 void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, int index) {
135 DCHECK(index < node->op()->EffectInputCount());
136 return node->ReplaceInput(FirstEffectIndex(node) + index, effect);
137 }
138
139
140 // static
141 void NodeProperties::ReplaceFrameStateInput(Node* node, Node* frame_state) {
142 DCHECK(OperatorProperties::HasFrameStateInput(node->op()));
143 node->ReplaceInput(FirstFrameStateIndex(node), frame_state);
144 }
145
146
147 // static
148 void NodeProperties::RemoveNonValueInputs(Node* node) {
149 node->TrimInputCount(node->op()->ValueInputCount());
150 }
151
152
153 // static
154 void NodeProperties::ReplaceWithValue(Node* node, Node* value, Node* effect) {
155 DCHECK(node->op()->ControlOutputCount() == 0);
156 if (!effect && node->op()->EffectInputCount() > 0) {
157 effect = NodeProperties::GetEffectInput(node);
158 }
159
160 // Requires distinguishing between value and effect edges.
161 for (Edge edge : node->use_edges()) {
162 if (IsEffectEdge(edge)) {
163 DCHECK_NOT_NULL(effect);
164 edge.UpdateTo(effect);
165 } else {
166 edge.UpdateTo(value);
167 }
168 }
169 }
170
171
172 // static
12 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) { 173 Node* NodeProperties::FindProjection(Node* node, size_t projection_index) {
13 for (auto use : node->uses()) { 174 for (auto use : node->uses()) {
14 if (use->opcode() == IrOpcode::kProjection && 175 if (use->opcode() == IrOpcode::kProjection &&
15 ProjectionIndexOf(use->op()) == projection_index) { 176 ProjectionIndexOf(use->op()) == projection_index) {
16 return use; 177 return use;
17 } 178 }
18 } 179 }
19 return nullptr; 180 return nullptr;
20 } 181 }
21 182
183
184 // static
185 bool NodeProperties::AllValueInputsAreTyped(Node* node) {
186 int input_count = node->op()->ValueInputCount();
187 for (int index = 0; index < input_count; ++index) {
188 if (!IsTyped(GetValueInput(node, index))) return false;
189 }
190 return true;
191 }
192
193
194 // static
195 bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
196 if (num == 0) return false;
197 int const index = edge.index();
198 return first <= index && index < first + num;
199 }
200
22 } // namespace compiler 201 } // namespace compiler
23 } // namespace internal 202 } // namespace internal
24 } // namespace v8 203 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/node-properties-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698