V8 Project
node-properties-inl.h
Go to the documentation of this file.
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 
13 #include "src/compiler/opcodes.h"
14 #include "src/compiler/operator.h"
17 
18 namespace v8 {
19 namespace internal {
20 namespace compiler {
21 
22 // -----------------------------------------------------------------------------
23 // Input layout.
24 // Inputs are always arranged in order as follows:
25 // 0 [ values, context, effects, control ] node->InputCount()
26 
27 inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
28 
29 inline int NodeProperties::FirstContextIndex(Node* node) {
30  return PastValueIndex(node);
31 }
32 
33 inline int NodeProperties::FirstFrameStateIndex(Node* node) {
34  return PastContextIndex(node);
35 }
36 
37 inline int NodeProperties::FirstEffectIndex(Node* node) {
38  return PastFrameStateIndex(node);
39 }
40 
41 inline int NodeProperties::FirstControlIndex(Node* node) {
42  return PastEffectIndex(node);
43 }
44 
45 
46 inline int NodeProperties::PastValueIndex(Node* node) {
47  return FirstValueIndex(node) +
49 }
50 
51 inline int NodeProperties::PastContextIndex(Node* node) {
52  return FirstContextIndex(node) +
54 }
55 
56 inline int NodeProperties::PastFrameStateIndex(Node* node) {
57  return FirstFrameStateIndex(node) +
59 }
60 
61 inline int NodeProperties::PastEffectIndex(Node* node) {
62  return FirstEffectIndex(node) +
64 }
65 
66 inline int NodeProperties::PastControlIndex(Node* node) {
67  return FirstControlIndex(node) +
69 }
70 
71 
72 // -----------------------------------------------------------------------------
73 // Input accessors.
74 
75 inline Node* NodeProperties::GetValueInput(Node* node, int index) {
76  DCHECK(0 <= index &&
77  index < OperatorProperties::GetValueInputCount(node->op()));
78  return node->InputAt(FirstValueIndex(node) + index);
79 }
80 
81 inline Node* NodeProperties::GetContextInput(Node* node) {
83  return node->InputAt(FirstContextIndex(node));
84 }
85 
86 inline Node* NodeProperties::GetFrameStateInput(Node* node) {
88  return node->InputAt(FirstFrameStateIndex(node));
89 }
90 
91 inline Node* NodeProperties::GetEffectInput(Node* node, int index) {
92  DCHECK(0 <= index &&
93  index < OperatorProperties::GetEffectInputCount(node->op()));
94  return node->InputAt(FirstEffectIndex(node) + index);
95 }
96 
97 inline Node* NodeProperties::GetControlInput(Node* node, int index) {
98  DCHECK(0 <= index &&
99  index < OperatorProperties::GetControlInputCount(node->op()));
100  return node->InputAt(FirstControlIndex(node) + index);
101 }
102 
103 inline int NodeProperties::GetFrameStateIndex(Node* node) {
105  return FirstFrameStateIndex(node);
106 }
107 
108 // -----------------------------------------------------------------------------
109 // Edge kinds.
110 
111 inline bool NodeProperties::IsInputRange(Node::Edge edge, int first, int num) {
112  // TODO(titzer): edge.index() is linear time;
113  // edges maybe need to be marked as value/effect/control.
114  if (num == 0) return false;
115  int index = edge.index();
116  return first <= index && index < first + num;
117 }
118 
119 inline bool NodeProperties::IsValueEdge(Node::Edge edge) {
120  Node* node = edge.from();
121  return IsInputRange(edge, FirstValueIndex(node),
123 }
124 
125 inline bool NodeProperties::IsContextEdge(Node::Edge edge) {
126  Node* node = edge.from();
127  return IsInputRange(edge, FirstContextIndex(node),
129 }
130 
131 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) {
132  Node* node = edge.from();
133  return IsInputRange(edge, FirstEffectIndex(node),
135 }
136 
137 inline bool NodeProperties::IsControlEdge(Node::Edge edge) {
138  Node* node = edge.from();
139  return IsInputRange(edge, FirstControlIndex(node),
141 }
142 
143 
144 // -----------------------------------------------------------------------------
145 // Miscellaneous predicates.
146 
147 inline bool NodeProperties::IsControl(Node* node) {
148  return IrOpcode::IsControlOpcode(node->opcode());
149 }
150 
151 
152 // -----------------------------------------------------------------------------
153 // Miscellaneous mutators.
154 
155 inline void NodeProperties::ReplaceControlInput(Node* node, Node* control) {
156  node->ReplaceInput(FirstControlIndex(node), control);
157 }
158 
159 inline void NodeProperties::ReplaceEffectInput(Node* node, Node* effect,
160  int index) {
161  DCHECK(index < OperatorProperties::GetEffectInputCount(node->op()));
162  return node->ReplaceInput(FirstEffectIndex(node) + index, effect);
163 }
164 
166  Node* frame_state) {
168  node->ReplaceInput(FirstFrameStateIndex(node), frame_state);
169 }
170 
171 inline void NodeProperties::RemoveNonValueInputs(Node* node) {
172  node->TrimInputCount(OperatorProperties::GetValueInputCount(node->op()));
173 }
174 
175 
176 // Replace value uses of {node} with {value} and effect uses of {node} with
177 // {effect}. If {effect == NULL}, then use the effect input to {node}.
178 inline void NodeProperties::ReplaceWithValue(Node* node, Node* value,
179  Node* effect) {
181  if (effect == NULL && OperatorProperties::HasEffectInput(node->op())) {
182  effect = NodeProperties::GetEffectInput(node);
183  }
184 
185  // Requires distinguishing between value and effect edges.
186  UseIter iter = node->uses().begin();
187  while (iter != node->uses().end()) {
188  if (NodeProperties::IsEffectEdge(iter.edge())) {
189  DCHECK_NE(NULL, effect);
190  iter = iter.UpdateToAndIncrement(effect);
191  } else {
192  iter = iter.UpdateToAndIncrement(value);
193  }
194  }
195 }
196 
197 
198 // -----------------------------------------------------------------------------
199 // Type Bounds.
200 
201 inline Bounds NodeProperties::GetBounds(Node* node) { return node->bounds(); }
202 
203 inline void NodeProperties::SetBounds(Node* node, Bounds b) {
204  node->set_bounds(b);
205 }
206 
207 
208 }
209 }
210 } // namespace v8::internal::compiler
211 
212 #endif // V8_COMPILER_NODE_PROPERTIES_INL_H_
static bool IsControlOpcode(Value val)
Definition: opcodes.h:280
static void ReplaceControlInput(Node *node, Node *control)
static void ReplaceWithValue(Node *node, Node *value, Node *effect=NULL)
static void ReplaceEffectInput(Node *node, Node *effect, int index=0)
static bool IsContextEdge(Node::Edge edge)
static Node * GetContextInput(Node *node)
static Node * GetValueInput(Node *node, int index)
static Node * GetFrameStateInput(Node *node)
static bool IsControlEdge(Node::Edge edge)
static void SetBounds(Node *node, Bounds bounds)
static bool IsEffectEdge(Node::Edge edge)
static bool IsValueEdge(Node::Edge edge)
static Node * GetEffectInput(Node *node, int index=0)
static void ReplaceFrameStateInput(Node *node, Node *frame_state)
static bool IsInputRange(Node::Edge edge, int first, int count)
static Node * GetControlInput(Node *node, int index=0)
static int GetEffectInputCount(const Operator *op)
static int GetFrameStateInputCount(const Operator *op)
static int GetContextInputCount(const Operator *op)
static int GetValueInputCount(const Operator *op)
static bool HasContextInput(const Operator *op)
static bool HasFrameStateInput(const Operator *op)
static bool HasEffectInput(const Operator *op)
static int GetControlInputCount(const Operator *op)
static bool HasControlOutput(const Operator *op)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_NE(v1, v2)
Definition: logging.h:207
#define DCHECK(condition)
Definition: logging.h:205
Node::Uses::iterator UseIter
Definition: node.h:81
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20