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

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

Issue 462633003: Provide mutators in NodeProperties instead of exposing indicies. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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') | test/cctest/compiler/test-simplified-lowering.cc » ('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 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_NODE_PROPERTIES_INL_H_ 5 #ifndef V8_COMPILER_NODE_PROPERTIES_INL_H_
6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_ 6 #define V8_COMPILER_NODE_PROPERTIES_INL_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
11 #include "src/compiler/node-properties.h" 11 #include "src/compiler/node-properties.h"
12 #include "src/compiler/opcodes.h" 12 #include "src/compiler/opcodes.h"
13 #include "src/compiler/operator.h" 13 #include "src/compiler/operator.h"
14 #include "src/compiler/operator-properties-inl.h" 14 #include "src/compiler/operator-properties-inl.h"
15 #include "src/compiler/operator-properties.h" 15 #include "src/compiler/operator-properties.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 namespace compiler { 19 namespace compiler {
20 20
21 // ----------------------------------------------------------------------------- 21 // -----------------------------------------------------------------------------
22 // Input layout. 22 // Input layout.
23 // Inputs are always arranged in order as follows: 23 // Inputs are always arranged in order as follows:
24 // 0 [ values, context, effects, control ] node->InputCount() 24 // 0 [ values, context, effects, control ] node->InputCount()
25 25
26 inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
26 27
27 inline int NodeProperties::GetContextIndex(Node* node) { 28 inline int NodeProperties::FirstContextIndex(Node* node) {
28 return PastValueIndex(node); 29 return PastValueIndex(node);
29 } 30 }
30 31
31 inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
32
33 inline int NodeProperties::FirstEffectIndex(Node* node) { 32 inline int NodeProperties::FirstEffectIndex(Node* node) {
34 return PastContextIndex(node); 33 return PastContextIndex(node);
35 } 34 }
36 35
37 inline int NodeProperties::FirstControlIndex(Node* node) { 36 inline int NodeProperties::FirstControlIndex(Node* node) {
38 return PastEffectIndex(node); 37 return PastEffectIndex(node);
39 } 38 }
40 39
41 40
42 inline int NodeProperties::PastValueIndex(Node* node) { 41 inline int NodeProperties::PastValueIndex(Node* node) {
43 return FirstValueIndex(node) + 42 return FirstValueIndex(node) +
44 OperatorProperties::GetValueInputCount(node->op()); 43 OperatorProperties::GetValueInputCount(node->op());
45 } 44 }
46 45
47 inline int NodeProperties::PastContextIndex(Node* node) { 46 inline int NodeProperties::PastContextIndex(Node* node) {
48 return GetContextIndex(node) + 47 return FirstContextIndex(node) +
49 OperatorProperties::GetContextInputCount(node->op()); 48 OperatorProperties::GetContextInputCount(node->op());
50 } 49 }
51 50
52 inline int NodeProperties::PastEffectIndex(Node* node) { 51 inline int NodeProperties::PastEffectIndex(Node* node) {
53 return FirstEffectIndex(node) + 52 return FirstEffectIndex(node) +
54 OperatorProperties::GetEffectInputCount(node->op()); 53 OperatorProperties::GetEffectInputCount(node->op());
55 } 54 }
56 55
57 inline int NodeProperties::PastControlIndex(Node* node) { 56 inline int NodeProperties::PastControlIndex(Node* node) {
58 return FirstControlIndex(node) + 57 return FirstControlIndex(node) +
59 OperatorProperties::GetControlInputCount(node->op()); 58 OperatorProperties::GetControlInputCount(node->op());
60 } 59 }
61 60
62 61
63 // ----------------------------------------------------------------------------- 62 // -----------------------------------------------------------------------------
64 // Input accessors. 63 // Input accessors.
65 64
66 inline Node* NodeProperties::GetValueInput(Node* node, int index) { 65 inline Node* NodeProperties::GetValueInput(Node* node, int index) {
67 DCHECK(0 <= index && 66 DCHECK(0 <= index &&
68 index < OperatorProperties::GetValueInputCount(node->op())); 67 index < OperatorProperties::GetValueInputCount(node->op()));
69 return node->InputAt(FirstValueIndex(node) + index); 68 return node->InputAt(FirstValueIndex(node) + index);
70 } 69 }
71 70
72 inline Node* NodeProperties::GetContextInput(Node* node) { 71 inline Node* NodeProperties::GetContextInput(Node* node) {
73 DCHECK(OperatorProperties::HasContextInput(node->op())); 72 DCHECK(OperatorProperties::HasContextInput(node->op()));
74 return node->InputAt(GetContextIndex(node)); 73 return node->InputAt(FirstContextIndex(node));
75 } 74 }
76 75
77 inline Node* NodeProperties::GetEffectInput(Node* node, int index) { 76 inline Node* NodeProperties::GetEffectInput(Node* node, int index) {
78 DCHECK(0 <= index && 77 DCHECK(0 <= index &&
79 index < OperatorProperties::GetEffectInputCount(node->op())); 78 index < OperatorProperties::GetEffectInputCount(node->op()));
80 return node->InputAt(FirstEffectIndex(node) + index); 79 return node->InputAt(FirstEffectIndex(node) + index);
81 } 80 }
82 81
83 inline Node* NodeProperties::GetControlInput(Node* node, int index) { 82 inline Node* NodeProperties::GetControlInput(Node* node, int index) {
84 DCHECK(0 <= index && 83 DCHECK(0 <= index &&
(...skipping 14 matching lines...) Expand all
99 } 98 }
100 99
101 inline bool NodeProperties::IsValueEdge(Node::Edge edge) { 100 inline bool NodeProperties::IsValueEdge(Node::Edge edge) {
102 Node* node = edge.from(); 101 Node* node = edge.from();
103 return IsInputRange(edge, FirstValueIndex(node), 102 return IsInputRange(edge, FirstValueIndex(node),
104 OperatorProperties::GetValueInputCount(node->op())); 103 OperatorProperties::GetValueInputCount(node->op()));
105 } 104 }
106 105
107 inline bool NodeProperties::IsContextEdge(Node::Edge edge) { 106 inline bool NodeProperties::IsContextEdge(Node::Edge edge) {
108 Node* node = edge.from(); 107 Node* node = edge.from();
109 return IsInputRange(edge, GetContextIndex(node), 108 return IsInputRange(edge, FirstContextIndex(node),
110 OperatorProperties::GetContextInputCount(node->op())); 109 OperatorProperties::GetContextInputCount(node->op()));
111 } 110 }
112 111
113 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) { 112 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) {
114 Node* node = edge.from(); 113 Node* node = edge.from();
115 return IsInputRange(edge, FirstEffectIndex(node), 114 return IsInputRange(edge, FirstEffectIndex(node),
116 OperatorProperties::GetEffectInputCount(node->op())); 115 OperatorProperties::GetEffectInputCount(node->op()));
117 } 116 }
118 117
119 inline bool NodeProperties::IsControlEdge(Node::Edge edge) { 118 inline bool NodeProperties::IsControlEdge(Node::Edge edge) {
120 Node* node = edge.from(); 119 Node* node = edge.from();
121 return IsInputRange(edge, FirstControlIndex(node), 120 return IsInputRange(edge, FirstControlIndex(node),
122 OperatorProperties::GetControlInputCount(node->op())); 121 OperatorProperties::GetControlInputCount(node->op()));
123 } 122 }
124 123
125 124
126 // ----------------------------------------------------------------------------- 125 // -----------------------------------------------------------------------------
127 // Miscellaneous predicates. 126 // Miscellaneous predicates.
128 127
129 inline bool NodeProperties::IsControl(Node* node) { 128 inline bool NodeProperties::IsControl(Node* node) {
130 return IrOpcode::IsControlOpcode(node->opcode()); 129 return IrOpcode::IsControlOpcode(node->opcode());
131 } 130 }
132 131
133 132
134 // ----------------------------------------------------------------------------- 133 // -----------------------------------------------------------------------------
135 // Miscellaneous mutators. 134 // Miscellaneous mutators.
136 135
136 inline void NodeProperties::ReplaceControlInput(Node* node, Node* control) {
137 node->ReplaceInput(FirstControlIndex(node), control);
138 }
139
137 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, 140 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect,
138 int index) { 141 int index) {
139 DCHECK(index < OperatorProperties::GetEffectInputCount(node->op())); 142 DCHECK(index < OperatorProperties::GetEffectInputCount(node->op()));
140 return node->ReplaceInput( 143 return node->ReplaceInput(FirstEffectIndex(node) + index, effect);
141 OperatorProperties::GetValueInputCount(node->op()) +
142 OperatorProperties::GetContextInputCount(node->op()) + index,
143 effect);
144 } 144 }
145 145
146 inline void NodeProperties::RemoveNonValueInputs(Node* node) { 146 inline void NodeProperties::RemoveNonValueInputs(Node* node) {
147 node->TrimInputCount(OperatorProperties::GetValueInputCount(node->op())); 147 node->TrimInputCount(OperatorProperties::GetValueInputCount(node->op()));
148 } 148 }
149 149
150 150
151 // ----------------------------------------------------------------------------- 151 // -----------------------------------------------------------------------------
152 // Type Bounds. 152 // Type Bounds.
153 153
154 inline Bounds NodeProperties::GetBounds(Node* node) { return node->bounds(); } 154 inline Bounds NodeProperties::GetBounds(Node* node) { return node->bounds(); }
155 155
156 inline void NodeProperties::SetBounds(Node* node, Bounds b) { 156 inline void NodeProperties::SetBounds(Node* node, Bounds b) {
157 node->set_bounds(b); 157 node->set_bounds(b);
158 } 158 }
159 159
160 160
161 } 161 }
162 } 162 }
163 } // namespace v8::internal::compiler 163 } // namespace v8::internal::compiler
164 164
165 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_ 165 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_
OLDNEW
« no previous file with comments | « src/compiler/node-properties.h ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698