V8 Project
node.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_H_
6 #define V8_COMPILER_NODE_H_
7 
8 #include <deque>
9 #include <set>
10 #include <vector>
11 
14 #include "src/compiler/opcodes.h"
15 #include "src/compiler/operator.h"
16 #include "src/types.h"
17 #include "src/zone.h"
18 #include "src/zone-allocator.h"
19 
20 namespace v8 {
21 namespace internal {
22 namespace compiler {
23 
24 class NodeData {
25  public:
26  const Operator* op() const { return op_; }
27  void set_op(const Operator* op) { op_ = op; }
28 
31  return static_cast<IrOpcode::Value>(op_->opcode());
32  }
33 
34  Bounds bounds() { return bounds_; }
35 
36  protected:
37  const Operator* op_;
39  explicit NodeData(Zone* zone) : bounds_(Bounds(Type::None(zone))) {}
40 
41  friend class NodeProperties;
42  void set_bounds(Bounds b) { bounds_ = b; }
43 };
44 
45 // A Node is the basic primitive of an IR graph. In addition to the members
46 // inherited from Vector, Nodes only contain a mutable Operator that may change
47 // during compilation, e.g. during lowering passes. Other information that
48 // needs to be associated with Nodes during compilation must be stored
49 // out-of-line indexed by the Node's id.
50 class Node FINAL : public GenericNode<NodeData, Node> {
51  public:
52  Node(GenericGraphBase* graph, int input_count)
53  : GenericNode<NodeData, Node>(graph, input_count) {}
54 
55  void Initialize(const Operator* op) { set_op(op); }
56 
57  bool IsDead() const { return InputCount() > 0 && InputAt(0) == NULL; }
58  void Kill();
59 
61  Node* FindProjection(size_t projection_index);
62 };
63 
64 OStream& operator<<(OStream& os, const Node& n);
65 
67 
68 typedef std::set<Node*, std::less<Node*>, zone_allocator<Node*> > NodeSet;
69 typedef NodeSet::iterator NodeSetIter;
70 typedef NodeSet::reverse_iterator NodeSetRIter;
71 
73 typedef NodeVector::iterator NodeVectorIter;
74 typedef NodeVector::const_iterator NodeVectorConstIter;
75 typedef NodeVector::reverse_iterator NodeVectorRIter;
76 
78 typedef NodeVectorVector::iterator NodeVectorVectorIter;
79 typedef NodeVectorVector::reverse_iterator NodeVectorVectorRIter;
80 
81 typedef Node::Uses::iterator UseIter;
82 typedef Node::Inputs::iterator InputIter;
83 
84 // Helper to extract parameters from Operator1<*> nodes.
85 template <typename T>
86 static inline const T& OpParameter(const Node* node) {
87  return OpParameter<T>(node->op());
88 }
89 
90 } // namespace compiler
91 } // namespace internal
92 } // namespace v8
93 
94 #endif // V8_COMPILER_NODE_H_
Source to read snapshot and builtins files from.
Definition: lithium-arm.h:372
Node * FindProjection(size_t projection_index)
Node(GenericGraphBase *graph, int input_count)
Definition: node.h:52
void CollectProjections(ZoneVector< Node * > *projections)
bool IsDead() const
Definition: node.h:57
void Initialize(const Operator *op)
Definition: node.h:55
const Operator * op() const
Definition: node.h:26
const Operator * op_
Definition: node.h:37
void set_op(const Operator *op)
Definition: node.h:27
void set_bounds(Bounds b)
Definition: node.h:42
IrOpcode::Value opcode() const
Definition: node.h:29
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(condition)
Definition: logging.h:205
ZoneVector< Node * > NodeVector
Definition: node.h:72
Node::Uses::iterator UseIter
Definition: node.h:81
NodeSet::iterator NodeSetIter
Definition: node.h:69
ZoneVector< NodeVector > NodeVectorVector
Definition: node.h:77
std::ostream & operator<<(std::ostream &os, const MachineType &type)
NodeVector::const_iterator NodeVectorConstIter
Definition: node.h:74
NodeVector::iterator NodeVectorIter
Definition: node.h:73
NodeSet::reverse_iterator NodeSetRIter
Definition: node.h:70
Node::Inputs::iterator InputIter
Definition: node.h:82
std::set< Node *, std::less< Node * >, zone_allocator< Node * > > NodeSet
Definition: node.h:68
NodeVector::reverse_iterator NodeVectorRIter
Definition: node.h:75
GenericGraphVisit::NullNodeVisitor< NodeData, Node > NullNodeVisitor
Definition: node.h:66
NodeVectorVector::reverse_iterator NodeVectorVectorRIter
Definition: node.h:79
static const T & OpParameter(const Node *node)
Definition: node.h:86
NodeVectorVector::iterator NodeVectorVectorIter
Definition: node.h:78
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
@ None
Definition: v8.h:2211
#define T(name, string, precedence)
Definition: token.cc:25