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" | |
13 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
14 | 13 |
15 namespace v8 { | 14 namespace v8 { |
16 namespace internal { | 15 namespace internal { |
17 namespace compiler { | 16 namespace compiler { |
18 | 17 |
19 class Typer; | 18 class Typer; |
20 | 19 |
21 // Implements a facade on a Graph, enhancing the graph with JS-specific | 20 // Implements a facade on a Graph, enhancing the graph with JS-specific |
22 // notions, including a builder for for JS* operators, canonicalized global | 21 // notions, including a builder for for JS* operators, canonicalized global |
23 // constants, and various helper methods. | 22 // constants, and various helper methods. |
24 class JSGraph : public ZoneObject { | 23 class JSGraph : public ZoneObject { |
25 public: | 24 public: |
26 JSGraph(Graph* graph, CommonOperatorBuilder* common, | 25 JSGraph(Graph* graph, CommonOperatorBuilder* common, Typer* typer) |
27 JSOperatorBuilder* javascript, Typer* typer, | |
28 MachineOperatorBuilder* machine) | |
29 : graph_(graph), | 26 : graph_(graph), |
30 common_(common), | 27 common_(common), |
31 javascript_(javascript), | 28 javascript_(zone()), |
32 typer_(typer), | 29 typer_(typer), |
33 machine_(machine), | |
34 cache_(zone()) {} | 30 cache_(zone()) {} |
35 | 31 |
36 // Canonicalized global constants. | 32 // Canonicalized global constants. |
37 Node* CEntryStubConstant(); | 33 Node* CEntryStubConstant(); |
38 Node* UndefinedConstant(); | 34 Node* UndefinedConstant(); |
39 Node* TheHoleConstant(); | 35 Node* TheHoleConstant(); |
40 Node* TrueConstant(); | 36 Node* TrueConstant(); |
41 Node* FalseConstant(); | 37 Node* FalseConstant(); |
42 Node* NullConstant(); | 38 Node* NullConstant(); |
43 Node* ZeroConstant(); | 39 Node* ZeroConstant(); |
(...skipping 26 matching lines...) Expand all Loading... |
70 Node* Float64Constant(double value); | 66 Node* Float64Constant(double value); |
71 | 67 |
72 // Creates an ExternalConstant node, usually canonicalized. | 68 // Creates an ExternalConstant node, usually canonicalized. |
73 Node* ExternalConstant(ExternalReference ref); | 69 Node* ExternalConstant(ExternalReference ref); |
74 | 70 |
75 Node* SmiConstant(int32_t immediate) { | 71 Node* SmiConstant(int32_t immediate) { |
76 DCHECK(Smi::IsValid(immediate)); | 72 DCHECK(Smi::IsValid(immediate)); |
77 return Constant(immediate); | 73 return Constant(immediate); |
78 } | 74 } |
79 | 75 |
80 JSOperatorBuilder* javascript() { return javascript_; } | 76 JSOperatorBuilder* javascript() { return &javascript_; } |
81 CommonOperatorBuilder* common() { return common_; } | 77 CommonOperatorBuilder* common() { return common_; } |
82 MachineOperatorBuilder* machine() { return machine_; } | |
83 Graph* graph() { return graph_; } | 78 Graph* graph() { return graph_; } |
84 Zone* zone() { return graph()->zone(); } | 79 Zone* zone() { return graph()->zone(); } |
85 Isolate* isolate() { return zone()->isolate(); } | 80 Isolate* isolate() { return zone()->isolate(); } |
86 | 81 |
87 private: | 82 private: |
88 Graph* graph_; | 83 Graph* graph_; |
89 CommonOperatorBuilder* common_; | 84 CommonOperatorBuilder* common_; |
90 JSOperatorBuilder* javascript_; | 85 JSOperatorBuilder javascript_; |
91 Typer* typer_; | 86 Typer* typer_; |
92 MachineOperatorBuilder* machine_; | |
93 | 87 |
94 SetOncePointer<Node> c_entry_stub_constant_; | 88 SetOncePointer<Node> c_entry_stub_constant_; |
95 SetOncePointer<Node> undefined_constant_; | 89 SetOncePointer<Node> undefined_constant_; |
96 SetOncePointer<Node> the_hole_constant_; | 90 SetOncePointer<Node> the_hole_constant_; |
97 SetOncePointer<Node> true_constant_; | 91 SetOncePointer<Node> true_constant_; |
98 SetOncePointer<Node> false_constant_; | 92 SetOncePointer<Node> false_constant_; |
99 SetOncePointer<Node> null_constant_; | 93 SetOncePointer<Node> null_constant_; |
100 SetOncePointer<Node> zero_constant_; | 94 SetOncePointer<Node> zero_constant_; |
101 SetOncePointer<Node> one_constant_; | 95 SetOncePointer<Node> one_constant_; |
102 SetOncePointer<Node> nan_constant_; | 96 SetOncePointer<Node> nan_constant_; |
103 | 97 |
104 CommonNodeCache cache_; | 98 CommonNodeCache cache_; |
105 | 99 |
106 Node* ImmovableHeapConstant(Handle<Object> value); | 100 Node* ImmovableHeapConstant(Handle<Object> value); |
107 Node* NumberConstant(double value); | 101 Node* NumberConstant(double value); |
108 Node* NewNode(Operator* op); | 102 Node* NewNode(Operator* op); |
109 | 103 |
110 Factory* factory() { return isolate()->factory(); } | 104 Factory* factory() { return isolate()->factory(); } |
111 }; | 105 }; |
112 } // namespace compiler | 106 } // namespace compiler |
113 } // namespace internal | 107 } // namespace internal |
114 } // namespace v8 | 108 } // namespace v8 |
115 | 109 |
116 #endif | 110 #endif |
OLD | NEW |