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 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
| 19 // Forward declarations. |
19 class Typer; | 20 class Typer; |
20 | 21 |
21 // Implements a facade on a Graph, enhancing the graph with JS-specific | 22 // Implements a facade on a Graph, enhancing the graph with JS-specific |
22 // notions, including a builder for for JS* operators, canonicalized global | 23 // notions, including a builder for for JS* operators, canonicalized global |
23 // constants, and various helper methods. | 24 // constants, and various helper methods. |
24 class JSGraph : public ZoneObject { | 25 class JSGraph : public ZoneObject { |
25 public: | 26 public: |
26 JSGraph(Graph* graph, CommonOperatorBuilder* common, | 27 JSGraph(Graph* graph, CommonOperatorBuilder* common, |
27 JSOperatorBuilder* javascript, MachineOperatorBuilder* machine) | 28 JSOperatorBuilder* javascript, MachineOperatorBuilder* machine) |
28 : graph_(graph), | 29 : graph_(graph), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 Node* SmiConstant(int32_t immediate) { | 104 Node* SmiConstant(int32_t immediate) { |
104 DCHECK(Smi::IsValid(immediate)); | 105 DCHECK(Smi::IsValid(immediate)); |
105 return Constant(immediate); | 106 return Constant(immediate); |
106 } | 107 } |
107 | 108 |
108 // Creates a dummy Constant node, used to satisfy calling conventions of | 109 // Creates a dummy Constant node, used to satisfy calling conventions of |
109 // stubs and runtime functions that do not require a context. | 110 // stubs and runtime functions that do not require a context. |
110 Node* NoContextConstant() { return ZeroConstant(); } | 111 Node* NoContextConstant() { return ZeroConstant(); } |
111 | 112 |
| 113 // Cached common types. |
| 114 Type* ZeroOneRangeType(); |
| 115 |
112 JSOperatorBuilder* javascript() { return javascript_; } | 116 JSOperatorBuilder* javascript() { return javascript_; } |
113 CommonOperatorBuilder* common() { return common_; } | 117 CommonOperatorBuilder* common() { return common_; } |
114 MachineOperatorBuilder* machine() { return machine_; } | 118 MachineOperatorBuilder* machine() { return machine_; } |
115 Graph* graph() { return graph_; } | 119 Graph* graph() { return graph_; } |
116 Zone* zone() { return graph()->zone(); } | 120 Zone* zone() { return graph()->zone(); } |
117 Isolate* isolate() { return zone()->isolate(); } | 121 Isolate* isolate() { return zone()->isolate(); } |
118 Factory* factory() { return isolate()->factory(); } | 122 Factory* factory() { return isolate()->factory(); } |
119 | 123 |
120 void GetCachedNodes(NodeVector* nodes); | 124 void GetCachedNodes(NodeVector* nodes); |
121 | 125 |
122 private: | 126 private: |
123 Graph* graph_; | 127 Graph* graph_; |
124 CommonOperatorBuilder* common_; | 128 CommonOperatorBuilder* common_; |
125 JSOperatorBuilder* javascript_; | 129 JSOperatorBuilder* javascript_; |
126 MachineOperatorBuilder* machine_; | 130 MachineOperatorBuilder* machine_; |
127 | 131 |
128 // TODO(titzer): make this into a simple array. | 132 // TODO(titzer): make this into a simple array. |
129 SetOncePointer<Node> c_entry_stub_constant_; | 133 SetOncePointer<Node> c_entry_stub_constant_; |
130 SetOncePointer<Node> undefined_constant_; | 134 SetOncePointer<Node> undefined_constant_; |
131 SetOncePointer<Node> the_hole_constant_; | 135 SetOncePointer<Node> the_hole_constant_; |
132 SetOncePointer<Node> true_constant_; | 136 SetOncePointer<Node> true_constant_; |
133 SetOncePointer<Node> false_constant_; | 137 SetOncePointer<Node> false_constant_; |
134 SetOncePointer<Node> null_constant_; | 138 SetOncePointer<Node> null_constant_; |
135 SetOncePointer<Node> zero_constant_; | 139 SetOncePointer<Node> zero_constant_; |
136 SetOncePointer<Node> one_constant_; | 140 SetOncePointer<Node> one_constant_; |
137 SetOncePointer<Node> nan_constant_; | 141 SetOncePointer<Node> nan_constant_; |
138 | 142 |
| 143 SetOncePointer<Type> zero_one_range_type_; |
| 144 |
139 CommonNodeCache cache_; | 145 CommonNodeCache cache_; |
140 | 146 |
141 Node* ImmovableHeapConstant(Handle<HeapObject> value); | 147 Node* ImmovableHeapConstant(Handle<HeapObject> value); |
142 Node* NumberConstant(double value); | 148 Node* NumberConstant(double value); |
143 | 149 |
144 DISALLOW_COPY_AND_ASSIGN(JSGraph); | 150 DISALLOW_COPY_AND_ASSIGN(JSGraph); |
145 }; | 151 }; |
146 | 152 |
147 } // namespace compiler | 153 } // namespace compiler |
148 } // namespace internal | 154 } // namespace internal |
149 } // namespace v8 | 155 } // namespace v8 |
150 | 156 |
151 #endif | 157 #endif |
OLD | NEW |