OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_JS_GRAPH_H_ | 5 #ifndef V8_COMPILER_JS_GRAPH_H_ |
6 #define V8_COMPILER_JS_GRAPH_H_ | 6 #define V8_COMPILER_JS_GRAPH_H_ |
7 | 7 |
8 #include "src/compiler/common-node-cache.h" | 8 #include "src/compiler/common-node-cache.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
11 #include "src/compiler/js-operator.h" | 11 #include "src/compiler/js-operator.h" |
12 #include "src/compiler/machine-operator.h" | 12 #include "src/compiler/machine-operator.h" |
13 #include "src/compiler/node-properties.h" | 13 #include "src/compiler/node-properties.h" |
14 #include "src/isolate.h" | 14 #include "src/isolate.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 namespace compiler { | 18 namespace compiler { |
19 | 19 |
| 20 class SimplifiedOperatorBuilder; |
20 class Typer; | 21 class Typer; |
21 | 22 |
22 // Implements a facade on a Graph, enhancing the graph with JS-specific | 23 // Implements a facade on a Graph, enhancing the graph with JS-specific |
23 // notions, including a builder for for JS* operators, canonicalized global | 24 // notions, including various builders for operators, canonicalized global |
24 // constants, and various helper methods. | 25 // constants, and various helper methods. |
25 class JSGraph : public ZoneObject { | 26 class JSGraph : public ZoneObject { |
26 public: | 27 public: |
27 JSGraph(Isolate* isolate, Graph* graph, CommonOperatorBuilder* common, | 28 JSGraph(Isolate* isolate, Graph* graph, CommonOperatorBuilder* common, |
28 JSOperatorBuilder* javascript, MachineOperatorBuilder* machine) | 29 JSOperatorBuilder* javascript, SimplifiedOperatorBuilder* simplified, |
| 30 MachineOperatorBuilder* machine) |
29 : isolate_(isolate), | 31 : isolate_(isolate), |
30 graph_(graph), | 32 graph_(graph), |
31 common_(common), | 33 common_(common), |
32 javascript_(javascript), | 34 javascript_(javascript), |
| 35 simplified_(simplified), |
33 machine_(machine), | 36 machine_(machine), |
34 cache_(zone()) { | 37 cache_(zone()) { |
35 for (int i = 0; i < kNumCachedNodes; i++) cached_nodes_[i] = nullptr; | 38 for (int i = 0; i < kNumCachedNodes; i++) cached_nodes_[i] = nullptr; |
36 } | 39 } |
37 | 40 |
38 // Canonicalized global constants. | 41 // Canonicalized global constants. |
39 Node* CEntryStubConstant(int result_size); | 42 Node* CEntryStubConstant(int result_size); |
40 Node* UndefinedConstant(); | 43 Node* UndefinedConstant(); |
41 Node* TheHoleConstant(); | 44 Node* TheHoleConstant(); |
42 Node* TrueConstant(); | 45 Node* TrueConstant(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // stubs and runtime functions that do not require a context. | 113 // stubs and runtime functions that do not require a context. |
111 Node* NoContextConstant() { return ZeroConstant(); } | 114 Node* NoContextConstant() { return ZeroConstant(); } |
112 | 115 |
113 // Creates an empty frame states for cases where we know that a function | 116 // Creates an empty frame states for cases where we know that a function |
114 // cannot deopt. | 117 // cannot deopt. |
115 Node* EmptyFrameState(); | 118 Node* EmptyFrameState(); |
116 | 119 |
117 // Create a control node that serves as dependency for dead nodes. | 120 // Create a control node that serves as dependency for dead nodes. |
118 Node* Dead(); | 121 Node* Dead(); |
119 | 122 |
| 123 CommonOperatorBuilder* common() const { return common_; } |
120 JSOperatorBuilder* javascript() const { return javascript_; } | 124 JSOperatorBuilder* javascript() const { return javascript_; } |
121 CommonOperatorBuilder* common() const { return common_; } | 125 SimplifiedOperatorBuilder* simplified() const { return simplified_; } |
122 MachineOperatorBuilder* machine() const { return machine_; } | 126 MachineOperatorBuilder* machine() const { return machine_; } |
123 Graph* graph() const { return graph_; } | 127 Graph* graph() const { return graph_; } |
124 Zone* zone() const { return graph()->zone(); } | 128 Zone* zone() const { return graph()->zone(); } |
125 Isolate* isolate() const { return isolate_; } | 129 Isolate* isolate() const { return isolate_; } |
126 Factory* factory() const { return isolate()->factory(); } | 130 Factory* factory() const { return isolate()->factory(); } |
127 | 131 |
128 void GetCachedNodes(NodeVector* nodes); | 132 void GetCachedNodes(NodeVector* nodes); |
129 | 133 |
130 private: | 134 private: |
131 enum CachedNode { | 135 enum CachedNode { |
132 kCEntryStubConstant, | 136 kCEntryStubConstant, |
133 kUndefinedConstant, | 137 kUndefinedConstant, |
134 kTheHoleConstant, | 138 kTheHoleConstant, |
135 kTrueConstant, | 139 kTrueConstant, |
136 kFalseConstant, | 140 kFalseConstant, |
137 kNullConstant, | 141 kNullConstant, |
138 kZeroConstant, | 142 kZeroConstant, |
139 kOneConstant, | 143 kOneConstant, |
140 kNaNConstant, | 144 kNaNConstant, |
141 kEmptyFrameState, | 145 kEmptyFrameState, |
142 kDead, | 146 kDead, |
143 kNumCachedNodes // Must remain last. | 147 kNumCachedNodes // Must remain last. |
144 }; | 148 }; |
145 | 149 |
146 Isolate* isolate_; | 150 Isolate* isolate_; |
147 Graph* graph_; | 151 Graph* graph_; |
148 CommonOperatorBuilder* common_; | 152 CommonOperatorBuilder* common_; |
149 JSOperatorBuilder* javascript_; | 153 JSOperatorBuilder* javascript_; |
| 154 SimplifiedOperatorBuilder* simplified_; |
150 MachineOperatorBuilder* machine_; | 155 MachineOperatorBuilder* machine_; |
151 CommonNodeCache cache_; | 156 CommonNodeCache cache_; |
152 Node* cached_nodes_[kNumCachedNodes]; | 157 Node* cached_nodes_[kNumCachedNodes]; |
153 | 158 |
154 Node* ImmovableHeapConstant(Handle<HeapObject> value); | 159 Node* ImmovableHeapConstant(Handle<HeapObject> value); |
155 Node* NumberConstant(double value); | 160 Node* NumberConstant(double value); |
156 | 161 |
157 DISALLOW_COPY_AND_ASSIGN(JSGraph); | 162 DISALLOW_COPY_AND_ASSIGN(JSGraph); |
158 }; | 163 }; |
159 | 164 |
160 } // namespace compiler | 165 } // namespace compiler |
161 } // namespace internal | 166 } // namespace internal |
162 } // namespace v8 | 167 } // namespace v8 |
163 | 168 |
164 #endif | 169 #endif |
OLD | NEW |