V8 Project
graph.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_GRAPH_H_
6 #define V8_COMPILER_GRAPH_H_
7 
8 #include <map>
9 #include <set>
10 
12 #include "src/compiler/node.h"
15 
16 namespace v8 {
17 namespace internal {
18 namespace compiler {
19 
20 class GraphDecorator;
21 
22 
23 class Graph : public GenericGraph<Node> {
24  public:
25  explicit Graph(Zone* zone);
26 
27  // Base implementation used by all factory methods.
28  Node* NewNode(const Operator* op, int input_count, Node** inputs);
29 
30  // Factories for nodes with static input counts.
31  Node* NewNode(const Operator* op) {
32  return NewNode(op, 0, static_cast<Node**>(NULL));
33  }
34  Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
35  Node* NewNode(const Operator* op, Node* n1, Node* n2) {
36  Node* nodes[] = {n1, n2};
37  return NewNode(op, arraysize(nodes), nodes);
38  }
39  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
40  Node* nodes[] = {n1, n2, n3};
41  return NewNode(op, arraysize(nodes), nodes);
42  }
43  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
44  Node* nodes[] = {n1, n2, n3, n4};
45  return NewNode(op, arraysize(nodes), nodes);
46  }
47  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
48  Node* n5) {
49  Node* nodes[] = {n1, n2, n3, n4, n5};
50  return NewNode(op, arraysize(nodes), nodes);
51  }
52  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
53  Node* n5, Node* n6) {
54  Node* nodes[] = {n1, n2, n3, n4, n5, n6};
55  return NewNode(op, arraysize(nodes), nodes);
56  }
57 
58  template <class Visitor>
59  void VisitNodeUsesFrom(Node* node, Visitor* visitor);
60 
61  template <class Visitor>
62  void VisitNodeUsesFromStart(Visitor* visitor);
63 
64  template <class Visitor>
65  void VisitNodeInputsFromEnd(Visitor* visitor);
66 
67  void AddDecorator(GraphDecorator* decorator) {
68  decorators_.push_back(decorator);
69  }
70 
71  void RemoveDecorator(GraphDecorator* decorator) {
73  std::find(decorators_.begin(), decorators_.end(), decorator);
74  DCHECK(it != decorators_.end());
75  decorators_.erase(it, it + 1);
76  }
77 
78  private:
80 };
81 
82 
83 class GraphDecorator : public ZoneObject {
84  public:
85  virtual ~GraphDecorator() {}
86  virtual void Decorate(Node* node) = 0;
87 };
88 
89 } // namespace compiler
90 } // namespace internal
91 } // namespace v8
92 
93 #endif // V8_COMPILER_GRAPH_H_
virtual void Decorate(Node *node)=0
ZoneVector< GraphDecorator * > decorators_
Definition: graph.h:79
void RemoveDecorator(GraphDecorator *decorator)
Definition: graph.h:71
void AddDecorator(GraphDecorator *decorator)
Definition: graph.h:67
Node * NewNode(const Operator *op, Node *n1, Node *n2)
Definition: graph.h:35
Node * NewNode(const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5)
Definition: graph.h:47
Node * NewNode(const Operator *op, Node *n1, Node *n2, Node *n3)
Definition: graph.h:39
void VisitNodeUsesFromStart(Visitor *visitor)
Definition: graph-inl.h:24
void VisitNodeInputsFromEnd(Visitor *visitor)
Definition: graph-inl.h:30
Node * NewNode(const Operator *op, Node *n1)
Definition: graph.h:34
Node * NewNode(const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4)
Definition: graph.h:43
Node * NewNode(const Operator *op)
Definition: graph.h:31
Node * NewNode(const Operator *op, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5, Node *n6)
Definition: graph.h:52
void VisitNodeUsesFrom(Node *node, Visitor *visitor)
Definition: graph-inl.h:16
Node * NewNode(const Operator *op, int input_count, Node **inputs)
Definition: graph.cc:24
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
#define arraysize(array)
Definition: macros.h:86
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20