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

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

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_NODE_PROPERTIES_INL_H_
6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_
7
8 #include "src/v8.h"
9
10 #include "src/compiler/common-operator.h"
11 #include "src/compiler/node-properties.h"
12 #include "src/compiler/opcodes.h"
13 #include "src/compiler/operator.h"
14 #include "src/compiler/operator-properties-inl.h"
15 #include "src/compiler/operator-properties.h"
16
17 namespace v8 {
18 namespace internal {
19 namespace compiler {
20
21 // -----------------------------------------------------------------------------
22 // Input counts & layout.
23 // Inputs are always arranged in order as follows:
24 // 0 [ values, context, effects, control ] node->InputCount()
25
26 inline bool NodeProperties::HasValueInput(Node* node) {
27 return OperatorProperties::GetValueInputCount(node->op()) > 0;
28 }
29
30 inline bool NodeProperties::HasContextInput(Node* node) {
31 return OperatorProperties::HasContextInput(node->op());
32 }
33
34 inline bool NodeProperties::HasEffectInput(Node* node) {
35 return OperatorProperties::GetEffectInputCount(node->op()) > 0;
36 }
37
38 inline bool NodeProperties::HasControlInput(Node* node) {
39 return OperatorProperties::GetControlInputCount(node->op()) > 0;
40 }
41
42
43 inline int NodeProperties::GetValueInputCount(Node* node) {
44 return OperatorProperties::GetValueInputCount(node->op());
45 }
46
47 inline int NodeProperties::GetContextInputCount(Node* node) {
48 return OperatorProperties::HasContextInput(node->op()) ? 1 : 0;
49 }
50
51 inline int NodeProperties::GetEffectInputCount(Node* node) {
52 return OperatorProperties::GetEffectInputCount(node->op());
53 }
54
55 inline int NodeProperties::GetControlInputCount(Node* node) {
56 return OperatorProperties::GetControlInputCount(node->op());
57 }
58
59
60 inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
61
62 inline int NodeProperties::FirstContextIndex(Node* node) {
63 return PastValueIndex(node);
64 }
65
66 inline int NodeProperties::FirstEffectIndex(Node* node) {
67 return PastContextIndex(node);
68 }
69
70 inline int NodeProperties::FirstControlIndex(Node* node) {
71 return PastEffectIndex(node);
72 }
73
74
75 inline int NodeProperties::PastValueIndex(Node* node) {
76 return FirstValueIndex(node) + GetValueInputCount(node);
77 }
78
79 inline int NodeProperties::PastContextIndex(Node* node) {
80 return FirstContextIndex(node) + GetContextInputCount(node);
81 }
82
83 inline int NodeProperties::PastEffectIndex(Node* node) {
84 return FirstEffectIndex(node) + GetEffectInputCount(node);
85 }
86
87 inline int NodeProperties::PastControlIndex(Node* node) {
88 return FirstControlIndex(node) + GetControlInputCount(node);
89 }
90
91
92 // -----------------------------------------------------------------------------
93 // Input accessors.
94
95 inline Node* NodeProperties::GetValueInput(Node* node, int index) {
96 ASSERT(0 <= index && index < GetValueInputCount(node));
97 return node->InputAt(FirstValueIndex(node) + index);
98 }
99
100 inline Node* NodeProperties::GetContextInput(Node* node) {
101 ASSERT(GetContextInputCount(node) > 0);
102 return node->InputAt(FirstContextIndex(node));
103 }
104
105 inline Node* NodeProperties::GetEffectInput(Node* node, int index) {
106 ASSERT(0 <= index && index < GetEffectInputCount(node));
107 return node->InputAt(FirstEffectIndex(node) + index);
108 }
109
110 inline Node* NodeProperties::GetControlInput(Node* node, int index) {
111 ASSERT(0 <= index && index < GetControlInputCount(node));
112 return node->InputAt(FirstControlIndex(node) + index);
113 }
114
115
116 // -----------------------------------------------------------------------------
117 // Output counts.
118
119 inline bool NodeProperties::HasValueOutput(Node* node) {
120 return GetValueOutputCount(node) > 0;
121 }
122
123 inline bool NodeProperties::HasEffectOutput(Node* node) {
124 return node->opcode() == IrOpcode::kStart ||
125 NodeProperties::GetEffectInputCount(node) > 0;
126 }
127
128 inline bool NodeProperties::HasControlOutput(Node* node) {
129 return (node->opcode() != IrOpcode::kEnd && IsControl(node)) ||
130 NodeProperties::CanLazilyDeoptimize(node);
131 }
132
133
134 inline int NodeProperties::GetValueOutputCount(Node* node) {
135 return OperatorProperties::GetValueOutputCount(node->op());
136 }
137
138 inline int NodeProperties::GetEffectOutputCount(Node* node) {
139 return HasEffectOutput(node) ? 1 : 0;
140 }
141
142 inline int NodeProperties::GetControlOutputCount(Node* node) {
143 return node->opcode() == IrOpcode::kBranch ? 2 : HasControlOutput(node) ? 1
144 : 0;
145 }
146
147
148 // -----------------------------------------------------------------------------
149 // Edge kinds.
150
151 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) {
152 // TODO(titzer): edge.index() is linear time;
153 // edges maybe need to be marked as value/effect/control.
154 if (num == 0) return false;
155 int index = edge.index();
156 return first <= index && index < first + num;
157 }
158
159 inline bool NodeProperties::IsValueEdge(Node::Edge edge) {
160 Node* node = edge.from();
161 return IsInputRange(edge, FirstValueIndex(node), GetValueInputCount(node));
162 }
163
164 inline bool NodeProperties::IsContextEdge(Node::Edge edge) {
165 Node* node = edge.from();
166 return IsInputRange(edge, FirstContextIndex(node),
167 GetContextInputCount(node));
168 }
169
170 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) {
171 Node* node = edge.from();
172 return IsInputRange(edge, FirstEffectIndex(node), GetEffectInputCount(node));
173 }
174
175 inline bool NodeProperties::IsControlEdge(Node::Edge edge) {
176 Node* node = edge.from();
177 return IsInputRange(edge, FirstControlIndex(node),
178 GetControlInputCount(node));
179 }
180
181
182 // -----------------------------------------------------------------------------
183 // Miscellaneous predicates.
184
185 inline bool NodeProperties::IsControl(Node* node) {
186 return IrOpcode::IsControlOpcode(node->opcode());
187 }
188
189 inline bool NodeProperties::IsBasicBlockBegin(Node* node) {
190 return OperatorProperties::IsBasicBlockBegin(node->op());
191 }
192
193 inline bool NodeProperties::CanBeScheduled(Node* node) {
194 return OperatorProperties::CanBeScheduled(node->op());
195 }
196
197 inline bool NodeProperties::HasFixedSchedulePosition(Node* node) {
198 return OperatorProperties::HasFixedSchedulePosition(node->op());
199 }
200
201 inline bool NodeProperties::IsScheduleRoot(Node* node) {
202 return OperatorProperties::IsScheduleRoot(node->op());
203 }
204
205
206 // -----------------------------------------------------------------------------
207 // Miscellaneous mutators.
208
209 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect,
210 int index) {
211 ASSERT(index < GetEffectInputCount(node));
212 return node->ReplaceInput(
213 GetValueInputCount(node) + GetContextInputCount(node) + index, effect);
214 }
215
216 inline void NodeProperties::RemoveNonValueInputs(Node* node) {
217 node->TrimInputCount(GetValueInputCount(node));
218 }
219
220
221 // -----------------------------------------------------------------------------
222 // Type Bounds.
223
224 inline Bounds NodeProperties::GetBounds(Node* node) { return node->bounds(); }
225
226 inline void NodeProperties::SetBounds(Node* node, Bounds b) {
227 node->set_bounds(b);
228 }
229
230
231 inline bool NodeProperties::CanLazilyDeoptimize(Node* node) {
232 return OperatorProperties::CanLazilyDeoptimize(node->op());
233 }
234 }
235 }
236 } // namespace v8::internal::compiler
237
238 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698